1 //===- ARMRegisterInfo.cpp - ARM Register Information -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the "Instituto Nokia de Tecnologia" and
6 // is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file contains the ARM implementation of the MRegisterInfo class.
13 //===----------------------------------------------------------------------===//
16 #include "ARMAddressingModes.h"
17 #include "ARMInstrInfo.h"
18 #include "ARMMachineFunctionInfo.h"
19 #include "ARMRegisterInfo.h"
20 #include "ARMSubtarget.h"
21 #include "llvm/Constants.h"
22 #include "llvm/DerivedTypes.h"
23 #include "llvm/CodeGen/MachineConstantPool.h"
24 #include "llvm/CodeGen/MachineFrameInfo.h"
25 #include "llvm/CodeGen/MachineFunction.h"
26 #include "llvm/CodeGen/MachineInstrBuilder.h"
27 #include "llvm/CodeGen/MachineLocation.h"
28 #include "llvm/Target/TargetFrameInfo.h"
29 #include "llvm/Target/TargetMachine.h"
30 #include "llvm/Target/TargetOptions.h"
31 #include "llvm/ADT/SmallVector.h"
32 #include "llvm/ADT/STLExtras.h"
36 unsigned ARMRegisterInfo::getRegisterNumbering(unsigned RegEnum) {
39 case R0: case S0: case D0: return 0;
40 case R1: case S1: case D1: return 1;
41 case R2: case S2: case D2: return 2;
42 case R3: case S3: case D3: return 3;
43 case R4: case S4: case D4: return 4;
44 case R5: case S5: case D5: return 5;
45 case R6: case S6: case D6: return 6;
46 case R7: case S7: case D7: return 7;
47 case R8: case S8: case D8: return 8;
48 case R9: case S9: case D9: return 9;
49 case R10: case S10: case D10: return 10;
50 case R11: case S11: case D11: return 11;
51 case R12: case S12: case D12: return 12;
52 case SP: case S13: case D13: return 13;
53 case LR: case S14: case D14: return 14;
54 case PC: case S15: case D15: return 15;
72 assert(0 && "Unknown ARM register!");
77 ARMRegisterInfo::ARMRegisterInfo(const TargetInstrInfo &tii,
78 const ARMSubtarget &sti)
79 : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP),
81 FramePtr(STI.useThumbBacktraces() ? ARM::R7 : ARM::R11) {
84 bool ARMRegisterInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB,
85 MachineBasicBlock::iterator MI,
86 const std::vector<CalleeSavedInfo> &CSI) const {
87 MachineFunction &MF = *MBB.getParent();
88 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
89 if (!AFI->isThumbFunction() || CSI.empty())
92 MachineInstrBuilder MIB = BuildMI(MBB, MI, TII.get(ARM::tPUSH));
93 for (unsigned i = CSI.size(); i != 0; --i)
94 MIB.addReg(CSI[i-1].getReg());
98 bool ARMRegisterInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
99 MachineBasicBlock::iterator MI,
100 const std::vector<CalleeSavedInfo> &CSI) const {
101 MachineFunction &MF = *MBB.getParent();
102 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
103 if (!AFI->isThumbFunction() || CSI.empty())
106 bool isVarArg = AFI->getVarArgsRegSaveSize() > 0;
107 MachineInstr *PopMI = new MachineInstr(TII.get(ARM::tPOP));
108 MBB.insert(MI, PopMI);
109 for (unsigned i = CSI.size(); i != 0; --i) {
110 unsigned Reg = CSI[i-1].getReg();
111 if (Reg == ARM::LR) {
112 // Special epilogue for vararg functions. See emitEpilogue
116 PopMI->setInstrDescriptor(TII.get(ARM::tPOP_RET));
119 PopMI->addRegOperand(Reg, true);
124 void ARMRegisterInfo::
125 storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
126 unsigned SrcReg, int FI,
127 const TargetRegisterClass *RC) const {
128 if (RC == ARM::GPRRegisterClass) {
129 MachineFunction &MF = *MBB.getParent();
130 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
131 if (AFI->isThumbFunction())
132 BuildMI(MBB, I, TII.get(ARM::tSpill)).addReg(SrcReg)
133 .addFrameIndex(FI).addImm(0);
135 BuildMI(MBB, I, TII.get(ARM::STR)).addReg(SrcReg)
136 .addFrameIndex(FI).addReg(0).addImm(0);
137 } else if (RC == ARM::DPRRegisterClass) {
138 BuildMI(MBB, I, TII.get(ARM::FSTD)).addReg(SrcReg)
139 .addFrameIndex(FI).addImm(0);
141 assert(RC == ARM::SPRRegisterClass && "Unknown regclass!");
142 BuildMI(MBB, I, TII.get(ARM::FSTS)).addReg(SrcReg)
143 .addFrameIndex(FI).addImm(0);
147 void ARMRegisterInfo::
148 loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
149 unsigned DestReg, int FI,
150 const TargetRegisterClass *RC) const {
151 if (RC == ARM::GPRRegisterClass) {
152 MachineFunction &MF = *MBB.getParent();
153 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
154 if (AFI->isThumbFunction())
155 BuildMI(MBB, I, TII.get(ARM::tRestore), DestReg)
156 .addFrameIndex(FI).addImm(0);
158 BuildMI(MBB, I, TII.get(ARM::LDR), DestReg)
159 .addFrameIndex(FI).addReg(0).addImm(0);
160 } else if (RC == ARM::DPRRegisterClass) {
161 BuildMI(MBB, I, TII.get(ARM::FLDD), DestReg)
162 .addFrameIndex(FI).addImm(0);
164 assert(RC == ARM::SPRRegisterClass && "Unknown regclass!");
165 BuildMI(MBB, I, TII.get(ARM::FLDS), DestReg)
166 .addFrameIndex(FI).addImm(0);
170 void ARMRegisterInfo::copyRegToReg(MachineBasicBlock &MBB,
171 MachineBasicBlock::iterator I,
172 unsigned DestReg, unsigned SrcReg,
173 const TargetRegisterClass *RC) const {
174 if (RC == ARM::GPRRegisterClass) {
175 MachineFunction &MF = *MBB.getParent();
176 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
177 BuildMI(MBB, I, TII.get(AFI->isThumbFunction() ? ARM::tMOVrr : ARM::MOVrr),
178 DestReg).addReg(SrcReg);
179 } else if (RC == ARM::SPRRegisterClass)
180 BuildMI(MBB, I, TII.get(ARM::FCPYS), DestReg).addReg(SrcReg);
181 else if (RC == ARM::DPRRegisterClass)
182 BuildMI(MBB, I, TII.get(ARM::FCPYD), DestReg).addReg(SrcReg);
187 /// isLowRegister - Returns true if the register is low register r0-r7.
189 static bool isLowRegister(unsigned Reg) {
192 case R0: case R1: case R2: case R3:
193 case R4: case R5: case R6: case R7:
200 MachineInstr *ARMRegisterInfo::foldMemoryOperand(MachineInstr *MI,
201 unsigned OpNum, int FI) const {
202 unsigned Opc = MI->getOpcode();
203 MachineInstr *NewMI = NULL;
207 if (OpNum == 0) { // move -> store
208 unsigned SrcReg = MI->getOperand(1).getReg();
209 NewMI = BuildMI(TII.get(ARM::STR)).addReg(SrcReg).addFrameIndex(FI)
210 .addReg(0).addImm(0);
211 } else { // move -> load
212 unsigned DstReg = MI->getOperand(0).getReg();
213 NewMI = BuildMI(TII.get(ARM::LDR), DstReg).addFrameIndex(FI).addReg(0)
219 if (OpNum == 0) { // move -> store
220 unsigned SrcReg = MI->getOperand(1).getReg();
221 if (isPhysicalRegister(SrcReg) && !isLowRegister(SrcReg))
222 // tSpill cannot take a high register operand.
224 NewMI = BuildMI(TII.get(ARM::tSpill)).addReg(SrcReg).addFrameIndex(FI)
226 } else { // move -> load
227 unsigned DstReg = MI->getOperand(0).getReg();
228 if (isPhysicalRegister(DstReg) && !isLowRegister(DstReg))
229 // tRestore cannot target a high register operand.
231 NewMI = BuildMI(TII.get(ARM::tRestore), DstReg).addFrameIndex(FI)
237 if (OpNum == 0) { // move -> store
238 unsigned SrcReg = MI->getOperand(1).getReg();
239 NewMI = BuildMI(TII.get(ARM::FSTS)).addReg(SrcReg).addFrameIndex(FI)
241 } else { // move -> load
242 unsigned DstReg = MI->getOperand(0).getReg();
243 NewMI = BuildMI(TII.get(ARM::FLDS), DstReg).addFrameIndex(FI).addImm(0);
248 if (OpNum == 0) { // move -> store
249 unsigned SrcReg = MI->getOperand(1).getReg();
250 NewMI = BuildMI(TII.get(ARM::FSTD)).addReg(SrcReg).addFrameIndex(FI)
252 } else { // move -> load
253 unsigned DstReg = MI->getOperand(0).getReg();
254 NewMI = BuildMI(TII.get(ARM::FLDD), DstReg).addFrameIndex(FI).addImm(0);
261 NewMI->copyKillDeadInfo(MI);
265 const unsigned* ARMRegisterInfo::getCalleeSavedRegs() const {
266 static const unsigned CalleeSavedRegs[] = {
267 ARM::LR, ARM::R11, ARM::R10, ARM::R9, ARM::R8,
268 ARM::R7, ARM::R6, ARM::R5, ARM::R4,
270 ARM::D15, ARM::D14, ARM::D13, ARM::D12,
271 ARM::D11, ARM::D10, ARM::D9, ARM::D8,
275 static const unsigned DarwinCalleeSavedRegs[] = {
276 ARM::LR, ARM::R7, ARM::R6, ARM::R5, ARM::R4,
277 ARM::R11, ARM::R10, ARM::R9, ARM::R8,
279 ARM::D15, ARM::D14, ARM::D13, ARM::D12,
280 ARM::D11, ARM::D10, ARM::D9, ARM::D8,
283 return STI.isTargetDarwin() ? DarwinCalleeSavedRegs : CalleeSavedRegs;
286 const TargetRegisterClass* const *
287 ARMRegisterInfo::getCalleeSavedRegClasses() const {
288 static const TargetRegisterClass * const CalleeSavedRegClasses[] = {
289 &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass,
290 &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass,
291 &ARM::GPRRegClass, &ARM::GPRRegClass, &ARM::GPRRegClass,
293 &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass,
294 &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass, &ARM::DPRRegClass,
297 return CalleeSavedRegClasses;
300 /// hasFP - Return true if the specified function should have a dedicated frame
301 /// pointer register. This is true if the function has variable sized allocas
302 /// or if frame pointer elimination is disabled.
304 bool ARMRegisterInfo::hasFP(const MachineFunction &MF) const {
305 return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects();
308 /// emitARMRegPlusImmediate - Emits a series of instructions to materialize
309 /// a destreg = basereg + immediate in ARM code.
311 void emitARMRegPlusImmediate(MachineBasicBlock &MBB,
312 MachineBasicBlock::iterator &MBBI,
313 unsigned DestReg, unsigned BaseReg,
314 int NumBytes, const TargetInstrInfo &TII) {
315 bool isSub = NumBytes < 0;
316 if (isSub) NumBytes = -NumBytes;
319 unsigned RotAmt = ARM_AM::getSOImmValRotate(NumBytes);
320 unsigned ThisVal = NumBytes & ARM_AM::rotr32(0xFF, RotAmt);
321 assert(ThisVal && "Didn't extract field correctly");
323 // We will handle these bits from offset, clear them.
324 NumBytes &= ~ThisVal;
326 // Get the properly encoded SOImmVal field.
327 int SOImmVal = ARM_AM::getSOImmVal(ThisVal);
328 assert(SOImmVal != -1 && "Bit extraction didn't work?");
330 // Build the new ADD / SUB.
331 BuildMI(MBB, MBBI, TII.get(isSub ? ARM::SUBri : ARM::ADDri), DestReg)
332 .addReg(BaseReg).addImm(SOImmVal);
337 /// calcNumMI - Returns the number of instructions required to materialize
338 /// the specific add / sub r, c instruction.
339 static unsigned calcNumMI(int Opc, int ExtraOpc, unsigned Bytes,
340 unsigned NumBits, unsigned Scale) {
342 unsigned Chunk = ((1 << NumBits) - 1) * Scale;
344 if (Opc == ARM::tADDrSPi) {
345 unsigned ThisVal = (Bytes > Chunk) ? Chunk : Bytes;
350 Chunk = ((1 << NumBits) - 1) * Scale;
353 NumMIs += Bytes / Chunk;
354 if ((Bytes % Chunk) != 0)
361 /// emitLoadConstPool - Emits a load from constpool to materialize NumBytes
363 static void emitLoadConstPool(MachineBasicBlock &MBB,
364 MachineBasicBlock::iterator &MBBI,
365 unsigned DestReg, int NumBytes,
366 const TargetInstrInfo &TII) {
367 MachineFunction &MF = *MBB.getParent();
368 MachineConstantPool *ConstantPool = MF.getConstantPool();
369 Constant *C = ConstantInt::get(Type::Int32Ty, NumBytes);
370 unsigned Idx = ConstantPool->getConstantPoolIndex(C, 2);
371 BuildMI(MBB, MBBI, TII.get(ARM::tLDRpci), DestReg).addConstantPoolIndex(Idx);
374 /// emitThumbRegPlusImmInReg - Emits a series of instructions to materialize
375 /// a destreg = basereg + immediate in Thumb code. Materialize the immediate
376 /// in a register using mov / mvn sequences or load the immediate from a
379 void emitThumbRegPlusImmInReg(MachineBasicBlock &MBB,
380 MachineBasicBlock::iterator &MBBI,
381 unsigned DestReg, unsigned BaseReg,
382 int NumBytes, bool CanChangeCC,
383 const TargetInstrInfo &TII) {
384 bool isHigh = !isLowRegister(DestReg) ||
385 (BaseReg != 0 && !isLowRegister(BaseReg));
387 // Subtract doesn't have high register version. Load the negative value
388 // if either base or dest register is a high register. Also, if do not
389 // issue sub as part of the sequence if condition register is to be
391 if (NumBytes < 0 && !isHigh && CanChangeCC) {
393 NumBytes = -NumBytes;
395 unsigned LdReg = DestReg;
396 if (DestReg == ARM::SP) {
397 assert(BaseReg == ARM::SP && "Unexpected!");
399 BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), ARM::R12).addReg(ARM::R3);
402 if (NumBytes <= 255 && NumBytes >= 0)
403 BuildMI(MBB, MBBI, TII.get(ARM::tMOVri8), LdReg).addImm(NumBytes);
404 else if (NumBytes < 0 && NumBytes >= -255) {
405 BuildMI(MBB, MBBI, TII.get(ARM::tMOVri8), LdReg).addImm(NumBytes);
406 BuildMI(MBB, MBBI, TII.get(ARM::tNEG), LdReg).addReg(LdReg);
408 emitLoadConstPool(MBB, MBBI, LdReg, NumBytes, TII);
411 int Opc = (isSub) ? ARM::tSUBrr : (isHigh ? ARM::tADDhirr : ARM::tADDrr);
412 const MachineInstrBuilder MIB = BuildMI(MBB, MBBI, TII.get(Opc), DestReg);
413 if (DestReg == ARM::SP)
414 MIB.addReg(BaseReg).addReg(LdReg);
416 MIB.addReg(BaseReg).addReg(LdReg);
418 MIB.addReg(LdReg).addReg(BaseReg);
419 if (DestReg == ARM::SP)
420 BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), ARM::R3).addReg(ARM::R12);
423 /// emitThumbRegPlusImmediate - Emits a series of instructions to materialize
424 /// a destreg = basereg + immediate in Thumb code.
426 void emitThumbRegPlusImmediate(MachineBasicBlock &MBB,
427 MachineBasicBlock::iterator &MBBI,
428 unsigned DestReg, unsigned BaseReg,
429 int NumBytes, const TargetInstrInfo &TII) {
430 bool isSub = NumBytes < 0;
431 unsigned Bytes = (unsigned)NumBytes;
432 if (isSub) Bytes = -NumBytes;
433 bool isMul4 = (Bytes & 3) == 0;
434 bool isTwoAddr = false;
435 bool DstNotEqBase = false;
436 unsigned NumBits = 1;
441 if (DestReg == BaseReg && BaseReg == ARM::SP) {
442 assert(isMul4 && "Thumb sp inc / dec size must be multiple of 4!");
445 Opc = isSub ? ARM::tSUBspi : ARM::tADDspi;
447 } else if (!isSub && BaseReg == ARM::SP) {
450 // r1 = add sp, 100 * 4
454 ExtraOpc = ARM::tADDi3;
463 if (DestReg != BaseReg)
466 Opc = isSub ? ARM::tSUBi8 : ARM::tADDi8;
470 unsigned NumMIs = calcNumMI(Opc, ExtraOpc, Bytes, NumBits, Scale);
471 unsigned Threshold = (DestReg == ARM::SP) ? 3 : 2;
472 if (NumMIs > Threshold) {
473 // This will expand into too many instructions. Load the immediate from a
475 emitThumbRegPlusImmInReg(MBB, MBBI, DestReg, BaseReg, NumBytes, true, TII);
480 if (isLowRegister(DestReg) && isLowRegister(BaseReg)) {
481 // If both are low registers, emit DestReg = add BaseReg, max(Imm, 7)
482 unsigned Chunk = (1 << 3) - 1;
483 unsigned ThisVal = (Bytes > Chunk) ? Chunk : Bytes;
485 BuildMI(MBB, MBBI, TII.get(isSub ? ARM::tSUBi3 : ARM::tADDi3), DestReg)
486 .addReg(BaseReg).addImm(ThisVal);
488 BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), DestReg).addReg(BaseReg);
493 unsigned Chunk = ((1 << NumBits) - 1) * Scale;
495 unsigned ThisVal = (Bytes > Chunk) ? Chunk : Bytes;
498 // Build the new tADD / tSUB.
500 BuildMI(MBB, MBBI, TII.get(Opc), DestReg).addReg(DestReg).addImm(ThisVal);
502 BuildMI(MBB, MBBI, TII.get(Opc), DestReg).addReg(BaseReg).addImm(ThisVal);
505 if (Opc == ARM::tADDrSPi) {
511 Chunk = ((1 << NumBits) - 1) * Scale;
512 Opc = isSub ? ARM::tSUBi8 : ARM::tADDi8;
519 BuildMI(MBB, MBBI, TII.get(ExtraOpc), DestReg).addReg(DestReg)
520 .addImm(((unsigned)NumBytes) & 3);
524 void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI,
525 int NumBytes, bool isThumb, const TargetInstrInfo &TII) {
527 emitThumbRegPlusImmediate(MBB, MBBI, ARM::SP, ARM::SP, NumBytes, TII);
529 emitARMRegPlusImmediate(MBB, MBBI, ARM::SP, ARM::SP, NumBytes, TII);
532 void ARMRegisterInfo::
533 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
534 MachineBasicBlock::iterator I) const {
536 // If we have alloca, convert as follows:
537 // ADJCALLSTACKDOWN -> sub, sp, sp, amount
538 // ADJCALLSTACKUP -> add, sp, sp, amount
539 MachineInstr *Old = I;
540 unsigned Amount = Old->getOperand(0).getImmedValue();
542 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
543 // We need to keep the stack aligned properly. To do this, we round the
544 // amount of space needed for the outgoing arguments up to the next
545 // alignment boundary.
546 unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
547 Amount = (Amount+Align-1)/Align*Align;
549 // Replace the pseudo instruction with a new instruction...
550 if (Old->getOpcode() == ARM::ADJCALLSTACKDOWN) {
551 emitSPUpdate(MBB, I, -Amount, AFI->isThumbFunction(), TII);
553 assert(Old->getOpcode() == ARM::ADJCALLSTACKUP);
554 emitSPUpdate(MBB, I, Amount, AFI->isThumbFunction(), TII);
561 /// emitThumbConstant - Emit a series of instructions to materialize a
563 static void emitThumbConstant(MachineBasicBlock &MBB,
564 MachineBasicBlock::iterator &MBBI,
565 unsigned DestReg, int Imm,
566 const TargetInstrInfo &TII) {
567 bool isSub = Imm < 0;
568 if (isSub) Imm = -Imm;
570 int Chunk = (1 << 8) - 1;
571 int ThisVal = (Imm > Chunk) ? Chunk : Imm;
573 BuildMI(MBB, MBBI, TII.get(ARM::tMOVri8), DestReg).addImm(ThisVal);
575 emitThumbRegPlusImmediate(MBB, MBBI, DestReg, DestReg, Imm, TII);
577 BuildMI(MBB, MBBI, TII.get(ARM::tNEG), DestReg).addReg(DestReg);
580 void ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const{
582 MachineInstr &MI = *II;
583 MachineBasicBlock &MBB = *MI.getParent();
584 MachineFunction &MF = *MBB.getParent();
585 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
586 bool isThumb = AFI->isThumbFunction();
588 while (!MI.getOperand(i).isFrameIndex()) {
590 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
593 unsigned FrameReg = ARM::SP;
594 int FrameIndex = MI.getOperand(i).getFrameIndex();
595 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
596 MF.getFrameInfo()->getStackSize();
598 if (AFI->isGPRCalleeSavedArea1Frame(FrameIndex))
599 Offset -= AFI->getGPRCalleeSavedArea1Offset();
600 else if (AFI->isGPRCalleeSavedArea2Frame(FrameIndex))
601 Offset -= AFI->getGPRCalleeSavedArea2Offset();
602 else if (AFI->isDPRCalleeSavedAreaFrame(FrameIndex))
603 Offset -= AFI->getDPRCalleeSavedAreaOffset();
604 else if (hasFP(MF)) {
605 // There is alloca()'s in this function, must reference off the frame
607 FrameReg = getFrameRegister(MF);
608 Offset -= AFI->getFramePtrSpillOffset();
611 unsigned Opcode = MI.getOpcode();
612 const TargetInstrDescriptor &Desc = TII.get(Opcode);
613 unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
616 if (Opcode == ARM::ADDri) {
617 Offset += MI.getOperand(i+1).getImm();
619 // Turn it into a move.
620 MI.setInstrDescriptor(TII.get(ARM::MOVrr));
621 MI.getOperand(i).ChangeToRegister(FrameReg, false);
622 MI.RemoveOperand(i+1);
624 } else if (Offset < 0) {
627 MI.setInstrDescriptor(TII.get(ARM::SUBri));
630 // Common case: small offset, fits into instruction.
631 int ImmedOffset = ARM_AM::getSOImmVal(Offset);
632 if (ImmedOffset != -1) {
633 // Replace the FrameIndex with sp / fp
634 MI.getOperand(i).ChangeToRegister(FrameReg, false);
635 MI.getOperand(i+1).ChangeToImmediate(ImmedOffset);
639 // Otherwise, we fallback to common code below to form the imm offset with
640 // a sequence of ADDri instructions. First though, pull as much of the imm
641 // into this ADDri as possible.
642 unsigned RotAmt = ARM_AM::getSOImmValRotate(Offset);
643 unsigned ThisImmVal = Offset & ARM_AM::rotr32(0xFF, (32-RotAmt) & 31);
645 // We will handle these bits from offset, clear them.
646 Offset &= ~ThisImmVal;
648 // Get the properly encoded SOImmVal field.
649 int ThisSOImmVal = ARM_AM::getSOImmVal(ThisImmVal);
650 assert(ThisSOImmVal != -1 && "Bit extraction didn't work?");
651 MI.getOperand(i+1).ChangeToImmediate(ThisSOImmVal);
652 } else if (Opcode == ARM::tADDrSPi) {
653 Offset += MI.getOperand(i+1).getImm();
654 assert((Offset & 3) == 0 &&
655 "Thumb add/sub sp, #imm immediate must be multiple of 4!");
657 // Turn it into a move.
658 MI.setInstrDescriptor(TII.get(ARM::tMOVrr));
659 MI.getOperand(i).ChangeToRegister(FrameReg, false);
660 MI.RemoveOperand(i+1);
664 // Common case: small offset, fits into instruction.
665 if (((Offset >> 2) & ~255U) == 0) {
666 // Replace the FrameIndex with sp / fp
667 MI.getOperand(i).ChangeToRegister(FrameReg, false);
668 MI.getOperand(i+1).ChangeToImmediate(Offset >> 2);
672 unsigned DestReg = MI.getOperand(0).getReg();
673 unsigned Bytes = (Offset > 0) ? Offset : -Offset;
674 unsigned NumMIs = calcNumMI(Opcode, 0, Bytes, 8, 1);
675 // MI would expand into a large number of instructions. Don't try to
676 // simplify the immediate.
678 emitThumbRegPlusImmediate(MBB, II, DestReg, FrameReg, Offset, TII);
684 // Translate r0 = add sp, imm to
685 // r0 = add sp, 255*4
686 // r0 = add r0, (imm - 255*4)
687 MI.getOperand(i).ChangeToRegister(FrameReg, false);
688 MI.getOperand(i+1).ChangeToImmediate(255);
689 Offset = (Offset - 255 * 4);
690 MachineBasicBlock::iterator NII = next(II);
691 emitThumbRegPlusImmediate(MBB, NII, DestReg, DestReg, Offset, TII);
693 // Translate r0 = add sp, -imm to
694 // r0 = -imm (this is then translated into a series of instructons)
696 emitThumbConstant(MBB, II, DestReg, Offset, TII);
697 MI.setInstrDescriptor(TII.get(ARM::tADDhirr));
698 MI.getOperand(i).ChangeToRegister(DestReg, false);
699 MI.getOperand(i+1).ChangeToRegister(FrameReg, false);
705 unsigned NumBits = 0;
708 case ARMII::AddrMode2: {
710 InstrOffs = ARM_AM::getAM2Offset(MI.getOperand(ImmIdx).getImm());
711 if (ARM_AM::getAM2Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub)
716 case ARMII::AddrMode3: {
718 InstrOffs = ARM_AM::getAM3Offset(MI.getOperand(ImmIdx).getImm());
719 if (ARM_AM::getAM3Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub)
724 case ARMII::AddrMode5: {
726 InstrOffs = ARM_AM::getAM5Offset(MI.getOperand(ImmIdx).getImm());
727 if (ARM_AM::getAM5Op(MI.getOperand(ImmIdx).getImm()) == ARM_AM::sub)
733 case ARMII::AddrModeTs: {
735 InstrOffs = MI.getOperand(ImmIdx).getImm();
736 NumBits = (FrameReg == ARM::SP) ? 8 : 5;
741 assert(0 && "Unsupported addressing mode!");
746 Offset += InstrOffs * Scale;
747 assert((Offset & (Scale-1)) == 0 && "Can't encode this offset!");
748 if (Offset < 0 && !isThumb) {
753 // Common case: small offset, fits into instruction.
754 MachineOperand &ImmOp = MI.getOperand(ImmIdx);
755 int ImmedOffset = Offset / Scale;
756 unsigned Mask = (1 << NumBits) - 1;
757 if ((unsigned)Offset <= Mask * Scale) {
758 // Replace the FrameIndex with sp
759 MI.getOperand(i).ChangeToRegister(FrameReg, false);
761 ImmedOffset |= 1 << NumBits;
762 ImmOp.ChangeToImmediate(ImmedOffset);
766 bool isThumSpillRestore = Opcode == ARM::tRestore || Opcode == ARM::tSpill;
767 if (AddrMode == ARMII::AddrModeTs) {
768 // Thumb tLDRspi, tSTRspi. These will change to instructions that use
769 // a different base register.
771 Mask = (1 << NumBits) - 1;
773 // If this is a thumb spill / restore, we will be using a constpool load to
774 // materialize the offset.
775 if (AddrMode == ARMII::AddrModeTs && isThumSpillRestore)
776 ImmOp.ChangeToImmediate(0);
778 // Otherwise, it didn't fit. Pull in what we can to simplify the immed.
779 ImmedOffset = ImmedOffset & Mask;
781 ImmedOffset |= 1 << NumBits;
782 ImmOp.ChangeToImmediate(ImmedOffset);
783 Offset &= ~(Mask*Scale);
787 // If we get here, the immediate doesn't fit into the instruction. We folded
788 // as much as possible above, handle the rest, providing a register that is
790 assert(Offset && "This code isn't needed if offset already handled!");
793 if (TII.isLoad(Opcode)) {
794 // Use the destination register to materialize sp + offset.
795 unsigned TmpReg = MI.getOperand(0).getReg();
797 if (Opcode == ARM::tRestore) {
798 if (FrameReg == ARM::SP)
799 emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
801 emitLoadConstPool(MBB, II, TmpReg, Offset, TII);
805 emitThumbRegPlusImmediate(MBB, II, TmpReg, FrameReg, Offset, TII);
806 MI.setInstrDescriptor(TII.get(ARM::tLDR));
807 MI.getOperand(i).ChangeToRegister(TmpReg, false);
809 MI.addRegOperand(FrameReg, false); // Use [reg, reg] addrmode.
811 MI.addRegOperand(0, false); // tLDR has an extra register operand.
812 } else if (TII.isStore(Opcode)) {
813 // FIXME! This is horrific!!! We need register scavenging.
814 // Our temporary workaround has marked r3 unavailable. Of course, r3 is
815 // also a ABI register so it's possible that is is the register that is
816 // being storing here. If that's the case, we do the following:
818 // Use r2 to materialize sp + offset
821 unsigned ValReg = MI.getOperand(0).getReg();
822 unsigned TmpReg = ARM::R3;
824 if (ValReg == ARM::R3) {
825 BuildMI(MBB, II, TII.get(ARM::tMOVrr), ARM::R12).addReg(ARM::R2);
828 if (TmpReg == ARM::R3 && AFI->isR3IsLiveIn())
829 BuildMI(MBB, II, TII.get(ARM::tMOVrr), ARM::R12).addReg(ARM::R3);
830 if (Opcode == ARM::tSpill) {
831 if (FrameReg == ARM::SP)
832 emitThumbRegPlusImmInReg(MBB, II, TmpReg, FrameReg,Offset,false,TII);
834 emitLoadConstPool(MBB, II, TmpReg, Offset, TII);
838 emitThumbRegPlusImmediate(MBB, II, TmpReg, FrameReg, Offset, TII);
839 MI.setInstrDescriptor(TII.get(ARM::tSTR));
840 MI.getOperand(i).ChangeToRegister(TmpReg, false);
842 MI.addRegOperand(FrameReg, false); // Use [reg, reg] addrmode.
844 MI.addRegOperand(0, false); // tSTR has an extra register operand.
846 MachineBasicBlock::iterator NII = next(II);
847 if (ValReg == ARM::R3)
848 BuildMI(MBB, NII, TII.get(ARM::tMOVrr), ARM::R2).addReg(ARM::R12);
849 if (TmpReg == ARM::R3 && AFI->isR3IsLiveIn())
850 BuildMI(MBB, NII, TII.get(ARM::tMOVrr), ARM::R3).addReg(ARM::R12);
852 assert(false && "Unexpected opcode!");
854 // Insert a set of r12 with the full address: r12 = sp + offset
855 // If the offset we have is too large to fit into the instruction, we need
856 // to form it with a series of ADDri's. Do this by taking 8-bit chunks
858 emitARMRegPlusImmediate(MBB, II, ARM::R12, FrameReg,
859 isSub ? -Offset : Offset, TII);
860 MI.getOperand(i).ChangeToRegister(ARM::R12, false);
864 void ARMRegisterInfo::
865 processFunctionBeforeCalleeSavedScan(MachineFunction &MF) const {
866 // This tells PEI to spill the FP as if it is any other callee-save register
867 // to take advantage the eliminateFrameIndex machinery. This also ensures it
868 // is spilled in the order specified by getCalleeSavedRegs() to make it easier
869 // to combine multiple loads / stores.
870 bool CanEliminateFrame = true;
871 bool CS1Spilled = false;
872 bool LRSpilled = false;
873 unsigned NumGPRSpills = 0;
874 SmallVector<unsigned, 4> UnspilledCS1GPRs;
875 SmallVector<unsigned, 4> UnspilledCS2GPRs;
877 // Don't spill FP if the frame can be eliminated. This is determined
878 // by scanning the callee-save registers to see if any is used.
879 const unsigned *CSRegs = getCalleeSavedRegs();
880 const TargetRegisterClass* const *CSRegClasses = getCalleeSavedRegClasses();
881 for (unsigned i = 0; CSRegs[i]; ++i) {
882 unsigned Reg = CSRegs[i];
883 bool Spilled = false;
884 if (MF.isPhysRegUsed(Reg)) {
886 CanEliminateFrame = false;
888 // Check alias registers too.
889 for (const unsigned *Aliases = getAliasSet(Reg); *Aliases; ++Aliases) {
890 if (MF.isPhysRegUsed(*Aliases)) {
892 CanEliminateFrame = false;
897 if (CSRegClasses[i] == &ARM::GPRRegClass) {
901 if (!STI.isTargetDarwin()) {
909 // Keep track if LR and any of R4, R5, R6, and R7 is spilled.
924 if (!STI.isTargetDarwin()) {
925 UnspilledCS1GPRs.push_back(Reg);
935 UnspilledCS1GPRs.push_back(Reg);
938 UnspilledCS2GPRs.push_back(Reg);
945 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
946 bool ForceLRSpill = false;
947 if (!LRSpilled && AFI->isThumbFunction()) {
948 unsigned FnSize = ARM::GetFunctionSize(MF);
949 // Force LR spill if the Thumb function size is > 2048. This enables the
950 // use of BL to implement far jump. If it turns out that it's not needed
951 // the branch fix up path will undo it.
952 if (FnSize >= (1 << 11)) {
953 CanEliminateFrame = false;
958 if (!CanEliminateFrame || hasFP(MF)) {
959 AFI->setHasStackFrame(true);
961 // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled.
962 // Spill LR as well so we can fold BX_RET to the registers restore (LDM).
963 if (!LRSpilled && CS1Spilled) {
964 MF.changePhyRegUsed(ARM::LR, true);
966 UnspilledCS1GPRs.erase(std::find(UnspilledCS1GPRs.begin(),
967 UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
968 ForceLRSpill = false;
971 // Darwin ABI requires FP to point to the stack slot that contains the
973 if (STI.isTargetDarwin() || hasFP(MF)) {
974 MF.changePhyRegUsed(FramePtr, true);
978 // If stack and double are 8-byte aligned and we are spilling an odd number
979 // of GPRs. Spill one extra callee save GPR so we won't have to pad between
980 // the integer and double callee save areas.
981 unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
982 if (TargetAlign == 8 && (NumGPRSpills & 1)) {
983 if (CS1Spilled && !UnspilledCS1GPRs.empty())
984 MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
985 else if (!UnspilledCS2GPRs.empty())
986 MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
991 MF.changePhyRegUsed(ARM::LR, true);
992 AFI->setLRIsForceSpilled(true);
996 /// Move iterator pass the next bunch of callee save load / store ops for
997 /// the particular spill area (1: integer area 1, 2: integer area 2,
998 /// 3: fp area, 0: don't care).
999 static void movePastCSLoadStoreOps(MachineBasicBlock &MBB,
1000 MachineBasicBlock::iterator &MBBI,
1001 int Opc, unsigned Area,
1002 const ARMSubtarget &STI) {
1003 while (MBBI != MBB.end() &&
1004 MBBI->getOpcode() == Opc && MBBI->getOperand(1).isFrameIndex()) {
1007 unsigned Category = 0;
1008 switch (MBBI->getOperand(0).getReg()) {
1009 case ARM::R4: case ARM::R5: case ARM::R6: case ARM::R7:
1013 case ARM::R8: case ARM::R9: case ARM::R10: case ARM::R11:
1014 Category = STI.isTargetDarwin() ? 2 : 1;
1016 case ARM::D8: case ARM::D9: case ARM::D10: case ARM::D11:
1017 case ARM::D12: case ARM::D13: case ARM::D14: case ARM::D15:
1024 if (Done || Category != Area)
1032 void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
1033 MachineBasicBlock &MBB = MF.front();
1034 MachineBasicBlock::iterator MBBI = MBB.begin();
1035 MachineFrameInfo *MFI = MF.getFrameInfo();
1036 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
1037 bool isThumb = AFI->isThumbFunction();
1038 unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
1039 unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
1040 unsigned NumBytes = MFI->getStackSize();
1041 const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
1044 // Check if R3 is live in. It might have to be used as a scratch register.
1045 for (MachineFunction::livein_iterator I=MF.livein_begin(),E=MF.livein_end();
1047 if ((*I).first == ARM::R3) {
1048 AFI->setR3IsLiveIn(true);
1053 // Thumb add/sub sp, imm8 instructions implicitly multiply the offset by 4.
1054 NumBytes = (NumBytes + 3) & ~3;
1055 MFI->setStackSize(NumBytes);
1058 // Determine the sizes of each callee-save spill areas and record which frame
1059 // belongs to which callee-save spill areas.
1060 unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
1061 int FramePtrSpillFI = 0;
1062 if (!AFI->hasStackFrame()) {
1064 emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
1069 emitSPUpdate(MBB, MBBI, -VARegSaveSize, isThumb, TII);
1071 for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
1072 unsigned Reg = CSI[i].getReg();
1073 int FI = CSI[i].getFrameIdx();
1080 if (Reg == FramePtr)
1081 FramePtrSpillFI = FI;
1082 AFI->addGPRCalleeSavedArea1Frame(FI);
1089 if (Reg == FramePtr)
1090 FramePtrSpillFI = FI;
1091 if (STI.isTargetDarwin()) {
1092 AFI->addGPRCalleeSavedArea2Frame(FI);
1095 AFI->addGPRCalleeSavedArea1Frame(FI);
1100 AFI->addDPRCalleeSavedAreaFrame(FI);
1105 if (Align == 8 && (GPRCS1Size & 7) != 0)
1106 // Pad CS1 to ensure proper alignment.
1110 // Build the new SUBri to adjust SP for integer callee-save spill area 1.
1111 emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
1112 movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
1113 } else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
1116 // Darwin ABI requires FP to point to the stack slot that contains the
1118 if (STI.isTargetDarwin() || hasFP(MF))
1119 BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
1120 .addFrameIndex(FramePtrSpillFI).addImm(0);
1123 // Build the new SUBri to adjust SP for integer callee-save spill area 2.
1124 emitSPUpdate(MBB, MBBI, -GPRCS2Size, false, TII);
1126 // Build the new SUBri to adjust SP for FP callee-save spill area.
1127 movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 2, STI);
1128 emitSPUpdate(MBB, MBBI, -DPRCSSize, false, TII);
1131 // Determine starting offsets of spill areas.
1132 unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize);
1133 unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize;
1134 unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size;
1135 AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes);
1136 AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset);
1137 AFI->setGPRCalleeSavedArea2Offset(GPRCS2Offset);
1138 AFI->setDPRCalleeSavedAreaOffset(DPRCSOffset);
1140 NumBytes = DPRCSOffset;
1142 // Insert it after all the callee-save spills.
1144 movePastCSLoadStoreOps(MBB, MBBI, ARM::FSTD, 3, STI);
1145 emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
1148 AFI->setGPRCalleeSavedArea1Size(GPRCS1Size);
1149 AFI->setGPRCalleeSavedArea2Size(GPRCS2Size);
1150 AFI->setDPRCalleeSavedAreaSize(DPRCSSize);
1153 static bool isCalleeSavedRegister(unsigned Reg, const unsigned *CSRegs) {
1154 for (unsigned i = 0; CSRegs[i]; ++i)
1155 if (Reg == CSRegs[i])
1160 static bool isCSRestore(MachineInstr *MI, const unsigned *CSRegs) {
1161 return ((MI->getOpcode() == ARM::FLDD ||
1162 MI->getOpcode() == ARM::LDR ||
1163 MI->getOpcode() == ARM::tRestore) &&
1164 MI->getOperand(1).isFrameIndex() &&
1165 isCalleeSavedRegister(MI->getOperand(0).getReg(), CSRegs));
1168 void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
1169 MachineBasicBlock &MBB) const {
1170 MachineBasicBlock::iterator MBBI = prior(MBB.end());
1171 assert((MBBI->getOpcode() == ARM::BX_RET ||
1172 MBBI->getOpcode() == ARM::tBX_RET ||
1173 MBBI->getOpcode() == ARM::tPOP_RET) &&
1174 "Can only insert epilog into returning blocks");
1176 MachineFrameInfo *MFI = MF.getFrameInfo();
1177 ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
1178 bool isThumb = AFI->isThumbFunction();
1179 unsigned VARegSaveSize = AFI->getVarArgsRegSaveSize();
1180 int NumBytes = (int)MFI->getStackSize();
1181 if (!AFI->hasStackFrame()) {
1183 emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
1187 // Unwind MBBI to point to first LDR / FLDD.
1188 const unsigned *CSRegs = getCalleeSavedRegs();
1189 if (MBBI != MBB.begin()) {
1192 while (MBBI != MBB.begin() && isCSRestore(MBBI, CSRegs));
1193 if (!isCSRestore(MBBI, CSRegs))
1197 // Move SP to start of FP callee save spill area.
1198 NumBytes -= (AFI->getGPRCalleeSavedArea1Size() +
1199 AFI->getGPRCalleeSavedArea2Size() +
1200 AFI->getDPRCalleeSavedAreaSize());
1203 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
1204 // Reset SP based on frame pointer only if the stack frame extends beyond
1205 // frame pointer stack slot or target is ELF and the function has FP.
1207 emitThumbRegPlusImmediate(MBB, MBBI, ARM::SP, FramePtr, -NumBytes, TII);
1209 BuildMI(MBB, MBBI, TII.get(ARM::tMOVrr), ARM::SP).addReg(FramePtr);
1211 if (MBBI->getOpcode() == ARM::tBX_RET &&
1212 &MBB.front() != MBBI &&
1213 prior(MBBI)->getOpcode() == ARM::tPOP) {
1214 MachineBasicBlock::iterator PMBBI = prior(MBBI);
1215 emitSPUpdate(MBB, PMBBI, NumBytes, isThumb, TII);
1217 emitSPUpdate(MBB, MBBI, NumBytes, isThumb, TII);
1220 // Darwin ABI requires FP to point to the stack slot that contains the
1222 if (STI.isTargetDarwin() || hasFP(MF)) {
1223 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
1224 // Reset SP based on frame pointer only if the stack frame extends beyond
1225 // frame pointer stack slot or target is ELF and the function has FP.
1226 if (AFI->getGPRCalleeSavedArea2Size() ||
1227 AFI->getDPRCalleeSavedAreaSize() ||
1228 AFI->getDPRCalleeSavedAreaOffset()||
1231 BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
1234 BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr);
1235 } else if (NumBytes) {
1236 emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
1239 // Move SP to start of integer callee save spill area 2.
1240 movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);
1241 emitSPUpdate(MBB, MBBI, AFI->getDPRCalleeSavedAreaSize(), false, TII);
1243 // Move SP to start of integer callee save spill area 1.
1244 movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 2, STI);
1245 emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea2Size(), false, TII);
1247 // Move SP to SP upon entry to the function.
1248 movePastCSLoadStoreOps(MBB, MBBI, ARM::LDR, 1, STI);
1249 emitSPUpdate(MBB, MBBI, AFI->getGPRCalleeSavedArea1Size(), false, TII);
1252 if (VARegSaveSize) {
1254 // Epilogue for vararg functions: pop LR to R3 and branch off it.
1255 // FIXME: Verify this is still ok when R3 is no longer being reserved.
1256 BuildMI(MBB, MBBI, TII.get(ARM::tPOP)).addReg(ARM::R3);
1258 emitSPUpdate(MBB, MBBI, VARegSaveSize, isThumb, TII);
1261 BuildMI(MBB, MBBI, TII.get(ARM::tBX_RET_vararg)).addReg(ARM::R3);
1267 unsigned ARMRegisterInfo::getRARegister() const {
1271 unsigned ARMRegisterInfo::getFrameRegister(MachineFunction &MF) const {
1272 return STI.useThumbBacktraces() ? ARM::R7 : ARM::R11;
1275 #include "ARMGenRegisterInfo.inc"