@@ -21,40 +21,42 @@ include "mlir/IR/OpAsmInterface.td"
21
21
// PtrAddOp
22
22
//===----------------------------------------------------------------------===//
23
23
24
- def Ptr_PtrAddOp : Pointer_Op<"ptradd", [
25
- Pure, AllTypesMatch<["base", "result"]>,
26
- DeclareOpInterfaceMethods<ViewLikeOpInterface>
24
+ def Ptr_PtrAddOp : Pointer_Op<"ptr_add", [
25
+ Pure, AllTypesMatch<["base", "result"]>, ViewLikeOpInterface
27
26
]> {
28
27
let summary = "Pointer add operation";
29
28
let description = [{
30
- The `ptradd ` operation adds an integer offset to a pointer to produce a new
29
+ The `ptr_add ` operation adds an integer offset to a pointer to produce a new
31
30
pointer. The input and output pointer types are always the same.
32
31
33
32
Example:
34
33
35
34
```mlir
36
- %x_off = ptr.ptradd %x, %off : !ptr.ptr<0>, i32
37
- %x_off0 = ptr.ptradd nusw %x, %off : !ptr.ptr<0>, i32
35
+ %x_off = ptr.ptr_add %x, %off : !ptr.ptr<0>, i32
36
+ %x_off0 = ptr.ptr_add nusw %x, %off : !ptr.ptr<0>, i32
38
37
```
39
38
}];
40
39
41
40
let arguments = (ins
42
41
Ptr_PtrType:$base,
43
42
AnySignlessIntegerOrIndex:$offset,
44
- DefaultValuedAttr<Ptr_PtrAddFlags,
45
- "::mlir::ptr::PtrAddFlags::none">:$flags);
43
+ DefaultValuedProp<EnumProp<Ptr_PtrAddFlags>, "PtrAddFlags::none">:$flags);
46
44
let results = (outs Ptr_PtrType:$result);
47
45
let assemblyFormat = [{
48
46
($flags^)? $base `,` $offset attr-dict `:` type($base) `,` type($offset)
49
47
}];
50
48
let hasFolder = 1;
49
+ let extraClassDeclaration = [{
50
+ /// `ViewLikeOp::getViewSource` method.
51
+ Value getViewSource() { return getBase(); }
52
+ }];
51
53
}
52
54
53
55
//===----------------------------------------------------------------------===//
54
56
// TypeOffsetOp
55
57
//===----------------------------------------------------------------------===//
56
58
57
- def Ptr_TypeOffsetOp : Pointer_Op<"type_offset", [ConstantLike, Pure]> {
59
+ def Ptr_TypeOffsetOp : Pointer_Op<"type_offset", [Pure]> {
58
60
let summary = "Type offset operation";
59
61
let description = [{
60
62
The `type_offset` operation produces an int or index-typed SSA value
@@ -64,25 +66,26 @@ def Ptr_TypeOffsetOp : Pointer_Op<"type_offset", [ConstantLike, Pure]> {
64
66
Example:
65
67
66
68
```mlir
69
+ // Return the offset between two f32 stored in memory
67
70
%0 = ptr.type_offset f32 : index
71
+ // Return the offset between two memref descriptors stored in memory
68
72
%1 = ptr.type_offset memref<12 x f64> : i32
69
73
```
70
74
}];
71
75
72
- let arguments = (ins TypeAttr:$element_type );
76
+ let arguments = (ins TypeAttr:$elementType );
73
77
let results = (outs AnySignlessIntegerOrIndex:$result);
74
78
let builders = [
75
- OpBuilder<(ins "TypeAttr ":$element_type )>
79
+ OpBuilder<(ins "Type ":$elementType )>
76
80
];
77
81
let assemblyFormat = [{
78
- $element_type attr-dict `:` type($result)
82
+ $elementType attr-dict `:` type($result)
79
83
}];
80
84
let extraClassDeclaration = [{
81
85
/// Returns the type offset according to `maybeLayout`. If `maybeLayout` is
82
86
/// `nullopt` the nearest layout the op will be used for the computation.
83
87
llvm::TypeSize getTypeSize(std::optional<DataLayout> layout = std::nullopt);
84
88
}];
85
- let hasFolder = 1;
86
89
}
87
90
88
91
#endif // PTR_OPS
0 commit comments