summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86FloatingPoint.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-06-27 04:08:36 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-06-27 04:08:36 +0000
commit1baeb006d2bb74dd9f6fa633fcc53e3b1ecbbf35 (patch)
tree52814f8f73acb385620ac6d0a41eebca86ea7bdf /lib/Target/X86/X86FloatingPoint.cpp
parentf792fa90f1125553008659c743cba85b9b5d2e5e (diff)
downloadllvm-1baeb006d2bb74dd9f6fa633fcc53e3b1ecbbf35.tar.gz
llvm-1baeb006d2bb74dd9f6fa633fcc53e3b1ecbbf35.tar.bz2
llvm-1baeb006d2bb74dd9f6fa633fcc53e3b1ecbbf35.tar.xz
Grow the X86FloatingPoint register map to hold 16 registers.
This allows for more live scratch registers which is needed to handle live ST registers before return and inline asm instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133903 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86FloatingPoint.cpp')
-rw-r--r--lib/Target/X86/X86FloatingPoint.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp
index 325d061181..e16f217812 100644
--- a/lib/Target/X86/X86FloatingPoint.cpp
+++ b/lib/Target/X86/X86FloatingPoint.cpp
@@ -126,10 +126,20 @@ namespace {
void bundleCFG(MachineFunction &MF);
MachineBasicBlock *MBB; // Current basic block
+
+ // The hardware keeps track of how many FP registers are live, so we have
+ // to model that exactly. Usually, each live register corresponds to an
+ // FP<n> register, but when dealing with calls, returns, and inline
+ // assembly, it is sometimes neccesary to have live scratch registers.
unsigned Stack[8]; // FP<n> Registers in each stack slot...
- unsigned RegMap[8]; // Track which stack slot contains each register
unsigned StackTop; // The current top of the FP stack.
+ // For each live FP<n> register, point to its Stack[] entry.
+ // The first entries correspond to FP0-FP6, the rest are scratch registers
+ // used when we need slightly different live registers than what the
+ // register allocator thinks.
+ unsigned RegMap[16];
+
// Set up our stack model to match the incoming registers to MBB.
void setupBlockStack();
@@ -148,7 +158,7 @@ namespace {
/// getSlot - Return the stack slot number a particular register number is
/// in.
unsigned getSlot(unsigned RegNo) const {
- assert(RegNo < 8 && "Regno out of range!");
+ assert(RegNo < array_lengthof(RegMap) && "Regno out of range!");
return RegMap[RegNo];
}
@@ -160,7 +170,7 @@ namespace {
/// getScratchReg - Return an FP register that is not currently in use.
unsigned getScratchReg() {
- for (int i = 7; i >= 0; --i)
+ for (int i = array_lengthof(RegMap) - 1; i >= 8; --i)
if (!isLive(i))
return i;
llvm_unreachable("Ran out of scratch FP registers");
@@ -181,7 +191,7 @@ namespace {
// pushReg - Push the specified FP<n> register onto the stack.
void pushReg(unsigned Reg) {
- assert(Reg < 8 && "Register number out of range!");
+ assert(Reg < array_lengthof(RegMap) && "Register number out of range!");
if (StackTop >= 8)
report_fatal_error("Stack overflow!");
Stack[StackTop] = Reg;
@@ -236,7 +246,7 @@ namespace {
/// Adjust the live registers to be the set in Mask.
void adjustLiveRegs(unsigned Mask, MachineBasicBlock::iterator I);
- /// Shuffle the top FixCount stack entries susch that FP reg FixStack[0] is
+ /// Shuffle the top FixCount stack entries such that FP reg FixStack[0] is
/// st(0), FP reg FixStack[1] is st(1) etc.
void shuffleStackTop(const unsigned char *FixStack, unsigned FixCount,
MachineBasicBlock::iterator I);