mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
* Keep the BBMap around as long as the pass is live
* Change getVarInfo to take real virtual register numbers and offset them itself. This has caused me so much grief, it's not even funny. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -28,6 +28,26 @@
|
|||||||
|
|
||||||
static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis");
|
static RegisterAnalysis<LiveVariables> X("livevars", "Live Variable Analysis");
|
||||||
|
|
||||||
|
const std::pair<MachineBasicBlock*, unsigned> &
|
||||||
|
LiveVariables::getMachineBasicBlockInfo(MachineBasicBlock *MBB) const{
|
||||||
|
return BBMap.find(MBB->getBasicBlock())->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) {
|
||||||
|
assert(RegIdx >= MRegisterInfo::FirstVirtualRegister &&
|
||||||
|
"getVarInfo: not a virtual register!");
|
||||||
|
RegIdx -= MRegisterInfo::FirstVirtualRegister;
|
||||||
|
if (RegIdx >= VirtRegInfo.size()) {
|
||||||
|
if (RegIdx >= 2*VirtRegInfo.size())
|
||||||
|
VirtRegInfo.resize(RegIdx*2);
|
||||||
|
else
|
||||||
|
VirtRegInfo.resize(2*VirtRegInfo.size());
|
||||||
|
}
|
||||||
|
return VirtRegInfo[RegIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
|
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
|
||||||
const BasicBlock *BB) {
|
const BasicBlock *BB) {
|
||||||
const std::pair<MachineBasicBlock*,unsigned> &Info = BBMap.find(BB)->second;
|
const std::pair<MachineBasicBlock*,unsigned> &Info = BBMap.find(BB)->second;
|
||||||
@@ -195,8 +215,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
MachineOperand &MO = MI->getOperand(i);
|
MachineOperand &MO = MI->getOperand(i);
|
||||||
if (MO.opIsUse() || MO.opIsDefAndUse()) {
|
if (MO.opIsUse() || MO.opIsDefAndUse()) {
|
||||||
if (MO.isVirtualRegister() && !MO.getVRegValueOrNull()) {
|
if (MO.isVirtualRegister() && !MO.getVRegValueOrNull()) {
|
||||||
unsigned RegIdx = MO.getReg()-MRegisterInfo::FirstVirtualRegister;
|
HandleVirtRegUse(getVarInfo(MO.getReg()), MBB, MI);
|
||||||
HandleVirtRegUse(getVarInfo(RegIdx), MBB, MI);
|
|
||||||
} else if (MO.isPhysicalRegister() &&
|
} else if (MO.isPhysicalRegister() &&
|
||||||
AllocatablePhysicalRegisters[MO.getReg()]) {
|
AllocatablePhysicalRegisters[MO.getReg()]) {
|
||||||
HandlePhysRegUse(MO.getReg(), MI);
|
HandlePhysRegUse(MO.getReg(), MI);
|
||||||
@@ -214,8 +233,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
MachineOperand &MO = MI->getOperand(i);
|
MachineOperand &MO = MI->getOperand(i);
|
||||||
if (MO.opIsDef() || MO.opIsDefAndUse()) {
|
if (MO.opIsDef() || MO.opIsDefAndUse()) {
|
||||||
if (MO.isVirtualRegister()) {
|
if (MO.isVirtualRegister()) {
|
||||||
unsigned RegIdx = MO.getReg()-MRegisterInfo::FirstVirtualRegister;
|
VarInfo &VRInfo = getVarInfo(MO.getReg());
|
||||||
VarInfo &VRInfo = getVarInfo(RegIdx);
|
|
||||||
|
|
||||||
assert(VRInfo.DefBlock == 0 && "Variable multiply defined!");
|
assert(VRInfo.DefBlock == 0 && "Variable multiply defined!");
|
||||||
VRInfo.DefBlock = MBB; // Created here...
|
VRInfo.DefBlock = MBB; // Created here...
|
||||||
@@ -245,8 +263,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
if (MI->getOperand(i+1).getMachineBasicBlock() == MBB) {
|
if (MI->getOperand(i+1).getMachineBasicBlock() == MBB) {
|
||||||
MachineOperand &MO = MI->getOperand(i);
|
MachineOperand &MO = MI->getOperand(i);
|
||||||
if (!MO.getVRegValueOrNull()) {
|
if (!MO.getVRegValueOrNull()) {
|
||||||
unsigned RegIdx = MO.getReg()-MRegisterInfo::FirstVirtualRegister;
|
VarInfo &VRInfo = getVarInfo(MO.getReg());
|
||||||
VarInfo &VRInfo = getVarInfo(RegIdx);
|
|
||||||
|
|
||||||
// Only mark it alive only in the block we are representing...
|
// Only mark it alive only in the block we are representing...
|
||||||
MarkVirtRegAliveInBlock(VRInfo, BB);
|
MarkVirtRegAliveInBlock(VRInfo, BB);
|
||||||
@@ -263,8 +280,6 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
HandlePhysRegDef(i, 0);
|
HandlePhysRegDef(i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BBMap.clear();
|
|
||||||
|
|
||||||
// Convert the information we have gathered into VirtRegInfo and transform it
|
// Convert the information we have gathered into VirtRegInfo and transform it
|
||||||
// into a form usable by RegistersKilled.
|
// into a form usable by RegistersKilled.
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user