1 //===- ARMBaseRegisterInfo.h - ARM Register Information Impl --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the base ARM implementation of TargetRegisterInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMBASEREGISTERINFO_H
15 #define ARMBASEREGISTERINFO_H
18 #include "llvm/Target/TargetRegisterInfo.h"
19 #include "ARMGenRegisterInfo.h.inc"
23 class ARMBaseInstrInfo;
26 /// Register allocation hints.
34 /// isARMLowRegister - Returns true if the register is low register r0-r7.
36 static inline bool isARMLowRegister(unsigned Reg) {
39 case R0: case R1: case R2: case R3:
40 case R4: case R5: case R6: case R7:
47 struct ARMBaseRegisterInfo : public ARMGenRegisterInfo {
49 const ARMBaseInstrInfo &TII;
50 const ARMSubtarget &STI;
52 /// FramePtr - ARM physical register used as frame ptr.
55 // Can be only subclassed.
56 explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii,
57 const ARMSubtarget &STI);
59 // Return the opcode that implements 'Op', or 0 if no opcode
60 unsigned getOpcode(int Op) const;
63 /// getRegisterNumbering - Given the enum value for some register, e.g.
64 /// ARM::LR, return the number that it corresponds to (e.g. 14).
65 static unsigned getRegisterNumbering(unsigned RegEnum);
67 /// Same as previous getRegisterNumbering except it returns true in isSPVFP
68 /// if the register is a single precision VFP register.
69 static unsigned getRegisterNumbering(unsigned RegEnum, bool &isSPVFP);
71 /// Code Generation virtual methods...
72 const unsigned *getCalleeSavedRegs(const MachineFunction *MF = 0) const;
74 const TargetRegisterClass* const*
75 getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
77 BitVector getReservedRegs(const MachineFunction &MF) const;
79 const TargetRegisterClass *getPointerRegClass() const;
81 std::pair<TargetRegisterClass::iterator,TargetRegisterClass::iterator>
82 getAllocationOrder(const TargetRegisterClass *RC,
83 unsigned HintType, unsigned HintReg,
84 const MachineFunction &MF) const;
86 unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg,
87 const MachineFunction &MF) const;
89 void UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
90 MachineFunction &MF) const;
92 bool hasFP(const MachineFunction &MF) const;
94 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
95 RegScavenger *RS = NULL) const;
97 // Debug information queries.
98 unsigned getRARegister() const;
99 unsigned getFrameRegister(MachineFunction &MF) const;
101 // Exception handling queries.
102 unsigned getEHExceptionRegister() const;
103 unsigned getEHHandlerRegister() const;
105 int getDwarfRegNum(unsigned RegNum, bool isEH) const;
107 bool isLowRegister(unsigned Reg) const;
110 /// emitLoadConstPool - Emits a load from constpool to materialize the
111 /// specified immediate.
112 virtual void emitLoadConstPool(MachineBasicBlock &MBB,
113 MachineBasicBlock::iterator &MBBI,
115 unsigned DestReg, unsigned SubIdx,
117 ARMCC::CondCodes Pred = ARMCC::AL,
118 unsigned PredReg = 0) const;
120 /// Code Generation virtual methods...
121 virtual bool isReservedReg(const MachineFunction &MF, unsigned Reg) const;
123 virtual bool requiresRegisterScavenging(const MachineFunction &MF) const;
125 virtual bool hasReservedCallFrame(MachineFunction &MF) const;
127 virtual void eliminateCallFramePseudoInstr(MachineFunction &MF,
128 MachineBasicBlock &MBB,
129 MachineBasicBlock::iterator I) const;
131 virtual void eliminateFrameIndex(MachineBasicBlock::iterator II,
132 int SPAdj, RegScavenger *RS = NULL) const;
134 virtual void emitPrologue(MachineFunction &MF) const;
135 virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
138 unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const;
140 unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const;
143 } // end namespace llvm