82 lines · plain
1// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s2// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s3// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s4// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s5// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s6// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s7// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s8// RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s9 10include "mlir/IR/OpBase.td"11include "mlir/IR/PatternBase.td"12 13// Check using the dialect name as the namespace14def A_Dialect : Dialect {15 let name = "a";16}17 18class A_Op<string mnemonic, list<Trait> traits = []> :19 Op<A_Dialect, mnemonic, traits>;20 21def OpA : A_Op<"op_a">, Arguments<(ins AnyInteger, AnyInteger)>, Results<(outs AnyInteger)>;22def OpB : A_Op<"op_b">, Arguments<(ins AnyInteger, AnyAttr:$value)>, Results<(outs AnyInteger)>;23 24#ifdef ERROR125def NativeMatcher : NativeCodeCall<"success(nativeCall($0, $1))">;26// ERROR1: [[@LINE+1]]:1: error: NativeCodeCall must have $_self as argument for passing the defining Operation27def : Pat<(OpA (NativeMatcher $val), AnyI32Attr:$arg),28 (OpB $val, $arg)>;29#endif30 31#ifdef ERROR232def NativeMatcher : NativeCodeCall<"success(nativeCall($_self, &$0))">;33// ERROR2: [[@LINE+1]]:1: error: binding symbol 'error' to NativecodeCall in MatchPattern is not supported34def : Pat<(OpA (NativeMatcher:$error $val), AnyI32Attr:$arg),35 (OpB $val, $arg)>;36#endif37 38#ifdef ERROR339def NativeMatcher : NativeCodeCall<"success(nativeCall($_self, $0, $1))">;40// ERROR3: [[@LINE+1]]:1: error: Matching nested tree in NativeCodecall not support for41def : Pat<(OpA (NativeMatcher (OpB $val, $unused)), AnyI32Attr:$arg),42 (OpB $val, $arg)>;43#endif44 45#ifdef ERROR446// Check trying to pass op as DAG node inside ReturnTypeFunc fails.47// ERROR4: [[@LINE+1]]:1: error: nested DAG in `returnType` must be a native code48def : Pat<(OpB $val, AnyI32Attr:$attr), (OpA (OpA $val, $val, (returnType (OpA $val, $val))), $val)>;49#endif50 51#ifdef ERROR552// Check that trying to specify explicit types at the root node fails.53// ERROR5: [[@LINE+1]]:1: error: Cannot specify explicit return types in an op54def : Pat<(OpB $val, AnyI32Attr:$attr), (OpA $val, $val, (returnType "someType()"))>;55#endif56 57#ifdef ERROR658// Check that type constraint has one argument59// ERROR6: [[@LINE+1]]:1: error: type constraint requires exactly one argument60def : Pat<(OpB:$result $val, $attr), (OpA $val, $val), [(AnyInteger:$result)]>;61#endif62 63#ifdef ERROR764// Check that type constraint has one argument65// ERROR7: [[@LINE+1]]:1: error: type constraint requires exactly one argument66def : Pat<(OpB:$opB $val, $attr), (OpA $val, $val), [(AnyInteger $opB, $val)]>;67#endif68 69def OpC : A_Op<"op_c">, Results<(outs AnyInteger)>;70def OpD : A_Op<"op_d">, Arguments<(ins Variadic<AnyInteger>:$vargs)>, Results<(outs AnyInteger)>;71 72#ifdef ERROR873// Check that op with variadic operand gets variadic operand in target,74//75// FIXME: this should be an error.76def : Pat<(OpB:$opB $val, $attr), (OpD $val)>;77 78// ERROR8: [[@LINE+2]]79// ERROR8-SAME: op expects variadic operand `vargs`, while provided is non-variadic80def : Pat<(OpB:$opB $val, $attr), (OpD (OpC))>;81#endif82