mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Begin adding support for updating LiveIntervals in TwoAddressInstructionPass.
This is far from complete, and only changes behavior when the -early-live-intervals flag is passed to llc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
24e79e55da
commit
5bfdedf6ab
@ -30,6 +30,7 @@
|
||||
#define DEBUG_TYPE "twoaddrinstr"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||
#include "llvm/CodeGen/LiveVariables.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
@ -65,6 +66,8 @@ namespace {
|
||||
const InstrItineraryData *InstrItins;
|
||||
MachineRegisterInfo *MRI;
|
||||
LiveVariables *LV;
|
||||
SlotIndexes *Indexes;
|
||||
LiveIntervals *LIS;
|
||||
AliasAnalysis *AA;
|
||||
CodeGenOpt::Level OptLevel;
|
||||
|
||||
@ -150,6 +153,8 @@ namespace {
|
||||
AU.setPreservesCFG();
|
||||
AU.addRequired<AliasAnalysis>();
|
||||
AU.addPreserved<LiveVariables>();
|
||||
AU.addPreserved<SlotIndexes>();
|
||||
AU.addPreserved<LiveIntervals>();
|
||||
AU.addPreservedID(MachineLoopInfoID);
|
||||
AU.addPreservedID(MachineDominatorsID);
|
||||
MachineFunctionPass::getAnalysisUsage(AU);
|
||||
@ -280,6 +285,9 @@ bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB,
|
||||
MBB->remove(MI);
|
||||
MBB->insert(KillPos, MI);
|
||||
|
||||
if (LIS)
|
||||
LIS->handleMove(MI);
|
||||
|
||||
++Num3AddrSunk;
|
||||
return true;
|
||||
}
|
||||
@ -537,6 +545,8 @@ TwoAddressInstructionPass::CommuteInstruction(MachineBasicBlock::iterator &mi,
|
||||
if (LV)
|
||||
// Update live variables
|
||||
LV->replaceKillInstruction(RegC, MI, NewMI);
|
||||
if (Indexes)
|
||||
Indexes->replaceMachineInstrInMaps(MI, NewMI);
|
||||
|
||||
mbbi->insert(mi, NewMI); // Insert the new inst
|
||||
mbbi->erase(mi); // Nuke the old inst.
|
||||
@ -585,6 +595,9 @@ TwoAddressInstructionPass::ConvertInstTo3Addr(MachineBasicBlock::iterator &mi,
|
||||
DEBUG(dbgs() << "2addr: TO 3-ADDR: " << *NewMI);
|
||||
bool Sunk = false;
|
||||
|
||||
if (Indexes)
|
||||
Indexes->replaceMachineInstrInMaps(mi, NewMI);
|
||||
|
||||
if (NewMI->findRegisterUseOperand(RegB, false, TRI))
|
||||
// FIXME: Temporary workaround. If the new instruction doesn't
|
||||
// uses RegB, convertToThreeAddress must have created more
|
||||
@ -823,6 +836,8 @@ TwoAddressInstructionPass::RescheduleMIBelowKill(MachineBasicBlock *MBB,
|
||||
// Update live variables
|
||||
LV->removeVirtualRegisterKilled(Reg, KillMI);
|
||||
LV->addVirtualRegisterKilled(Reg, MI);
|
||||
if (LIS)
|
||||
LIS->handleMove(MI);
|
||||
|
||||
DEBUG(dbgs() << "\trescheduled below kill: " << *KillMI);
|
||||
return true;
|
||||
@ -977,6 +992,8 @@ TwoAddressInstructionPass::RescheduleKillAboveMI(MachineBasicBlock *MBB,
|
||||
// Update live variables
|
||||
LV->removeVirtualRegisterKilled(Reg, KillMI);
|
||||
LV->addVirtualRegisterKilled(Reg, MI);
|
||||
if (LIS)
|
||||
LIS->handleMove(KillMI);
|
||||
|
||||
DEBUG(dbgs() << "\trescheduled kill: " << *KillMI);
|
||||
return true;
|
||||
@ -1181,7 +1198,9 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
TII = TM.getInstrInfo();
|
||||
TRI = TM.getRegisterInfo();
|
||||
InstrItins = TM.getInstrItineraryData();
|
||||
Indexes = getAnalysisIfAvailable<SlotIndexes>();
|
||||
LV = getAnalysisIfAvailable<LiveVariables>();
|
||||
LIS = getAnalysisIfAvailable<LiveIntervals>();
|
||||
AA = &getAnalysis<AliasAnalysis>();
|
||||
OptLevel = TM.getOptLevel();
|
||||
|
||||
@ -1341,6 +1360,10 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
DistanceMap.insert(std::make_pair(prevMI, Dist));
|
||||
DistanceMap[mi] = ++Dist;
|
||||
|
||||
SlotIndex CopyIdx;
|
||||
if (Indexes)
|
||||
CopyIdx = Indexes->insertMachineInstrInMaps(prevMI).getRegSlot();
|
||||
|
||||
DEBUG(dbgs() << "\t\tprepend:\t" << *prevMI);
|
||||
|
||||
MachineOperand &MO = mi->getOperand(SrcIdx);
|
||||
|
Loading…
Reference in New Issue
Block a user