PLD, PLDW, PLI encodings, plus refactor their use of addrmode2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117571 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMMCCodeEmitter.cpp b/lib/Target/ARM/ARMMCCodeEmitter.cpp
index 1259672..122aadf 100644
--- a/lib/Target/ARM/ARMMCCodeEmitter.cpp
+++ b/lib/Target/ARM/ARMMCCodeEmitter.cpp
@@ -190,9 +190,15 @@
const MCOperand &MO1 = MI.getOperand(OpIdx + 1);
unsigned Reg = getARMRegisterNumbering(MO.getReg());
int32_t Imm12 = MO1.getImm();
- uint32_t Binary;
- Binary = Imm12 & 0xfff;
- if (Imm12 >= 0)
+ bool isAdd = Imm12 >= 0;
+ // Special value for #-0
+ if (Imm12 == INT32_MIN)
+ Imm12 = 0;
+ // Immediate is always encoded as positive. The 'U' bit controls add vs sub.
+ if (Imm12 < 0)
+ Imm12 = -Imm12;
+ uint32_t Binary = Imm12 & 0xfff;
+ if (isAdd)
Binary |= (1 << 12);
Binary |= (Reg << 13);
return Binary;