blob: ece26efceedf105b2ac2daa1386c935f0e666a84 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- AMDILISelDAGToDAG.cpp - A dag to dag inst selector for AMDIL ------===//
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 Defines an instruction selector for the AMDGPU target.
12//
13//===----------------------------------------------------------------------===//
14#include "AMDGPUInstrInfo.h"
15#include "AMDGPUISelLowering.h" // For AMDGPUISD
16#include "AMDGPURegisterInfo.h"
17#include "AMDILDevices.h"
18#include "R600InstrInfo.h"
19#include "llvm/ADT/ValueMap.h"
20#include "llvm/CodeGen/PseudoSourceValue.h"
21#include "llvm/CodeGen/SelectionDAGISel.h"
22#include "llvm/Support/Compiler.h"
Tom Stellard365366f2013-01-23 02:09:06 +000023#include "llvm/CodeGen/SelectionDAG.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000024#include <list>
25#include <queue>
26
27using namespace llvm;
28
29//===----------------------------------------------------------------------===//
30// Instruction Selector Implementation
31//===----------------------------------------------------------------------===//
32
33namespace {
34/// AMDGPU specific code to select AMDGPU machine instructions for
35/// SelectionDAG operations.
36class AMDGPUDAGToDAGISel : public SelectionDAGISel {
37 // Subtarget - Keep a pointer to the AMDGPU Subtarget around so that we can
38 // make the right decision when generating code for different targets.
39 const AMDGPUSubtarget &Subtarget;
40public:
41 AMDGPUDAGToDAGISel(TargetMachine &TM);
42 virtual ~AMDGPUDAGToDAGISel();
43
44 SDNode *Select(SDNode *N);
45 virtual const char *getPassName() const;
46
47private:
48 inline SDValue getSmallIPtrImm(unsigned Imm);
Tom Stellard365366f2013-01-23 02:09:06 +000049 bool FoldOperands(unsigned, const R600InstrInfo *, std::vector<SDValue> &);
Tom Stellard75aadc22012-12-11 21:25:42 +000050
51 // Complex pattern selectors
52 bool SelectADDRParam(SDValue Addr, SDValue& R1, SDValue& R2);
53 bool SelectADDR(SDValue N, SDValue &R1, SDValue &R2);
54 bool SelectADDR64(SDValue N, SDValue &R1, SDValue &R2);
55
56 static bool checkType(const Value *ptr, unsigned int addrspace);
57 static const Value *getBasePointerValue(const Value *V);
58
59 static bool isGlobalStore(const StoreSDNode *N);
60 static bool isPrivateStore(const StoreSDNode *N);
61 static bool isLocalStore(const StoreSDNode *N);
62 static bool isRegionStore(const StoreSDNode *N);
63
64 static bool isCPLoad(const LoadSDNode *N);
65 static bool isConstantLoad(const LoadSDNode *N, int cbID);
66 static bool isGlobalLoad(const LoadSDNode *N);
67 static bool isParamLoad(const LoadSDNode *N);
68 static bool isPrivateLoad(const LoadSDNode *N);
69 static bool isLocalLoad(const LoadSDNode *N);
70 static bool isRegionLoad(const LoadSDNode *N);
71
Tom Stellard365366f2013-01-23 02:09:06 +000072 bool SelectGlobalValueConstantOffset(SDValue Addr, SDValue& IntPtr);
73 bool SelectGlobalValueVariableOffset(SDValue Addr,
74 SDValue &BaseReg, SDValue& Offset);
Tom Stellard75aadc22012-12-11 21:25:42 +000075 bool SelectADDR8BitOffset(SDValue Addr, SDValue& Base, SDValue& Offset);
76 bool SelectADDRReg(SDValue Addr, SDValue& Base, SDValue& Offset);
77 bool SelectADDRVTX_READ(SDValue Addr, SDValue &Base, SDValue &Offset);
78
79 // Include the pieces autogenerated from the target description.
80#include "AMDGPUGenDAGISel.inc"
81};
82} // end anonymous namespace
83
84/// \brief This pass converts a legalized DAG into a AMDGPU-specific
85// DAG, ready for instruction scheduling.
86FunctionPass *llvm::createAMDGPUISelDag(TargetMachine &TM
87 ) {
88 return new AMDGPUDAGToDAGISel(TM);
89}
90
91AMDGPUDAGToDAGISel::AMDGPUDAGToDAGISel(TargetMachine &TM
92 )
93 : SelectionDAGISel(TM), Subtarget(TM.getSubtarget<AMDGPUSubtarget>()) {
94}
95
96AMDGPUDAGToDAGISel::~AMDGPUDAGToDAGISel() {
97}
98
99SDValue AMDGPUDAGToDAGISel::getSmallIPtrImm(unsigned int Imm) {
100 return CurDAG->getTargetConstant(Imm, MVT::i32);
101}
102
103bool AMDGPUDAGToDAGISel::SelectADDRParam(
104 SDValue Addr, SDValue& R1, SDValue& R2) {
105
106 if (Addr.getOpcode() == ISD::FrameIndex) {
107 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
108 R1 = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
109 R2 = CurDAG->getTargetConstant(0, MVT::i32);
110 } else {
111 R1 = Addr;
112 R2 = CurDAG->getTargetConstant(0, MVT::i32);
113 }
114 } else if (Addr.getOpcode() == ISD::ADD) {
115 R1 = Addr.getOperand(0);
116 R2 = Addr.getOperand(1);
117 } else {
118 R1 = Addr;
119 R2 = CurDAG->getTargetConstant(0, MVT::i32);
120 }
121 return true;
122}
123
124bool AMDGPUDAGToDAGISel::SelectADDR(SDValue Addr, SDValue& R1, SDValue& R2) {
125 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
126 Addr.getOpcode() == ISD::TargetGlobalAddress) {
127 return false;
128 }
129 return SelectADDRParam(Addr, R1, R2);
130}
131
132
133bool AMDGPUDAGToDAGISel::SelectADDR64(SDValue Addr, SDValue& R1, SDValue& R2) {
134 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
135 Addr.getOpcode() == ISD::TargetGlobalAddress) {
136 return false;
137 }
138
139 if (Addr.getOpcode() == ISD::FrameIndex) {
140 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
141 R1 = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i64);
142 R2 = CurDAG->getTargetConstant(0, MVT::i64);
143 } else {
144 R1 = Addr;
145 R2 = CurDAG->getTargetConstant(0, MVT::i64);
146 }
147 } else if (Addr.getOpcode() == ISD::ADD) {
148 R1 = Addr.getOperand(0);
149 R2 = Addr.getOperand(1);
150 } else {
151 R1 = Addr;
152 R2 = CurDAG->getTargetConstant(0, MVT::i64);
153 }
154 return true;
155}
156
157SDNode *AMDGPUDAGToDAGISel::Select(SDNode *N) {
158 unsigned int Opc = N->getOpcode();
159 if (N->isMachineOpcode()) {
160 return NULL; // Already selected.
161 }
162 switch (Opc) {
163 default: break;
164 case ISD::FrameIndex: {
165 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N)) {
166 unsigned int FI = FIN->getIndex();
167 EVT OpVT = N->getValueType(0);
168 unsigned int NewOpc = AMDGPU::COPY;
169 SDValue TFI = CurDAG->getTargetFrameIndex(FI, MVT::i32);
170 return CurDAG->SelectNodeTo(N, NewOpc, OpVT, TFI);
171 }
172 break;
173 }
174 case ISD::ConstantFP:
175 case ISD::Constant: {
176 const AMDGPUSubtarget &ST = TM.getSubtarget<AMDGPUSubtarget>();
177 // XXX: Custom immediate lowering not implemented yet. Instead we use
178 // pseudo instructions defined in SIInstructions.td
179 if (ST.device()->getGeneration() > AMDGPUDeviceInfo::HD6XXX) {
180 break;
181 }
182 const R600InstrInfo *TII = static_cast<const R600InstrInfo*>(TM.getInstrInfo());
183
184 uint64_t ImmValue = 0;
185 unsigned ImmReg = AMDGPU::ALU_LITERAL_X;
186
187 if (N->getOpcode() == ISD::ConstantFP) {
188 // XXX: 64-bit Immediates not supported yet
189 assert(N->getValueType(0) != MVT::f64);
190
191 ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(N);
192 APFloat Value = C->getValueAPF();
193 float FloatValue = Value.convertToFloat();
194 if (FloatValue == 0.0) {
195 ImmReg = AMDGPU::ZERO;
196 } else if (FloatValue == 0.5) {
197 ImmReg = AMDGPU::HALF;
198 } else if (FloatValue == 1.0) {
199 ImmReg = AMDGPU::ONE;
200 } else {
201 ImmValue = Value.bitcastToAPInt().getZExtValue();
202 }
203 } else {
204 // XXX: 64-bit Immediates not supported yet
205 assert(N->getValueType(0) != MVT::i64);
206
207 ConstantSDNode *C = dyn_cast<ConstantSDNode>(N);
208 if (C->getZExtValue() == 0) {
209 ImmReg = AMDGPU::ZERO;
210 } else if (C->getZExtValue() == 1) {
211 ImmReg = AMDGPU::ONE_INT;
212 } else {
213 ImmValue = C->getZExtValue();
214 }
215 }
216
217 for (SDNode::use_iterator Use = N->use_begin(), Next = llvm::next(Use);
218 Use != SDNode::use_end(); Use = Next) {
219 Next = llvm::next(Use);
220 std::vector<SDValue> Ops;
221 for (unsigned i = 0; i < Use->getNumOperands(); ++i) {
222 Ops.push_back(Use->getOperand(i));
223 }
224
225 if (!Use->isMachineOpcode()) {
226 if (ImmReg == AMDGPU::ALU_LITERAL_X) {
227 // We can only use literal constants (e.g. AMDGPU::ZERO,
228 // AMDGPU::ONE, etc) in machine opcodes.
229 continue;
230 }
231 } else {
232 if (!TII->isALUInstr(Use->getMachineOpcode())) {
233 continue;
234 }
235
236 int ImmIdx = TII->getOperandIdx(Use->getMachineOpcode(), R600Operands::IMM);
237 assert(ImmIdx != -1);
238
239 // subtract one from ImmIdx, because the DST operand is usually index
240 // 0 for MachineInstrs, but we have no DST in the Ops vector.
241 ImmIdx--;
242
243 // Check that we aren't already using an immediate.
244 // XXX: It's possible for an instruction to have more than one
245 // immediate operand, but this is not supported yet.
246 if (ImmReg == AMDGPU::ALU_LITERAL_X) {
247 ConstantSDNode *C = dyn_cast<ConstantSDNode>(Use->getOperand(ImmIdx));
248 assert(C);
249
250 if (C->getZExtValue() != 0) {
251 // This instruction is already using an immediate.
252 continue;
253 }
254
255 // Set the immediate value
256 Ops[ImmIdx] = CurDAG->getTargetConstant(ImmValue, MVT::i32);
257 }
258 }
259 // Set the immediate register
260 Ops[Use.getOperandNo()] = CurDAG->getRegister(ImmReg, MVT::i32);
261
262 CurDAG->UpdateNodeOperands(*Use, Ops.data(), Use->getNumOperands());
263 }
264 break;
265 }
266 }
Tom Stellard365366f2013-01-23 02:09:06 +0000267 SDNode *Result = SelectCode(N);
268
269 // Fold operands of selected node
270
271 const AMDGPUSubtarget &ST = TM.getSubtarget<AMDGPUSubtarget>();
272 if (ST.device()->getGeneration() <= AMDGPUDeviceInfo::HD6XXX) {
273 const R600InstrInfo *TII =
274 static_cast<const R600InstrInfo*>(TM.getInstrInfo());
275 if (Result && TII->isALUInstr(Result->getMachineOpcode())) {
276 bool IsModified = false;
277 do {
278 std::vector<SDValue> Ops;
279 for(SDNode::op_iterator I = Result->op_begin(), E = Result->op_end();
280 I != E; ++I)
281 Ops.push_back(*I);
282 IsModified = FoldOperands(Result->getMachineOpcode(), TII, Ops);
283 if (IsModified) {
284 Result = CurDAG->MorphNodeTo(Result, Result->getOpcode(),
285 Result->getVTList(), Ops.data(), Ops.size());
286 }
287 } while (IsModified);
288 }
289 }
290
291 return Result;
292}
293
294bool AMDGPUDAGToDAGISel::FoldOperands(unsigned Opcode,
295 const R600InstrInfo *TII, std::vector<SDValue> &Ops) {
296 int OperandIdx[] = {
297 TII->getOperandIdx(Opcode, R600Operands::SRC0),
298 TII->getOperandIdx(Opcode, R600Operands::SRC1),
299 TII->getOperandIdx(Opcode, R600Operands::SRC2)
300 };
301 int SelIdx[] = {
302 TII->getOperandIdx(Opcode, R600Operands::SRC0_SEL),
303 TII->getOperandIdx(Opcode, R600Operands::SRC1_SEL),
304 TII->getOperandIdx(Opcode, R600Operands::SRC2_SEL)
305 };
306 for (unsigned i = 0; i < 3; i++) {
307 if (OperandIdx[i] < 0)
308 return false;
309 SDValue Operand = Ops[OperandIdx[i] - 1];
310 switch (Operand.getOpcode()) {
311 case AMDGPUISD::CONST_ADDRESS: {
312 SDValue CstOffset;
313 if (!Operand.getValueType().isVector() &&
314 SelectGlobalValueConstantOffset(Operand.getOperand(0), CstOffset)) {
315 Ops[OperandIdx[i] - 1] = CurDAG->getRegister(AMDGPU::ALU_CONST, MVT::f32);
316 Ops[SelIdx[i] - 1] = CstOffset;
317 return true;
318 }
319 }
320 break;
Tom Stellarddd04c832013-01-31 22:11:53 +0000321 case ISD::BITCAST:
322 Ops[OperandIdx[i] - 1] = Operand.getOperand(0);
323 return true;
Tom Stellard365366f2013-01-23 02:09:06 +0000324 default:
325 break;
326 }
327 }
328 return false;
Tom Stellard75aadc22012-12-11 21:25:42 +0000329}
330
331bool AMDGPUDAGToDAGISel::checkType(const Value *ptr, unsigned int addrspace) {
332 if (!ptr) {
333 return false;
334 }
335 Type *ptrType = ptr->getType();
336 return dyn_cast<PointerType>(ptrType)->getAddressSpace() == addrspace;
337}
338
339const Value * AMDGPUDAGToDAGISel::getBasePointerValue(const Value *V) {
340 if (!V) {
341 return NULL;
342 }
343 const Value *ret = NULL;
344 ValueMap<const Value *, bool> ValueBitMap;
345 std::queue<const Value *, std::list<const Value *> > ValueQueue;
346 ValueQueue.push(V);
347 while (!ValueQueue.empty()) {
348 V = ValueQueue.front();
349 if (ValueBitMap.find(V) == ValueBitMap.end()) {
350 ValueBitMap[V] = true;
351 if (dyn_cast<Argument>(V) && dyn_cast<PointerType>(V->getType())) {
352 ret = V;
353 break;
354 } else if (dyn_cast<GlobalVariable>(V)) {
355 ret = V;
356 break;
357 } else if (dyn_cast<Constant>(V)) {
358 const ConstantExpr *CE = dyn_cast<ConstantExpr>(V);
359 if (CE) {
360 ValueQueue.push(CE->getOperand(0));
361 }
362 } else if (const AllocaInst *AI = dyn_cast<AllocaInst>(V)) {
363 ret = AI;
364 break;
365 } else if (const Instruction *I = dyn_cast<Instruction>(V)) {
366 uint32_t numOps = I->getNumOperands();
367 for (uint32_t x = 0; x < numOps; ++x) {
368 ValueQueue.push(I->getOperand(x));
369 }
370 } else {
371 assert(!"Found a Value that we didn't know how to handle!");
372 }
373 }
374 ValueQueue.pop();
375 }
376 return ret;
377}
378
379bool AMDGPUDAGToDAGISel::isGlobalStore(const StoreSDNode *N) {
380 return checkType(N->getSrcValue(), AMDGPUAS::GLOBAL_ADDRESS);
381}
382
383bool AMDGPUDAGToDAGISel::isPrivateStore(const StoreSDNode *N) {
384 return (!checkType(N->getSrcValue(), AMDGPUAS::LOCAL_ADDRESS)
385 && !checkType(N->getSrcValue(), AMDGPUAS::GLOBAL_ADDRESS)
386 && !checkType(N->getSrcValue(), AMDGPUAS::REGION_ADDRESS));
387}
388
389bool AMDGPUDAGToDAGISel::isLocalStore(const StoreSDNode *N) {
390 return checkType(N->getSrcValue(), AMDGPUAS::LOCAL_ADDRESS);
391}
392
393bool AMDGPUDAGToDAGISel::isRegionStore(const StoreSDNode *N) {
394 return checkType(N->getSrcValue(), AMDGPUAS::REGION_ADDRESS);
395}
396
397bool AMDGPUDAGToDAGISel::isConstantLoad(const LoadSDNode *N, int cbID) {
398 if (checkType(N->getSrcValue(), AMDGPUAS::CONSTANT_ADDRESS)) {
399 return true;
400 }
401 MachineMemOperand *MMO = N->getMemOperand();
402 const Value *V = MMO->getValue();
403 const Value *BV = getBasePointerValue(V);
404 if (MMO
405 && MMO->getValue()
406 && ((V && dyn_cast<GlobalValue>(V))
407 || (BV && dyn_cast<GlobalValue>(
408 getBasePointerValue(MMO->getValue()))))) {
409 return checkType(N->getSrcValue(), AMDGPUAS::PRIVATE_ADDRESS);
410 } else {
411 return false;
412 }
413}
414
415bool AMDGPUDAGToDAGISel::isGlobalLoad(const LoadSDNode *N) {
416 return checkType(N->getSrcValue(), AMDGPUAS::GLOBAL_ADDRESS);
417}
418
419bool AMDGPUDAGToDAGISel::isParamLoad(const LoadSDNode *N) {
420 return checkType(N->getSrcValue(), AMDGPUAS::PARAM_I_ADDRESS);
421}
422
423bool AMDGPUDAGToDAGISel::isLocalLoad(const LoadSDNode *N) {
424 return checkType(N->getSrcValue(), AMDGPUAS::LOCAL_ADDRESS);
425}
426
427bool AMDGPUDAGToDAGISel::isRegionLoad(const LoadSDNode *N) {
428 return checkType(N->getSrcValue(), AMDGPUAS::REGION_ADDRESS);
429}
430
431bool AMDGPUDAGToDAGISel::isCPLoad(const LoadSDNode *N) {
432 MachineMemOperand *MMO = N->getMemOperand();
433 if (checkType(N->getSrcValue(), AMDGPUAS::PRIVATE_ADDRESS)) {
434 if (MMO) {
435 const Value *V = MMO->getValue();
436 const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V);
437 if (PSV && PSV == PseudoSourceValue::getConstantPool()) {
438 return true;
439 }
440 }
441 }
442 return false;
443}
444
445bool AMDGPUDAGToDAGISel::isPrivateLoad(const LoadSDNode *N) {
446 if (checkType(N->getSrcValue(), AMDGPUAS::PRIVATE_ADDRESS)) {
447 // Check to make sure we are not a constant pool load or a constant load
448 // that is marked as a private load
449 if (isCPLoad(N) || isConstantLoad(N, -1)) {
450 return false;
451 }
452 }
453 if (!checkType(N->getSrcValue(), AMDGPUAS::LOCAL_ADDRESS)
454 && !checkType(N->getSrcValue(), AMDGPUAS::GLOBAL_ADDRESS)
455 && !checkType(N->getSrcValue(), AMDGPUAS::REGION_ADDRESS)
456 && !checkType(N->getSrcValue(), AMDGPUAS::CONSTANT_ADDRESS)
457 && !checkType(N->getSrcValue(), AMDGPUAS::PARAM_D_ADDRESS)
458 && !checkType(N->getSrcValue(), AMDGPUAS::PARAM_I_ADDRESS)) {
459 return true;
460 }
461 return false;
462}
463
464const char *AMDGPUDAGToDAGISel::getPassName() const {
465 return "AMDGPU DAG->DAG Pattern Instruction Selection";
466}
467
468#ifdef DEBUGTMP
469#undef INT64_C
470#endif
471#undef DEBUGTMP
472
473///==== AMDGPU Functions ====///
474
Tom Stellard365366f2013-01-23 02:09:06 +0000475bool AMDGPUDAGToDAGISel::SelectGlobalValueConstantOffset(SDValue Addr,
476 SDValue& IntPtr) {
477 if (ConstantSDNode *Cst = dyn_cast<ConstantSDNode>(Addr)) {
478 IntPtr = CurDAG->getIntPtrConstant(Cst->getZExtValue() / 4, true);
479 return true;
480 }
481 return false;
482}
483
484bool AMDGPUDAGToDAGISel::SelectGlobalValueVariableOffset(SDValue Addr,
485 SDValue& BaseReg, SDValue &Offset) {
486 if (!dyn_cast<ConstantSDNode>(Addr)) {
487 BaseReg = Addr;
488 Offset = CurDAG->getIntPtrConstant(0, true);
489 return true;
490 }
491 return false;
492}
493
Tom Stellard75aadc22012-12-11 21:25:42 +0000494bool AMDGPUDAGToDAGISel::SelectADDR8BitOffset(SDValue Addr, SDValue& Base,
495 SDValue& Offset) {
496 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
497 Addr.getOpcode() == ISD::TargetGlobalAddress) {
498 return false;
499 }
500
501
502 if (Addr.getOpcode() == ISD::ADD) {
503 bool Match = false;
504
505 // Find the base ptr and the offset
506 for (unsigned i = 0; i < Addr.getNumOperands(); i++) {
507 SDValue Arg = Addr.getOperand(i);
508 ConstantSDNode * OffsetNode = dyn_cast<ConstantSDNode>(Arg);
509 // This arg isn't a constant so it must be the base PTR.
510 if (!OffsetNode) {
511 Base = Addr.getOperand(i);
512 continue;
513 }
514 // Check if the constant argument fits in 8-bits. The offset is in bytes
515 // so we need to convert it to dwords.
516 if (isUInt<8>(OffsetNode->getZExtValue() >> 2)) {
517 Match = true;
518 Offset = CurDAG->getTargetConstant(OffsetNode->getZExtValue() >> 2,
519 MVT::i32);
520 }
521 }
522 return Match;
523 }
524
525 // Default case, no offset
526 Base = Addr;
527 Offset = CurDAG->getTargetConstant(0, MVT::i32);
528 return true;
529}
530
531bool AMDGPUDAGToDAGISel::SelectADDRVTX_READ(SDValue Addr, SDValue &Base,
532 SDValue &Offset) {
533 ConstantSDNode * IMMOffset;
534
535 if (Addr.getOpcode() == ISD::ADD
536 && (IMMOffset = dyn_cast<ConstantSDNode>(Addr.getOperand(1)))
537 && isInt<16>(IMMOffset->getZExtValue())) {
538
539 Base = Addr.getOperand(0);
540 Offset = CurDAG->getTargetConstant(IMMOffset->getZExtValue(), MVT::i32);
541 return true;
542 // If the pointer address is constant, we can move it to the offset field.
543 } else if ((IMMOffset = dyn_cast<ConstantSDNode>(Addr))
544 && isInt<16>(IMMOffset->getZExtValue())) {
545 Base = CurDAG->getCopyFromReg(CurDAG->getEntryNode(),
546 CurDAG->getEntryNode().getDebugLoc(),
547 AMDGPU::ZERO, MVT::i32);
548 Offset = CurDAG->getTargetConstant(IMMOffset->getZExtValue(), MVT::i32);
549 return true;
550 }
551
552 // Default case, no offset
553 Base = Addr;
554 Offset = CurDAG->getTargetConstant(0, MVT::i32);
555 return true;
556}
557
558bool AMDGPUDAGToDAGISel::SelectADDRReg(SDValue Addr, SDValue& Base,
559 SDValue& Offset) {
560 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
561 Addr.getOpcode() == ISD::TargetGlobalAddress ||
562 Addr.getOpcode() != ISD::ADD) {
563 return false;
564 }
565
566 Base = Addr.getOperand(0);
567 Offset = Addr.getOperand(1);
568
569 return true;
570}