llvm.org GIT mirror llvm / 8ba1474
ARM: Better disassembly for pc-relative LDR. When the operand is a plain immediate rather than a label, print it as [pc, #imm] like we do for the Thumb2 wide encoding variant. rdar://12154503 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166991 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Grosbach 8 years ago
9 changed file(s) with 15 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
222222 def t_addrmode_pc : Operand {
223223 let EncoderMethod = "getAddrModePCOpValue";
224224 let DecoderMethod = "DecodeThumbAddrModePC";
225 let PrintMethod = "printThumbLdrLabelOperand";
225226 }
226227
227228 //===----------------------------------------------------------------------===//
158158 // t2ldrlabel := imm12
159159 def t2ldrlabel : Operand {
160160 let EncoderMethod = "getAddrModeImm12OpValue";
161 let PrintMethod = "printT2LdrLabelOperand";
161 let PrintMethod = "printThumbLdrLabelOperand";
162162 }
163163
164164 def t2ldr_pcrel_imm12_asmoperand : AsmOperandClass {let Name = "MemPCRelImm12";}
282282 }
283283 }
284284
285 void ARMInstPrinter::printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum,
286 raw_ostream &O) {
285 void ARMInstPrinter::printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
286 raw_ostream &O) {
287287 const MCOperand &MO1 = MI->getOperand(OpNum);
288288 if (MO1.isExpr())
289289 O << *MO1.getExpr();
125125 void printRotImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
126126
127127 void printPCLabel(const MCInst *MI, unsigned OpNum, raw_ostream &O);
128 void printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
128 void printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
129 raw_ostream &O);
129130 void printFBits16(const MCInst *MI, unsigned OpNum, raw_ostream &O);
130131 void printFBits32(const MCInst *MI, unsigned OpNum, raw_ostream &O);
131132 void printVectorIndex(const MCInst *MI, unsigned OpNum, raw_ostream &O);
258258
259259 @ CHECK: ldr r1, _foo @ encoding: [A,0x49]
260260 @ fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_cp
261 @ CHECK: ldr r3, #604 @ encoding: [0x97,0x4b]
262 @ CHECK: ldr r3, #368 @ encoding: [0x5c,0x4b]
261 @ CHECK: ldr r3, [pc, #604] @ encoding: [0x97,0x4b]
262 @ CHECK: ldr r3, [pc, #368] @ encoding: [0x5c,0x4b]
263263
264264 @------------------------------------------------------------------------------
265265 @ LDR (register)
0 # RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -mdis < %s | FileCheck %s
1 # CHECK: ldr , >
1 # CHECK: ldr , ]>
22 0x08 0x4c
33 # CHECK: push {, , }
44 0x86 0xb4
66 # CHECK-NEXT: add r3, sp, #20
77 # CHECK-NEXT: ldr r5, [r3], #4
88 # CHECK-NEXT: str r3, [sp]
9 # CHECK-NEXT: ldr r3, #52
9 # CHECK-NEXT: ldr r3, [pc, #52]
1010 # CHECK-NEXT: add r3, pc
1111 # CHECK-NEXT: ldr r0, [r3]
1212 # CHECK-NEXT: ldr r4, [r0]
13 # CHECK-NEXT: ldr r0, #48
13 # CHECK-NEXT: ldr r0, [pc, #48]
1414 # CHECK-NEXT: add r0, pc
1515 # CHECK-NEXT: ldr r0, [r0]
1616 # CHECK-NEXT: ldr r0, [r0]
1717 # CHECK-NEXT: blx #191548
1818 # CHECK-NEXT: cbnz r0, #6
19 # CHECK-NEXT: ldr r1, #40
19 # CHECK-NEXT: ldr r1, [pc, #40]
2020 # CHECK-NEXT: add r1, pc
2121 # CHECK-NEXT: ldr r1, [r1]
2222 # CHECK-NEXT: b #0
2929 # CHECK: ldm r0!, {r1}
3030 0x02 0xc8
3131
32 # CHECK: ldr r5, #432
32 # CHECK: ldr r5, [pc, #432]
3333 0x6c 0x4d
3434
3535 # CHECK: str r0, [r3]
159159 # CHECK: ldr r1, [sp]
160160 # CHECK: ldr r2, [sp, #24]
161161 # CHECK: ldr r3, [sp, #1020]
162 # CHECK: ldr r1, [pc, #12]
162163
163164
164165 0x29 0x68
167168 0x00 0x99
168169 0x06 0x9a
169170 0xff 0x9b
171 0x03 0x49
170172
171173 #------------------------------------------------------------------------------
172174 # LDR (register)