2020-03-07 05:55:36 +08:00
|
|
|
// RUN: mlir-tblgen -gen-op-defs -I %S/../../include %s | FileCheck %s
|
|
|
|
|
2020-05-07 03:52:00 +08:00
|
|
|
include "mlir/Interfaces/SideEffectInterfaces.td"
|
2020-03-07 05:55:36 +08:00
|
|
|
|
|
|
|
def TEST_Dialect : Dialect {
|
|
|
|
let name = "test";
|
|
|
|
}
|
|
|
|
class TEST_Op<string mnemonic, list<OpTrait> traits = []> :
|
|
|
|
Op<TEST_Dialect, mnemonic, traits>;
|
|
|
|
|
2020-04-27 19:46:04 +08:00
|
|
|
def CustomResource : Resource<"CustomResource">;
|
|
|
|
|
2020-03-07 05:55:36 +08:00
|
|
|
def SideEffectOpA : TEST_Op<"side_effect_op_a"> {
|
2020-11-19 10:31:40 +08:00
|
|
|
let arguments = (ins
|
|
|
|
Arg<Variadic<AnyMemRef>, "", [MemRead]>,
|
|
|
|
Arg<SymbolRefAttr, "", [MemRead]>:$symbol,
|
|
|
|
Arg<FlatSymbolRefAttr, "", [MemWrite]>:$flat_symbol,
|
|
|
|
Arg<OptionalAttr<SymbolRefAttr>, "", [MemRead]>:$optional_symbol
|
|
|
|
);
|
2020-04-27 19:46:04 +08:00
|
|
|
let results = (outs Res<AnyMemRef, "", [MemAlloc<CustomResource>]>);
|
2020-03-07 05:55:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
def SideEffectOpB : TEST_Op<"side_effect_op_b",
|
2020-04-27 19:46:04 +08:00
|
|
|
[MemoryEffects<[MemWrite<CustomResource>]>]>;
|
2020-03-07 05:55:36 +08:00
|
|
|
|
|
|
|
// CHECK: void SideEffectOpA::getEffects
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK: for (::mlir::Value value : getODSOperands(0))
|
2020-03-07 05:55:36 +08:00
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Read::get(), value, ::mlir::SideEffects::DefaultResource::get());
|
2020-11-19 10:31:40 +08:00
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Read::get(), symbol(), ::mlir::SideEffects::DefaultResource::get());
|
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Write::get(), flat_symbol(), ::mlir::SideEffects::DefaultResource::get());
|
|
|
|
// CHECK: if (auto symbolRef = optional_symbolAttr())
|
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Read::get(), symbolRef, ::mlir::SideEffects::DefaultResource::get());
|
2020-06-26 19:20:44 +08:00
|
|
|
// CHECK: for (::mlir::Value value : getODSResults(0))
|
2020-03-07 05:55:36 +08:00
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Allocate::get(), value, CustomResource::get());
|
|
|
|
|
|
|
|
// CHECK: void SideEffectOpB::getEffects
|
|
|
|
// CHECK: effects.emplace_back(MemoryEffects::Write::get(), CustomResource::get());
|