Skip to content

Commit 6de2628

Browse files
committed
[M68k] Change printing of absolute memory references
This also includes PC-relative addresses since they are still referenced as absolute addresses in assembly and converted to relative addresses by the assembler. This changes, for example: - `bra #-2` -> `bra $100` - `jsr #16` -> `jsr $10` Differential Revision: https://reviews.llvm.org/D100697
1 parent 8030481 commit 6de2628

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,14 @@ void M68kInstPrinter::printARIIMem(const MCInst *MI, unsigned opNum,
192192
void M68kInstPrinter::printAbsMem(const MCInst *MI, unsigned opNum,
193193
raw_ostream &O) {
194194
const MCOperand &MO = MI->getOperand(opNum);
195-
if (MO.isImm()) {
196-
// ??? Print it in hex?
197-
O << (unsigned int)MO.getImm();
198-
} else {
199-
printOperand(MI, opNum, O);
195+
196+
if (MO.isExpr()) {
197+
MO.getExpr()->print(O, &MAI);
198+
return;
200199
}
200+
201+
assert(MO.isImm() && "absolute memory addressing needs an immediate");
202+
O << format("$%0" PRIx64, (uint64_t)MO.getImm());
201203
}
202204

203205
void M68kInstPrinter::printPCDMem(const MCInst *MI, uint64_t Address,

llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class M68kInstPrinter : public MCInstPrinter {
6565
//
6666
void printPCRelImm(const MCInst *MI, uint64_t Address, unsigned opNum,
6767
raw_ostream &O) {
68-
printOperand(MI, opNum, O);
68+
printAbsMem(MI, opNum, O);
6969
}
7070

7171
void printARI8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {

0 commit comments

Comments
 (0)