Home | History | Annotate | Download | only in X86

Lines Matching defs:Stack

1 //===-- X86FloatingPoint.cpp - Floating point Reg -> Stack converter ------===//
11 // pseudo registers into register stack instructions. This pass uses live
15 // The x87 hardware tracks liveness of the stack registers, so it is necessary
18 // identical stack positions. Instructions are inserted at the end of each basic
58 memset(Stack, 0, sizeof(Stack));
79 // LiveBundle. It represents a set of CFG edges where the live FP stack
80 // registers must be allocated identically in the x87 stack.
87 // but the exact mapping of FP registers to stack slots is fixed later.
93 // stack order has not yet been fixed.
96 // Assigned stack order for live-in registers.
102 // Have the live registers been assigned a stack order yet?
134 unsigned Stack[8]; // FP<n> Registers in each stack slot...
135 unsigned StackTop; // The current top of the FP stack.
141 // For each live FP<n> register, point to its Stack[] entry.
148 // in fixed stack slot positions. This is handled by copying FP registers
168 // Set up our stack model to match the incoming registers to MBB.
176 dbgs() << "Stack contents:";
178 dbgs() << " FP" << Stack[i];
179 assert(RegMap[Stack[i]] == i && "Stack[] doesn't match RegMap[]!");
187 /// getSlot - Return the stack slot number a particular register number is
194 /// isLive - Is RegNo currently live in the stack?
197 return Slot < StackTop && Stack[Slot] == RegNo;
216 report_fatal_error("Access past stack top!");
217 return Stack[StackTop-1-STi];
226 // pushReg - Push the specified FP<n> register onto the stack.
230 report_fatal_error("Stack overflow!");
231 Stack[StackTop] = Reg;
246 // Swap stack slot contents.
248 report_fatal_error("Access past stack top!");
249 std::swap(Stack[RegMap[RegOnTop]], Stack[StackTop-1]);
259 pushReg(AsReg); // New register on top of stack
279 /// popStackAfter - Pop the current value off of the top of the FP stack
284 /// stack, so that it is no longer in a register. If the register is
285 /// currently at the top of the stack, we just pop the current instruction,
286 /// otherwise we store the current top-of-stack into the specified slot,
287 /// then pop the top of stack.
298 /// Shuffle the top FixCount stack entries such that FP reg FixStack[0] is
337 /// register references into FP stack references.
405 /// transforming FP instructions into their stack form.
494 /// setupBlockStack - Use the live bundles to set up our model of the stack
495 /// to match predecessors' live out stack.
509 // Depth-first iteration should ensure that we always have an assigned stack.
528 /// MBB. Shuffle live registers to match the expected fixed stack of any
530 /// stack.
553 // Has the stack order been fixed yet?
556 DEBUG(dbgs() << "Shuffling stack to match.\n");
560 DEBUG(dbgs() << "Fixing stack order now.\n");
616 // Register File -> Register Stack Mapping Methods
619 // OpcodeTable - Sorted map of register instructions to their stack version.
621 // concrete X86 instruction which uses the register stack.
788 assert(Opc != -1 && "FP Stack instruction not in OpcodeTable!");
823 /// popStackAfter - Pop the current value off of the top of the FP stack after
834 report_fatal_error("Cannot pop empty stack!");
835 RegMap[Stack[--StackTop]] = ~0; // Update state
848 /// freeStackSlotAfter - Free the specified register from the register stack, so
850 /// of the stack, we just pop the current instruction, otherwise we store the
851 /// current top-of-stack into the specified slot, then pop the top of stack.
853 if (getStackEntry(0) == FPRegNo) { // already at the top of stack? easy.
858 // Otherwise, store the top of stack into the dead slot, killing the operand
870 unsigned TopReg = Stack[StackTop-1];
871 Stack[OldSlot] = TopReg;
874 Stack[--StackTop] = ~0;
884 unsigned RegNo = Stack[i];
899 std::swap(Stack[getSlot(KReg)], Stack[getSlot(DReg)]);
946 // Move items into place, starting from the desired stack bottom.
977 // Result gets pushed on the stack.
998 // on the stack instead of moving it. This ensure that popping the value is
1018 moveToTop(Reg, I); // Move to the top of the stack...
1031 report_fatal_error("Stack empty??");
1039 /// handleOneArgFPRW: Handle instructions that read from the top of stack and
1061 // the top of the stack.
1064 report_fatal_error("Stack cannot be empty!");
1069 // of the stack.
1173 // One of our operands must be on the top of the stack. If neither is yet, we
1176 // We can choose to move either operand to the top of the stack. If one of
1188 // duplicate one of the stack elements to the top. It doesn't matter
1196 // If we DO have one of our operands at the top of the stack, but we don't
1198 // on the stack.
1204 // Now we know that one of our operands is on the top of the stack, and at
1207 "Stack conditions not set up right!");
1209 // We decide which form to use based on what is on the top of the stack, and
1230 // NotTOS - The register which is not on the top of stack...
1237 // If both operands are killed, pop one off of the stack in addition to
1241 popStackAfter(I); // Pop the top of stack
1244 // Update stack information so that we know the destination register is now on
1245 // the stack.
1248 Stack[UpdatedSlot] = Dest;
1268 // Make sure the first operand is on the top of stack, the other one can be
1284 /// instructions require that the first operand is at the top of the stack, but
1285 /// otherwise don't modify the stack at all.
1293 // The first operand *must* be on the top of the stack.
1296 // Change the second operand to the stack register that the operand is in.
1303 // If we kill the second operand, make sure to pop it from the stack.
1305 // Get this value off of the register stack.
1350 Stack[Slot] = SR;
1357 // FP = COPY ST. Extract fixed stack value.
1368 // DstFP steals the stack slot from SrcFP.
1370 Stack[Slot] = DstFP;
1386 // incoming stack slot into the result.
1388 Stack[Slot] = DstFP;
1391 // For COPY we just duplicate the specified value to a new stack slot.
1409 // the floating point stack. We cannot model this with ST defs since CALL
1411 // to mean that there is one more live register on the stack than we
1414 // This means that StackTop does not match the hardware stack between a
1417 // hardware stack.
1420 // Move existing stack elements up to reflect reality.
1421 assert(StackTop < 8 && "Stack overflowed before FpPOP_RETVAL");
1423 std::copy_backward(Stack, Stack + StackTop, Stack + StackTop + 1);
1429 // DstFP is the new bottom of the stack.
1430 Stack[0] = DstFP;
1444 // Otherwise it is not possible to restore the stack state after the inline
1449 // 1. Popped inputs. These must appear at the stack top in ST0-STn. A
1450 // popped input operand must be in a fixed stack slot, and it is either
1454 // 2. Fixed inputs. These inputs appear in fixed stack slots, but are
1455 // preserved by the inline asm. The fixed stack slots must be STn-STm
1462 // stack slots.
1466 // stack as if it popped all the popped inputs and then pushed all the
1505 MI->emitError("fixed input regs must be last on the x87 stack");
1508 // Defs must be contiguous from the stack top. ST0-STn.
1510 MI->emitError("output regs must be last on the x87 stack");
1515 // So must the clobbered stack slots. ST0-STm, m >= n.
1517 MI->emitError("clobbers must be last on the x87 stack");
1522 MI->emitError("implicitly popped regs must be last on the x87 stack");
1542 // If we kill this operand, make sure to pop it from the stack after the
1595 // With the stack layout fixed, rewrite the FP registers.
1637 // better by trying to pop in stack order or something.
1714 // FP Stack.
1716 // Assert that the top of stack contains the right FP register.
1718 "Top of stack not the right register for RET!");
1720 stack
1721 // anymore so that our assertion about the stack being empty at end of
1729 // stack. Consider: RET FP1, FP1
1732 "Stack misconfiguration for RET!");
1752 /// ST(1). Just remove both from our understanding of the stack and return.