1 //===------------ AMDILInstrInfo.td - AMDIL Target ------*-tablegen-*------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //==-----------------------------------------------------------------------===//
10 // This file describes the AMDIL instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
13 // AMDIL Instruction Predicate Definitions
14 // Predicate that is set to true if the hardware supports double precision
16 def HasHWDDiv : Predicate<"Subtarget.device()"
17 "->getGeneration() > AMDGPUDeviceInfo::HD4XXX && "
18 "Subtarget.device()->usesHardware(AMDGPUDeviceInfo::DoubleOps)">;
20 // Predicate that is set to true if the hardware supports double, but not double
21 // precision divide in hardware
22 def HasSWDDiv : Predicate<"Subtarget.device()"
23 "->getGeneration() == AMDGPUDeviceInfo::HD4XXX &&"
24 "Subtarget.device()->usesHardware(AMDGPUDeviceInfo::DoubleOps)">;
26 // Predicate that is set to true if the hardware support 24bit signed
27 // math ops. Otherwise a software expansion to 32bit math ops is used instead.
28 def HasHWSign24Bit : Predicate<"Subtarget.device()"
29 "->getGeneration() > AMDGPUDeviceInfo::HD5XXX">;
31 // Predicate that is set to true if 64bit operations are supported or not
32 def HasHW64Bit : Predicate<"Subtarget.device()"
33 "->usesHardware(AMDGPUDeviceInfo::LongOps)">;
34 def HasSW64Bit : Predicate<"Subtarget.device()"
35 "->usesSoftware(AMDGPUDeviceInfo::LongOps)">;
37 // Predicate that is set to true if the timer register is supported
38 def HasTmrRegister : Predicate<"Subtarget.device()"
39 "->isSupported(AMDGPUDeviceInfo::TmrReg)">;
40 // Predicate that is true if we are at least evergreen series
41 def HasDeviceIDInst : Predicate<"Subtarget.device()"
42 "->getGeneration() >= AMDGPUDeviceInfo::HD5XXX">;
44 // Predicate that is true if we have region address space.
45 def hasRegionAS : Predicate<"Subtarget.device()"
46 "->usesHardware(AMDGPUDeviceInfo::RegionMem)">;
48 // Predicate that is false if we don't have region address space.
49 def noRegionAS : Predicate<"!Subtarget.device()"
50 "->isSupported(AMDGPUDeviceInfo::RegionMem)">;
53 // Predicate that is set to true if 64bit Mul is supported in the IL or not
54 def HasHW64Mul : Predicate<"Subtarget.calVersion()"
55 ">= CAL_VERSION_SC_139"
56 "&& Subtarget.device()"
57 "->getGeneration() >="
58 "AMDGPUDeviceInfo::HD5XXX">;
59 def HasSW64Mul : Predicate<"Subtarget.calVersion()"
60 "< CAL_VERSION_SC_139">;
61 // Predicate that is set to true if 64bit Div/Mod is supported in the IL or not
62 def HasHW64DivMod : Predicate<"Subtarget.device()"
63 "->usesHardware(AMDGPUDeviceInfo::HW64BitDivMod)">;
64 def HasSW64DivMod : Predicate<"Subtarget.device()"
65 "->usesSoftware(AMDGPUDeviceInfo::HW64BitDivMod)">;
67 // Predicate that is set to true if 64bit pointer are used.
68 def Has64BitPtr : Predicate<"Subtarget.is64bit()">;
69 def Has32BitPtr : Predicate<"!Subtarget.is64bit()">;
70 //===--------------------------------------------------------------------===//
72 //===--------------------------------------------------------------------===//
73 def brtarget : Operand<OtherVT>;
75 //===--------------------------------------------------------------------===//
76 // Custom Selection DAG Type Profiles
77 //===--------------------------------------------------------------------===//
78 //===----------------------------------------------------------------------===//
79 // Generic Profile Types
80 //===----------------------------------------------------------------------===//
82 def SDTIL_GenBinaryOp : SDTypeProfile<1, 2, [
83 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
85 def SDTIL_GenTernaryOp : SDTypeProfile<1, 3, [
86 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<2, 3>
88 def SDTIL_GenVecBuild : SDTypeProfile<1, 1, [
92 //===----------------------------------------------------------------------===//
93 // Flow Control Profile Types
94 //===----------------------------------------------------------------------===//
95 // Branch instruction where second and third are basic blocks
96 def SDTIL_BRCond : SDTypeProfile<0, 2, [
100 //===--------------------------------------------------------------------===//
101 // Custom Selection DAG Nodes
102 //===--------------------------------------------------------------------===//
103 //===----------------------------------------------------------------------===//
104 // Flow Control DAG Nodes
105 //===----------------------------------------------------------------------===//
106 def IL_brcond : SDNode<"AMDGPUISD::BRANCH_COND", SDTIL_BRCond, [SDNPHasChain]>;
108 //===----------------------------------------------------------------------===//
109 // Call/Return DAG Nodes
110 //===----------------------------------------------------------------------===//
111 def IL_retflag : SDNode<"AMDGPUISD::RET_FLAG", SDTNone,
112 [SDNPHasChain, SDNPOptInGlue]>;
114 //===--------------------------------------------------------------------===//
116 //===--------------------------------------------------------------------===//
117 // Floating point math functions
118 def IL_div_inf : SDNode<"AMDGPUISD::DIV_INF", SDTIL_GenBinaryOp>;
119 def IL_mad : SDNode<"AMDGPUISD::MAD", SDTIL_GenTernaryOp>;
121 //===----------------------------------------------------------------------===//
123 //===----------------------------------------------------------------------===//
124 def IL_umul : SDNode<"AMDGPUISD::UMUL" , SDTIntBinOp,
125 [SDNPCommutative, SDNPAssociative]>;
127 //===----------------------------------------------------------------------===//
129 //===----------------------------------------------------------------------===//
130 def IL_vbuild : SDNode<"AMDGPUISD::VBUILD", SDTIL_GenVecBuild,
133 //===--------------------------------------------------------------------===//
134 // Custom Pattern DAG Nodes
135 //===--------------------------------------------------------------------===//
136 def global_store : PatFrag<(ops node:$val, node:$ptr),
137 (store node:$val, node:$ptr), [{
138 return isGlobalStore(dyn_cast<StoreSDNode>(N));
141 //===----------------------------------------------------------------------===//
142 // Load pattern fragments
143 //===----------------------------------------------------------------------===//
144 // Global address space loads
145 def global_load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
146 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
148 // Constant address space loads
149 def constant_load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
150 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
153 //===----------------------------------------------------------------------===//
154 // Complex addressing mode patterns
155 //===----------------------------------------------------------------------===//
156 def ADDR : ComplexPattern<i32, 2, "SelectADDR", [], []>;
157 def ADDRF : ComplexPattern<i32, 2, "SelectADDR", [frameindex], []>;
158 def ADDR64 : ComplexPattern<i64, 2, "SelectADDR64", [], []>;
159 def ADDR64F : ComplexPattern<i64, 2, "SelectADDR64", [frameindex], []>;
161 //===----------------------------------------------------------------------===//
162 // Instruction format classes
163 //===----------------------------------------------------------------------===//
164 class ILFormat<dag outs, dag ins, string asmstr, list<dag> pattern>
167 let Namespace = "AMDGPU";
168 dag OutOperandList = outs;
169 dag InOperandList = ins;
170 let Pattern = pattern;
171 let AsmString = !strconcat(asmstr, "\n");
173 let Itinerary = NullALU;
175 bit hasZeroOpFlag = 0;
178 //===--------------------------------------------------------------------===//
179 // Multiclass Instruction formats
180 //===--------------------------------------------------------------------===//
181 // Multiclass that handles branch instructions
182 multiclass BranchConditional<SDNode Op> {
183 def _i32 : ILFormat<(outs),
184 (ins brtarget:$target, GPRI32:$src0),
185 "; i32 Pseudo branch instruction",
186 [(Op bb:$target, GPRI32:$src0)]>;
187 def _f32 : ILFormat<(outs),
188 (ins brtarget:$target, GPRF32:$src0),
189 "; f32 Pseudo branch instruction",
190 [(Op bb:$target, GPRF32:$src0)]>;
193 // Only scalar types should generate flow control
194 multiclass BranchInstr<string name> {
195 def _i32 : ILFormat<(outs), (ins GPRI32:$src),
196 !strconcat(name, " $src"), []>;
197 def _f32 : ILFormat<(outs), (ins GPRF32:$src),
198 !strconcat(name, " $src"), []>;
200 // Only scalar types should generate flow control
201 multiclass BranchInstr2<string name> {
202 def _i32 : ILFormat<(outs), (ins GPRI32:$src0, GPRI32:$src1),
203 !strconcat(name, " $src0, $src1"), []>;
204 def _f32 : ILFormat<(outs), (ins GPRF32:$src0, GPRF32:$src1),
205 !strconcat(name, " $src0, $src1"), []>;
208 //===--------------------------------------------------------------------===//
209 // Intrinsics support
210 //===--------------------------------------------------------------------===//
211 include "AMDILIntrinsics.td"
213 //===--------------------------------------------------------------------===//
214 // Instructions support
215 //===--------------------------------------------------------------------===//
216 //===---------------------------------------------------------------------===//
217 // Custom Inserter for Branches and returns, this eventually will be a
219 //===---------------------------------------------------------------------===//
220 let isTerminator = 1, usesCustomInserter = 1 in {
221 def BRANCH : ILFormat<(outs), (ins brtarget:$target),
222 "; Pseudo unconditional branch instruction",
224 defm BRANCH_COND : BranchConditional<IL_brcond>;
227 //===---------------------------------------------------------------------===//
228 // Flow and Program control Instructions
229 //===---------------------------------------------------------------------===//
230 let isTerminator=1 in {
231 def SWITCH : ILFormat< (outs), (ins GPRI32:$src),
232 !strconcat("SWITCH", " $src"), []>;
233 def CASE : ILFormat< (outs), (ins GPRI32:$src),
234 !strconcat("CASE", " $src"), []>;
235 def BREAK : ILFormat< (outs), (ins),
237 def CONTINUE : ILFormat< (outs), (ins),
239 def DEFAULT : ILFormat< (outs), (ins),
241 def ELSE : ILFormat< (outs), (ins),
243 def ENDSWITCH : ILFormat< (outs), (ins),
245 def ENDMAIN : ILFormat< (outs), (ins),
247 def END : ILFormat< (outs), (ins),
249 def ENDFUNC : ILFormat< (outs), (ins),
251 def ENDIF : ILFormat< (outs), (ins),
253 def WHILELOOP : ILFormat< (outs), (ins),
255 def ENDLOOP : ILFormat< (outs), (ins),
257 def FUNC : ILFormat< (outs), (ins),
259 def RETDYN : ILFormat< (outs), (ins),
261 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
262 defm IF_LOGICALNZ : BranchInstr<"IF_LOGICALNZ">;
263 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
264 defm IF_LOGICALZ : BranchInstr<"IF_LOGICALZ">;
265 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
266 defm BREAK_LOGICALNZ : BranchInstr<"BREAK_LOGICALNZ">;
267 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
268 defm BREAK_LOGICALZ : BranchInstr<"BREAK_LOGICALZ">;
269 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
270 defm CONTINUE_LOGICALNZ : BranchInstr<"CONTINUE_LOGICALNZ">;
271 // This opcode has custom swizzle pattern encoded in Swizzle Encoder
272 defm CONTINUE_LOGICALZ : BranchInstr<"CONTINUE_LOGICALZ">;
273 defm IFC : BranchInstr2<"IFC">;
274 defm BREAKC : BranchInstr2<"BREAKC">;
275 defm CONTINUEC : BranchInstr2<"CONTINUEC">;