'ptr' Dialect
Pointer dialect
Operations ¶
ptr.ptr_add
(ptr::PtrAddOp) ¶
Pointer add operation
Syntax:
operation ::= `ptr.ptr_add` ($flags^)? $base `,` $offset attr-dict `:` type($base) `,` type($offset)
The ptr_add
operation adds an integer offset to a pointer to produce a new
pointer. The input and output pointer types are always the same.
Example:
%x_off = ptr.ptr_add %x, %off : !ptr.ptr<0>, i32
%x_off0 = ptr.ptr_add nusw %x, %off : !ptr.ptr<0>, i32
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
, ViewLikeOpInterface
Effects: MemoryEffects::Effect{}
Operands: ¶
Operand | Description |
---|---|
base | pointer type |
offset | signless integer or index |
Results: ¶
Result | Description |
---|---|
result | pointer type |
ptr.type_offset
(ptr::TypeOffsetOp) ¶
Type offset operation
Syntax:
operation ::= `ptr.type_offset` $elementType attr-dict `:` type($result)
The type_offset
operation produces an int or index-typed SSA value
equal to a target-specific constant representing the offset of a single
element of the given type.
Example:
// Return the offset between two f32 stored in memory
%0 = ptr.type_offset f32 : index
// Return the offset between two memref descriptors stored in memory
%1 = ptr.type_offset memref<12 x f64> : i32
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable
, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes: ¶
Attribute | MLIR Type | Description |
---|---|---|
elementType | ::mlir::TypeAttr | any type attribute |
Results: ¶
Result | Description |
---|---|
result | signless integer or index |
Attributes ¶
GenericSpaceAttr ¶
Generic memory space
Syntax: #ptr.generic_space
The generic_space
attribute defines a memory space attribute with the
following properties:
- Load and store operations are always valid, regardless of the type.
- Atomic operations are always valid, regardless of the type.
- Cast operations to
generic_space
are always valid.
Example:
#ptr.generic_space
SpecAttr ¶
Ptr data layout spec
Syntax:
#ptr.spec<
uint32_t, # size
uint32_t, # abi
uint32_t, # preferred
uint32_t # index
>
Defines the data layout spec for a pointer type. This attribute has 4 fields:
- [Required] size: size of the pointer in bits.
- [Required] abi: ABI-required alignment for the pointer in bits.
- [Required] preferred: preferred alignment for the pointer in bits.
- [Optional] index: bitwidth that should be used when performing index
computations for the type. Setting the field to
kOptionalSpecValue
, means the field is optional.
Furthermore, the attribute will verify that all present values are divisible
by 8 (number of bits in a byte), and that preferred
> abi
.
Example:
// Spec for a 64 bit ptr, with a required alignment of 64 bits, but with
// a preferred alignment of 128 bits and an index bitwidth of 64 bits.
#ptr.spec<size = 64, abi = 64, preferred = 128, index = 64>
Parameters: ¶
Parameter | C++ type | Description |
---|---|---|
size | uint32_t | |
abi | uint32_t | |
preferred | uint32_t | |
index | uint32_t |
Types ¶
PtrType ¶
Pointer type
Syntax:
!ptr.ptr<
MemorySpaceAttrInterface # memorySpace
>
The ptr
type is an opaque pointer type. This type typically represents a
handle to an object in memory or target-dependent values like nullptr
.
Pointers are parameterized by a memory space.
Syntax:
pointer ::= `ptr` (`<` memory-space `>`)?
memory-space ::= attribute-value
Parameters: ¶
Parameter | C++ type | Description |
---|---|---|
memorySpace | MemorySpaceAttrInterface |
Enums ¶
AtomicBinOp ¶
Ptr.atomicrmw binary operations
Cases: ¶
Symbol | Value | String |
---|---|---|
xchg | 0 | xchg |
add | 1 | add |
sub | 2 | sub |
_and | 3 | _and |
nand | 4 | nand |
_or | 5 | _or |
_xor | 6 | _xor |
max | 7 | max |
min | 8 | min |
umax | 9 | umax |
umin | 10 | umin |
fadd | 11 | fadd |
fsub | 12 | fsub |
fmax | 13 | fmax |
fmin | 14 | fmin |
uinc_wrap | 15 | uinc_wrap |
udec_wrap | 16 | udec_wrap |
AtomicOrdering ¶
Atomic ordering for LLVM’s memory model
Cases: ¶
Symbol | Value | String |
---|---|---|
not_atomic | 0 | not_atomic |
unordered | 1 | unordered |
monotonic | 2 | monotonic |
acquire | 3 | acquire |
release | 4 | release |
acq_rel | 5 | acq_rel |
seq_cst | 6 | seq_cst |
PtrAddFlags ¶
Pointer add flags
Cases: ¶
Symbol | Value | String |
---|---|---|
none | 0 | none |
nusw | 1 | nusw |
nuw | 2 | nuw |
inbounds | 3 | inbounds |