diff options
Diffstat (limited to 'mlir/test/lib/TestDialect/TestOps.td')
-rw-r--r-- | mlir/test/lib/TestDialect/TestOps.td | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index 944ce79a182..41e44f69c2f 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -194,6 +194,26 @@ def SizedRegionOp : TEST_Op<"sized_region_op", []> { let regions = (region SizedRegion<2>:$my_region, SizedRegion<1>); } +//===----------------------------------------------------------------------===// +// Test Call Interfaces +//===----------------------------------------------------------------------===// + +def ConversionCallOp : TEST_Op<"conversion_call_op", + [CallOpInterface]> { + let arguments = (ins Variadic<AnyType>:$inputs, SymbolRefAttr:$callee); + let results = (outs Variadic<AnyType>); + + let extraClassDeclaration = [{ + /// Get the argument operands to the called function. + operand_range getArgOperands() { return inputs(); } + + /// Return the callee of this operation. + CallInterfaceCallable getCallableForCallee() { + return getAttrOfType<SymbolRefAttr>("callee"); + } + }]; +} + def FunctionalRegionOp : TEST_Op<"functional_region_op", [CallableOpInterface]> { let regions = (region AnyRegion:$body); @@ -204,6 +224,9 @@ def FunctionalRegionOp : TEST_Op<"functional_region_op", void getCallableRegions(SmallVectorImpl<Region *> &callables) { callables.push_back(&body()); } + ArrayRef<Type> getCallableResults(Region *) { + return getType().cast<FunctionType>().getResults(); + } }]; } |