mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-21 12:38:45 +00:00
A little more progress on StrongPHIElimination, now that I have a better sense of
how the CodeGen machinery works. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
11a4f64bd4
commit
afc6de0015
@ -39,6 +39,9 @@ namespace {
|
|||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {}
|
StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {}
|
||||||
|
|
||||||
|
DenseMap<MachineBasicBlock*,
|
||||||
|
SmallVector<std::pair<unsigned, unsigned>, 2> > Waiting;
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &Fn);
|
bool runOnMachineFunction(MachineFunction &Fn);
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
@ -263,6 +266,8 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
|
|||||||
while (P->getOpcode() == TargetInstrInfo::PHI) {
|
while (P->getOpcode() == TargetInstrInfo::PHI) {
|
||||||
LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg());
|
LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg());
|
||||||
|
|
||||||
|
unsigned DestReg = P->getOperand(0).getReg();
|
||||||
|
|
||||||
// Hold the names that are currently in the candidate set.
|
// Hold the names that are currently in the candidate set.
|
||||||
std::set<unsigned> PHIUnion;
|
std::set<unsigned> PHIUnion;
|
||||||
std::set<MachineBasicBlock*> UnionedBlocks;
|
std::set<MachineBasicBlock*> UnionedBlocks;
|
||||||
@ -271,17 +276,17 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
|
|||||||
unsigned SrcReg = P->getOperand(i-1).getReg();
|
unsigned SrcReg = P->getOperand(i-1).getReg();
|
||||||
LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
|
LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg);
|
||||||
|
|
||||||
if (isLiveIn(SrcInfo, P->getParent())) {
|
// Check for trivial interferences
|
||||||
|
if (isLiveIn(SrcInfo, P->getParent()) ||
|
||||||
|
isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
|
||||||
|
( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
|
||||||
|
isLiveIn(PHIInfo, SrcInfo.DefInst->getParent()) ) ||
|
||||||
|
ProcessedNames.count(SrcReg) ||
|
||||||
|
UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
|
||||||
|
|
||||||
// add a copy from a_i to p in Waiting[From[a_i]]
|
// add a copy from a_i to p in Waiting[From[a_i]]
|
||||||
} else if (isLiveOut(PHIInfo, SrcInfo.DefInst->getParent())) {
|
MachineBasicBlock* From = P->getOperand(i).getMachineBasicBlock();
|
||||||
// add a copy to Waiting[From[a_i]]
|
Waiting[From].push_back(std::make_pair(SrcReg, DestReg));
|
||||||
} else if (PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
|
|
||||||
isLiveIn(PHIInfo, SrcInfo.DefInst->getParent())) {
|
|
||||||
// add a copy to Waiting[From[a_i]]
|
|
||||||
} else if (ProcessedNames.count(SrcReg)) {
|
|
||||||
// add a copy to Waiting[From[a_i]]
|
|
||||||
} else if (UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
|
|
||||||
// add a copy to Waiting[From[a_i]]
|
|
||||||
} else {
|
} else {
|
||||||
PHIUnion.insert(SrcReg);
|
PHIUnion.insert(SrcReg);
|
||||||
UnionedBlocks.insert(SrcInfo.DefInst->getParent());
|
UnionedBlocks.insert(SrcInfo.DefInst->getParent());
|
||||||
@ -291,7 +296,7 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
|
|||||||
std::vector<StrongPHIElimination::DomForestNode*> DF =
|
std::vector<StrongPHIElimination::DomForestNode*> DF =
|
||||||
computeDomForest(PHIUnion);
|
computeDomForest(PHIUnion);
|
||||||
|
|
||||||
// DO STUFF HERE
|
// Walk DomForest to resolve interferences
|
||||||
|
|
||||||
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
|
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
|
||||||
++P;
|
++P;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user