brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 3ed700c Raw
58 lines · plain
1// RUN: tblgen-to-irdl %s -I=%S/../../include --gen-dialect-irdl-defs --dialect=cmath | FileCheck %s2 3include "mlir/IR/OpBase.td"4include "mlir/IR/AttrTypeBase.td"5 6// CHECK-LABEL: irdl.dialect @cmath {7def CMath_Dialect : Dialect {8  let name = "cmath";9}10 11class CMath_Type<string name, string typeMnemonic, list<Trait> traits = []>12: TypeDef<CMath_Dialect, name, traits> {13  let mnemonic = typeMnemonic;14}15 16class CMath_Op<string mnemonic, list<Trait> traits = []>17    : Op<CMath_Dialect, mnemonic, traits>;18 19def f32Orf64Type : Or<[CPred<"::llvm::isa<::mlir::F32>">,20                       CPred<"::llvm::isa<::mlir::F64>">]>;21 22// CHECK: irdl.type @"!complex"23def CMath_ComplexType : CMath_Type<"ComplexType", "complex"> {24  let parameters = (ins f32Orf64Type:$elementType);25  let assemblyFormat = "`<` $elementType `>`";26}27 28// CHECK:      irdl.operation @identity {29// CHECK-NEXT:   %0 = irdl.base @cmath::@"!complex"30// CHECK-NEXT:   irdl.results(out: %0)31// CHECK-NEXT: }32def CMath_IdentityOp : CMath_Op<"identity"> {33  let results = (outs CMath_ComplexType:$out);34}35 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(in1: %0, in2: %1)41// CHECK-NEXT:   irdl.results(out: %2)42// CHECK-NEXT: }43def CMath_MulOp : CMath_Op<"mul"> {44  let arguments = (ins CMath_ComplexType:$in1, CMath_ComplexType:$in2);45  let results = (outs CMath_ComplexType:$out);46}47 48// CHECK:      irdl.operation @norm {49// CHECK-NEXT:   %0 = irdl.any50// CHECK-NEXT:   %1 = irdl.base @cmath::@"!complex"51// CHECK-NEXT:   irdl.operands(in: %0)52// CHECK-NEXT:   irdl.results(out: %1)53// CHECK-NEXT: }54def CMath_NormOp : CMath_Op<"norm"> {55  let arguments = (ins AnyType:$in);56  let results = (outs CMath_ComplexType:$out);57}58