summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-01-09 22:42:48 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-01-09 22:42:48 +0000
commitda1f1f495066f95957fd1c19ad44d4453e47aff4 (patch)
treeea7414adc13d84d995fdc1377ca4359b51326bcc /include
parent7975e3ebbac67cc50d918843bf68373cf48daa2e (diff)
downloadllvm-da1f1f495066f95957fd1c19ad44d4453e47aff4.tar.gz
llvm-da1f1f495066f95957fd1c19ad44d4453e47aff4.tar.bz2
llvm-da1f1f495066f95957fd1c19ad44d4453e47aff4.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Target/TargetRegisterInfo.h34
1 files changed, 15 insertions, 19 deletions
diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h
index c2a973e0db..d6887ead01 100644
--- a/include/llvm/Target/TargetRegisterInfo.h
+++ b/include/llvm/Target/TargetRegisterInfo.h
@@ -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