1 // RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s
3 include "mlir/Interfaces/SideEffectInterfaces.td"
5 def TEST_Dialect : Dialect {
8 class TEST_Op<string mnemonic, list<Trait> traits = []> :
9 Op<TEST_Dialect, mnemonic, traits>;
11 def CustomResource : Resource<"CustomResource">;
13 def SideEffectOpA : TEST_Op<"side_effect_op_a"> {
15 Arg<Variadic<AnyMemRef>, "", [MemRead]>,
16 Arg<AnyMemRef, "", [MemWriteAt<1, FullEffect>]>,
17 Arg<SymbolRefAttr, "", [MemRead]>:$symbol,
18 Arg<FlatSymbolRefAttr, "", [MemWrite]>:$flat_symbol,
19 Arg<OptionalAttr<SymbolRefAttr>, "", [MemRead]>:$optional_symbol
21 let results = (outs Res<AnyMemRef, "", [MemAlloc<CustomResource, 0>]>);
24 def SideEffectOpB : TEST_Op<"side_effect_op_b",
25 [MemoryEffects<[MemWrite<CustomResource, 0>]>]>;
27 // CHECK: void SideEffectOpA::getEffects
29 // CHECK: auto valueRange = getODSOperandIndexAndLength(0);
30 // CHECK: for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
31 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
35 // CHECK: auto valueRange = getODSOperandIndexAndLength(1);
36 // CHECK: for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
37 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 1, true, ::mlir::SideEffects::DefaultResource::get());
40 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Read::get(), getSymbolAttr(), 0, false, ::mlir::SideEffects::DefaultResource::get());
41 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Write::get(), getFlatSymbolAttr(), 0, false, ::mlir::SideEffects::DefaultResource::get());
42 // CHECK: if (auto symbolRef = getOptionalSymbolAttr())
43 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Read::get(), symbolRef, 0, false, ::mlir::SideEffects::DefaultResource::get());
45 // CHECK: auto valueRange = getODSResultIndexAndLength(0);
46 // CHECK: for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
47 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), getOperation()->getOpResult(idx), 0, false, CustomResource::get());
51 // CHECK: void SideEffectOpB::getEffects
52 // CHECK: effects.emplace_back(::mlir::MemoryEffects::Write::get(), 0, false, CustomResource::get());