1 // RUN: tblgen-to-irdl %s -I=%S/../../include --gen-dialect-irdl-defs --dialect=cmath | FileCheck %s
3 include "mlir/IR/OpBase.td"
4 include "mlir/IR/AttrTypeBase.td"
6 // CHECK-LABEL: irdl.dialect @cmath {
7 def CMath_Dialect : Dialect {
11 class CMath_Type<string name, string typeMnemonic, list<Trait> traits = []>
12 : TypeDef<CMath_Dialect, name, traits> {
13 let mnemonic = typeMnemonic;
16 class CMath_Op<string mnemonic, list<Trait> traits = []>
17 : Op<CMath_Dialect, mnemonic, traits>;
19 def f32Orf64Type : Or<[CPred<"::llvm::isa<::mlir::F32>">,
20 CPred<"::llvm::isa<::mlir::F64>">]>;
22 // CHECK: irdl.type @"!complex"
23 def CMath_ComplexType : CMath_Type<"ComplexType", "complex"> {
24 let parameters = (ins f32Orf64Type:$elementType);
25 let assemblyFormat = "`<` $elementType `>`";
28 // CHECK: irdl.operation @identity {
29 // CHECK-NEXT: %0 = irdl.base @cmath::@"!complex"
30 // CHECK-NEXT: irdl.results(%0)
32 def CMath_IdentityOp : CMath_Op<"identity"> {
33 let results = (outs CMath_ComplexType:$out);
36 // CHECK: irdl.operation @mul {
37 // CHECK-NEXT: %0 = irdl.base @cmath::@"!complex"
38 // CHECK-NEXT: %1 = irdl.base @cmath::@"!complex"
39 // CHECK-NEXT: %2 = irdl.base @cmath::@"!complex"
40 // CHECK-NEXT: irdl.operands(%0, %1)
41 // CHECK-NEXT: irdl.results(%2)
43 def CMath_MulOp : CMath_Op<"mul"> {
44 let arguments = (ins CMath_ComplexType:$in1, CMath_ComplexType:$in2);
45 let results = (outs CMath_ComplexType:$out);
48 // CHECK: irdl.operation @norm {
49 // CHECK-NEXT: %0 = irdl.any
50 // CHECK-NEXT: %1 = irdl.base @cmath::@"!complex"
51 // CHECK-NEXT: irdl.operands(%0)
52 // CHECK-NEXT: irdl.results(%1)
54 def CMath_NormOp : CMath_Op<"norm"> {
55 let arguments = (ins AnyType:$in);
56 let results = (outs CMath_ComplexType:$out);