1 // RUN: llvm-tblgen -gen-dag-isel -I %p/../../include %s 2>&1 | FileCheck -check-prefix=SDAG %s
2 // RUN: llvm-tblgen -gen-global-isel -optimize-match-table=false -I %p/../../include %s -o - < %s | FileCheck -check-prefix=GISEL %s
4 include "llvm/Target/Target.td"
6 def TestTargetInstrInfo : InstrInfo;
9 def TestTarget : Target {
10 let InstructionSet = TestTargetInstrInfo;
13 def R0 : Register<"r0"> { let Namespace = "MyTarget"; }
14 def GPR32 : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
17 // With one address space
18 def pat_frag_a : PatFrag <(ops node:$ptr), (load node:$ptr), [{}]> {
19 let IsLoad = 1; // FIXME: Can this be inferred?
23 // With multiple address spaces
24 def pat_frag_b : PatFrag <(ops node:$ptr), (load node:$ptr), [{}]> {
25 let AddressSpaces = [ 123, 455 ];
26 let IsLoad = 1; // FIXME: Can this be inferred?
29 def inst_a : Instruction {
30 let OutOperandList = (outs GPR32:$dst);
31 let InOperandList = (ins GPR32:$src);
34 def inst_b : Instruction {
35 let OutOperandList = (outs GPR32:$dst);
36 let InOperandList = (ins GPR32:$src);
39 def inst_c : Instruction {
40 let OutOperandList = (outs);
41 let InOperandList = (ins GPR32:$src0, GPR32:$src1);
44 def inst_d : Instruction {
45 let OutOperandList = (outs);
46 let InOperandList = (ins GPR32:$src0, GPR32:$src1);
50 // SDAG-NEXT: // Predicate_pat_frag_b
51 // SDAG-NEXT: // Predicate_truncstorei16_addrspace
52 // SDAG-NEXT: SDNode *N = Node;
53 // SDAG-NEXT: (void)N;
54 // SDAG-NEXT: unsigned AddrSpace = cast<MemSDNode>(N)->getAddressSpace();
55 // SDAG-NEXT: if (AddrSpace != 123 && AddrSpace != 455)
56 // SDAG-NEXT: return false;
57 // SDAG-NEXT: return true;
60 // GISEL: GIM_Try, /*On fail goto*//*Label 0*/ {{[0-9]+}}, // Rule ID 0 //
61 // GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
62 // GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_LOAD,
63 // GISEL-NEXT: GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
64 // GISEL-NEXT: GIM_CheckMemoryAddressSpace, /*MI*/0, /*MMO*/0, /*NumAddrSpace*/2, /*AddrSpace*/123, /*AddrSpace*/455,
65 // GISEL-NEXT: GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(int64_t)AtomicOrdering::NotAtomic,
67 (pat_frag_b GPR32:$src),
73 // SDAG: // Predicate_pat_frag_a
74 // SDAG-NEXT: SDNode *N = Node;
75 // SDAG-NEXT: (void)N;
76 // SDAG-NEXT: if (cast<MemSDNode>(N)->getAlign() < Align(2))
77 // SDAG-NEXT: return false;
78 // SDAG-NEXT: return true;
80 // GISEL: GIM_Try, /*On fail goto*//*Label 1*/ {{[0-9]+}}, // Rule ID 1 //
81 // GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
82 // GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_LOAD,
83 // GISEL-NEXT: GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
84 // GISEL-NEXT: GIM_CheckMemoryAlignment, /*MI*/0, /*MMO*/0, /*MinAlign*/2,
85 // GISEL-NEXT: GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(int64_t)AtomicOrdering::NotAtomic,
87 (pat_frag_a GPR32:$src),
92 def truncstorei16_addrspace : PatFrag<(ops node:$val, node:$ptr),
93 (truncstorei16 node:$val, node:$ptr)> {
95 let AddressSpaces = [ 123, 455 ];
98 // Test truncstore without a specific MemoryVT
99 // GISEL: GIM_Try, /*On fail goto*//*Label 2*/ {{[0-9]+}}, // Rule ID 2 //
100 // GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
101 // GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_STORE,
102 // GISEL-NEXT: GIM_CheckMemorySizeLessThanLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
103 // GISEL-NEXT: GIM_CheckAtomicOrdering, /*MI*/0, /*Order*/(int64_t)AtomicOrdering::NotAtomic,
104 // GISEL-NEXT: // MIs[0] src0
105 // GISEL-NEXT: GIM_CheckType, /*MI*/0, /*Op*/0, /*Type*/GILLT_s32,
107 (truncstore GPR32:$src0, GPR32:$src1),
108 (inst_c GPR32:$src0, GPR32:$src1)
111 // Test non-truncstore has a size equal to LLT check.
112 // GISEL: GIM_Try, /*On fail goto*//*Label 3*/ {{[0-9]+}}, // Rule ID 3 //
113 // GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
114 // GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_STORE,
115 // GISEL-NEXT: GIM_CheckMemorySizeEqualToLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
117 (store GPR32:$src0, GPR32:$src1),
118 (inst_d GPR32:$src0, GPR32:$src1)
121 // Test truncstore with specific MemoryVT
122 // GISEL: GIM_Try, /*On fail goto*//*Label 4*/ {{[0-9]+}}, // Rule ID 4 //
123 // GISEL-NEXT: GIM_CheckNumOperands, /*MI*/0, /*Expected*/2,
124 // GISEL-NEXT: GIM_CheckOpcode, /*MI*/0, TargetOpcode::G_STORE,
125 // GISEL-NEXT: GIM_CheckMemorySizeLessThanLLT, /*MI*/0, /*MMO*/0, /*OpIdx*/0,
126 // GISEL-NEXT: GIM_CheckMemorySizeEqualTo, /*MI*/0, /*MMO*/0, /*Size*/2,
127 // GISEL-NEXT: GIM_CheckMemoryAddressSpace, /*MI*/0, /*MMO*/0, /*NumAddrSpace*/2, /*AddrSpace*/123, /*AddrSpace*/455,
129 (truncstorei16_addrspace GPR32:$src0, GPR32:$src1),
130 (inst_c GPR32:$src0, GPR32:$src1)