[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 17 00:16:46 PDT 2004
Changes in directory llvm/lib/Target/X86:
X86AsmPrinter.cpp updated: 1.125 -> 1.126
---
Log message:
Give the asmprinter the ability to print memrefs with a constant pool index,
index reg and scale
---
Diffs of the changes: (+41 -26)
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.125 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.126
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.125 Thu Oct 14 23:44:53 2004
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp Sun Oct 17 02:16:32 2004
@@ -312,26 +312,34 @@
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();
+ 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 (MI->getOperand(Op).isConstantPoolIndex()) {
+ } else if (BaseReg.isConstantPoolIndex()) {
O << "[.CPI" << CurrentFnName << "_"
- << MI->getOperand(Op).getConstantPoolIndex();
- if (MI->getOperand(Op+3).getImmedValue())
- O << " + " << MI->getOperand(Op+3).getImmedValue();
+ << BaseReg.getConstantPoolIndex();
+
+ if (IndexReg.getReg()) {
+ O << " + ";
+ if (ScaleVal != 1)
+ O << ScaleVal << "*";
+ printOp(IndexReg);
+ }
+
+ if (DispSpec.getImmedValue())
+ O << " + " << DispSpec.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);
-
O << "[";
bool NeedPlus = false;
if (BaseReg.getReg()) {
@@ -520,25 +528,32 @@
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();
+ 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 (MI->getOperand(Op).isConstantPoolIndex()) {
+ } else if (BaseReg.isConstantPoolIndex()) {
O << ".CPI" << CurrentFnName << "_"
- << MI->getOperand(Op).getConstantPoolIndex();
- if (MI->getOperand(Op+3).getImmedValue())
- O << " + " << MI->getOperand(Op+3).getImmedValue();
+ << BaseReg.getConstantPoolIndex();
+ if (DispSpec.getImmedValue())
+ O << "+" << DispSpec.getImmedValue();
+ if (IndexReg.getReg()) {
+ O << "(,";
+ printOp(IndexReg);
+ if (ScaleVal != 1)
+ O << "," << ScaleVal;
+ 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 (DispSpec.isGlobalAddress()) {
printOp(DispSpec, true);
} else {
More information about the llvm-commits
mailing list