[llvm-commits] [llvm] r114183 - /llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp

Jim Grosbach grosbach at apple.com
Fri Sep 17 09:25:53 PDT 2010


Author: grosbach
Date: Fri Sep 17 11:25:52 2010
New Revision: 114183

URL: http://llvm.org/viewvc/llvm-project?rev=114183&view=rev
Log:
expand PICLDR MC lowering to handle other PICLDR and PICSTR versions.

Modified:
    llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=114183&r1=114182&r2=114183&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Sep 17 11:25:52 2010
@@ -1351,10 +1351,17 @@
     OutStreamer.EmitInstruction(AddInst);
     return;
   }
-  case ARM::PICLDR: {
+  case ARM::PICSTR:
+  case ARM::PICSTRB:
+  case ARM::PICSTRH:
+  case ARM::PICLDR:
+  case ARM::PICLDRB:
+  case ARM::PICLDRH:
+  case ARM::PICLDRSB:
+  case ARM::PICLDRSH: {
     // This is a pseudo op for a label + instruction sequence, which looks like:
     // LPC0:
-    //     ldr r0, [pc, r0]
+    //     OP r0, [pc, r0]
     // The LCP0 label is referenced by a constant pool entry in order to get
     // a PC-relative address at the ldr instruction.
 
@@ -1367,16 +1374,29 @@
     OutStreamer.EmitLabel(Label);
 
     // Form and emit the load
-    MCInst LdrInst;
-    LdrInst.setOpcode(ARM::LDR);
-    LdrInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg()));
-    LdrInst.addOperand(MCOperand::CreateReg(ARM::PC));
-    LdrInst.addOperand(MCOperand::CreateReg(MI->getOperand(1).getReg()));
-    LdrInst.addOperand(MCOperand::CreateImm(0));
+    unsigned Opcode;
+    switch (MI->getOpcode()) {
+    default:
+      llvm_unreachable("Unexpected opcode!");
+    case ARM::PICSTR:   Opcode = ARM::STR; break;
+    case ARM::PICSTRB:  Opcode = ARM::STRB; break;
+    case ARM::PICSTRH:  Opcode = ARM::STRH; break;
+    case ARM::PICLDR:   Opcode = ARM::LDR; break;
+    case ARM::PICLDRB:  Opcode = ARM::LDRB; break;
+    case ARM::PICLDRH:  Opcode = ARM::LDRH; break;
+    case ARM::PICLDRSB: Opcode = ARM::LDRSB; break;
+    case ARM::PICLDRSH: Opcode = ARM::LDRSH; break;
+    }
+    MCInst LdStInst;
+    LdStInst.setOpcode(Opcode);
+    LdStInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg()));
+    LdStInst.addOperand(MCOperand::CreateReg(ARM::PC));
+    LdStInst.addOperand(MCOperand::CreateReg(MI->getOperand(1).getReg()));
+    LdStInst.addOperand(MCOperand::CreateImm(0));
     // Add predicate operands.
-    LdrInst.addOperand(MCOperand::CreateImm(MI->getOperand(3).getImm()));
-    LdrInst.addOperand(MCOperand::CreateReg(MI->getOperand(4).getReg()));
-    OutStreamer.EmitInstruction(LdrInst);
+    LdStInst.addOperand(MCOperand::CreateImm(MI->getOperand(3).getImm()));
+    LdStInst.addOperand(MCOperand::CreateReg(MI->getOperand(4).getReg()));
+    OutStreamer.EmitInstruction(LdStInst);
 
     return;
   }





More information about the llvm-commits mailing list