Skip to content

Commit

Permalink
Rename SIMD.value to SIMD._value.
Browse files Browse the repository at this point in the history
Use an alias for the underlying mlir type in `SIMD`.

Signed-off-by: Max Brylski <helehex@gmail.com>
  • Loading branch information
helehex committed Oct 18, 2024
1 parent f840ba2 commit 37be8c0
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 83 deletions.
2 changes: 1 addition & 1 deletion stdlib/src/bit/bit.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn bit_not[
"""
constrained[type.is_integral(), "must be integral"]()
var neg_one = SIMD[type, width](-1)
return __mlir_op.`pop.simd.xor`(val.value, neg_one.value)
return __mlir_op.`pop.simd.xor`(val._value, neg_one._value)


# ===----------------------------------------------------------------------===#
Expand Down
24 changes: 12 additions & 12 deletions stdlib/src/builtin/dtype.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ struct DType(
return False
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred eq>`](
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsSigned.value),
UInt8(0).value,
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsSigned._value),
UInt8(0)._value,
)
)

Expand All @@ -344,8 +344,8 @@ struct DType(
return False
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsSigned.value),
UInt8(0).value,
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsSigned._value),
UInt8(0)._value,
)
)

Expand All @@ -358,8 +358,8 @@ struct DType(
"""
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsInteger.value),
UInt8(0).value,
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsInteger._value),
UInt8(0)._value,
)
)

Expand All @@ -386,8 +386,8 @@ struct DType(
return False
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsFloat.value),
UInt8(0).value,
__mlir_op.`pop.simd.and`(self._as_i8(), _mIsFloat._value),
UInt8(0)._value,
)
)

Expand Down Expand Up @@ -436,15 +436,15 @@ struct DType(
return int(
UInt8(
__mlir_op.`pop.shl`(
UInt8(1).value,
UInt8(1)._value,
__mlir_op.`pop.sub`(
__mlir_op.`pop.shr`(
__mlir_op.`pop.simd.and`(
self._as_i8(), _mIsNotInteger.value
self._as_i8(), _mIsNotInteger._value
),
UInt8(1).value,
UInt8(1)._value,
),
UInt8(3).value,
UInt8(3)._value,
),
)
)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/builtin/file.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ struct FileHandle:
"KGEN_CompilerRT_IO_GetFD",
Int64,
](self.handle)
return Int(i64_res.value)
return Int(i64_res._value)


fn open[
Expand Down
2 changes: 1 addition & 1 deletion stdlib/src/builtin/io.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ fn _float_repr[
# Using `%.17g` with decimal check is equivalent to CPython's fallback path
# when its more complex dtoa library (forked from
# https://github.com/dtolnay/dtoa) is not available.
var n = _snprintf[fmt](buffer, size, x.value)
var n = _snprintf[fmt](buffer, size, x._value)
# If the buffer isn't big enough to add anything, then just return.
if n + 2 >= size:
return n
Expand Down
4 changes: 2 additions & 2 deletions stdlib/src/builtin/math.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn max(x: SIMD, y: __type_of(x), /) -> __type_of(x):
A SIMD vector containing the elementwise maximum of x and y.
"""
constrained[x.type.is_numeric(), "the SIMD type must be numeric"]()
return __mlir_op.`pop.max`(x.value, y.value)
return __mlir_op.`pop.max`(x._value, y._value)


# ===----------------------------------------------------------------------=== #
Expand Down Expand Up @@ -246,7 +246,7 @@ fn min(x: SIMD, y: __type_of(x), /) -> __type_of(x):
A SIMD vector containing the elementwise minimum of x and y.
"""
constrained[x.type.is_numeric(), "the SIMD type must be numeric"]()
return __mlir_op.`pop.min`(x.value, y.value)
return __mlir_op.`pop.min`(x._value, y._value)


# ===----------------------------------------------------------------------=== #
Expand Down
6 changes: 3 additions & 3 deletions stdlib/src/builtin/object.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -1799,10 +1799,10 @@ struct object(
@always_inline
fn _convert_index_to_int(i: object) raises -> Int:
if i._value.is_bool():
return i._value.convert_bool_to_int().get_as_int().value
return i._value.convert_bool_to_int().get_as_int()._value
elif not i._value.is_int():
raise Error("TypeError: string indices must be integers")
return i._value.get_as_int().value
return i._value.get_as_int()._value

@always_inline
fn __getitem__(self, i: object) raises -> object:
Expand All @@ -1828,7 +1828,7 @@ struct object(
var char = self._value.get_as_string().data[index]
impl.data.init_pointee_move(char)
return _ObjectImpl(impl)
return self._value.get_list_element(i._value.get_as_int().value)
return self._value.get_list_element(i._value.get_as_int()._value)

@always_inline
fn __getitem__(self, *index: object) raises -> object:
Expand Down
Loading

0 comments on commit 37be8c0

Please sign in to comment.