Ptr
ptr
¶
This is a port of the 'ptr' dialect proposed in this thread https://discourse.llvm.org/t/rfc-ptr-dialect-modularizing-ptr-ops-in-the-llvm-dialect/75142/21 Main parts of the dialect has already been agreed upon but only the basic datatype is implemented upstream. When the upstream implementation is merged we should fix our implementation to be consistent with the mlir version. Current deviations: 1. Name of the dialect should be changed: ptr_xdsl -> ptr. We currently chose another name to avoid conflicts when loading our dialect to mlir-opt. 2. There is no ptr.to_ptr operation currently proposed, but there is a memref.to_ptr. We do this so that we can feed the results of convert-memref-to-ptr pass without any conflict.
Ptr = Dialect('ptr_xdsl', [PtrAddOp, TypeOffsetOp, StoreOp, LoadOp, ToPtrOp, FromPtrOp], [PtrType])
module-attribute
¶
PtrType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.ptr'
class-attribute
instance-attribute
¶
PtrAddOpHasCanonicalizationPatterns
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/ptr.py
PtrAddOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.ptradd'
class-attribute
instance-attribute
¶
addr = operand_def(PtrType)
class-attribute
instance-attribute
¶
offset = operand_def(IntegerAttrTypeConstr)
class-attribute
instance-attribute
¶
result = result_def(PtrType)
class-attribute
instance-attribute
¶
assembly_format = '$addr `,` $offset attr-dict `:` `(` type($addr) `,` type($offset) `)` `->` type($result)'
class-attribute
instance-attribute
¶
traits = traits_def(PtrAddOpHasCanonicalizationPatterns())
class-attribute
instance-attribute
¶
TypeOffsetOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.type_offset'
class-attribute
instance-attribute
¶
elem_type = prop_def(AnyAttr())
class-attribute
instance-attribute
¶
offset = result_def(IntegerAttrTypeConstr)
class-attribute
instance-attribute
¶
assembly_format = '$elem_type attr-dict `:` type($offset)'
class-attribute
instance-attribute
¶
StoreOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.store'
class-attribute
instance-attribute
¶
addr = operand_def(PtrType)
class-attribute
instance-attribute
¶
value = operand_def()
class-attribute
instance-attribute
¶
volatile = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
syncscope = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
ordering = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '(`volatile` $volatile^)? $value `,` $addr (`atomic` (`syncscope` `(` $syncscope^ `)`)? $ordering^)? attr-dict `:` type($value) `,` type($addr)'
class-attribute
instance-attribute
¶
__init__(addr: SSAValue, value: SSAValue, *, volatile: bool = False, syncscope: bool = False, ordering: bool = False)
¶
Source code in xdsl/dialects/ptr.py
LoadOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.load'
class-attribute
instance-attribute
¶
addr = operand_def(PtrType)
class-attribute
instance-attribute
¶
res = result_def()
class-attribute
instance-attribute
¶
volatile = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
syncscope = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
ordering = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
invariant = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
assembly_format = '(`volatile` $volatile^)? $addr (`atomic` (`syncscope` `(` $syncscope^ `)`)? $ordering^)? (`invariant` $invariant^)? attr-dict `:` type($addr) `->` type($res)'
class-attribute
instance-attribute
¶
__init__(addr: SSAValue, result_type: Attribute, *, volatile: bool = False, syncscope: bool = False, ordering: bool = False, invariant: bool = False)
¶
Source code in xdsl/dialects/ptr.py
ToPtrOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/ptr.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
ToPtrOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/ptr.py
name = 'ptr_xdsl.to_ptr'
class-attribute
instance-attribute
¶
source = operand_def(MemRefType)
class-attribute
instance-attribute
¶
res = result_def(PtrType)
class-attribute
instance-attribute
¶
assembly_format = '$source attr-dict `:` type($source) `->` type($res)'
class-attribute
instance-attribute
¶
traits = traits_def(Pure(), ToPtrOpHasCanonicalizationPatternsTrait())
class-attribute
instance-attribute
¶
FromPtrOpHasCanonicalizationPatternsTrait
dataclass
¶
Bases: HasCanonicalizationPatternsTrait
Source code in xdsl/dialects/ptr.py
get_canonicalization_patterns() -> tuple[RewritePattern, ...]
classmethod
¶
FromPtrOp
¶
Bases: IRDLOperation