blob: d74d9f89c374cda402d23acd03c842b8cb8a71e6 [file] [log] [blame]
Tom Stellardf98f2ce2012-12-11 21:25:42 +00001//===-- AMDGPUISelLowering.cpp - AMDGPU Common DAG lowering functions -----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10/// \file
11/// \brief This is the parent TargetLowering class for hardware code gen
12/// targets.
13//
14//===----------------------------------------------------------------------===//
15
16#include "AMDGPUISelLowering.h"
Tom Stellarde7397ee2013-06-03 17:40:11 +000017#include "AMDGPU.h"
Christian Konig90c64cb2013-03-07 09:03:52 +000018#include "AMDGPURegisterInfo.h"
Christian Konig90c64cb2013-03-07 09:03:52 +000019#include "AMDGPUSubtarget.h"
Benjamin Kramer5c352902013-05-23 17:10:37 +000020#include "AMDILIntrinsicInfo.h"
Tom Stellarde7397ee2013-06-03 17:40:11 +000021#include "SIMachineFunctionInfo.h"
Christian Konig90c64cb2013-03-07 09:03:52 +000022#include "llvm/CodeGen/CallingConvLower.h"
Tom Stellardf98f2ce2012-12-11 21:25:42 +000023#include "llvm/CodeGen/MachineFunction.h"
24#include "llvm/CodeGen/MachineRegisterInfo.h"
25#include "llvm/CodeGen/SelectionDAG.h"
26#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
Tom Stellarde3d4cbc2013-06-28 15:47:08 +000027#include "llvm/IR/DataLayout.h"
Tom Stellardf98f2ce2012-12-11 21:25:42 +000028
29using namespace llvm;
30
Christian Konig90c64cb2013-03-07 09:03:52 +000031#include "AMDGPUGenCallingConv.inc"
32
Tom Stellardf98f2ce2012-12-11 21:25:42 +000033AMDGPUTargetLowering::AMDGPUTargetLowering(TargetMachine &TM) :
34 TargetLowering(TM, new TargetLoweringObjectFileELF()) {
35
36 // Initialize target lowering borrowed from AMDIL
37 InitAMDILLowering();
38
39 // We need to custom lower some of the intrinsics
40 setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
41
42 // Library functions. These default to Expand, but we have instructions
43 // for them.
44 setOperationAction(ISD::FCEIL, MVT::f32, Legal);
45 setOperationAction(ISD::FEXP2, MVT::f32, Legal);
46 setOperationAction(ISD::FPOW, MVT::f32, Legal);
47 setOperationAction(ISD::FLOG2, MVT::f32, Legal);
48 setOperationAction(ISD::FABS, MVT::f32, Legal);
49 setOperationAction(ISD::FFLOOR, MVT::f32, Legal);
50 setOperationAction(ISD::FRINT, MVT::f32, Legal);
51
Tom Stellardba534c22013-05-20 15:02:19 +000052 // The hardware supports ROTR, but not ROTL
53 setOperationAction(ISD::ROTL, MVT::i32, Expand);
54
Tom Stellardf98f2ce2012-12-11 21:25:42 +000055 // Lower floating point store/load to integer store/load to reduce the number
56 // of patterns in tablegen.
57 setOperationAction(ISD::STORE, MVT::f32, Promote);
58 AddPromotedToType(ISD::STORE, MVT::f32, MVT::i32);
59
Tom Stellardfc047272013-07-18 21:43:42 +000060 setOperationAction(ISD::STORE, MVT::v2f32, Promote);
61 AddPromotedToType(ISD::STORE, MVT::v2f32, MVT::v2i32);
62
Tom Stellardf98f2ce2012-12-11 21:25:42 +000063 setOperationAction(ISD::STORE, MVT::v4f32, Promote);
64 AddPromotedToType(ISD::STORE, MVT::v4f32, MVT::v4i32);
65
Tom Stellard68e13282013-07-12 18:14:56 +000066 setOperationAction(ISD::STORE, MVT::f64, Promote);
67 AddPromotedToType(ISD::STORE, MVT::f64, MVT::i64);
68
Tom Stellardf98f2ce2012-12-11 21:25:42 +000069 setOperationAction(ISD::LOAD, MVT::f32, Promote);
70 AddPromotedToType(ISD::LOAD, MVT::f32, MVT::i32);
71
Tom Stellardac85f3f2013-07-18 21:43:48 +000072 setOperationAction(ISD::LOAD, MVT::v2f32, Promote);
73 AddPromotedToType(ISD::LOAD, MVT::v2f32, MVT::v2i32);
74
Tom Stellardf98f2ce2012-12-11 21:25:42 +000075 setOperationAction(ISD::LOAD, MVT::v4f32, Promote);
76 AddPromotedToType(ISD::LOAD, MVT::v4f32, MVT::v4i32);
77
Tom Stellard68e13282013-07-12 18:14:56 +000078 setOperationAction(ISD::LOAD, MVT::f64, Promote);
79 AddPromotedToType(ISD::LOAD, MVT::f64, MVT::i64);
80
Tom Stellardd7a472c2013-07-23 01:47:46 +000081 setOperationAction(ISD::FNEG, MVT::v2f32, Expand);
82 setOperationAction(ISD::FNEG, MVT::v4f32, Expand);
83
Christian Konig45b14e32013-03-27 09:12:51 +000084 setOperationAction(ISD::MUL, MVT::i64, Expand);
85
Tom Stellardf98f2ce2012-12-11 21:25:42 +000086 setOperationAction(ISD::UDIV, MVT::i32, Expand);
87 setOperationAction(ISD::UDIVREM, MVT::i32, Custom);
88 setOperationAction(ISD::UREM, MVT::i32, Expand);
Tom Stellardf5660aa2013-07-18 21:43:35 +000089 setOperationAction(ISD::VSELECT, MVT::v2f32, Expand);
90 setOperationAction(ISD::VSELECT, MVT::v4f32, Expand);
Aaron Watryf97c7fe2013-06-25 13:55:57 +000091
Craig Topper787e71d2013-07-15 06:39:13 +000092 static const int types[] = {
Aaron Watryf97c7fe2013-06-25 13:55:57 +000093 (int)MVT::v2i32,
94 (int)MVT::v4i32
95 };
Craig Topperb9df53a2013-07-15 04:27:47 +000096 const size_t NumTypes = array_lengthof(types);
Aaron Watryf97c7fe2013-06-25 13:55:57 +000097
98 for (unsigned int x = 0; x < NumTypes; ++x) {
99 MVT::SimpleValueType VT = (MVT::SimpleValueType)types[x];
100 //Expand the following operations for the current type by default
101 setOperationAction(ISD::ADD, VT, Expand);
102 setOperationAction(ISD::AND, VT, Expand);
103 setOperationAction(ISD::MUL, VT, Expand);
104 setOperationAction(ISD::OR, VT, Expand);
105 setOperationAction(ISD::SHL, VT, Expand);
106 setOperationAction(ISD::SRL, VT, Expand);
107 setOperationAction(ISD::SRA, VT, Expand);
108 setOperationAction(ISD::SUB, VT, Expand);
109 setOperationAction(ISD::UDIV, VT, Expand);
110 setOperationAction(ISD::UREM, VT, Expand);
Tom Stellardf5660aa2013-07-18 21:43:35 +0000111 setOperationAction(ISD::VSELECT, VT, Expand);
Aaron Watryf97c7fe2013-06-25 13:55:57 +0000112 setOperationAction(ISD::XOR, VT, Expand);
113 }
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000114}
115
116//===---------------------------------------------------------------------===//
117// TargetLowering Callbacks
118//===---------------------------------------------------------------------===//
119
Christian Konig90c64cb2013-03-07 09:03:52 +0000120void AMDGPUTargetLowering::AnalyzeFormalArguments(CCState &State,
121 const SmallVectorImpl<ISD::InputArg> &Ins) const {
122
123 State.AnalyzeFormalArguments(Ins, CC_AMDGPU);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000124}
125
126SDValue AMDGPUTargetLowering::LowerReturn(
127 SDValue Chain,
128 CallingConv::ID CallConv,
129 bool isVarArg,
130 const SmallVectorImpl<ISD::OutputArg> &Outs,
131 const SmallVectorImpl<SDValue> &OutVals,
Andrew Trickac6d9be2013-05-25 02:42:55 +0000132 SDLoc DL, SelectionDAG &DAG) const {
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000133 return DAG.getNode(AMDGPUISD::RET_FLAG, DL, MVT::Other, Chain);
134}
135
136//===---------------------------------------------------------------------===//
137// Target specific lowering
138//===---------------------------------------------------------------------===//
139
140SDValue AMDGPUTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG)
141 const {
142 switch (Op.getOpcode()) {
143 default:
144 Op.getNode()->dump();
145 assert(0 && "Custom lowering code for this"
146 "instruction is not implemented yet!");
147 break;
148 // AMDIL DAG lowering
149 case ISD::SDIV: return LowerSDIV(Op, DAG);
150 case ISD::SREM: return LowerSREM(Op, DAG);
151 case ISD::SIGN_EXTEND_INREG: return LowerSIGN_EXTEND_INREG(Op, DAG);
152 case ISD::BRCOND: return LowerBRCOND(Op, DAG);
153 // AMDGPU DAG lowering
154 case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
155 case ISD::UDIVREM: return LowerUDIVREM(Op, DAG);
156 }
157 return Op;
158}
159
Tom Stellarde3d4cbc2013-06-28 15:47:08 +0000160SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
161 SDValue Op,
162 SelectionDAG &DAG) const {
163
164 const DataLayout *TD = getTargetMachine().getDataLayout();
165 GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Op);
166 // XXX: What does the value of G->getOffset() mean?
167 assert(G->getOffset() == 0 &&
168 "Do not know what to do with an non-zero offset");
169
170 unsigned Offset = MFI->LDSSize;
171 const GlobalValue *GV = G->getGlobal();
172 uint64_t Size = TD->getTypeAllocSize(GV->getType()->getElementType());
173
174 // XXX: Account for alignment?
175 MFI->LDSSize += Size;
176
Michel Danzera3e39dc2013-07-10 16:37:07 +0000177 return DAG.getConstant(Offset, TD->getPointerSize() == 8 ? MVT::i64 : MVT::i32);
Tom Stellarde3d4cbc2013-06-28 15:47:08 +0000178}
179
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000180SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
181 SelectionDAG &DAG) const {
182 unsigned IntrinsicID = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
Andrew Trickac6d9be2013-05-25 02:42:55 +0000183 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000184 EVT VT = Op.getValueType();
185
186 switch (IntrinsicID) {
187 default: return Op;
188 case AMDGPUIntrinsic::AMDIL_abs:
189 return LowerIntrinsicIABS(Op, DAG);
190 case AMDGPUIntrinsic::AMDIL_exp:
191 return DAG.getNode(ISD::FEXP2, DL, VT, Op.getOperand(1));
192 case AMDGPUIntrinsic::AMDGPU_lrp:
193 return LowerIntrinsicLRP(Op, DAG);
194 case AMDGPUIntrinsic::AMDIL_fraction:
195 return DAG.getNode(AMDGPUISD::FRACT, DL, VT, Op.getOperand(1));
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000196 case AMDGPUIntrinsic::AMDIL_max:
197 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, Op.getOperand(1),
198 Op.getOperand(2));
199 case AMDGPUIntrinsic::AMDGPU_imax:
200 return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Op.getOperand(1),
201 Op.getOperand(2));
202 case AMDGPUIntrinsic::AMDGPU_umax:
203 return DAG.getNode(AMDGPUISD::UMAX, DL, VT, Op.getOperand(1),
204 Op.getOperand(2));
205 case AMDGPUIntrinsic::AMDIL_min:
206 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, Op.getOperand(1),
207 Op.getOperand(2));
208 case AMDGPUIntrinsic::AMDGPU_imin:
209 return DAG.getNode(AMDGPUISD::SMIN, DL, VT, Op.getOperand(1),
210 Op.getOperand(2));
211 case AMDGPUIntrinsic::AMDGPU_umin:
212 return DAG.getNode(AMDGPUISD::UMIN, DL, VT, Op.getOperand(1),
213 Op.getOperand(2));
214 case AMDGPUIntrinsic::AMDIL_round_nearest:
215 return DAG.getNode(ISD::FRINT, DL, VT, Op.getOperand(1));
216 }
217}
218
219///IABS(a) = SMAX(sub(0, a), a)
220SDValue AMDGPUTargetLowering::LowerIntrinsicIABS(SDValue Op,
221 SelectionDAG &DAG) const {
222
Andrew Trickac6d9be2013-05-25 02:42:55 +0000223 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000224 EVT VT = Op.getValueType();
225 SDValue Neg = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, VT),
226 Op.getOperand(1));
227
228 return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Neg, Op.getOperand(1));
229}
230
231/// Linear Interpolation
232/// LRP(a, b, c) = muladd(a, b, (1 - a) * c)
233SDValue AMDGPUTargetLowering::LowerIntrinsicLRP(SDValue Op,
234 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000235 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000236 EVT VT = Op.getValueType();
237 SDValue OneSubA = DAG.getNode(ISD::FSUB, DL, VT,
238 DAG.getConstantFP(1.0f, MVT::f32),
239 Op.getOperand(1));
240 SDValue OneSubAC = DAG.getNode(ISD::FMUL, DL, VT, OneSubA,
241 Op.getOperand(3));
Vincent Lejeunee3111962013-02-18 14:11:28 +0000242 return DAG.getNode(ISD::FADD, DL, VT,
243 DAG.getNode(ISD::FMUL, DL, VT, Op.getOperand(1), Op.getOperand(2)),
244 OneSubAC);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000245}
246
247/// \brief Generate Min/Max node
248SDValue AMDGPUTargetLowering::LowerMinMax(SDValue Op,
249 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000250 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000251 EVT VT = Op.getValueType();
252
253 SDValue LHS = Op.getOperand(0);
254 SDValue RHS = Op.getOperand(1);
255 SDValue True = Op.getOperand(2);
256 SDValue False = Op.getOperand(3);
257 SDValue CC = Op.getOperand(4);
258
259 if (VT != MVT::f32 ||
260 !((LHS == True && RHS == False) || (LHS == False && RHS == True))) {
261 return SDValue();
262 }
263
264 ISD::CondCode CCOpcode = cast<CondCodeSDNode>(CC)->get();
265 switch (CCOpcode) {
266 case ISD::SETOEQ:
267 case ISD::SETONE:
268 case ISD::SETUNE:
269 case ISD::SETNE:
270 case ISD::SETUEQ:
271 case ISD::SETEQ:
272 case ISD::SETFALSE:
273 case ISD::SETFALSE2:
274 case ISD::SETTRUE:
275 case ISD::SETTRUE2:
276 case ISD::SETUO:
277 case ISD::SETO:
278 assert(0 && "Operation should already be optimised !");
279 case ISD::SETULE:
280 case ISD::SETULT:
281 case ISD::SETOLE:
282 case ISD::SETOLT:
283 case ISD::SETLE:
284 case ISD::SETLT: {
285 if (LHS == True)
286 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, LHS, RHS);
287 else
288 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, LHS, RHS);
289 }
290 case ISD::SETGT:
291 case ISD::SETGE:
292 case ISD::SETUGE:
293 case ISD::SETOGE:
294 case ISD::SETUGT:
295 case ISD::SETOGT: {
296 if (LHS == True)
297 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, LHS, RHS);
298 else
299 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, LHS, RHS);
300 }
301 case ISD::SETCC_INVALID:
302 assert(0 && "Invalid setcc condcode !");
303 }
304 return Op;
305}
306
307
308
309SDValue AMDGPUTargetLowering::LowerUDIVREM(SDValue Op,
310 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000311 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000312 EVT VT = Op.getValueType();
313
314 SDValue Num = Op.getOperand(0);
315 SDValue Den = Op.getOperand(1);
316
317 SmallVector<SDValue, 8> Results;
318
319 // RCP = URECIP(Den) = 2^32 / Den + e
320 // e is rounding error.
321 SDValue RCP = DAG.getNode(AMDGPUISD::URECIP, DL, VT, Den);
322
323 // RCP_LO = umulo(RCP, Den) */
324 SDValue RCP_LO = DAG.getNode(ISD::UMULO, DL, VT, RCP, Den);
325
326 // RCP_HI = mulhu (RCP, Den) */
327 SDValue RCP_HI = DAG.getNode(ISD::MULHU, DL, VT, RCP, Den);
328
329 // NEG_RCP_LO = -RCP_LO
330 SDValue NEG_RCP_LO = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, VT),
331 RCP_LO);
332
333 // ABS_RCP_LO = (RCP_HI == 0 ? NEG_RCP_LO : RCP_LO)
334 SDValue ABS_RCP_LO = DAG.getSelectCC(DL, RCP_HI, DAG.getConstant(0, VT),
335 NEG_RCP_LO, RCP_LO,
336 ISD::SETEQ);
337 // Calculate the rounding error from the URECIP instruction
338 // E = mulhu(ABS_RCP_LO, RCP)
339 SDValue E = DAG.getNode(ISD::MULHU, DL, VT, ABS_RCP_LO, RCP);
340
341 // RCP_A_E = RCP + E
342 SDValue RCP_A_E = DAG.getNode(ISD::ADD, DL, VT, RCP, E);
343
344 // RCP_S_E = RCP - E
345 SDValue RCP_S_E = DAG.getNode(ISD::SUB, DL, VT, RCP, E);
346
347 // Tmp0 = (RCP_HI == 0 ? RCP_A_E : RCP_SUB_E)
348 SDValue Tmp0 = DAG.getSelectCC(DL, RCP_HI, DAG.getConstant(0, VT),
349 RCP_A_E, RCP_S_E,
350 ISD::SETEQ);
351 // Quotient = mulhu(Tmp0, Num)
352 SDValue Quotient = DAG.getNode(ISD::MULHU, DL, VT, Tmp0, Num);
353
354 // Num_S_Remainder = Quotient * Den
355 SDValue Num_S_Remainder = DAG.getNode(ISD::UMULO, DL, VT, Quotient, Den);
356
357 // Remainder = Num - Num_S_Remainder
358 SDValue Remainder = DAG.getNode(ISD::SUB, DL, VT, Num, Num_S_Remainder);
359
360 // Remainder_GE_Den = (Remainder >= Den ? -1 : 0)
361 SDValue Remainder_GE_Den = DAG.getSelectCC(DL, Remainder, Den,
362 DAG.getConstant(-1, VT),
363 DAG.getConstant(0, VT),
364 ISD::SETGE);
365 // Remainder_GE_Zero = (Remainder >= 0 ? -1 : 0)
366 SDValue Remainder_GE_Zero = DAG.getSelectCC(DL, Remainder,
367 DAG.getConstant(0, VT),
368 DAG.getConstant(-1, VT),
369 DAG.getConstant(0, VT),
370 ISD::SETGE);
371 // Tmp1 = Remainder_GE_Den & Remainder_GE_Zero
372 SDValue Tmp1 = DAG.getNode(ISD::AND, DL, VT, Remainder_GE_Den,
373 Remainder_GE_Zero);
374
375 // Calculate Division result:
376
377 // Quotient_A_One = Quotient + 1
378 SDValue Quotient_A_One = DAG.getNode(ISD::ADD, DL, VT, Quotient,
379 DAG.getConstant(1, VT));
380
381 // Quotient_S_One = Quotient - 1
382 SDValue Quotient_S_One = DAG.getNode(ISD::SUB, DL, VT, Quotient,
383 DAG.getConstant(1, VT));
384
385 // Div = (Tmp1 == 0 ? Quotient : Quotient_A_One)
386 SDValue Div = DAG.getSelectCC(DL, Tmp1, DAG.getConstant(0, VT),
387 Quotient, Quotient_A_One, ISD::SETEQ);
388
389 // Div = (Remainder_GE_Zero == 0 ? Quotient_S_One : Div)
390 Div = DAG.getSelectCC(DL, Remainder_GE_Zero, DAG.getConstant(0, VT),
391 Quotient_S_One, Div, ISD::SETEQ);
392
393 // Calculate Rem result:
394
395 // Remainder_S_Den = Remainder - Den
396 SDValue Remainder_S_Den = DAG.getNode(ISD::SUB, DL, VT, Remainder, Den);
397
398 // Remainder_A_Den = Remainder + Den
399 SDValue Remainder_A_Den = DAG.getNode(ISD::ADD, DL, VT, Remainder, Den);
400
401 // Rem = (Tmp1 == 0 ? Remainder : Remainder_S_Den)
402 SDValue Rem = DAG.getSelectCC(DL, Tmp1, DAG.getConstant(0, VT),
403 Remainder, Remainder_S_Den, ISD::SETEQ);
404
405 // Rem = (Remainder_GE_Zero == 0 ? Remainder_A_Den : Rem)
406 Rem = DAG.getSelectCC(DL, Remainder_GE_Zero, DAG.getConstant(0, VT),
407 Remainder_A_Den, Rem, ISD::SETEQ);
408 SDValue Ops[2];
409 Ops[0] = Div;
410 Ops[1] = Rem;
411 return DAG.getMergeValues(Ops, 2, DL);
412}
413
414//===----------------------------------------------------------------------===//
415// Helper functions
416//===----------------------------------------------------------------------===//
417
418bool AMDGPUTargetLowering::isHWTrueValue(SDValue Op) const {
419 if (ConstantFPSDNode * CFP = dyn_cast<ConstantFPSDNode>(Op)) {
420 return CFP->isExactlyValue(1.0);
421 }
422 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
423 return C->isAllOnesValue();
424 }
425 return false;
426}
427
428bool AMDGPUTargetLowering::isHWFalseValue(SDValue Op) const {
429 if (ConstantFPSDNode * CFP = dyn_cast<ConstantFPSDNode>(Op)) {
430 return CFP->getValueAPF().isZero();
431 }
432 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
433 return C->isNullValue();
434 }
435 return false;
436}
437
438SDValue AMDGPUTargetLowering::CreateLiveInRegister(SelectionDAG &DAG,
439 const TargetRegisterClass *RC,
440 unsigned Reg, EVT VT) const {
441 MachineFunction &MF = DAG.getMachineFunction();
442 MachineRegisterInfo &MRI = MF.getRegInfo();
443 unsigned VirtualRegister;
444 if (!MRI.isLiveIn(Reg)) {
445 VirtualRegister = MRI.createVirtualRegister(RC);
446 MRI.addLiveIn(Reg, VirtualRegister);
447 } else {
448 VirtualRegister = MRI.getLiveInVirtReg(Reg);
449 }
450 return DAG.getRegister(VirtualRegister, VT);
451}
452
453#define NODE_NAME_CASE(node) case AMDGPUISD::node: return #node;
454
455const char* AMDGPUTargetLowering::getTargetNodeName(unsigned Opcode) const {
456 switch (Opcode) {
457 default: return 0;
458 // AMDIL DAG nodes
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000459 NODE_NAME_CASE(CALL);
460 NODE_NAME_CASE(UMUL);
461 NODE_NAME_CASE(DIV_INF);
462 NODE_NAME_CASE(RET_FLAG);
463 NODE_NAME_CASE(BRANCH_COND);
464
465 // AMDGPU DAG nodes
466 NODE_NAME_CASE(DWORDADDR)
467 NODE_NAME_CASE(FRACT)
468 NODE_NAME_CASE(FMAX)
469 NODE_NAME_CASE(SMAX)
470 NODE_NAME_CASE(UMAX)
471 NODE_NAME_CASE(FMIN)
472 NODE_NAME_CASE(SMIN)
473 NODE_NAME_CASE(UMIN)
474 NODE_NAME_CASE(URECIP)
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000475 NODE_NAME_CASE(EXPORT)
Tom Stellardc7e18882013-01-23 02:09:03 +0000476 NODE_NAME_CASE(CONST_ADDRESS)
Tom Stellardc0b0c672013-02-06 17:32:29 +0000477 NODE_NAME_CASE(REGISTER_LOAD)
478 NODE_NAME_CASE(REGISTER_STORE)
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000479 }
480}