#include "llvm/Transforms/Utils/SSAUpdaterImpl.h"
using namespace llvm;
+#define DEBUG_TYPE "machine-ssaupdater"
+
typedef DenseMap<MachineBasicBlock*, unsigned> AvailableValsTy;
static AvailableValsTy &getAvailableVals(void *AV) {
return *static_cast<AvailableValsTy*>(AV);
MachineSSAUpdater::MachineSSAUpdater(MachineFunction &MF,
SmallVectorImpl<MachineInstr*> *NewPHI)
- : AV(0), InsertedPHIs(NewPHI) {
+ : AV(nullptr), InsertedPHIs(NewPHI) {
TII = MF.getTarget().getInstrInfo();
MRI = &MF.getRegInfo();
}
/// 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) {
- if (AV == 0)
+ if (!AV)
AV = new AvailableValsTy();
else
getAvailableVals(AV).clear();
U.setReg(NewVR);
}
-void MachineSSAUpdater::ReplaceRegWith(unsigned OldReg, unsigned NewReg) {
- MRI->replaceRegWith(OldReg, NewReg);
-
- AvailableValsTy &AvailableVals = getAvailableVals(AV);
- for (DenseMap<MachineBasicBlock*, unsigned>::iterator
- I = AvailableVals.begin(), E = AvailableVals.end(); I != E; ++I)
- if (I->second == OldReg)
- I->second = NewReg;
-}
-
/// SSAUpdaterTraits<MachineSSAUpdater> - Traits for the SSAUpdaterImpl
/// template, specialized for MachineSSAUpdater.
namespace llvm {
static MachineInstr *InstrIsPHI(MachineInstr *I) {
if (I && I->isPHI())
return I;
- return 0;
+ return nullptr;
}
/// ValueIsPHI - Check if the instruction that defines the specified register
MachineInstr *PHI = ValueIsPHI(Val, Updater);
if (PHI && PHI->getNumOperands() <= 1)
return PHI;
- return 0;
+ return nullptr;
}
/// GetPHIValue - For the specified PHI instruction, return the register