[llvm-commits] [llvm] r117978 - /llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp

Jim Grosbach grosbach at apple.com
Mon Nov 1 16:45:50 PDT 2010


Author: grosbach
Date: Mon Nov  1 18:45:50 2010
New Revision: 117978

URL: http://llvm.org/viewvc/llvm-project?rev=117978&view=rev
Log:
Explicitly check for non-consant reference in an LDRi12 instruction. Add FIXME
for handling the fixup necessary.

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

Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=117978&r1=117977&r2=117978&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon Nov  1 18:45:50 2010
@@ -178,6 +178,15 @@
   // {11-0}  = imm12
   const MCOperand &MO  = MI.getOperand(OpIdx);
   const MCOperand &MO1 = MI.getOperand(OpIdx + 1);
+  uint32_t Binary = 0;
+
+  // If The first operand isn't a register, we have a label reference.
+  if (!MO.isReg()) {
+    Binary |= ARM::PC << 13;     // Rn is PC.
+    // FIXME: Add a fixup referencing the label.
+    return Binary;
+  }
+
   unsigned Reg = getARMRegisterNumbering(MO.getReg());
   int32_t Imm12 = MO1.getImm();
   bool isAdd = Imm12 >= 0;
@@ -187,7 +196,7 @@
   // Immediate is always encoded as positive. The 'U' bit controls add vs sub.
   if (Imm12 < 0)
     Imm12 = -Imm12;
-  uint32_t Binary = Imm12 & 0xfff;
+  Binary = Imm12 & 0xfff;
   if (isAdd)
     Binary |= (1 << 12);
   Binary |= (Reg << 13);





More information about the llvm-commits mailing list