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 //===--------------------------------------------------------------------===//
128 // Custom Pattern DAG Nodes
129 //===--------------------------------------------------------------------===//
130 def global_store : PatFrag<(ops node:$val, node:$ptr),
131 (store node:$val, node:$ptr), [{
132 return isGlobalStore(dyn_cast<StoreSDNode>(N));
135 //===----------------------------------------------------------------------===//
136 // Load pattern fragments
137 //===----------------------------------------------------------------------===//
138 // Global address space loads
139 def global_load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
140 return isGlobalLoad(dyn_cast<LoadSDNode>(N));
142 // Constant address space loads
143 def constant_load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
144 return isConstantLoad(dyn_cast<LoadSDNode>(N), -1);
147 //===----------------------------------------------------------------------===//
148 // Complex addressing mode patterns
149 //===----------------------------------------------------------------------===//
150 def ADDR : ComplexPattern<i32, 2, "SelectADDR", [], []>;
151 def ADDRF : ComplexPattern<i32, 2, "SelectADDR", [frameindex], []>;
152 def ADDR64 : ComplexPattern<i64, 2, "SelectADDR64", [], []>;
153 def ADDR64F : ComplexPattern<i64, 2, "SelectADDR64", [frameindex], []>;
155 //===----------------------------------------------------------------------===//
156 // Instruction format classes
157 //===----------------------------------------------------------------------===//
158 class ILFormat<dag outs, dag ins, string asmstr, list<dag> pattern>
161 let Namespace = "AMDGPU";
162 dag OutOperandList = outs;
163 dag InOperandList = ins;
164 let Pattern = pattern;
165 let AsmString = !strconcat(asmstr, "\n");
167 let Itinerary = NullALU;
169 bit hasZeroOpFlag = 0;
172 let hasSideEffects = 0;
175 //===--------------------------------------------------------------------===//
176 // Multiclass Instruction formats
177 //===--------------------------------------------------------------------===//
178 // Multiclass that handles branch instructions
179 multiclass BranchConditional<SDNode Op> {
180 def _i32 : ILFormat<(outs),
181 (ins brtarget:$target, GPRI32:$src0),
182 "; i32 Pseudo branch instruction",
183 [(Op bb:$target, GPRI32:$src0)]>;
184 def _f32 : ILFormat<(outs),
185 (ins brtarget:$target, GPRF32:$src0),
186 "; f32 Pseudo branch instruction",
187 [(Op bb:$target, GPRF32:$src0)]>;
190 // Only scalar types should generate flow control
191 multiclass BranchInstr<string name> {
192 def _i32 : ILFormat<(outs), (ins GPRI32:$src),
193 !strconcat(name, " $src"), []>;
194 def _f32 : ILFormat<(outs), (ins GPRF32:$src),
195 !strconcat(name, " $src"), []>;
197 // Only scalar types should generate flow control
198 multiclass BranchInstr2<string name> {
199 def _i32 : ILFormat<(outs), (ins GPRI32:$src0, GPRI32:$src1),
200 !strconcat(name, " $src0, $src1"), []>;
201 def _f32 : ILFormat<(outs), (ins GPRF32:$src0, GPRF32:$src1),
202 !strconcat(name, " $src0, $src1"), []>;
205 //===--------------------------------------------------------------------===//
206 // Intrinsics support
207 //===--------------------------------------------------------------------===//
208 include "AMDILIntrinsics.td"