Skip to content

Commit

Permalink
[Stdlib] Further remove pop operations from the dtype checks, NFC (#3…
Browse files Browse the repository at this point in the history
…2290)

This continues to remove the pop operations from the dtype checks
without getting recursive elaborator errors

E.g

```
no work left, no deferred search, and no recursion?
UNREACHABLE executed at /Users/abduld/code/modular/KGEN/lib/Elaborator/Elaborator.cpp:2703!
PLEASE submit a bug report to [Internal Link] and include the crash backtrace.
 #0 0x0000000102c4ca08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/abduld/code/modular/.derived/build-release/bin/mojo-prime-package-cache+0x1000c4a08)
 #1 0x0000000102c4ab68 llvm::sys::RunSignalHandlers() (/Users/abduld/code/modular/.derived/build-release/bin/mojo-prime-package-cache+0x1000c2b68)
 modular#2 0x0000000102c4d0a8 SignalHandler(int) (/Users/abduld/code/modular/.derived/build-release/bin/mojo-prime-package-cache+0x1000c50a8)
 modular#3 0x00000001880e02a4 (/usr/lib/system/libsystem_platform.dylib+0x1803fc2a4)
 modular#4 0x00000001880b1cec (/usr/lib/system/libsystem_pthread.dylib+0x1803cdcec)
 modular#5 0x0000000187feb2c8 (/usr/lib/system/libsystem_c.dylib+0x1803072c8)
 modular#6 0x0000000102be03a0 llvm::install_out_of_memory_new_handler() (/Users/abduld/code/modular/.derived/build-release/bin/mojo-prime-package-cache+0x1000583a0)
```

modular-orig-commit: ebb7c424801291198503fde0ebdd6fd28da8f2e9
  • Loading branch information
abduld authored Feb 17, 2024
1 parent c88e244 commit bf78b6b
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions stdlib/src/builtin/dtype.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,9 @@ struct DType(Stringable, KeyElement):
"""
if not self.is_integral():
return False
let val = __mlir_op.`pop.dtype.to_ui8`(self.value)
let ui8 = __mlir_op.`pop.cast_from_builtin`[
_type = __mlir_type.`!pop.scalar<ui8>`
](val)
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred eq>`](
__mlir_op.`pop.and`(ui8, _mIsSigned.value),
__mlir_op.`pop.and`(self._as_i8(), _mIsSigned.value),
UInt8(0).value,
)
)
Expand All @@ -367,13 +363,9 @@ struct DType(Stringable, KeyElement):
return True
if not self.is_integral():
return False
let val = __mlir_op.`pop.dtype.to_ui8`(self.value)
let ui8 = __mlir_op.`pop.cast_from_builtin`[
_type = __mlir_type.`!pop.scalar<ui8>`
](val)
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.and`(ui8, _mIsSigned.value),
__mlir_op.`pop.and`(self._as_i8(), _mIsSigned.value),
UInt8(0).value,
)
)
Expand All @@ -387,13 +379,9 @@ struct DType(Stringable, KeyElement):
"""
if self.is_index():
return True
let val = __mlir_op.`pop.dtype.to_ui8`(self.value)
let ui8 = __mlir_op.`pop.cast_from_builtin`[
_type = __mlir_type.`!pop.scalar<ui8>`
](val)
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.and`(ui8, _mIsInteger.value),
__mlir_op.`pop.and`(self._as_i8(), _mIsInteger.value),
UInt8(0).value,
)
)
Expand All @@ -408,13 +396,9 @@ struct DType(Stringable, KeyElement):
"""
if self.is_integral():
return False
let val = __mlir_op.`pop.dtype.to_ui8`(self.value)
let ui8 = __mlir_op.`pop.cast_from_builtin`[
_type = __mlir_type.`!pop.scalar<ui8>`
](val)
return Bool(
__mlir_op.`pop.cmp`[pred = __mlir_attr.`#pop<cmp_pred ne>`](
__mlir_op.`pop.and`(ui8, _mIsFloat.value),
__mlir_op.`pop.and`(self._as_i8(), _mIsFloat.value),
UInt8(0).value,
)
)
Expand Down

0 comments on commit bf78b6b

Please sign in to comment.