Skip to content

Commit 262108e

Browse files
committed
[mlir] Extended Alloc and Dealloc operations with memory-effect traits.
Extended standard Alloc and Dealloc operations with memory-effect traits. Differential Revision: https://reviews.llvm.org/D78619
1 parent 8488763 commit 262108e

File tree

1 file changed

+7
-5
lines changed
  • mlir/include/mlir/Dialect/StandardOps/IR

1 file changed

+7
-5
lines changed

mlir/include/mlir/Dialect/StandardOps/IR/Ops.td

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ class FloatArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
129129
//
130130
// %0 = alloclike(%m)[%s] : memref<8x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1)>
131131
//
132-
class AllocLikeOp<string mnemonic, list<OpTrait> traits = []> :
132+
class AllocLikeOp<string mnemonic,
133+
list<OpVariableDecorator> resultDecorators = [],
134+
list<OpTrait> traits = []> :
133135
Std_Op<mnemonic, traits> {
134136

135137
let arguments = (ins Variadic<Index>:$value,
136138
Confined<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$alignment);
137-
let results = (outs AnyMemRef);
139+
let results = (outs Arg<AnyMemRef, "", resultDecorators>);
138140

139141
let builders = [OpBuilder<
140142
"Builder *builder, OperationState &result, MemRefType memrefType", [{
@@ -276,7 +278,7 @@ def AddIOp : IntArithmeticOp<"addi", [Commutative]> {
276278
// AllocOp
277279
//===----------------------------------------------------------------------===//
278280

279-
def AllocOp : AllocLikeOp<"alloc"> {
281+
def AllocOp : AllocLikeOp<"alloc", [MemAlloc], [MemoryEffects<[MemAlloc]>]> {
280282
let summary = "memory allocation operation";
281283
let description = [{
282284
The `alloc` operation allocates a region of memory, as specified by its
@@ -1253,7 +1255,7 @@ def CosOp : FloatUnaryOp<"cos"> {
12531255
// DeallocOp
12541256
//===----------------------------------------------------------------------===//
12551257

1256-
def DeallocOp : Std_Op<"dealloc"> {
1258+
def DeallocOp : Std_Op<"dealloc", [MemoryEffects<[MemFree]>]> {
12571259
let summary = "memory deallocation operation";
12581260
let description = [{
12591261
The `dealloc` operation frees the region of memory referenced by a memref
@@ -1269,7 +1271,7 @@ def DeallocOp : Std_Op<"dealloc"> {
12691271
```
12701272
}];
12711273

1272-
let arguments = (ins AnyMemRef:$memref);
1274+
let arguments = (ins Arg<AnyMemRef, "", [MemFree]>:$memref);
12731275

12741276
let hasCanonicalizer = 1;
12751277
let hasFolder = 1;

0 commit comments

Comments
 (0)