diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineSSAUpdater.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineSSAUpdater.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/llvm/lib/CodeGen/MachineSSAUpdater.cpp b/llvm/lib/CodeGen/MachineSSAUpdater.cpp index 258a5f9e04820..b12557d6d326d 100644 --- a/llvm/lib/CodeGen/MachineSSAUpdater.cpp +++ b/llvm/lib/CodeGen/MachineSSAUpdater.cpp @@ -34,7 +34,7 @@ using namespace llvm; #define DEBUG_TYPE "machine-ssaupdater" -using AvailableValsTy = DenseMap<MachineBasicBlock *, unsigned>; +using AvailableValsTy = DenseMap<MachineBasicBlock *, Register>; static AvailableValsTy &getAvailableVals(void *AV) { return *static_cast<AvailableValsTy*>(AV); @@ -51,7 +51,7 @@ MachineSSAUpdater::~MachineSSAUpdater() { /// Initialize - Reset this object to get ready for a new set of SSA /// updates. ProtoValue is the value used to name PHI nodes. -void MachineSSAUpdater::Initialize(unsigned V) { +void MachineSSAUpdater::Initialize(Register V) { if (!AV) AV = new AvailableValsTy(); else @@ -69,25 +69,25 @@ bool MachineSSAUpdater::HasValueForBlock(MachineBasicBlock *BB) const { /// AddAvailableValue - Indicate that a rewritten value is available in the /// specified block with the specified value. -void MachineSSAUpdater::AddAvailableValue(MachineBasicBlock *BB, unsigned V) { +void MachineSSAUpdater::AddAvailableValue(MachineBasicBlock *BB, Register V) { getAvailableVals(AV)[BB] = V; } /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is /// live at the end of the specified block. -unsigned MachineSSAUpdater::GetValueAtEndOfBlock(MachineBasicBlock *BB) { +Register MachineSSAUpdater::GetValueAtEndOfBlock(MachineBasicBlock *BB) { return GetValueAtEndOfBlockInternal(BB); } static -unsigned LookForIdenticalPHI(MachineBasicBlock *BB, - SmallVectorImpl<std::pair<MachineBasicBlock *, unsigned>> &PredValues) { +Register LookForIdenticalPHI(MachineBasicBlock *BB, + SmallVectorImpl<std::pair<MachineBasicBlock *, Register>> &PredValues) { if (BB->empty()) - return 0; + return Register(); MachineBasicBlock::iterator I = BB->begin(); if (!I->isPHI()) - return 0; + return Register(); AvailableValsTy AVals; for (unsigned i = 0, e = PredValues.size(); i != e; ++i) @@ -106,7 +106,7 @@ unsigned LookForIdenticalPHI(MachineBasicBlock *BB, return I->getOperand(0).getReg(); ++I; } - return 0; + return Register(); } /// InsertNewDef - Insert an empty PHI or IMPLICIT_DEF instruction which define @@ -140,7 +140,7 @@ MachineInstrBuilder InsertNewDef(unsigned Opcode, /// their respective blocks. However, the use of X happens in the *middle* of /// a block. Because of this, we need to insert a new PHI node in SomeBB to /// merge the appropriate values, and this value isn't live out of the block. -unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { +Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { // If there is no definition of the renamed variable in this block, just use // GetValueAtEndOfBlock to do our work. if (!HasValueForBlock(BB)) @@ -157,14 +157,14 @@ unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { // Otherwise, we have the hard case. Get the live-in values for each // predecessor. - SmallVector<std::pair<MachineBasicBlock*, unsigned>, 8> PredValues; - unsigned SingularValue = 0; + SmallVector<std::pair<MachineBasicBlock*, Register>, 8> PredValues; + Register SingularValue; bool isFirstPred = true; for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(), E = BB->pred_end(); PI != E; ++PI) { MachineBasicBlock *PredBB = *PI; - unsigned PredVal = GetValueAtEndOfBlockInternal(PredBB); + Register PredVal = GetValueAtEndOfBlockInternal(PredBB); PredValues.push_back(std::make_pair(PredBB, PredVal)); // Compute SingularValue. @@ -172,15 +172,15 @@ unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { SingularValue = PredVal; isFirstPred = false; } else if (PredVal != SingularValue) - SingularValue = 0; + SingularValue = Register(); } // Otherwise, if all the merged values are the same, just use it. - if (SingularValue != 0) + if (SingularValue) return SingularValue; // If an identical PHI is already in BB, just reuse it. - unsigned DupPHI = LookForIdenticalPHI(BB, PredValues); + Register DupPHI = LookForIdenticalPHI(BB, PredValues); if (DupPHI) return DupPHI; @@ -204,7 +204,7 @@ unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); LLVM_DEBUG(dbgs() << " Inserted PHI: " << *InsertedPHI << "\n"); - return InsertedPHI->getOperand(0).getReg(); + return InsertedPHI.getReg(0); } static @@ -222,7 +222,7 @@ MachineBasicBlock *findCorrespondingPred(const MachineInstr *MI, /// which use their value in the corresponding predecessor. void MachineSSAUpdater::RewriteUse(MachineOperand &U) { MachineInstr *UseMI = U.getParent(); - unsigned NewVR = 0; + Register NewVR; if (UseMI->isPHI()) { MachineBasicBlock *SourceBB = findCorrespondingPred(UseMI, &U); NewVR = GetValueAtEndOfBlockInternal(SourceBB); @@ -241,7 +241,7 @@ template<> class SSAUpdaterTraits<MachineSSAUpdater> { public: using BlkT = MachineBasicBlock; - using ValT = unsigned; + using ValT = Register; using PhiT = MachineInstr; using BlkSucc_iterator = MachineBasicBlock::succ_iterator; @@ -288,7 +288,7 @@ public: /// GetUndefVal - Create an IMPLICIT_DEF instruction with a new register. /// Add it into the specified block and return the register. - static unsigned GetUndefVal(MachineBasicBlock *BB, + static Register GetUndefVal(MachineBasicBlock *BB, MachineSSAUpdater *Updater) { // Insert an implicit_def to represent an undef value. MachineInstr *NewDef = InsertNewDef(TargetOpcode::IMPLICIT_DEF, @@ -300,7 +300,7 @@ public: /// CreateEmptyPHI - Create a PHI instruction that defines a new register. /// Add it into the specified block and return the register. - static unsigned CreateEmptyPHI(MachineBasicBlock *BB, unsigned NumPreds, + static Register CreateEmptyPHI(MachineBasicBlock *BB, unsigned NumPreds, MachineSSAUpdater *Updater) { MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->begin(); MachineInstr *PHI = InsertNewDef(TargetOpcode::PHI, BB, Loc, @@ -311,7 +311,7 @@ public: /// AddPHIOperand - Add the specified value as an operand of the PHI for /// the specified predecessor block. - static void AddPHIOperand(MachineInstr *PHI, unsigned Val, + static void AddPHIOperand(MachineInstr *PHI, Register Val, MachineBasicBlock *Pred) { MachineInstrBuilder(*Pred->getParent(), PHI).addReg(Val).addMBB(Pred); } @@ -325,13 +325,13 @@ public: /// ValueIsPHI - Check if the instruction that defines the specified register /// is a PHI instruction. - static MachineInstr *ValueIsPHI(unsigned Val, MachineSSAUpdater *Updater) { + static MachineInstr *ValueIsPHI(Register Val, MachineSSAUpdater *Updater) { return InstrIsPHI(Updater->MRI->getVRegDef(Val)); } /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source /// operands, i.e., it was just added. - static MachineInstr *ValueIsNewPHI(unsigned Val, MachineSSAUpdater *Updater) { + static MachineInstr *ValueIsNewPHI(Register Val, MachineSSAUpdater *Updater) { MachineInstr *PHI = ValueIsPHI(Val, Updater); if (PHI && PHI->getNumOperands() <= 1) return PHI; @@ -340,7 +340,7 @@ public: /// GetPHIValue - For the specified PHI instruction, return the register /// that it defines. - static unsigned GetPHIValue(MachineInstr *PHI) { + static Register GetPHIValue(MachineInstr *PHI) { return PHI->getOperand(0).getReg(); } }; @@ -351,9 +351,9 @@ public: /// for the specified BB and if so, return it. If not, construct SSA form by /// first calculating the required placement of PHIs and then inserting new /// PHIs where needed. -unsigned MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){ +Register MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){ AvailableValsTy &AvailableVals = getAvailableVals(AV); - if (unsigned V = AvailableVals[BB]) + if (Register V = AvailableVals[BB]) return V; SSAUpdaterImpl<MachineSSAUpdater> Impl(this, &AvailableVals, InsertedPHIs); |