@@ -21,40 +21,42 @@ include "mlir/IR/OpAsmInterface.td"
2121// PtrAddOp
2222//===----------------------------------------------------------------------===//
2323
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
2726 ]> {
2827 let summary = "Pointer add operation";
2928 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
3130 pointer. The input and output pointer types are always the same.
3231
3332 Example:
3433
3534 ```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
3837 ```
3938 }];
4039
4140 let arguments = (ins
4241 Ptr_PtrType:$base,
4342 AnySignlessIntegerOrIndex:$offset,
44- DefaultValuedAttr<Ptr_PtrAddFlags,
45- "::mlir::ptr::PtrAddFlags::none">:$flags);
43+ DefaultValuedProp<EnumProp<Ptr_PtrAddFlags>, "PtrAddFlags::none">:$flags);
4644 let results = (outs Ptr_PtrType:$result);
4745 let assemblyFormat = [{
4846 ($flags^)? $base `,` $offset attr-dict `:` type($base) `,` type($offset)
4947 }];
5048 let hasFolder = 1;
49+ let extraClassDeclaration = [{
50+ /// `ViewLikeOp::getViewSource` method.
51+ Value getViewSource() { return getBase(); }
52+ }];
5153}
5254
5355//===----------------------------------------------------------------------===//
5456// TypeOffsetOp
5557//===----------------------------------------------------------------------===//
5658
57- def Ptr_TypeOffsetOp : Pointer_Op<"type_offset", [ConstantLike, Pure]> {
59+ def Ptr_TypeOffsetOp : Pointer_Op<"type_offset", [Pure]> {
5860 let summary = "Type offset operation";
5961 let description = [{
6062 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]> {
6466 Example:
6567
6668 ```mlir
69+ // Return the offset between two f32 stored in memory
6770 %0 = ptr.type_offset f32 : index
71+ // Return the offset between two memref descriptors stored in memory
6872 %1 = ptr.type_offset memref<12 x f64> : i32
6973 ```
7074 }];
7175
72- let arguments = (ins TypeAttr:$element_type );
76+ let arguments = (ins TypeAttr:$elementType );
7377 let results = (outs AnySignlessIntegerOrIndex:$result);
7478 let builders = [
75- OpBuilder<(ins "TypeAttr ":$element_type )>
79+ OpBuilder<(ins "Type ":$elementType )>
7680 ];
7781 let assemblyFormat = [{
78- $element_type attr-dict `:` type($result)
82+ $elementType attr-dict `:` type($result)
7983 }];
8084 let extraClassDeclaration = [{
8185 /// Returns the type offset according to `maybeLayout`. If `maybeLayout` is
8286 /// `nullopt` the nearest layout the op will be used for the computation.
8387 llvm::TypeSize getTypeSize(std::optional<DataLayout> layout = std::nullopt);
8488 }];
85- let hasFolder = 1;
8689}
8790
8891#endif // PTR_OPS
0 commit comments