mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[AArch64InstPrinter] Change printADRPLabel to print the target address in hexadecimal form
Similar to D77853. Change ADRP to print the target address in hex, instead of the raw immediate. The behavior is similar to GNU objdump but we also include `0x`. Note: GNU objdump is not consistent whether or not to emit `0x` for different architectures. We try emitting 0x consistently for all targets. ``` GNU objdump: adrp x16, 10000000 Old llvm-objdump: adrp x16, #0 New llvm-objdump: adrp x16, 0x10000000 ``` `adrp Xd, 0x...` assembles to a relocation referencing `*ABS*+0x10000` which is not intended. We need to use a linker or use yaml2obj. The main test is `test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml` Differential Revision: https://reviews.llvm.org/D93241
This commit is contained in:
parent
13ee52e4a2
commit
04f2a7afd9
@ -263,6 +263,7 @@ def adrplabel : Operand<i64> {
|
||||
let EncoderMethod = "getAdrLabelOpValue";
|
||||
let PrintMethod = "printAdrpLabel";
|
||||
let ParserMatchClass = AdrpOperand;
|
||||
let OperandType = "OPERAND_PCREL";
|
||||
}
|
||||
|
||||
def AdrOperand : AsmOperandClass {
|
||||
|
@ -1377,7 +1377,8 @@ void AArch64InstPrinter::printAlignedLabel(const MCInst *MI, uint64_t Address,
|
||||
}
|
||||
}
|
||||
|
||||
void AArch64InstPrinter::printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
||||
void AArch64InstPrinter::printAdrpLabel(const MCInst *MI, uint64_t Address,
|
||||
unsigned OpNum,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &Op = MI->getOperand(OpNum);
|
||||
@ -1385,7 +1386,11 @@ void AArch64InstPrinter::printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
||||
// If the label has already been resolved to an immediate offset (say, when
|
||||
// we're running the disassembler), just print the immediate.
|
||||
if (Op.isImm()) {
|
||||
O << "#" << formatImm(Op.getImm() * (1 << 12));
|
||||
const int64_t Offset = Op.getImm() << 12;
|
||||
if (PrintBranchImmAsAddress)
|
||||
O << formatHex((Address & -4096) + Offset);
|
||||
else
|
||||
O << "#" << Offset;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ protected:
|
||||
|
||||
void printVectorIndex(const MCInst *MI, unsigned OpNum,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
||||
void printAdrpLabel(const MCInst *MI, uint64_t Address, unsigned OpNum,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
void printBarrierOption(const MCInst *MI, unsigned OpNum,
|
||||
const MCSubtargetInfo &STI, raw_ostream &O);
|
||||
|
@ -19,15 +19,15 @@
|
||||
adr x5, (0xffffffff000f1000 - 0xffffffff00000000 + Symbol)
|
||||
adr x6, Symbol + (0xffffffff000f1000 - 0xffffffff00000000)
|
||||
|
||||
// CHECK-NEXT: adrp x0, #0
|
||||
// CHECK-NEXT: adrp x0, 0x0
|
||||
// CHECK-NEXT: R_AARCH64_ADR_PREL_PG_HI21 Symbol
|
||||
// CHECK-NEXT: adrp x2, #0
|
||||
// CHECK-NEXT: adrp x2, 0x0
|
||||
// CHECK-NEXT: R_AARCH64_ADR_PREL_PG_HI21 Symbol
|
||||
// CHECK-NEXT: adrp x3, #0
|
||||
// CHECK-NEXT: adrp x3, 0x0
|
||||
// CHECK-NEXT: R_AARCH64_ADR_PREL_PG_HI21 Symbol+0xf1000
|
||||
// CHECK-NEXT: adrp x4, #0
|
||||
// CHECK-NEXT: adrp x4, 0x0
|
||||
// CHECK-NEXT: R_AARCH64_ADR_PREL_PG_HI21 Symbol+0xf1000
|
||||
// CHECK-NEXT: adrp x5, #0
|
||||
// CHECK-NEXT: adrp x5, 0x0
|
||||
// CHECK-NEXT: R_AARCH64_ADR_PREL_PG_HI21 Symbol+0xf1000
|
||||
|
||||
adrp x0, Symbol
|
||||
|
@ -89,7 +89,7 @@ tbz x0, #0, target
|
||||
; CHECK: }
|
||||
; CHECK: ]
|
||||
|
||||
; DISASM: 30: 20 1a 09 b0 adrp x0, #305418240
|
||||
; DISASM: 30: 20 1a 09 b0 adrp x0, 0x12345000
|
||||
; DISASM: 34: 00 14 0d 91 add x0, x0, #837
|
||||
; DISASM: 38: 00 14 4d 39 ldrb w0, [x0, #837]
|
||||
; DISASM: 3c: 00 a4 41 f9 ldr x0, [x0, #840]
|
||||
|
@ -24,7 +24,7 @@ mystr:
|
||||
# CHECK: 10: 0a 00 .short 0x000a
|
||||
# CHECK: Disassembly of section .myothersection:
|
||||
# CHECK: <$x.2>:
|
||||
# CHECK: 0: 01 00 00 90 adrp x1, #0
|
||||
# CHECK: 0: 01 00 00 90 adrp x1, 0x0
|
||||
# CHECK: <mystr>:
|
||||
# CHECK: 4: 62 6c 61 68 .word
|
||||
# CHECK: 8: 00 .byte 0x01
|
||||
|
26
test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
Normal file
26
test/tools/llvm-objdump/ELF/AArch64/pcrel-address.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
# RUN: yaml2obj %s -o %t
|
||||
# RUN: llvm-objdump %t -d --no-show-raw-insn --no-leading-addr | FileCheck %s
|
||||
|
||||
# CHECK-LABEL: <_start>:
|
||||
# CHECK-NEXT: adrp x2, 0x220000 <_start+0x80>
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_EXEC
|
||||
Machine: EM_AARCH64
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Address: 0x200100
|
||||
Flags: [SHF_ALLOC, SHF_EXECINSTR]
|
||||
Content: '02010090'
|
||||
- Name: .data
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [SHF_ALLOC, SHF_WRITE]
|
||||
Address: 0x220000
|
||||
Symbols:
|
||||
- Name: _start
|
||||
Section: .text
|
||||
Value: 0x200100
|
Loading…
Reference in New Issue
Block a user