blob: 2a4e44f8624d199105f125a89ef0384681e6bfb8 [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
Christian Konig45b14e32013-03-27 09:12:51 +000081 setOperationAction(ISD::MUL, MVT::i64, Expand);
82
Tom Stellardf98f2ce2012-12-11 21:25:42 +000083 setOperationAction(ISD::UDIV, MVT::i32, Expand);
84 setOperationAction(ISD::UDIVREM, MVT::i32, Custom);
85 setOperationAction(ISD::UREM, MVT::i32, Expand);
Tom Stellardf5660aa2013-07-18 21:43:35 +000086 setOperationAction(ISD::VSELECT, MVT::v2f32, Expand);
87 setOperationAction(ISD::VSELECT, MVT::v4f32, Expand);
Aaron Watryf97c7fe2013-06-25 13:55:57 +000088
Craig Topper787e71d2013-07-15 06:39:13 +000089 static const int types[] = {
Aaron Watryf97c7fe2013-06-25 13:55:57 +000090 (int)MVT::v2i32,
91 (int)MVT::v4i32
92 };
Craig Topperb9df53a2013-07-15 04:27:47 +000093 const size_t NumTypes = array_lengthof(types);
Aaron Watryf97c7fe2013-06-25 13:55:57 +000094
95 for (unsigned int x = 0; x < NumTypes; ++x) {
96 MVT::SimpleValueType VT = (MVT::SimpleValueType)types[x];
97 //Expand the following operations for the current type by default
98 setOperationAction(ISD::ADD, VT, Expand);
99 setOperationAction(ISD::AND, VT, Expand);
100 setOperationAction(ISD::MUL, VT, Expand);
101 setOperationAction(ISD::OR, VT, Expand);
102 setOperationAction(ISD::SHL, VT, Expand);
103 setOperationAction(ISD::SRL, VT, Expand);
104 setOperationAction(ISD::SRA, VT, Expand);
105 setOperationAction(ISD::SUB, VT, Expand);
106 setOperationAction(ISD::UDIV, VT, Expand);
107 setOperationAction(ISD::UREM, VT, Expand);
Tom Stellardf5660aa2013-07-18 21:43:35 +0000108 setOperationAction(ISD::VSELECT, VT, Expand);
Aaron Watryf97c7fe2013-06-25 13:55:57 +0000109 setOperationAction(ISD::XOR, VT, Expand);
110 }
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000111}
112
113//===---------------------------------------------------------------------===//
114// TargetLowering Callbacks
115//===---------------------------------------------------------------------===//
116
Christian Konig90c64cb2013-03-07 09:03:52 +0000117void AMDGPUTargetLowering::AnalyzeFormalArguments(CCState &State,
118 const SmallVectorImpl<ISD::InputArg> &Ins) const {
119
120 State.AnalyzeFormalArguments(Ins, CC_AMDGPU);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000121}
122
123SDValue AMDGPUTargetLowering::LowerReturn(
124 SDValue Chain,
125 CallingConv::ID CallConv,
126 bool isVarArg,
127 const SmallVectorImpl<ISD::OutputArg> &Outs,
128 const SmallVectorImpl<SDValue> &OutVals,
Andrew Trickac6d9be2013-05-25 02:42:55 +0000129 SDLoc DL, SelectionDAG &DAG) const {
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000130 return DAG.getNode(AMDGPUISD::RET_FLAG, DL, MVT::Other, Chain);
131}
132
133//===---------------------------------------------------------------------===//
134// Target specific lowering
135//===---------------------------------------------------------------------===//
136
137SDValue AMDGPUTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG)
138 const {
139 switch (Op.getOpcode()) {
140 default:
141 Op.getNode()->dump();
142 assert(0 && "Custom lowering code for this"
143 "instruction is not implemented yet!");
144 break;
145 // AMDIL DAG lowering
146 case ISD::SDIV: return LowerSDIV(Op, DAG);
147 case ISD::SREM: return LowerSREM(Op, DAG);
148 case ISD::SIGN_EXTEND_INREG: return LowerSIGN_EXTEND_INREG(Op, DAG);
149 case ISD::BRCOND: return LowerBRCOND(Op, DAG);
150 // AMDGPU DAG lowering
151 case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
152 case ISD::UDIVREM: return LowerUDIVREM(Op, DAG);
153 }
154 return Op;
155}
156
Tom Stellarde3d4cbc2013-06-28 15:47:08 +0000157SDValue AMDGPUTargetLowering::LowerGlobalAddress(AMDGPUMachineFunction* MFI,
158 SDValue Op,
159 SelectionDAG &DAG) const {
160
161 const DataLayout *TD = getTargetMachine().getDataLayout();
162 GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Op);
163 // XXX: What does the value of G->getOffset() mean?
164 assert(G->getOffset() == 0 &&
165 "Do not know what to do with an non-zero offset");
166
167 unsigned Offset = MFI->LDSSize;
168 const GlobalValue *GV = G->getGlobal();
169 uint64_t Size = TD->getTypeAllocSize(GV->getType()->getElementType());
170
171 // XXX: Account for alignment?
172 MFI->LDSSize += Size;
173
Michel Danzera3e39dc2013-07-10 16:37:07 +0000174 return DAG.getConstant(Offset, TD->getPointerSize() == 8 ? MVT::i64 : MVT::i32);
Tom Stellarde3d4cbc2013-06-28 15:47:08 +0000175}
176
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000177SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
178 SelectionDAG &DAG) const {
179 unsigned IntrinsicID = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
Andrew Trickac6d9be2013-05-25 02:42:55 +0000180 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000181 EVT VT = Op.getValueType();
182
183 switch (IntrinsicID) {
184 default: return Op;
185 case AMDGPUIntrinsic::AMDIL_abs:
186 return LowerIntrinsicIABS(Op, DAG);
187 case AMDGPUIntrinsic::AMDIL_exp:
188 return DAG.getNode(ISD::FEXP2, DL, VT, Op.getOperand(1));
189 case AMDGPUIntrinsic::AMDGPU_lrp:
190 return LowerIntrinsicLRP(Op, DAG);
191 case AMDGPUIntrinsic::AMDIL_fraction:
192 return DAG.getNode(AMDGPUISD::FRACT, DL, VT, Op.getOperand(1));
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000193 case AMDGPUIntrinsic::AMDIL_max:
194 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, Op.getOperand(1),
195 Op.getOperand(2));
196 case AMDGPUIntrinsic::AMDGPU_imax:
197 return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Op.getOperand(1),
198 Op.getOperand(2));
199 case AMDGPUIntrinsic::AMDGPU_umax:
200 return DAG.getNode(AMDGPUISD::UMAX, DL, VT, Op.getOperand(1),
201 Op.getOperand(2));
202 case AMDGPUIntrinsic::AMDIL_min:
203 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, Op.getOperand(1),
204 Op.getOperand(2));
205 case AMDGPUIntrinsic::AMDGPU_imin:
206 return DAG.getNode(AMDGPUISD::SMIN, DL, VT, Op.getOperand(1),
207 Op.getOperand(2));
208 case AMDGPUIntrinsic::AMDGPU_umin:
209 return DAG.getNode(AMDGPUISD::UMIN, DL, VT, Op.getOperand(1),
210 Op.getOperand(2));
211 case AMDGPUIntrinsic::AMDIL_round_nearest:
212 return DAG.getNode(ISD::FRINT, DL, VT, Op.getOperand(1));
213 }
214}
215
216///IABS(a) = SMAX(sub(0, a), a)
217SDValue AMDGPUTargetLowering::LowerIntrinsicIABS(SDValue Op,
218 SelectionDAG &DAG) const {
219
Andrew Trickac6d9be2013-05-25 02:42:55 +0000220 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000221 EVT VT = Op.getValueType();
222 SDValue Neg = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, VT),
223 Op.getOperand(1));
224
225 return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Neg, Op.getOperand(1));
226}
227
228/// Linear Interpolation
229/// LRP(a, b, c) = muladd(a, b, (1 - a) * c)
230SDValue AMDGPUTargetLowering::LowerIntrinsicLRP(SDValue Op,
231 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000232 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000233 EVT VT = Op.getValueType();
234 SDValue OneSubA = DAG.getNode(ISD::FSUB, DL, VT,
235 DAG.getConstantFP(1.0f, MVT::f32),
236 Op.getOperand(1));
237 SDValue OneSubAC = DAG.getNode(ISD::FMUL, DL, VT, OneSubA,
238 Op.getOperand(3));
Vincent Lejeunee3111962013-02-18 14:11:28 +0000239 return DAG.getNode(ISD::FADD, DL, VT,
240 DAG.getNode(ISD::FMUL, DL, VT, Op.getOperand(1), Op.getOperand(2)),
241 OneSubAC);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000242}
243
244/// \brief Generate Min/Max node
245SDValue AMDGPUTargetLowering::LowerMinMax(SDValue Op,
246 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000247 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000248 EVT VT = Op.getValueType();
249
250 SDValue LHS = Op.getOperand(0);
251 SDValue RHS = Op.getOperand(1);
252 SDValue True = Op.getOperand(2);
253 SDValue False = Op.getOperand(3);
254 SDValue CC = Op.getOperand(4);
255
256 if (VT != MVT::f32 ||
257 !((LHS == True && RHS == False) || (LHS == False && RHS == True))) {
258 return SDValue();
259 }
260
261 ISD::CondCode CCOpcode = cast<CondCodeSDNode>(CC)->get();
262 switch (CCOpcode) {
263 case ISD::SETOEQ:
264 case ISD::SETONE:
265 case ISD::SETUNE:
266 case ISD::SETNE:
267 case ISD::SETUEQ:
268 case ISD::SETEQ:
269 case ISD::SETFALSE:
270 case ISD::SETFALSE2:
271 case ISD::SETTRUE:
272 case ISD::SETTRUE2:
273 case ISD::SETUO:
274 case ISD::SETO:
275 assert(0 && "Operation should already be optimised !");
276 case ISD::SETULE:
277 case ISD::SETULT:
278 case ISD::SETOLE:
279 case ISD::SETOLT:
280 case ISD::SETLE:
281 case ISD::SETLT: {
282 if (LHS == True)
283 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, LHS, RHS);
284 else
285 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, LHS, RHS);
286 }
287 case ISD::SETGT:
288 case ISD::SETGE:
289 case ISD::SETUGE:
290 case ISD::SETOGE:
291 case ISD::SETUGT:
292 case ISD::SETOGT: {
293 if (LHS == True)
294 return DAG.getNode(AMDGPUISD::FMAX, DL, VT, LHS, RHS);
295 else
296 return DAG.getNode(AMDGPUISD::FMIN, DL, VT, LHS, RHS);
297 }
298 case ISD::SETCC_INVALID:
299 assert(0 && "Invalid setcc condcode !");
300 }
301 return Op;
302}
303
304
305
306SDValue AMDGPUTargetLowering::LowerUDIVREM(SDValue Op,
307 SelectionDAG &DAG) const {
Andrew Trickac6d9be2013-05-25 02:42:55 +0000308 SDLoc DL(Op);
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000309 EVT VT = Op.getValueType();
310
311 SDValue Num = Op.getOperand(0);
312 SDValue Den = Op.getOperand(1);
313
314 SmallVector<SDValue, 8> Results;
315
316 // RCP = URECIP(Den) = 2^32 / Den + e
317 // e is rounding error.
318 SDValue RCP = DAG.getNode(AMDGPUISD::URECIP, DL, VT, Den);
319
320 // RCP_LO = umulo(RCP, Den) */
321 SDValue RCP_LO = DAG.getNode(ISD::UMULO, DL, VT, RCP, Den);
322
323 // RCP_HI = mulhu (RCP, Den) */
324 SDValue RCP_HI = DAG.getNode(ISD::MULHU, DL, VT, RCP, Den);
325
326 // NEG_RCP_LO = -RCP_LO
327 SDValue NEG_RCP_LO = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, VT),
328 RCP_LO);
329
330 // ABS_RCP_LO = (RCP_HI == 0 ? NEG_RCP_LO : RCP_LO)
331 SDValue ABS_RCP_LO = DAG.getSelectCC(DL, RCP_HI, DAG.getConstant(0, VT),
332 NEG_RCP_LO, RCP_LO,
333 ISD::SETEQ);
334 // Calculate the rounding error from the URECIP instruction
335 // E = mulhu(ABS_RCP_LO, RCP)
336 SDValue E = DAG.getNode(ISD::MULHU, DL, VT, ABS_RCP_LO, RCP);
337
338 // RCP_A_E = RCP + E
339 SDValue RCP_A_E = DAG.getNode(ISD::ADD, DL, VT, RCP, E);
340
341 // RCP_S_E = RCP - E
342 SDValue RCP_S_E = DAG.getNode(ISD::SUB, DL, VT, RCP, E);
343
344 // Tmp0 = (RCP_HI == 0 ? RCP_A_E : RCP_SUB_E)
345 SDValue Tmp0 = DAG.getSelectCC(DL, RCP_HI, DAG.getConstant(0, VT),
346 RCP_A_E, RCP_S_E,
347 ISD::SETEQ);
348 // Quotient = mulhu(Tmp0, Num)
349 SDValue Quotient = DAG.getNode(ISD::MULHU, DL, VT, Tmp0, Num);
350
351 // Num_S_Remainder = Quotient * Den
352 SDValue Num_S_Remainder = DAG.getNode(ISD::UMULO, DL, VT, Quotient, Den);
353
354 // Remainder = Num - Num_S_Remainder
355 SDValue Remainder = DAG.getNode(ISD::SUB, DL, VT, Num, Num_S_Remainder);
356
357 // Remainder_GE_Den = (Remainder >= Den ? -1 : 0)
358 SDValue Remainder_GE_Den = DAG.getSelectCC(DL, Remainder, Den,
359 DAG.getConstant(-1, VT),
360 DAG.getConstant(0, VT),
361 ISD::SETGE);
362 // Remainder_GE_Zero = (Remainder >= 0 ? -1 : 0)
363 SDValue Remainder_GE_Zero = DAG.getSelectCC(DL, Remainder,
364 DAG.getConstant(0, VT),
365 DAG.getConstant(-1, VT),
366 DAG.getConstant(0, VT),
367 ISD::SETGE);
368 // Tmp1 = Remainder_GE_Den & Remainder_GE_Zero
369 SDValue Tmp1 = DAG.getNode(ISD::AND, DL, VT, Remainder_GE_Den,
370 Remainder_GE_Zero);
371
372 // Calculate Division result:
373
374 // Quotient_A_One = Quotient + 1
375 SDValue Quotient_A_One = DAG.getNode(ISD::ADD, DL, VT, Quotient,
376 DAG.getConstant(1, VT));
377
378 // Quotient_S_One = Quotient - 1
379 SDValue Quotient_S_One = DAG.getNode(ISD::SUB, DL, VT, Quotient,
380 DAG.getConstant(1, VT));
381
382 // Div = (Tmp1 == 0 ? Quotient : Quotient_A_One)
383 SDValue Div = DAG.getSelectCC(DL, Tmp1, DAG.getConstant(0, VT),
384 Quotient, Quotient_A_One, ISD::SETEQ);
385
386 // Div = (Remainder_GE_Zero == 0 ? Quotient_S_One : Div)
387 Div = DAG.getSelectCC(DL, Remainder_GE_Zero, DAG.getConstant(0, VT),
388 Quotient_S_One, Div, ISD::SETEQ);
389
390 // Calculate Rem result:
391
392 // Remainder_S_Den = Remainder - Den
393 SDValue Remainder_S_Den = DAG.getNode(ISD::SUB, DL, VT, Remainder, Den);
394
395 // Remainder_A_Den = Remainder + Den
396 SDValue Remainder_A_Den = DAG.getNode(ISD::ADD, DL, VT, Remainder, Den);
397
398 // Rem = (Tmp1 == 0 ? Remainder : Remainder_S_Den)
399 SDValue Rem = DAG.getSelectCC(DL, Tmp1, DAG.getConstant(0, VT),
400 Remainder, Remainder_S_Den, ISD::SETEQ);
401
402 // Rem = (Remainder_GE_Zero == 0 ? Remainder_A_Den : Rem)
403 Rem = DAG.getSelectCC(DL, Remainder_GE_Zero, DAG.getConstant(0, VT),
404 Remainder_A_Den, Rem, ISD::SETEQ);
405 SDValue Ops[2];
406 Ops[0] = Div;
407 Ops[1] = Rem;
408 return DAG.getMergeValues(Ops, 2, DL);
409}
410
411//===----------------------------------------------------------------------===//
412// Helper functions
413//===----------------------------------------------------------------------===//
414
415bool AMDGPUTargetLowering::isHWTrueValue(SDValue Op) const {
416 if (ConstantFPSDNode * CFP = dyn_cast<ConstantFPSDNode>(Op)) {
417 return CFP->isExactlyValue(1.0);
418 }
419 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
420 return C->isAllOnesValue();
421 }
422 return false;
423}
424
425bool AMDGPUTargetLowering::isHWFalseValue(SDValue Op) const {
426 if (ConstantFPSDNode * CFP = dyn_cast<ConstantFPSDNode>(Op)) {
427 return CFP->getValueAPF().isZero();
428 }
429 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
430 return C->isNullValue();
431 }
432 return false;
433}
434
435SDValue AMDGPUTargetLowering::CreateLiveInRegister(SelectionDAG &DAG,
436 const TargetRegisterClass *RC,
437 unsigned Reg, EVT VT) const {
438 MachineFunction &MF = DAG.getMachineFunction();
439 MachineRegisterInfo &MRI = MF.getRegInfo();
440 unsigned VirtualRegister;
441 if (!MRI.isLiveIn(Reg)) {
442 VirtualRegister = MRI.createVirtualRegister(RC);
443 MRI.addLiveIn(Reg, VirtualRegister);
444 } else {
445 VirtualRegister = MRI.getLiveInVirtReg(Reg);
446 }
447 return DAG.getRegister(VirtualRegister, VT);
448}
449
450#define NODE_NAME_CASE(node) case AMDGPUISD::node: return #node;
451
452const char* AMDGPUTargetLowering::getTargetNodeName(unsigned Opcode) const {
453 switch (Opcode) {
454 default: return 0;
455 // AMDIL DAG nodes
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000456 NODE_NAME_CASE(CALL);
457 NODE_NAME_CASE(UMUL);
458 NODE_NAME_CASE(DIV_INF);
459 NODE_NAME_CASE(RET_FLAG);
460 NODE_NAME_CASE(BRANCH_COND);
461
462 // AMDGPU DAG nodes
463 NODE_NAME_CASE(DWORDADDR)
464 NODE_NAME_CASE(FRACT)
465 NODE_NAME_CASE(FMAX)
466 NODE_NAME_CASE(SMAX)
467 NODE_NAME_CASE(UMAX)
468 NODE_NAME_CASE(FMIN)
469 NODE_NAME_CASE(SMIN)
470 NODE_NAME_CASE(UMIN)
471 NODE_NAME_CASE(URECIP)
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000472 NODE_NAME_CASE(EXPORT)
Tom Stellardc7e18882013-01-23 02:09:03 +0000473 NODE_NAME_CASE(CONST_ADDRESS)
Tom Stellardc0b0c672013-02-06 17:32:29 +0000474 NODE_NAME_CASE(REGISTER_LOAD)
475 NODE_NAME_CASE(REGISTER_STORE)
Tom Stellardf98f2ce2012-12-11 21:25:42 +0000476 }
477}