1// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s 2 3include "mlir/Interfaces/SideEffectInterfaces.td" 4 5def TEST_Dialect : Dialect { 6 let name = "test"; 7} 8class TEST_Op<string mnemonic, list<OpTrait> traits = []> : 9 Op<TEST_Dialect, mnemonic, traits>; 10 11def CustomResource : Resource<"CustomResource">; 12 13def SideEffectOpA : TEST_Op<"side_effect_op_a"> { 14 let arguments = (ins 15 Arg<Variadic<AnyMemRef>, "", [MemRead]>, 16 Arg<SymbolRefAttr, "", [MemRead]>:$symbol, 17 Arg<FlatSymbolRefAttr, "", [MemWrite]>:$flat_symbol, 18 Arg<OptionalAttr<SymbolRefAttr>, "", [MemRead]>:$optional_symbol 19 ); 20 let results = (outs Res<AnyMemRef, "", [MemAlloc<CustomResource>]>); 21} 22 23def SideEffectOpB : TEST_Op<"side_effect_op_b", 24 [MemoryEffects<[MemWrite<CustomResource>]>]>; 25 26// CHECK: void SideEffectOpA::getEffects 27// CHECK: for (::mlir::Value value : getODSOperands(0)) 28// CHECK: effects.emplace_back(MemoryEffects::Read::get(), value, ::mlir::SideEffects::DefaultResource::get()); 29// CHECK: effects.emplace_back(MemoryEffects::Read::get(), symbol(), ::mlir::SideEffects::DefaultResource::get()); 30// CHECK: effects.emplace_back(MemoryEffects::Write::get(), flat_symbol(), ::mlir::SideEffects::DefaultResource::get()); 31// CHECK: if (auto symbolRef = optional_symbolAttr()) 32// CHECK: effects.emplace_back(MemoryEffects::Read::get(), symbolRef, ::mlir::SideEffects::DefaultResource::get()); 33// CHECK: for (::mlir::Value value : getODSResults(0)) 34// CHECK: effects.emplace_back(MemoryEffects::Allocate::get(), value, CustomResource::get()); 35 36// CHECK: void SideEffectOpB::getEffects 37// CHECK: effects.emplace_back(MemoryEffects::Write::get(), CustomResource::get()); 38