ARMBaseRegisterInfo.h revision 303da1baf2a90d18a709f29f4f7cd0e1962be5f9
1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg//===-- ARMBaseRegisterInfo.h - ARM Register Information Impl ---*- C++ -*-===// 2120d71a45cfda1edfa8cd6b1732e209eb98b53d8Brian Paul// 35e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen// The LLVM Compiler Infrastructure 49f6022d0567dc1288888212d7128acc48795b306Brian// 580684649a6d01f0e0517b14f61cbcad6fa101929Brian Paul// This file is distributed under the University of Illinois Open Source 65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen// License. See LICENSE.TXT for details. 7afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg// 8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg//===----------------------------------------------------------------------===// 9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg// 10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg// This file contains the base ARM implementation of TargetRegisterInfo class. 11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg// 12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg//===----------------------------------------------------------------------===// 135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 14afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#ifndef ARMBASEREGISTERINFO_H 15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define ARMBASEREGISTERINFO_H 165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 17afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "ARM.h" 18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "llvm/Target/TargetRegisterInfo.h" 19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#define GET_REGINFO_HEADER 21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "ARMGenRegisterInfo.inc" 22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgnamespace llvm { 24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg class ARMSubtarget; 256dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell class ARMBaseInstrInfo; 26add9f2168a5d6b15eb9955ee761246c4f4cf8458Brian Paul class Type; 27add9f2168a5d6b15eb9955ee761246c4f4cf8458Brian Paul 2877ee31930a1b0cc7766939415f4f04ed6a1fa4acBrian Paul/// Register allocation hints. 29add9f2168a5d6b15eb9955ee761246c4f4cf8458Brian Paulnamespace ARMRI { 30add9f2168a5d6b15eb9955ee761246c4f4cf8458Brian Paul enum { 31ea9b212fca78eada7cc7c4449de3f31d2ceea1c3Ian Romanick RegPairOdd = 1, 32fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul RegPairEven = 2 33b46712ca9d379d9c091f5543500088d82cf9776cBrian Paul }; 34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 35d100cbf721010f4eacc87507cc87c5314150d493Maciej Cencora 3634bd1233a9874fe12a822c4fcb926d48456e1f29Brian Paul/// isARMArea1Register - Returns true if the register is a low register (r0-r7) 3734bd1233a9874fe12a822c4fcb926d48456e1f29Brian Paul/// or a stack/pc register that we should push/pop. 382897cee99fb877e1f3cd9a881a61418c9c31867fBrian Paulstatic inline bool isARMArea1Register(unsigned Reg, bool isIOS) { 39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg using namespace ARM; 403c63452e64df7e10aa073c6c3b9492b1d7dabbb8Brian Paul switch (Reg) { 41ebb248aa5c018dc676d389221d76ed329059789eBrian Paul case R0: case R1: case R2: case R3: 42db61b9ce39bccc43140357652ceb78baaf2aea44Vinson Lee case R4: case R5: case R6: case R7: 43fa4525e289b475b928a7b2c4055af9dd7fe46600Brian Paul case LR: case SP: case PC: 4489fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul return true; 45c1a9e6010baceeff78f72ac0692aefc4312d815fBrian Paul case R8: case R9: case R10: case R11: 46afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg // For iOS we want r7 and lr to be next to each other. 47878c69fe540a73011b676ead33ac8d9b8c9e63aaBrian Paul return !isIOS; 48afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg default: 495e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen return false; 509ad8f431b2a47060bf05517246ab0fa8d249c800Jordan Justen } 51afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg} 52afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 53409620e47748479aaef593dc9bec0d6dd520e14aIan Romanickstatic inline bool isARMArea2Register(unsigned Reg, bool isIOS) { 54409620e47748479aaef593dc9bec0d6dd520e14aIan Romanick using namespace ARM; 55409620e47748479aaef593dc9bec0d6dd520e14aIan Romanick switch (Reg) { 56409620e47748479aaef593dc9bec0d6dd520e14aIan Romanick case R8: case R9: case R10: case R11: 57409620e47748479aaef593dc9bec0d6dd520e14aIan Romanick // iOS has this second area. 58409620e47748479aaef593dc9bec0d6dd520e14aIan Romanick return isIOS; 594cf6718725c7cf3bfb728118a8b14f8cf206c701Brian Paul default: 6063f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul return false; 6163f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul } 6263f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul} 6363f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul 647ecb61c30c4984a8513b306b640f9d274d8ecf61Brian Paulstatic inline bool isARMArea3Register(unsigned Reg, bool isIOS) { 6563f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul using namespace ARM; 6663f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul switch (Reg) { 6763f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul case D15: case D14: case D13: case D12: 6863f01309801c5a900d8d7f5ccd63413e33ff9bffBrian Paul case D11: case D10: case D9: case D8: 691749a25ca889d514889b34cf6311c8014d97bf66Brian Paul return true; 701749a25ca889d514889b34cf6311c8014d97bf66Brian Paul default: 716dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell return false; 726dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell } 731749a25ca889d514889b34cf6311c8014d97bf66Brian Paul} 746dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell 756dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellclass ARMBaseRegisterInfo : public ARMGenRegisterInfo { 766dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellprotected: 7789fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul const ARMBaseInstrInfo &TII; 7889fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul const ARMSubtarget &STI; 7989fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul 80afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /// FramePtr - ARM physical register used as frame ptr. 81b132e8da5e5f2b7da1f2141e0322e66bb0608e02Brian Paul unsigned FramePtr; 82f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg 83afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /// BasePtr - ARM physical register used as a base ptr in complex stack 841749a25ca889d514889b34cf6311c8014d97bf66Brian Paul /// frames. I.e., when we need a 3rd base, not just SP and FP, due to 85afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /// variable size stack objects. 86afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned BasePtr; 87afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 88afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg // Can be only subclassed. 89afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg explicit ARMBaseRegisterInfo(const ARMBaseInstrInfo &tii, 90ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick const ARMSubtarget &STI); 91afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 92afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg // Return the opcode that implements 'Op', or 0 if no opcode 93afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned getOpcode(int Op) const; 94afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 95afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtgpublic: 96afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg /// Code Generation virtual methods... 97ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick const uint16_t *getCalleeSavedRegs(const MachineFunction *MF = 0) const; 98afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const uint32_t *getCallPreservedMask(CallingConv::ID) const; 99afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const uint32_t *getNoPreservedMask() const; 100afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 101afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg BitVector getReservedRegs(const MachineFunction &MF) const; 102afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 103afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const TargetRegisterClass* 104afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg getPointerRegClass(const MachineFunction &MF, unsigned Kind = 0) const; 105afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const TargetRegisterClass* 106ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick getCrossCopyRegClass(const TargetRegisterClass *RC) const; 107afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 108afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const TargetRegisterClass* 109afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg getLargestLegalSuperClass(const TargetRegisterClass *RC) const; 110afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 111afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned getRegPressureLimit(const TargetRegisterClass *RC, 112ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick MachineFunction &MF) const; 113afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 114ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick ArrayRef<uint16_t> getRawAllocationOrder(const TargetRegisterClass *RC, 115afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned HintType, unsigned HintReg, 116afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const MachineFunction &MF) const; 117afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 118afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg void getRegAllocationHints(unsigned VirtReg, 119afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg ArrayRef<MCPhysReg> Order, 120afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg SmallVectorImpl<MCPhysReg> &Hints, 121afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const MachineFunction &MF, 122afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg const VirtRegMap *VRM) const; 123afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 124afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, 125ae88281b7b67d656a7d1467c39c8d93dc8778485Ian Romanick const MachineFunction &MF) const; 126afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 127afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, 128afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg MachineFunction &MF) const; 129afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 130afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg virtual bool avoidWriteAfterWrite(const TargetRegisterClass *RC) const; 131afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 132afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg bool hasBasePointer(const MachineFunction &MF) const; 133afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg 134afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg bool canRealignStack(const MachineFunction &MF) const; 135f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul bool needsStackRealignment(const MachineFunction &MF) const; 136f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const; 137f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const; 138f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul void materializeFrameBaseRegister(MachineBasicBlock *MBB, 13929386d1f2d60e905d63f4c5f045ff3794b2ff99cIan Romanick unsigned BaseReg, int FrameIdx, 14029386d1f2d60e905d63f4c5f045ff3794b2ff99cIan Romanick int64_t Offset) const; 14109714c09a40501d82823e42f7461d7b8d7bf11c0Jordan Justen void resolveFrameIndex(MachineBasicBlock::iterator I, 142f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke unsigned BaseReg, int64_t Offset) const; 14329386d1f2d60e905d63f4c5f045ff3794b2ff99cIan Romanick bool isFrameOffsetLegal(const MachineInstr *MI, int64_t Offset) const; 144f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke 145f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke bool cannotEliminateFrame(const MachineFunction &MF) const; 146f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke 1471a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák // Debug information queries. 1481a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák unsigned getFrameRegister(const MachineFunction &MF) const; 1491a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák unsigned getBaseRegister() const { return BasePtr; } 1501a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák 1511a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák // Exception handling queries. 1521a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák unsigned getEHExceptionRegister() const; 1531a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák unsigned getEHHandlerRegister() const; 1541a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák 1551a06e8454ec714e950bc88882cd985534a18bf1fMarek Olšák bool isLowRegister(unsigned Reg) const; 156f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke 157f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke 158f1452844fe2522387bbc6633f22aec09b8a06204Benjamin Franzke /// emitLoadConstPool - Emits a load from constpool to materialize the 1594741dbcbbc2514de370a760f4b78a17491014555Ian Romanick /// specified immediate. 160f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul virtual void emitLoadConstPool(MachineBasicBlock &MBB, 161f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul MachineBasicBlock::iterator &MBBI, 1624741dbcbbc2514de370a760f4b78a17491014555Ian Romanick DebugLoc dl, 1634741dbcbbc2514de370a760f4b78a17491014555Ian Romanick unsigned DestReg, unsigned SubIdx, 1644741dbcbbc2514de370a760f4b78a17491014555Ian Romanick int Val, 165f7e1dfeaefda8865252513bc4d880ea8640efe4dBrian Paul ARMCC::CondCodes Pred = ARMCC::AL, 166f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul unsigned PredReg = 0, 167f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul unsigned MIFlags = MachineInstr::NoFlags)const; 168f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul 169f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul /// Code Generation virtual methods... 17089fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul virtual bool requiresRegisterScavenging(const MachineFunction &MF) const; 17133fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 17233fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick virtual bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const; 17333fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 17433fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const; 17533fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 17633fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const; 17733fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 17833fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick virtual void eliminateCallFramePseudoInstr(MachineFunction &MF, 17933fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick MachineBasicBlock &MBB, 18033fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick MachineBasicBlock::iterator I) const; 18133fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 18233fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick virtual void eliminateFrameIndex(MachineBasicBlock::iterator II, 18333fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick int SPAdj, RegScavenger *RS = NULL) const; 18433fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick 18533fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanickprivate: 186f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; 187f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul 188f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const; 189f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul}; 190f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul 19189fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul} // end namespace llvm 192f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul 19389fb06fcc11cbe3f23521312155d6c55d869f526Brian Paul#endif 194f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97Brian Paul