1// RUN: llvm-tblgen -gen-dag-isel -I %p/../../include %s 2>&1 | FileCheck %s 2// RUN: llvm-tblgen -gen-dag-isel -I %p/../../include -DIGNORE %s 2>&1 | FileCheck %s 3 4include "llvm/Target/Target.td" 5 6// Minimal Target definition 7def DemoInstrInfo : InstrInfo; 8def Demo : Target { 9 let InstructionSet = DemoInstrInfo; 10} 11 12// Some registers which can hold ints or floats 13foreach i = 0...7 in 14 def "R" # i: Register<"r" # i>; 15def GPR : RegisterClass<"Demo", [i32, f32], 32, (sequence "R%u", 0, 7)>; 16 17// Instruction to convert an int to a float 18def i2f : Instruction { 19 let Size = 2; 20 let OutOperandList = (outs GPR:$dst); 21 let InOperandList = (ins GPR:$src); 22 let AsmString = "i2f $dst, $src"; 23} 24 25// Some kind of special type-conversion node supported by this target 26def specialconvert : SDNode<"TEST_TARGET_ISD::SPECIAL_CONVERT", SDTUnaryOp>; 27 28// A PatFrags that matches either bitconvert or the special version 29def anyconvert : PatFrags<(ops node:$src), 30 [(bitconvert node:$src), 31 (specialconvert node:$src)]>; 32 33#ifdef IGNORE 34// Ensure ShouldIgnore does not disable records in dag isel emitter 35let GISelShouldIgnore = 1 in 36#endif 37// And a rule that matches that PatFrag and turns it into i2f 38def : Pat<(f32 (anyconvert (i32 GPR:$val))), (i2f GPR:$val)>; 39 40// CHECK: SwitchOpcode{{.*}}ISD::BITCAST 41// CHECK: MorphNodeTo1{{.*}}i2f 42// CHECK: SwitchOpcode{{.*}}TEST_TARGET_ISD::SPECIAL_CONVERT 43// CHECK: MorphNodeTo1{{.*}}i2f 44