diff options
Diffstat (limited to 'lib/Target/X86/X86FloatingPoint.cpp')
-rw-r--r-- | lib/Target/X86/X86FloatingPoint.cpp | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp index 9a72e7114be0..ae748901164a 100644 --- a/lib/Target/X86/X86FloatingPoint.cpp +++ b/lib/Target/X86/X86FloatingPoint.cpp @@ -39,6 +39,7 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" +#include "llvm/Config/llvm-config.h" #include "llvm/IR/InlineAsm.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -434,7 +435,7 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) { PrevMI = &*std::prev(I); ++NumFP; // Keep track of # of pseudo instrs - DEBUG(dbgs() << "\nFPInst:\t" << MI); + LLVM_DEBUG(dbgs() << "\nFPInst:\t" << MI); // Get dead variables list now because the MI pointer may be deleted as part // of processing! @@ -464,13 +465,13 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) { // is in the clobber list and marked dead might not be live on the stack. static_assert(X86::FP7 - X86::FP0 == 7, "sequential FP regnumbers"); if (Reg >= X86::FP0 && Reg <= X86::FP6 && isLive(Reg-X86::FP0)) { - DEBUG(dbgs() << "Register FP#" << Reg-X86::FP0 << " is dead!\n"); + LLVM_DEBUG(dbgs() << "Register FP#" << Reg - X86::FP0 << " is dead!\n"); freeStackSlotAfter(I, Reg-X86::FP0); } } // Print out all of the instructions expanded to if -debug - DEBUG({ + LLVM_DEBUG({ MachineBasicBlock::iterator PrevI = PrevMI; if (I == PrevI) { dbgs() << "Just deleted pseudo instruction\n"; @@ -499,15 +500,15 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) { /// setupBlockStack - Use the live bundles to set up our model of the stack /// to match predecessors' live out stack. void FPS::setupBlockStack() { - DEBUG(dbgs() << "\nSetting up live-ins for " << printMBBReference(*MBB) - << " derived from " << MBB->getName() << ".\n"); + LLVM_DEBUG(dbgs() << "\nSetting up live-ins for " << printMBBReference(*MBB) + << " derived from " << MBB->getName() << ".\n"); StackTop = 0; // Get the live-in bundle for MBB. const LiveBundle &Bundle = LiveBundles[Bundles->getBundle(MBB->getNumber(), false)]; if (!Bundle.Mask) { - DEBUG(dbgs() << "Block has no FP live-ins.\n"); + LLVM_DEBUG(dbgs() << "Block has no FP live-ins.\n"); return; } @@ -516,8 +517,8 @@ void FPS::setupBlockStack() { // Push the fixed live-in registers. for (unsigned i = Bundle.FixCount; i > 0; --i) { - DEBUG(dbgs() << "Live-in st(" << (i-1) << "): %fp" - << unsigned(Bundle.FixStack[i-1]) << '\n'); + LLVM_DEBUG(dbgs() << "Live-in st(" << (i - 1) << "): %fp" + << unsigned(Bundle.FixStack[i - 1]) << '\n'); pushReg(Bundle.FixStack[i-1]); } @@ -526,7 +527,7 @@ void FPS::setupBlockStack() { // to be revived at the end of a short block. It might save a few instrs. unsigned Mask = calcLiveInMask(MBB, /*RemoveFPs=*/true); adjustLiveRegs(Mask, MBB->begin()); - DEBUG(MBB->dump()); + LLVM_DEBUG(MBB->dump()); } /// finishBlockStack - Revive live-outs that are implicitly defined out of @@ -538,8 +539,8 @@ void FPS::finishBlockStack() { if (MBB->succ_empty()) return; - DEBUG(dbgs() << "Setting up live-outs for " << printMBBReference(*MBB) - << " derived from " << MBB->getName() << ".\n"); + LLVM_DEBUG(dbgs() << "Setting up live-outs for " << printMBBReference(*MBB) + << " derived from " << MBB->getName() << ".\n"); // Get MBB's live-out bundle. unsigned BundleIdx = Bundles->getBundle(MBB->getNumber(), true); @@ -551,18 +552,18 @@ void FPS::finishBlockStack() { adjustLiveRegs(Bundle.Mask, Term); if (!Bundle.Mask) { - DEBUG(dbgs() << "No live-outs.\n"); + LLVM_DEBUG(dbgs() << "No live-outs.\n"); return; } // Has the stack order been fixed yet? - DEBUG(dbgs() << "LB#" << BundleIdx << ": "); + LLVM_DEBUG(dbgs() << "LB#" << BundleIdx << ": "); if (Bundle.isFixed()) { - DEBUG(dbgs() << "Shuffling stack to match.\n"); + LLVM_DEBUG(dbgs() << "Shuffling stack to match.\n"); shuffleStackTop(Bundle.FixStack, Bundle.FixCount, Term); } else { // Not fixed yet, we get to choose. - DEBUG(dbgs() << "Fixing stack order now.\n"); + LLVM_DEBUG(dbgs() << "Fixing stack order now.\n"); Bundle.FixCount = StackTop; for (unsigned i = 0; i < StackTop; ++i) Bundle.FixStack[i] = getStackEntry(i); @@ -599,13 +600,14 @@ static int Lookup(ArrayRef<TableEntry> Table, unsigned Opcode) { #ifdef NDEBUG #define ASSERT_SORTED(TABLE) #else -#define ASSERT_SORTED(TABLE) \ - { static bool TABLE##Checked = false; \ - if (!TABLE##Checked) { \ - assert(std::is_sorted(std::begin(TABLE), std::end(TABLE)) && \ - "All lookup tables must be sorted for efficient access!"); \ - TABLE##Checked = true; \ - } \ +#define ASSERT_SORTED(TABLE) \ + { \ + static std::atomic<bool> TABLE##Checked(false); \ + if (!TABLE##Checked.load(std::memory_order_relaxed)) { \ + assert(std::is_sorted(std::begin(TABLE), std::end(TABLE)) && \ + "All lookup tables must be sorted for efficient access!"); \ + TABLE##Checked.store(true, std::memory_order_relaxed); \ + } \ } #endif @@ -893,7 +895,8 @@ void FPS::adjustLiveRegs(unsigned Mask, MachineBasicBlock::iterator I) { while (Kills && Defs) { unsigned KReg = countTrailingZeros(Kills); unsigned DReg = countTrailingZeros(Defs); - DEBUG(dbgs() << "Renaming %fp" << KReg << " as imp %fp" << DReg << "\n"); + LLVM_DEBUG(dbgs() << "Renaming %fp" << KReg << " as imp %fp" << DReg + << "\n"); std::swap(Stack[getSlot(KReg)], Stack[getSlot(DReg)]); std::swap(RegMap[KReg], RegMap[DReg]); Kills &= ~(1 << KReg); @@ -907,7 +910,7 @@ void FPS::adjustLiveRegs(unsigned Mask, MachineBasicBlock::iterator I) { unsigned KReg = getStackEntry(0); if (!(Kills & (1 << KReg))) break; - DEBUG(dbgs() << "Popping %fp" << KReg << "\n"); + LLVM_DEBUG(dbgs() << "Popping %fp" << KReg << "\n"); popStackAfter(I2); Kills &= ~(1 << KReg); } @@ -916,7 +919,7 @@ void FPS::adjustLiveRegs(unsigned Mask, MachineBasicBlock::iterator I) { // Manually kill the rest. while (Kills) { unsigned KReg = countTrailingZeros(Kills); - DEBUG(dbgs() << "Killing %fp" << KReg << "\n"); + LLVM_DEBUG(dbgs() << "Killing %fp" << KReg << "\n"); freeStackSlotBefore(I, KReg); Kills &= ~(1 << KReg); } @@ -924,14 +927,14 @@ void FPS::adjustLiveRegs(unsigned Mask, MachineBasicBlock::iterator I) { // Load zeros for all the imp-defs. while(Defs) { unsigned DReg = countTrailingZeros(Defs); - DEBUG(dbgs() << "Defining %fp" << DReg << " as 0\n"); + LLVM_DEBUG(dbgs() << "Defining %fp" << DReg << " as 0\n"); BuildMI(*MBB, I, DebugLoc(), TII->get(X86::LD_F0)); pushReg(DReg); Defs &= ~(1 << DReg); } // Now we should have the correct registers live. - DEBUG(dumpStack()); + LLVM_DEBUG(dumpStack()); assert(StackTop == countPopulation(Mask) && "Live count mismatch"); } @@ -954,7 +957,7 @@ void FPS::shuffleStackTop(const unsigned char *FixStack, if (FixCount > 0) moveToTop(OldReg, I); } - DEBUG(dumpStack()); + LLVM_DEBUG(dumpStack()); } @@ -1466,7 +1469,7 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &Inst) { case TargetOpcode::IMPLICIT_DEF: { // All FP registers must be explicitly defined, so load a 0 instead. unsigned Reg = MI.getOperand(0).getReg() - X86::FP0; - DEBUG(dbgs() << "Emitting LD_F0 for implicit FP" << Reg << '\n'); + LLVM_DEBUG(dbgs() << "Emitting LD_F0 for implicit FP" << Reg << '\n'); BuildMI(*MBB, Inst, MI.getDebugLoc(), TII->get(X86::LD_F0)); pushReg(Reg); break; @@ -1571,8 +1574,9 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &Inst) { MI.emitError("implicitly popped regs must be last on the x87 stack"); unsigned NumSTPopped = countTrailingOnes(STPopped); - DEBUG(dbgs() << "Asm uses " << NumSTUses << " fixed regs, pops " - << NumSTPopped << ", and defines " << NumSTDefs << " regs.\n"); + LLVM_DEBUG(dbgs() << "Asm uses " << NumSTUses << " fixed regs, pops " + << NumSTPopped << ", and defines " << NumSTDefs + << " regs.\n"); #ifndef NDEBUG // If any input operand uses constraint "f", all output register @@ -1610,7 +1614,10 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &Inst) { STUsesArray[I] = I; shuffleStackTop(STUsesArray, NumSTUses, Inst); - DEBUG({dbgs() << "Before asm: "; dumpStack();}); + LLVM_DEBUG({ + dbgs() << "Before asm: "; + dumpStack(); + }); // With the stack layout fixed, rewrite the FP registers. for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { @@ -1658,7 +1665,7 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &Inst) { // We want to leave I pointing to the previous instruction, but what if we // just erased the first instruction? if (Inst == MBB->begin()) { - DEBUG(dbgs() << "Inserting dummy KILL\n"); + LLVM_DEBUG(dbgs() << "Inserting dummy KILL\n"); Inst = BuildMI(*MBB, Inst, DebugLoc(), TII->get(TargetOpcode::KILL)); } else --Inst; @@ -1673,7 +1680,7 @@ void FPS::setKillFlags(MachineBasicBlock &MBB) const { for (MachineBasicBlock::reverse_iterator I = MBB.rbegin(), E = MBB.rend(); I != E; ++I) { - if (I->isDebugValue()) + if (I->isDebugInstr()) continue; std::bitset<8> Defs; |