diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -143,12 +143,14 @@ // // %0 = alloclike(%m)[%s] : memref<8x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1)> // -class AllocLikeOp traits = []> : - Std_Op])> { +class AllocLikeOp traits = []> : + Std_Op]>], traits)> { let arguments = (ins Variadic:$value, Confined, [IntMinValue<0>]>:$alignment); - let results = (outs Res); + let results = (outs Res]>); let builders = [OpBuilder< "OpBuilder &builder, OperationState &result, MemRefType memrefType", [{ @@ -310,7 +312,7 @@ // AllocOp //===----------------------------------------------------------------------===// -def AllocOp : AllocLikeOp<"alloc"> { +def AllocOp : AllocLikeOp<"alloc", DefaultResource> { let summary = "memory allocation operation"; let description = [{ The `alloc` operation allocates a region of memory, as specified by its @@ -357,7 +359,7 @@ // AllocaOp //===----------------------------------------------------------------------===// -def AllocaOp : AllocLikeOp<"alloca"> { +def AllocaOp : AllocLikeOp<"alloca", AutomaticAllocationScopeResource> { let summary = "stack memory allocation operation"; let description = [{ The `alloca` operation allocates memory on the stack, to be automatically diff --git a/mlir/include/mlir/Interfaces/SideEffectInterfaces.td b/mlir/include/mlir/Interfaces/SideEffectInterfaces.td --- a/mlir/include/mlir/Interfaces/SideEffectInterfaces.td +++ b/mlir/include/mlir/Interfaces/SideEffectInterfaces.td @@ -33,6 +33,9 @@ // A link to the DefaultResource class. def DefaultResource : IntrinsicResource<"DefaultResource">; +// A link to the AutomaticAllocationScopeResource class. +def AutomaticAllocationScopeResource : + IntrinsicResource<"AutomaticAllocationScopeResource">; //===----------------------------------------------------------------------===// // EffectOpInterface diff --git a/mlir/include/mlir/Interfaces/SideEffects.h b/mlir/include/mlir/Interfaces/SideEffects.h --- a/mlir/include/mlir/Interfaces/SideEffects.h +++ b/mlir/include/mlir/Interfaces/SideEffects.h @@ -122,6 +122,13 @@ StringRef getName() final { return ""; } }; +/// An automatic allocation-scope resource that is valid in the context of a +/// parent AutomaticAllocationScope trait. +struct AutomaticAllocationScopeResource + : public Resource::Base { + StringRef getName() final { return "AutomaticAllocationScope"; } +}; + /// This class represents a specific instance of an effect. It contains the /// effect being applied, a resource that corresponds to where the effect is /// applied, and an optional value(either operand, result, or region entry