add addrmode2 support, getting us up to:
authorChris Lattner <sabre@nondot.org>
Mon, 19 Oct 2009 21:57:05 +0000 (21:57 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 19 Oct 2009 21:57:05 +0000 (21:57 +0000)
_main:
stm ,
mov r7, sp
sub sp, sp, #4
mov r0, #0
str r0, [sp]
ldr r0, LCPI1_0
bl _printf
ldr r0, [sp]
mov sp, r7
ldm ,

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84543 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
lib/Target/ARM/AsmPrinter/ARMInstPrinter.h

index 41be859ce0d2a9699208eca06720a7a43a095986..95ff0a23d64848cea9bae9de43aef0bc0f3952fa 100644 (file)
@@ -77,3 +77,37 @@ void ARMInstPrinter::printSOImmOperand(const MCInst *MI, unsigned OpNum) {
   assert(MO.isImm() && "Not a valid so_imm value!");
   printSOImm(O, MO.getImm(), VerboseAsm, &MAI);
 }
+
+
+
+void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op) {
+  const MCOperand &MO1 = MI->getOperand(Op);
+  const MCOperand &MO2 = MI->getOperand(Op+1);
+  const MCOperand &MO3 = MI->getOperand(Op+2);
+  
+  if (!MO1.isReg()) {   // FIXME: This is for CP entries, but isn't right.
+    printOperand(MI, Op);
+    return;
+  }
+  
+  O << "[" << getRegisterName(MO1.getReg());
+  
+  if (!MO2.getReg()) {
+    if (ARM_AM::getAM2Offset(MO3.getImm()))  // Don't print +0.
+      O << ", #"
+      << (char)ARM_AM::getAM2Op(MO3.getImm())
+      << ARM_AM::getAM2Offset(MO3.getImm());
+    O << "]";
+    return;
+  }
+  
+  O << ", "
+  << (char)ARM_AM::getAM2Op(MO3.getImm())
+  << getRegisterName(MO2.getReg());
+  
+  if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
+    O << ", "
+    << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
+    << " #" << ShImm;
+  O << "]";
+}  
index 2b99dfd3d538d3690678d28282d85e89aec8bfa0..f129c0482c91dcb5e2fdbb4e786e12d20f81c3a6 100644 (file)
@@ -40,7 +40,7 @@ public:
   
   void printSOImm2PartOperand(const MCInst *MI, unsigned OpNum) {}
   void printSORegOperand(const MCInst *MI, unsigned OpNum) {}
-  void printAddrMode2Operand(const MCInst *MI, unsigned OpNum) {}
+  void printAddrMode2Operand(const MCInst *MI, unsigned OpNum);
   void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum) {}
   void printAddrMode3Operand(const MCInst *MI, unsigned OpNum) {}
   void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum) {}