1 //===-- ARMISelDAGToDAG.cpp - A dag to dag inst selector for ARM ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines an instruction selector for the ARM target.
12 //===----------------------------------------------------------------------===//
15 #include "ARMTargetMachine.h"
16 #include "llvm/CallingConv.h"
17 #include "llvm/DerivedTypes.h"
18 #include "llvm/Function.h"
19 #include "llvm/Constants.h"
20 #include "llvm/Intrinsics.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
22 #include "llvm/CodeGen/MachineFunction.h"
23 #include "llvm/CodeGen/MachineInstrBuilder.h"
24 #include "llvm/CodeGen/SelectionDAG.h"
25 #include "llvm/CodeGen/SelectionDAGISel.h"
26 #include "llvm/CodeGen/SSARegMap.h"
27 #include "llvm/Target/TargetLowering.h"
28 #include "llvm/Support/Debug.h"
35 class ARMTargetLowering : public TargetLowering {
36 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
38 ARMTargetLowering(TargetMachine &TM);
39 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
40 virtual const char *getTargetNodeName(unsigned Opcode) const;
45 ARMTargetLowering::ARMTargetLowering(TargetMachine &TM)
46 : TargetLowering(TM) {
47 addRegisterClass(MVT::i32, ARM::IntRegsRegisterClass);
48 addRegisterClass(MVT::f32, ARM::FPRegsRegisterClass);
49 addRegisterClass(MVT::f64, ARM::DFPRegsRegisterClass);
51 setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
53 setOperationAction(ISD::RET, MVT::Other, Custom);
54 setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
55 setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
57 setOperationAction(ISD::SETCC, MVT::i32, Expand);
58 setOperationAction(ISD::SELECT_CC, MVT::i32, Custom);
59 setOperationAction(ISD::BR_CC, MVT::i32, Custom);
61 setOperationAction(ISD::VASTART, MVT::Other, Custom);
62 setOperationAction(ISD::VAEND, MVT::Other, Expand);
64 setOperationAction(ISD::ConstantFP, MVT::f64, Expand);
65 setOperationAction(ISD::ConstantFP, MVT::f32, Expand);
67 setSchedulingPreference(SchedulingForRegPressure);
68 computeRegisterProperties();
74 // Start the numbering where the builting ops and target ops leave off.
75 FIRST_NUMBER = ISD::BUILTIN_OP_END+ARM::INSTRUCTION_LIST_END,
76 /// CALL - A direct function call.
79 /// Return with a flag operand.
97 /// DAGCCToARMCC - Convert a DAG integer condition code to an ARM CC
98 static ARMCC::CondCodes DAGCCToARMCC(ISD::CondCode CC) {
101 std::cerr << "CC = " << CC << "\n";
102 assert(0 && "Unknown condition code!");
103 case ISD::SETUGT: return ARMCC::HI;
104 case ISD::SETULE: return ARMCC::LS;
105 case ISD::SETLE: return ARMCC::LE;
106 case ISD::SETLT: return ARMCC::LT;
107 case ISD::SETGT: return ARMCC::GT;
108 case ISD::SETNE: return ARMCC::NE;
109 case ISD::SETEQ: return ARMCC::EQ;
110 case ISD::SETGE: return ARMCC::GE;
111 case ISD::SETUGE: return ARMCC::CS;
112 case ISD::SETULT: return ARMCC::CC;
116 const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const {
119 case ARMISD::CALL: return "ARMISD::CALL";
120 case ARMISD::RET_FLAG: return "ARMISD::RET_FLAG";
121 case ARMISD::SELECT: return "ARMISD::SELECT";
122 case ARMISD::CMP: return "ARMISD::CMP";
123 case ARMISD::BR: return "ARMISD::BR";
124 case ARMISD::FSITOS: return "ARMISD::FSITOS";
125 case ARMISD::FSITOD: return "ARMISD::FSITOD";
126 case ARMISD::FMRRD: return "ARMISD::FMRRD";
130 // This transforms a ISD::CALL node into a
131 // callseq_star <- ARMISD:CALL <- callseq_end
133 static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) {
134 SDOperand Chain = Op.getOperand(0);
135 unsigned CallConv = cast<ConstantSDNode>(Op.getOperand(1))->getValue();
136 assert(CallConv == CallingConv::C && "unknown calling convention");
137 bool isVarArg = cast<ConstantSDNode>(Op.getOperand(2))->getValue() != 0;
138 bool isTailCall = cast<ConstantSDNode>(Op.getOperand(3))->getValue() != 0;
139 assert(isTailCall == false && "tail call not supported");
140 SDOperand Callee = Op.getOperand(4);
141 unsigned NumOps = (Op.getNumOperands() - 5) / 2;
143 // Count how many bytes are to be pushed on the stack.
144 unsigned NumBytes = 0;
146 // Add up all the space actually used.
147 for (unsigned i = 4; i < NumOps; ++i)
148 NumBytes += MVT::getSizeInBits(Op.getOperand(5+2*i).getValueType())/8;
150 // Adjust the stack pointer for the new arguments...
151 // These operations are automatically eliminated by the prolog/epilog pass
152 Chain = DAG.getCALLSEQ_START(Chain,
153 DAG.getConstant(NumBytes, MVT::i32));
155 SDOperand StackPtr = DAG.getRegister(ARM::R13, MVT::i32);
157 static const unsigned int num_regs = 4;
158 static const unsigned regs[num_regs] = {
159 ARM::R0, ARM::R1, ARM::R2, ARM::R3
162 std::vector<std::pair<unsigned, SDOperand> > RegsToPass;
163 std::vector<SDOperand> MemOpChains;
165 for (unsigned i = 0; i != NumOps; ++i) {
166 SDOperand Arg = Op.getOperand(5+2*i);
167 assert(Arg.getValueType() == MVT::i32);
169 RegsToPass.push_back(std::make_pair(regs[i], Arg));
171 unsigned ArgOffset = (i - num_regs) * 4;
172 SDOperand PtrOff = DAG.getConstant(ArgOffset, StackPtr.getValueType());
173 PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
174 MemOpChains.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
175 Arg, PtrOff, DAG.getSrcValue(NULL)));
178 if (!MemOpChains.empty())
179 Chain = DAG.getNode(ISD::TokenFactor, MVT::Other,
180 &MemOpChains[0], MemOpChains.size());
182 // Build a sequence of copy-to-reg nodes chained together with token chain
183 // and flag operands which copy the outgoing args into the appropriate regs.
185 for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
186 Chain = DAG.getCopyToReg(Chain, RegsToPass[i].first, RegsToPass[i].second,
188 InFlag = Chain.getValue(1);
191 std::vector<MVT::ValueType> NodeTys;
192 NodeTys.push_back(MVT::Other); // Returns a chain
193 NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use.
195 // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
196 // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
197 // node so that legalize doesn't hack it.
198 if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
199 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), Callee.getValueType());
201 // If this is a direct call, pass the chain and the callee.
203 std::vector<SDOperand> Ops;
204 Ops.push_back(Chain);
205 Ops.push_back(Callee);
207 // Add argument registers to the end of the list so that they are known live
209 for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
210 Ops.push_back(DAG.getRegister(RegsToPass[i].first,
211 RegsToPass[i].second.getValueType()));
213 unsigned CallOpc = ARMISD::CALL;
215 Ops.push_back(InFlag);
216 Chain = DAG.getNode(CallOpc, NodeTys, &Ops[0], Ops.size());
217 InFlag = Chain.getValue(1);
219 std::vector<SDOperand> ResultVals;
222 // If the call has results, copy the values out of the ret val registers.
223 switch (Op.Val->getValueType(0)) {
224 default: assert(0 && "Unexpected ret value!");
228 Chain = DAG.getCopyFromReg(Chain, ARM::R0, MVT::i32, InFlag).getValue(1);
229 ResultVals.push_back(Chain.getValue(0));
230 NodeTys.push_back(MVT::i32);
233 Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain,
234 DAG.getConstant(NumBytes, MVT::i32));
235 NodeTys.push_back(MVT::Other);
237 if (ResultVals.empty())
240 ResultVals.push_back(Chain);
241 SDOperand Res = DAG.getNode(ISD::MERGE_VALUES, NodeTys, &ResultVals[0],
243 return Res.getValue(Op.ResNo);
246 static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG) {
248 SDOperand Chain = Op.getOperand(0);
249 SDOperand R0 = DAG.getRegister(ARM::R0, MVT::i32);
250 SDOperand R1 = DAG.getRegister(ARM::R1, MVT::i32);
252 switch(Op.getNumOperands()) {
254 assert(0 && "Do not know how to return this many arguments!");
257 SDOperand LR = DAG.getRegister(ARM::R14, MVT::i32);
258 return DAG.getNode(ARMISD::RET_FLAG, MVT::Other, Chain);
261 SDOperand Val = Op.getOperand(1);
262 assert(Val.getValueType() == MVT::i32 ||
263 Val.getValueType() == MVT::f32 ||
264 Val.getValueType() == MVT::f64);
266 if (Val.getValueType() == MVT::f64) {
267 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Flag);
268 SDOperand Ops[] = {Chain, R0, R1, Val};
269 Copy = DAG.getNode(ARMISD::FMRRD, VTs, Ops, 4);
271 if (Val.getValueType() == MVT::f32)
272 Val = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Val);
273 Copy = DAG.getCopyToReg(Chain, R0, Val, SDOperand());
276 if (DAG.getMachineFunction().liveout_empty()) {
277 DAG.getMachineFunction().addLiveOut(ARM::R0);
278 if (Val.getValueType() == MVT::f64)
279 DAG.getMachineFunction().addLiveOut(ARM::R1);
284 Copy = DAG.getCopyToReg(Chain, ARM::R1, Op.getOperand(3), SDOperand());
285 Copy = DAG.getCopyToReg(Copy, ARM::R0, Op.getOperand(1), Copy.getValue(1));
286 // If we haven't noted the R0+R1 are live out, do so now.
287 if (DAG.getMachineFunction().liveout_empty()) {
288 DAG.getMachineFunction().addLiveOut(ARM::R0);
289 DAG.getMachineFunction().addLiveOut(ARM::R1);
294 //We must use RET_FLAG instead of BRIND because BRIND doesn't have a flag
295 return DAG.getNode(ARMISD::RET_FLAG, MVT::Other, Copy, Copy.getValue(1));
298 static SDOperand LowerFORMAL_ARGUMENT(SDOperand Op, SelectionDAG &DAG,
301 MachineFunction &MF = DAG.getMachineFunction();
302 MVT::ValueType ObjectVT = Op.getValue(ArgNo).getValueType();
303 assert (ObjectVT == MVT::i32);
304 SDOperand Root = Op.getOperand(0);
305 SSARegMap *RegMap = MF.getSSARegMap();
307 unsigned num_regs = 4;
308 static const unsigned REGS[] = {
309 ARM::R0, ARM::R1, ARM::R2, ARM::R3
312 if(ArgNo < num_regs) {
313 unsigned VReg = RegMap->createVirtualRegister(&ARM::IntRegsRegClass);
314 MF.addLiveIn(REGS[ArgNo], VReg);
316 return DAG.getCopyFromReg(Root, VReg, MVT::i32);
318 // If the argument is actually used, emit a load from the right stack
320 if (!Op.Val->hasNUsesOfValue(0, ArgNo)) {
321 unsigned ArgOffset = (ArgNo - num_regs) * 4;
323 MachineFrameInfo *MFI = MF.getFrameInfo();
324 unsigned ObjSize = MVT::getSizeInBits(ObjectVT)/8;
325 int FI = MFI->CreateFixedObject(ObjSize, ArgOffset);
326 SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
327 return DAG.getLoad(ObjectVT, Root, FIN,
328 DAG.getSrcValue(NULL));
330 // Don't emit a dead load.
331 return DAG.getNode(ISD::UNDEF, ObjectVT);
336 static SDOperand LowerConstantPool(SDOperand Op, SelectionDAG &DAG) {
337 MVT::ValueType PtrVT = Op.getValueType();
338 ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
339 Constant *C = CP->getConstVal();
340 SDOperand CPI = DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment());
345 static SDOperand LowerGlobalAddress(SDOperand Op,
347 GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
349 SDOperand CPAddr = DAG.getConstantPool(GV, MVT::i32, alignment);
350 return DAG.getLoad(MVT::i32, DAG.getEntryNode(), CPAddr,
351 DAG.getSrcValue(NULL));
354 static SDOperand LowerVASTART(SDOperand Op, SelectionDAG &DAG,
355 unsigned VarArgsFrameIndex) {
356 // vastart just stores the address of the VarArgsFrameIndex slot into the
357 // memory location argument.
358 MVT::ValueType PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
359 SDOperand FR = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT);
360 return DAG.getNode(ISD::STORE, MVT::Other, Op.getOperand(0), FR,
361 Op.getOperand(1), Op.getOperand(2));
364 static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
365 int &VarArgsFrameIndex) {
366 std::vector<SDOperand> ArgValues;
367 SDOperand Root = Op.getOperand(0);
370 unsigned NumArgs = Op.Val->getNumValues()-1;
371 for (unsigned ArgNo = 0; ArgNo < NumArgs; ++ArgNo) {
372 SDOperand ArgVal = LowerFORMAL_ARGUMENT(Op, DAG, VRegs, ArgNo);
374 ArgValues.push_back(ArgVal);
377 bool isVarArg = cast<ConstantSDNode>(Op.getOperand(2))->getValue() != 0;
379 MachineFunction &MF = DAG.getMachineFunction();
380 SSARegMap *RegMap = MF.getSSARegMap();
381 MachineFrameInfo *MFI = MF.getFrameInfo();
382 VarArgsFrameIndex = MFI->CreateFixedObject(MVT::getSizeInBits(MVT::i32)/8,
386 static const unsigned REGS[] = {
387 ARM::R0, ARM::R1, ARM::R2, ARM::R3
389 // If this function is vararg, store r0-r3 to their spots on the stack
390 // so that they may be loaded by deferencing the result of va_next.
391 SmallVector<SDOperand, 4> MemOps;
392 for (unsigned ArgNo = 0; ArgNo < 4; ++ArgNo) {
393 int ArgOffset = - (4 - ArgNo) * 4;
394 int FI = MFI->CreateFixedObject(MVT::getSizeInBits(MVT::i32)/8,
396 SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
402 VReg = RegMap->createVirtualRegister(&ARM::IntRegsRegClass);
403 if (ArgNo >= NumArgs)
404 MF.addLiveIn(REGS[ArgNo], VReg);
406 SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::i32);
407 SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1),
408 Val, FIN, DAG.getSrcValue(NULL));
409 MemOps.push_back(Store);
411 Root = DAG.getNode(ISD::TokenFactor, MVT::Other,&MemOps[0],MemOps.size());
414 ArgValues.push_back(Root);
416 // Return the new list of results.
417 std::vector<MVT::ValueType> RetVT(Op.Val->value_begin(),
418 Op.Val->value_end());
419 return DAG.getNode(ISD::MERGE_VALUES, RetVT, &ArgValues[0], ArgValues.size());
422 static SDOperand LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG) {
423 SDOperand LHS = Op.getOperand(0);
424 SDOperand RHS = Op.getOperand(1);
425 ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(4))->get();
426 SDOperand TrueVal = Op.getOperand(2);
427 SDOperand FalseVal = Op.getOperand(3);
428 SDOperand ARMCC = DAG.getConstant(DAGCCToARMCC(CC), MVT::i32);
430 SDOperand Cmp = DAG.getNode(ARMISD::CMP, MVT::Flag, LHS, RHS);
431 return DAG.getNode(ARMISD::SELECT, MVT::i32, TrueVal, FalseVal, ARMCC, Cmp);
434 static SDOperand LowerBR_CC(SDOperand Op, SelectionDAG &DAG) {
435 SDOperand Chain = Op.getOperand(0);
436 ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(1))->get();
437 SDOperand LHS = Op.getOperand(2);
438 SDOperand RHS = Op.getOperand(3);
439 SDOperand Dest = Op.getOperand(4);
440 SDOperand ARMCC = DAG.getConstant(DAGCCToARMCC(CC), MVT::i32);
442 SDOperand Cmp = DAG.getNode(ARMISD::CMP, MVT::Flag, LHS, RHS);
443 return DAG.getNode(ARMISD::BR, MVT::Other, Chain, Dest, ARMCC, Cmp);
446 static SDOperand LowerSINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
447 SDOperand IntVal = Op.getOperand(0);
448 assert(IntVal.getValueType() == MVT::i32);
449 MVT::ValueType vt = Op.getValueType();
450 assert(vt == MVT::f32 ||
453 SDOperand Tmp = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, IntVal);
454 ARMISD::NodeType op = vt == MVT::f32 ? ARMISD::FSITOS : ARMISD::FSITOD;
455 return DAG.getNode(op, vt, Tmp);
458 SDOperand ARMTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
459 switch (Op.getOpcode()) {
461 assert(0 && "Should not custom lower this!");
463 case ISD::ConstantPool:
464 return LowerConstantPool(Op, DAG);
465 case ISD::GlobalAddress:
466 return LowerGlobalAddress(Op, DAG);
467 case ISD::SINT_TO_FP:
468 return LowerSINT_TO_FP(Op, DAG);
469 case ISD::FORMAL_ARGUMENTS:
470 return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex);
472 return LowerCALL(Op, DAG);
474 return LowerRET(Op, DAG);
476 return LowerSELECT_CC(Op, DAG);
478 return LowerBR_CC(Op, DAG);
480 return LowerVASTART(Op, DAG, VarArgsFrameIndex);
484 //===----------------------------------------------------------------------===//
485 // Instruction Selector Implementation
486 //===----------------------------------------------------------------------===//
488 //===--------------------------------------------------------------------===//
489 /// ARMDAGToDAGISel - ARM specific code to select ARM machine
490 /// instructions for SelectionDAG operations.
493 class ARMDAGToDAGISel : public SelectionDAGISel {
494 ARMTargetLowering Lowering;
497 ARMDAGToDAGISel(TargetMachine &TM)
498 : SelectionDAGISel(Lowering), Lowering(TM) {
501 SDNode *Select(SDOperand Op);
502 virtual void InstructionSelectBasicBlock(SelectionDAG &DAG);
503 bool SelectAddrRegImm(SDOperand N, SDOperand &Offset, SDOperand &Base);
504 bool SelectAddrMode1(SDOperand N, SDOperand &Arg, SDOperand &Shift,
505 SDOperand &ShiftType);
507 // Include the pieces autogenerated from the target description.
508 #include "ARMGenDAGISel.inc"
511 void ARMDAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) {
514 DAG.setRoot(SelectRoot(DAG.getRoot()));
515 DAG.RemoveDeadNodes();
517 ScheduleAndEmitDAG(DAG);
520 static bool isInt12Immediate(SDNode *N, short &Imm) {
521 if (N->getOpcode() != ISD::Constant)
524 int32_t t = cast<ConstantSDNode>(N)->getValue();
527 if (t > min && t < max) {
535 static bool isInt12Immediate(SDOperand Op, short &Imm) {
536 return isInt12Immediate(Op.Val, Imm);
539 static uint32_t rotateL(uint32_t x) {
540 uint32_t bit31 = (x & (1 << 31)) >> 31;
545 static bool isUInt8Immediate(uint32_t x) {
549 static bool isRotInt8Immediate(uint32_t x) {
551 for (r = 0; r < 16; r++) {
552 if (isUInt8Immediate(x))
554 x = rotateL(rotateL(x));
559 bool ARMDAGToDAGISel::SelectAddrMode1(SDOperand N,
562 SDOperand &ShiftType) {
563 switch(N.getOpcode()) {
564 case ISD::Constant: {
565 uint32_t val = cast<ConstantSDNode>(N)->getValue();
566 if(!isRotInt8Immediate(val)) {
567 const Type *t = MVT::getTypeForValueType(MVT::i32);
568 Constant *C = ConstantUInt::get(t, val);
570 SDOperand Addr = CurDAG->getTargetConstantPool(C, MVT::i32, alignment);
571 SDOperand Z = CurDAG->getTargetConstant(0, MVT::i32);
572 SDNode *n = CurDAG->getTargetNode(ARM::ldr, MVT::i32, Z, Addr);
573 Arg = SDOperand(n, 0);
575 Arg = CurDAG->getTargetConstant(val, MVT::i32);
577 Shift = CurDAG->getTargetConstant(0, MVT::i32);
578 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
582 Arg = N.getOperand(0);
583 Shift = N.getOperand(1);
584 ShiftType = CurDAG->getTargetConstant(ARMShift::ASR, MVT::i32);
587 Arg = N.getOperand(0);
588 Shift = N.getOperand(1);
589 ShiftType = CurDAG->getTargetConstant(ARMShift::LSR, MVT::i32);
592 Arg = N.getOperand(0);
593 Shift = N.getOperand(1);
594 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
599 Shift = CurDAG->getTargetConstant(0, MVT::i32);
600 ShiftType = CurDAG->getTargetConstant(ARMShift::LSL, MVT::i32);
604 //register plus/minus 12 bit offset
605 bool ARMDAGToDAGISel::SelectAddrRegImm(SDOperand N, SDOperand &Offset,
607 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(N)) {
608 Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32);
609 Offset = CurDAG->getTargetConstant(0, MVT::i32);
612 if (N.getOpcode() == ISD::ADD) {
614 if (isInt12Immediate(N.getOperand(1), imm)) {
615 Offset = CurDAG->getTargetConstant(imm, MVT::i32);
616 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N.getOperand(0))) {
617 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), N.getValueType());
619 Base = N.getOperand(0);
621 return true; // [r+i]
625 Offset = CurDAG->getTargetConstant(0, MVT::i32);
626 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N)) {
627 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), N.getValueType());
631 return true; //any address fits in a register
634 SDNode *ARMDAGToDAGISel::Select(SDOperand Op) {
637 switch (N->getOpcode()) {
639 return SelectCode(Op);
645 } // end anonymous namespace
647 /// createARMISelDag - This pass converts a legalized DAG into a
648 /// ARM-specific DAG, ready for instruction scheduling.
650 FunctionPass *llvm::createARMISelDag(TargetMachine &TM) {
651 return new ARMDAGToDAGISel(TM);