mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Use addGlobalAddress and addMBB for call & branch targets instead of addPCDisp.
Abort if we see a PCRelativeDisp MachineOperand, to be safe. This matches the X86 backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f70c22b019
commit
09c1309814
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
||||
.addReg (ArgReg);
|
||||
}
|
||||
|
||||
BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
|
||||
BuildMI (BB, V8::CALL, 1).addGlobalAddress(I.getCalledFunction (), true);
|
||||
if (I.getType () == Type::VoidTy)
|
||||
return;
|
||||
unsigned DestReg = getReg (I);
|
||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||
if (!I.isConditional()) { // Unconditional branch?
|
||||
if (I.getSuccessor(0) != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||
if (notTakenSucc == NextBB) {
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||
} else {
|
||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
||||
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,8 +353,9 @@ bool V8Printer::runOnMachineFunction(MachineFunction &MF) {
|
||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||
I != E; ++I) {
|
||||
// Print a label for the basic block.
|
||||
O << ".LBB" << NumberForBB[I->getBasicBlock()] << ":\t! "
|
||||
<< I->getBasicBlock()->getName() << "\n";
|
||||
O << ".LBB" << Mang->getValueName(MF.getFunction ())
|
||||
<< "_" << I->getNumber () << ":\t! "
|
||||
<< I->getBasicBlock ()->getName () << "\n";
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
@ -405,19 +406,17 @@ void V8Printer::printOperand(const MachineInstr *MI, int opNum) {
|
||||
case MachineOperand::MO_UnextendedImmed:
|
||||
O << (int)MO.getImmedValue();
|
||||
break;
|
||||
case MachineOperand::MO_PCRelativeDisp: {
|
||||
if (isa<GlobalValue> (MO.getVRegValue ())) {
|
||||
O << Mang->getValueName (MO.getVRegValue ());
|
||||
break;
|
||||
}
|
||||
assert (isa<BasicBlock> (MO.getVRegValue ())
|
||||
&& "Trying to look up something which is not a BB in the NumberForBB map");
|
||||
ValueMapTy::const_iterator i = NumberForBB.find(MO.getVRegValue());
|
||||
assert (i != NumberForBB.end()
|
||||
&& "Could not find a BB in the NumberForBB map!");
|
||||
O << ".LBB" << i->second << " ! PC rel: " << MO.getVRegValue()->getName();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock: {
|
||||
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
||||
O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
|
||||
<< "_" << MBBOp->getNumber () << "\t! "
|
||||
<< MBBOp->getBasicBlock ()->getName ();
|
||||
return;
|
||||
}
|
||||
case MachineOperand::MO_PCRelativeDisp:
|
||||
std::cerr << "Shouldn't use addPCDisp() when building SparcV8 MachineInstrs";
|
||||
abort ();
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << Mang->getValueName(MO.getGlobal());
|
||||
break;
|
||||
|
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
||||
.addReg (ArgReg);
|
||||
}
|
||||
|
||||
BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
|
||||
BuildMI (BB, V8::CALL, 1).addGlobalAddress(I.getCalledFunction (), true);
|
||||
if (I.getType () == Type::VoidTy)
|
||||
return;
|
||||
unsigned DestReg = getReg (I);
|
||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||
if (!I.isConditional()) { // Unconditional branch?
|
||||
if (I.getSuccessor(0) != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||
if (notTakenSucc == NextBB) {
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||
} else {
|
||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
||||
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
||||
.addReg (ArgReg);
|
||||
}
|
||||
|
||||
BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
|
||||
BuildMI (BB, V8::CALL, 1).addGlobalAddress(I.getCalledFunction (), true);
|
||||
if (I.getType () == Type::VoidTy)
|
||||
return;
|
||||
unsigned DestReg = getReg (I);
|
||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||
if (!I.isConditional()) { // Unconditional branch?
|
||||
if (I.getSuccessor(0) != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||
if (notTakenSucc == NextBB) {
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||
} else {
|
||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
||||
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,8 +353,9 @@ bool V8Printer::runOnMachineFunction(MachineFunction &MF) {
|
||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||
I != E; ++I) {
|
||||
// Print a label for the basic block.
|
||||
O << ".LBB" << NumberForBB[I->getBasicBlock()] << ":\t! "
|
||||
<< I->getBasicBlock()->getName() << "\n";
|
||||
O << ".LBB" << Mang->getValueName(MF.getFunction ())
|
||||
<< "_" << I->getNumber () << ":\t! "
|
||||
<< I->getBasicBlock ()->getName () << "\n";
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
@ -405,19 +406,17 @@ void V8Printer::printOperand(const MachineInstr *MI, int opNum) {
|
||||
case MachineOperand::MO_UnextendedImmed:
|
||||
O << (int)MO.getImmedValue();
|
||||
break;
|
||||
case MachineOperand::MO_PCRelativeDisp: {
|
||||
if (isa<GlobalValue> (MO.getVRegValue ())) {
|
||||
O << Mang->getValueName (MO.getVRegValue ());
|
||||
break;
|
||||
}
|
||||
assert (isa<BasicBlock> (MO.getVRegValue ())
|
||||
&& "Trying to look up something which is not a BB in the NumberForBB map");
|
||||
ValueMapTy::const_iterator i = NumberForBB.find(MO.getVRegValue());
|
||||
assert (i != NumberForBB.end()
|
||||
&& "Could not find a BB in the NumberForBB map!");
|
||||
O << ".LBB" << i->second << " ! PC rel: " << MO.getVRegValue()->getName();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock: {
|
||||
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
||||
O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
|
||||
<< "_" << MBBOp->getNumber () << "\t! "
|
||||
<< MBBOp->getBasicBlock ()->getName ();
|
||||
return;
|
||||
}
|
||||
case MachineOperand::MO_PCRelativeDisp:
|
||||
std::cerr << "Shouldn't use addPCDisp() when building SparcV8 MachineInstrs";
|
||||
abort ();
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << Mang->getValueName(MO.getGlobal());
|
||||
break;
|
||||
|
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
||||
.addReg (ArgReg);
|
||||
}
|
||||
|
||||
BuildMI (BB, V8::CALL, 1).addPCDisp (I.getOperand (0));
|
||||
BuildMI (BB, V8::CALL, 1).addGlobalAddress(I.getCalledFunction (), true);
|
||||
if (I.getType () == Type::VoidTy)
|
||||
return;
|
||||
unsigned DestReg = getReg (I);
|
||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||
if (!I.isConditional()) { // Unconditional branch?
|
||||
if (I.getSuccessor(0) != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||
if (notTakenSucc == NextBB) {
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||
} else {
|
||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
||||
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||
if (takenSucc != NextBB)
|
||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
||||
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user