Ub
ub
The ub (undefined behavior) dialect.
Mirrors MLIR's UB dialect, which provides operations and attributes for representing deferred undefined behavior.
UB = Dialect('ub', [PoisonOp, UnreachableOp], [PoisonAttr])
module-attribute
PoisonAttr
dataclass
Bases: ParametrizedAttribute
Attribute carrying poison semantics for ub.poison.
A default (empty) #ub.poison indicates a fully poisoned result. Other
attributes (e.g. partially poisoned vectors) may be used to indicate
additional poison semantics; in MLIR this is modelled via the
PoisonAttrInterface.
Source code in xdsl/dialects/ub.py
23 24 25 26 27 28 29 30 31 32 33 34 | |
name = 'ub.poison'
class-attribute
instance-attribute
PoisonOp
Bases: IRDLOperation
Materializes a compile-time poisoned constant value to indicate deferred undefined behavior.
The value attribute indicates optional additional poison semantics (e.g.
partially poisoned vectors); the default value indicates the result is
fully poisoned.
Examples:
// Short form (fully poisoned)
%0 = ub.poison : i32
// Long form (additional poison semantics)
%1 = ub.poison <#custom_poison_elements_attr> : vector<4xi64>
Source code in xdsl/dialects/ub.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
name = 'ub.poison'
class-attribute
instance-attribute
value = prop_def(Attribute, default_value=(PoisonAttr()))
class-attribute
instance-attribute
result = result_def()
class-attribute
instance-attribute
traits = traits_def(ConstantLike(), Pure())
class-attribute
instance-attribute
assembly_format = 'attr-dict (`<` $value^ `>`)? `:` type($result)'
class-attribute
instance-attribute
__init__(result_type: Attribute, value: Attribute | None = None)
Source code in xdsl/dialects/ub.py
71 72 73 74 75 76 77 78 79 | |
UnreachableOp
dataclass
Bases: IRDLOperation
Triggers immediate undefined behavior if executed.
Example:
ub.unreachable
Source code in xdsl/dialects/ub.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |