Lines Matching full: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?
135 unsigned Stack[8]; // FP<n> Registers in each stack slot...
136 unsigned StackTop; // The current top of the FP stack.
142 // For each live FP<n> register, point to its Stack[] entry.
149 // in fixed stack slot positions. This is handled by copying FP registers
169 // Set up our stack model to match the incoming registers to MBB.
177 dbgs() << "Stack contents:";
179 dbgs() << " FP" << Stack[i];
180 assert(RegMap[Stack[i]] == i && "Stack[] doesn't match RegMap[]!");
188 /// getSlot - Return the stack slot number a particular register number is
195 /// isLive - Is RegNo currently live in the stack?
198 return Slot < StackTop && Stack[Slot] == RegNo;
217 report_fatal_error("Access past stack top!");
218 return Stack[StackTop-1-STi];
227 // pushReg - Push the specified FP<n> register onto the stack.
231 report_fatal_error("Stack overflow!");
232 Stack[StackTop] = Reg;
247 // Swap stack slot contents.
249 report_fatal_error("Access past stack top!");
250 std::swap(Stack[RegMap[RegOnTop]], Stack[StackTop-1]);
260 pushReg(AsReg); // New register on top of stack
280 /// popStackAfter - Pop the current value off of the top of the FP stack
285 /// stack, so that it is no longer in a register. If the register is
286 /// currently at the top of the stack, we just pop the current instruction,
287 /// otherwise we store the current top-of-stack into the specified slot,
288 /// then pop the top of stack.
299 /// Shuffle the top FixCount stack entries such that FP reg FixStack[0] is
338 /// register references into FP stack references.
406 /// transforming FP instructions into their stack form.
495 /// setupBlockStack - Use the live bundles to set up our model of the stack
496 /// to match predecessors' live out stack.
510 // Depth-first iteration should ensure that we always have an assigned stack.
529 /// MBB. Shuffle live registers to match the expected fixed stack of any
531 /// stack.
554 // Has the stack order been fixed yet?
557 DEBUG(dbgs() << "Shuffling stack to match.\n");
561 DEBUG(dbgs() << "Fixing stack order now.\n");
617 // Register File -> Register Stack Mapping Methods
620 // OpcodeTable - Sorted map of register instructions to their stack version.
622 // concrete X86 instruction which uses the register stack.
789 assert(Opc != -1 && "FP Stack instruction not in OpcodeTable!");
824 /// popStackAfter - Pop the current value off of the top of the FP stack after
835 report_fatal_error("Cannot pop empty stack!");
836 RegMap[Stack[--StackTop]] = ~0; // Update state
849 /// freeStackSlotAfter - Free the specified register from the register stack, so
851 /// of the stack, we just pop the current instruction, otherwise we store the
852 /// current top-of-stack into the specified slot, then pop the top of stack.
854 if (getStackEntry(0) == FPRegNo) { // already at the top of stack? easy.
859 // Otherwise, store the top of stack
871 unsigned TopReg = Stack[StackTop-1];
872 Stack[OldSlot] = TopReg;
875 Stack[--StackTop] = ~0;
885 unsigned RegNo = Stack[i];
900 std::swap(Stack[getSlot(KReg)], Stack[getSlot(DReg)]);
947 // Move items into place, starting from the desired stack bottom.
978 // Result gets pushed on the stack.
999 // on the stack instead of moving it. This ensure that popping the value is
1019 moveToTop(Reg, I); // Move to the top of the stack...
1032 report_fatal_error("Stack empty??");
1040 /// handleOneArgFPRW: Handle instructions that read from the top of stack and
1062 // the top of the stack.
1065 report_fatal_error("Stack cannot be empty!");
1070 // of the stack.
1174 // One of our operands must be on the top of the stack. If neither is yet, we
1177 // We can choose to move either operand to the top of the stack. If one of
1189 // duplicate one of the stack elements to the top. It doesn't matter
1197 // If we DO have one of our operands at the top of the stack, but we don't
1199 // on the stack.
1205 // Now we know that one of our operands is on the top of the stack, and at
1208 "Stack conditions not set up right!");
1210 // We decide which form to use based on what is on the top of the stack, and
1231 // NotTOS - The register which is not on the top of stack...
1238 // If both operands are killed, pop one off of the stack in addition to
1242 popStackAfter(I); // Pop the top of stack
1245 // Update stack information so that we know the destination register is now on
1246 // the stack.
1249 Stack[UpdatedSlot] = Dest;
1269 // Make sure the first operand is on the top of stack, the other one can be
1285 /// instructions require that the first operand is at the top of the stack, but
1286 /// otherwise don't modify the stack at all.
1294 // The first operand *must* be on the top of the stack.
1297 // Change the second operand to the stack register that the operand is in.
1304 // If we kill the second operand, make sure to pop it from the stack.
1306 // Get this value off of the register stack.
1351 Stack[Slot] = SR;
1358 // FP = COPY ST. Extract fixed stack value.
1369 // DstFP steals the stack slot from SrcFP.
1371 Stack[Slot] = DstFP;
1387 // incoming stack slot into the result.
1389 Stack[Slot] = DstFP;
1392 // For COPY we just duplicate the specified value to a new stack slot.
1410 // the floating point stack. We cannot model this with ST defs since CALL
1412 // to mean that there is one more live register on the stack than we
1415 // This means that StackTop does not match the hardware stack between a
1418 // hardware stack.
1421 // Move existing stack elements up to reflect reality.
1422 assert(StackTop < 8 && "Stack overflowed before FpPOP_RETVAL");
1424 std::copy_backward(Stack, Stack + StackTop, Stack + StackTop + 1);
1430 // DstFP is the new bottom of the stack.
1431 Stack[0] = DstFP;
1445 // Otherwise it is not possible to restore the stack state after the inline
1450 // 1. Popped inputs. These must appear at the stack top in ST0-STn. A
1451 // popped input operand must be in a fixed stack slot, and it is either
1455 // 2. Fixed inputs. These inputs appear in fixed stack slots, but are
1456 // preserved by the inline asm. The fixed stack slots must be STn-STm
1463 // stack slots.
1467 // stack as if it popped all the popped inputs and then pushed all the
1506 MI->emitError("fixed input regs must be last on the x87 stack");
1509 // Defs must be contiguous from the stack top. ST0-STn.
1511 MI->emitError("output regs must be last on the x87 stack");
1516 // So must the clobbered stack slots. ST0-STm, m >= n.
1518 MI->emitError("clobbers must be last on the x87 stack");
1523 MI->emitError("implicitly popped regs must be last on the x87 stack");
1543 // If we kill this operand, make sure to pop it from the stack after the
1596 // With the stack layout fixed, rewrite the FP registers.
1638 // better by trying to pop in stack order or something.
1716 // FP Stack.
1718 // Assert that the top of stack contains the right FP register.
1720 "Top of stack
1722 // Ok, everything is good, mark the value as not being on the stack
1723 // anymore so that our assertion about the stack being empty at end of
1731 // stack. Consider: RET FP1, FP1
1734 "Stack misconfiguration for RET!");
1754 /// ST(1). Just remove both from our understanding of the stack and return.