mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 21:34:23 +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);
|
.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)
|
if (I.getType () == Type::VoidTy)
|
||||||
return;
|
return;
|
||||||
unsigned DestReg = getReg (I);
|
unsigned DestReg = getReg (I);
|
||||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||||
if (!I.isConditional()) { // Unconditional branch?
|
if (!I.isConditional()) { // Unconditional branch?
|
||||||
if (I.getSuccessor(0) != NextBB)
|
if (I.getSuccessor(0) != NextBB)
|
||||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||||
if (notTakenSucc == NextBB) {
|
if (notTakenSucc == NextBB) {
|
||||||
if (takenSucc != NextBB)
|
if (takenSucc != NextBB)
|
||||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||||
} else {
|
} else {
|
||||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||||
if (takenSucc != NextBB)
|
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();
|
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
// Print a label for the basic block.
|
// Print a label for the basic block.
|
||||||
O << ".LBB" << NumberForBB[I->getBasicBlock()] << ":\t! "
|
O << ".LBB" << Mang->getValueName(MF.getFunction ())
|
||||||
<< I->getBasicBlock()->getName() << "\n";
|
<< "_" << I->getNumber () << ":\t! "
|
||||||
|
<< I->getBasicBlock ()->getName () << "\n";
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
@ -405,19 +406,17 @@ void V8Printer::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
case MachineOperand::MO_UnextendedImmed:
|
case MachineOperand::MO_UnextendedImmed:
|
||||||
O << (int)MO.getImmedValue();
|
O << (int)MO.getImmedValue();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_PCRelativeDisp: {
|
case MachineOperand::MO_MachineBasicBlock: {
|
||||||
if (isa<GlobalValue> (MO.getVRegValue ())) {
|
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
||||||
O << Mang->getValueName (MO.getVRegValue ());
|
O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
|
||||||
break;
|
<< "_" << MBBOp->getNumber () << "\t! "
|
||||||
}
|
<< MBBOp->getBasicBlock ()->getName ();
|
||||||
assert (isa<BasicBlock> (MO.getVRegValue ())
|
return;
|
||||||
&& "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_PCRelativeDisp:
|
||||||
|
std::cerr << "Shouldn't use addPCDisp() when building SparcV8 MachineInstrs";
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
O << Mang->getValueName(MO.getGlobal());
|
||||||
break;
|
break;
|
||||||
|
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
|||||||
.addReg (ArgReg);
|
.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)
|
if (I.getType () == Type::VoidTy)
|
||||||
return;
|
return;
|
||||||
unsigned DestReg = getReg (I);
|
unsigned DestReg = getReg (I);
|
||||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||||
if (!I.isConditional()) { // Unconditional branch?
|
if (!I.isConditional()) { // Unconditional branch?
|
||||||
if (I.getSuccessor(0) != NextBB)
|
if (I.getSuccessor(0) != NextBB)
|
||||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||||
if (notTakenSucc == NextBB) {
|
if (notTakenSucc == NextBB) {
|
||||||
if (takenSucc != NextBB)
|
if (takenSucc != NextBB)
|
||||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||||
} else {
|
} else {
|
||||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||||
if (takenSucc != NextBB)
|
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);
|
.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)
|
if (I.getType () == Type::VoidTy)
|
||||||
return;
|
return;
|
||||||
unsigned DestReg = getReg (I);
|
unsigned DestReg = getReg (I);
|
||||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||||
if (!I.isConditional()) { // Unconditional branch?
|
if (!I.isConditional()) { // Unconditional branch?
|
||||||
if (I.getSuccessor(0) != NextBB)
|
if (I.getSuccessor(0) != NextBB)
|
||||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||||
if (notTakenSucc == NextBB) {
|
if (notTakenSucc == NextBB) {
|
||||||
if (takenSucc != NextBB)
|
if (takenSucc != NextBB)
|
||||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||||
} else {
|
} else {
|
||||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||||
if (takenSucc != NextBB)
|
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();
|
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
// Print a label for the basic block.
|
// Print a label for the basic block.
|
||||||
O << ".LBB" << NumberForBB[I->getBasicBlock()] << ":\t! "
|
O << ".LBB" << Mang->getValueName(MF.getFunction ())
|
||||||
<< I->getBasicBlock()->getName() << "\n";
|
<< "_" << I->getNumber () << ":\t! "
|
||||||
|
<< I->getBasicBlock ()->getName () << "\n";
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
// Print the assembly for the instruction.
|
// Print the assembly for the instruction.
|
||||||
@ -405,19 +406,17 @@ void V8Printer::printOperand(const MachineInstr *MI, int opNum) {
|
|||||||
case MachineOperand::MO_UnextendedImmed:
|
case MachineOperand::MO_UnextendedImmed:
|
||||||
O << (int)MO.getImmedValue();
|
O << (int)MO.getImmedValue();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_PCRelativeDisp: {
|
case MachineOperand::MO_MachineBasicBlock: {
|
||||||
if (isa<GlobalValue> (MO.getVRegValue ())) {
|
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
||||||
O << Mang->getValueName (MO.getVRegValue ());
|
O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
|
||||||
break;
|
<< "_" << MBBOp->getNumber () << "\t! "
|
||||||
}
|
<< MBBOp->getBasicBlock ()->getName ();
|
||||||
assert (isa<BasicBlock> (MO.getVRegValue ())
|
return;
|
||||||
&& "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_PCRelativeDisp:
|
||||||
|
std::cerr << "Shouldn't use addPCDisp() when building SparcV8 MachineInstrs";
|
||||||
|
abort ();
|
||||||
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
O << Mang->getValueName(MO.getGlobal());
|
||||||
break;
|
break;
|
||||||
|
@ -452,7 +452,7 @@ void V8ISel::visitCallInst(CallInst &I) {
|
|||||||
.addReg (ArgReg);
|
.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)
|
if (I.getType () == Type::VoidTy)
|
||||||
return;
|
return;
|
||||||
unsigned DestReg = getReg (I);
|
unsigned DestReg = getReg (I);
|
||||||
@ -509,7 +509,7 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BasicBlock *takenSucc = I.getSuccessor (0);
|
BasicBlock *takenSucc = I.getSuccessor (0);
|
||||||
if (!I.isConditional()) { // Unconditional branch?
|
if (!I.isConditional()) { // Unconditional branch?
|
||||||
if (I.getSuccessor(0) != NextBB)
|
if (I.getSuccessor(0) != NextBB)
|
||||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,11 +519,11 @@ void V8ISel::visitBranchInst(BranchInst &I) {
|
|||||||
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
BuildMI (BB, V8::CMPri, 2).addSImm (0).addReg (CondReg);
|
||||||
if (notTakenSucc == NextBB) {
|
if (notTakenSucc == NextBB) {
|
||||||
if (takenSucc != NextBB)
|
if (takenSucc != NextBB)
|
||||||
BuildMI (BB, V8::BNE, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BNE, 1).addMBB (MBBMap[takenSucc]);
|
||||||
} else {
|
} else {
|
||||||
BuildMI (BB, V8::BE, 1).addPCDisp (notTakenSucc);
|
BuildMI (BB, V8::BE, 1).addMBB (MBBMap[notTakenSucc]);
|
||||||
if (takenSucc != NextBB)
|
if (takenSucc != NextBB)
|
||||||
BuildMI (BB, V8::BA, 1).addPCDisp (takenSucc);
|
BuildMI (BB, V8::BA, 1).addMBB (MBBMap[takenSucc]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user