forked from OSchip/llvm-project
Change virtual register numbering to make more space for physical registers.
The numbering plan is now: 0 NoRegister. [1;2^30) Physical registers. [2^30;2^31) Stack slots. [2^31;2^32) Virtual registers. (With -1u and -2u used by DenseMapInfo.) Each segment is filled from the left, so any mistaken interpretation should quickly cause crashes. FirstVirtualRegister has been removed. TargetRegisterInfo provides predicates conversion functions that should be used instead of interpreting register numbers manually. It is now legal to pass NoRegister to isPhysicalRegister() and isVirtualRegister(). The result is false in both cases. It is quite rare to represent stack slots in this way, so isPhysicalRegister() and isVirtualRegister() require that isStackSlot() be checked first if it can possibly return true. This allows a very fast implementation of the common predicates. llvm-svn: 123137
This commit is contained in:
parent
dff679f4b6
commit
8828e482b6
|
@ -297,65 +297,61 @@ public:
|
|||
|
||||
enum { // Define some target independent constants
|
||||
/// NoRegister - This physical register is not a real target register. It
|
||||
/// is useful as a sentinal.
|
||||
NoRegister = 0,
|
||||
|
||||
/// FirstVirtualRegister - This is the first register number that is
|
||||
/// considered to be a 'virtual' register, which is part of the SSA
|
||||
/// namespace. This must be the same for all targets, which means that each
|
||||
/// target is limited to this fixed number of registers.
|
||||
FirstVirtualRegister = 16384
|
||||
/// is useful as a sentinel.
|
||||
NoRegister = 0
|
||||
};
|
||||
|
||||
/// isStackSlot - Sometimes it is useful the be able to store a non-negative
|
||||
/// frame index in a variable that normally holds a register. isStackSlot()
|
||||
/// returns true if Reg is in the range used for stack slots.
|
||||
///
|
||||
/// Note that isVirtualRegister() and isPhysicalRegister() may also return
|
||||
/// true for such a value. In that case, isStackSlot() takes precedence.
|
||||
/// Note that isVirtualRegister() and isPhysicalRegister() cannot handle stack
|
||||
/// slots, so if a variable may contains a stack slot, always check
|
||||
/// isStackSlot() first.
|
||||
///
|
||||
static bool isStackSlot(unsigned Reg) {
|
||||
return Reg >= (1u << 31);
|
||||
return int(Reg) >= (1 << 30);
|
||||
}
|
||||
|
||||
/// stackSlot2Index - Compute the frame index from a register value
|
||||
/// representing a stack slot.
|
||||
static int stackSlot2Index(unsigned Reg) {
|
||||
assert(isStackSlot(Reg) && "Not a stack slot");
|
||||
return int(Reg - (1u << 31));
|
||||
return int(Reg - (1u << 30));
|
||||
}
|
||||
|
||||
/// index2StackSlot - Convert a non-negative frame index to a stack slot
|
||||
/// register value.
|
||||
static unsigned index2StackSlot(int FI) {
|
||||
assert(FI >= 0 && "Cannot hold a negative frame index.");
|
||||
return FI + (1u << 31);
|
||||
return FI + (1u << 30);
|
||||
}
|
||||
|
||||
/// isPhysicalRegister - Return true if the specified register number is in
|
||||
/// the physical register namespace.
|
||||
static bool isPhysicalRegister(unsigned Reg) {
|
||||
assert(Reg && "this is not a register!");
|
||||
return Reg < FirstVirtualRegister;
|
||||
assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first.");
|
||||
return int(Reg) > 0;
|
||||
}
|
||||
|
||||
/// isVirtualRegister - Return true if the specified register number is in
|
||||
/// the virtual register namespace.
|
||||
static bool isVirtualRegister(unsigned Reg) {
|
||||
assert(!isStackSlot(Reg) && "this is not a register!");
|
||||
return Reg >= FirstVirtualRegister;
|
||||
assert(!isStackSlot(Reg) && "Not a register! Check isStackSlot() first.");
|
||||
return int(Reg) < 0;
|
||||
}
|
||||
|
||||
/// virtReg2Index - Convert a virtual register number to a 0-based index.
|
||||
/// The first virtual register in a function will get the index 0.
|
||||
static unsigned virtReg2Index(unsigned Reg) {
|
||||
return Reg - FirstVirtualRegister;
|
||||
assert(isVirtualRegister(Reg) && "Not a virtual register");
|
||||
return Reg - (1u << 31);
|
||||
}
|
||||
|
||||
/// index2VirtReg - Convert a 0-based index to a virtual register number.
|
||||
/// This is the inverse operation of VirtReg2IndexFunctor below.
|
||||
static unsigned index2VirtReg(unsigned Index) {
|
||||
return Index + FirstVirtualRegister;
|
||||
return Index + (1u << 31);
|
||||
}
|
||||
|
||||
/// getMinimalPhysRegClass - Returns the Register Class of a physical
|
||||
|
|
Loading…
Reference in New Issue