1 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
2 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
3 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s
4 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s
5 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s
6 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s
7 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s
8 // RUN: not mlir-tblgen -gen-rewriters -I %S/../../include -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s
10 include "mlir/IR/OpBase.td"
11 include "mlir/IR/PatternBase.td"
13 // Check using the dialect name as the namespace
14 def A_Dialect : Dialect {
18 class A_Op<string mnemonic, list<Trait> traits = []> :
19 Op<A_Dialect, mnemonic, traits>;
21 def OpA : A_Op<"op_a">, Arguments<(ins AnyInteger, AnyInteger)>, Results<(outs AnyInteger)>;
22 def OpB : A_Op<"op_b">, Arguments<(ins AnyInteger, AnyAttr:$value)>, Results<(outs AnyInteger)>;
25 def NativeMatcher : NativeCodeCall<"success(nativeCall($0, $1))">;
26 // ERROR1: [[@LINE+1]]:1: error: NativeCodeCall must have $_self as argument for passing the defining Operation
27 def : Pat<(OpA (NativeMatcher $val), AnyI32Attr:$arg),
32 def NativeMatcher : NativeCodeCall<"success(nativeCall($_self, &$0))">;
33 // ERROR2: [[@LINE+1]]:1: error: binding symbol 'error' to NativecodeCall in MatchPattern is not supported
34 def : Pat<(OpA (NativeMatcher:$error $val), AnyI32Attr:$arg),
39 def NativeMatcher : NativeCodeCall<"success(nativeCall($_self, $0, $1))">;
40 // ERROR3: [[@LINE+1]]:1: error: Matching nested tree in NativeCodecall not support for
41 def : Pat<(OpA (NativeMatcher (OpB $val, $unused)), AnyI32Attr:$arg),
46 // 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 code
48 def : Pat<(OpB $val, AnyI32Attr:$attr), (OpA (OpA $val, $val, (returnType (OpA $val, $val))), $val)>;
52 // 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 op
54 def : Pat<(OpB $val, AnyI32Attr:$attr), (OpA $val, $val, (returnType "someType()"))>;
58 // Check that type constraint has one argument
59 // ERROR6: [[@LINE+1]]:1: error: type constraint requires exactly one argument
60 def : Pat<(OpB:$result $val, $attr), (OpA $val, $val), [(AnyInteger:$result)]>;
64 // Check that type constraint has one argument
65 // ERROR7: [[@LINE+1]]:1: error: type constraint requires exactly one argument
66 def : Pat<(OpB:$opB $val, $attr), (OpA $val, $val), [(AnyInteger $opB, $val)]>;
69 def OpC : A_Op<"op_c">, Results<(outs AnyInteger)>;
70 def OpD : A_Op<"op_d">, Arguments<(ins Variadic<AnyInteger>:$vargs)>, Results<(outs AnyInteger)>;
73 // Check that op with variadic operand gets variadic operand in target,
75 // FIXME: this should be an error.
76 def : Pat<(OpB:$opB $val, $attr), (OpD $val)>;
78 // ERROR8: [[@LINE+2]]
79 // ERROR8-SAME: op expects variadic operand `vargs`, while provided is non-variadic
80 def : Pat<(OpB:$opB $val, $attr), (OpD (OpC))>;