mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Give the asmprinter the ability to print memrefs with a constant pool index,
index reg and scale git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17081 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
de95c9e0bb
commit
0e0ed85697
@ -312,26 +312,34 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
||||
void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
||||
assert(isMem(MI, Op) && "Invalid memory reference!");
|
||||
|
||||
if (MI->getOperand(Op).isFrameIndex()) {
|
||||
O << "[frame slot #" << MI->getOperand(Op).getFrameIndex();
|
||||
if (MI->getOperand(Op+3).getImmedValue())
|
||||
O << " + " << MI->getOperand(Op+3).getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
} else if (MI->getOperand(Op).isConstantPoolIndex()) {
|
||||
O << "[.CPI" << CurrentFnName << "_"
|
||||
<< MI->getOperand(Op).getConstantPoolIndex();
|
||||
if (MI->getOperand(Op+3).getImmedValue())
|
||||
O << " + " << MI->getOperand(Op+3).getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
}
|
||||
|
||||
const MachineOperand &BaseReg = MI->getOperand(Op);
|
||||
int ScaleVal = MI->getOperand(Op+1).getImmedValue();
|
||||
const MachineOperand &IndexReg = MI->getOperand(Op+2);
|
||||
const MachineOperand &DispSpec = MI->getOperand(Op+3);
|
||||
|
||||
if (BaseReg.isFrameIndex()) {
|
||||
O << "[frame slot #" << BaseReg.getFrameIndex();
|
||||
if (DispSpec.getImmedValue())
|
||||
O << " + " << DispSpec.getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
} else if (BaseReg.isConstantPoolIndex()) {
|
||||
O << "[.CPI" << CurrentFnName << "_"
|
||||
<< BaseReg.getConstantPoolIndex();
|
||||
|
||||
if (IndexReg.getReg()) {
|
||||
O << " + ";
|
||||
if (ScaleVal != 1)
|
||||
O << ScaleVal << "*";
|
||||
printOp(IndexReg);
|
||||
}
|
||||
|
||||
if (DispSpec.getImmedValue())
|
||||
O << " + " << DispSpec.getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
}
|
||||
|
||||
O << "[";
|
||||
bool NeedPlus = false;
|
||||
if (BaseReg.getReg()) {
|
||||
@ -520,25 +528,32 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
|
||||
void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
||||
assert(isMem(MI, Op) && "Invalid memory reference!");
|
||||
|
||||
if (MI->getOperand(Op).isFrameIndex()) {
|
||||
O << "[frame slot #" << MI->getOperand(Op).getFrameIndex();
|
||||
if (MI->getOperand(Op+3).getImmedValue())
|
||||
O << " + " << MI->getOperand(Op+3).getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
} else if (MI->getOperand(Op).isConstantPoolIndex()) {
|
||||
O << ".CPI" << CurrentFnName << "_"
|
||||
<< MI->getOperand(Op).getConstantPoolIndex();
|
||||
if (MI->getOperand(Op+3).getImmedValue())
|
||||
O << " + " << MI->getOperand(Op+3).getImmedValue();
|
||||
return;
|
||||
}
|
||||
|
||||
const MachineOperand &BaseReg = MI->getOperand(Op);
|
||||
int ScaleVal = MI->getOperand(Op+1).getImmedValue();
|
||||
const MachineOperand &IndexReg = MI->getOperand(Op+2);
|
||||
const MachineOperand &DispSpec = MI->getOperand(Op+3);
|
||||
|
||||
if (BaseReg.isFrameIndex()) {
|
||||
O << "[frame slot #" << BaseReg.getFrameIndex();
|
||||
if (DispSpec.getImmedValue())
|
||||
O << " + " << DispSpec.getImmedValue();
|
||||
O << "]";
|
||||
return;
|
||||
} else if (BaseReg.isConstantPoolIndex()) {
|
||||
O << ".CPI" << CurrentFnName << "_"
|
||||
<< BaseReg.getConstantPoolIndex();
|
||||
if (DispSpec.getImmedValue())
|
||||
O << "+" << DispSpec.getImmedValue();
|
||||
if (IndexReg.getReg()) {
|
||||
O << "(,";
|
||||
printOp(IndexReg);
|
||||
if (ScaleVal != 1)
|
||||
O << "," << ScaleVal;
|
||||
O << ")";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (DispSpec.isGlobalAddress()) {
|
||||
printOp(DispSpec, true);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user