[PATCH] D100697: [M68k] Change printing of absolute memory references
Ricky Taylor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 17 03:24:41 PDT 2021
ricky26 created this revision.
ricky26 added a reviewer: myhsu.
Herald added a subscriber: hiraditya.
ricky26 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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`
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100697
Files:
llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
Index: llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
===================================================================
--- llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
+++ llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
@@ -65,7 +65,7 @@
//
void printPCRelImm(const MCInst *MI, uint64_t Address, unsigned opNum,
raw_ostream &O) {
- printOperand(MI, opNum, O);
+ printAbsMem(MI, opNum, O);
}
void printARI8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
Index: llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
===================================================================
--- llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
+++ llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
@@ -192,12 +192,14 @@
void M68kInstPrinter::printAbsMem(const MCInst *MI, unsigned opNum,
raw_ostream &O) {
const MCOperand &MO = MI->getOperand(opNum);
- if (MO.isImm()) {
- // ??? Print it in hex?
- O << (unsigned int)MO.getImm();
- } else {
- printOperand(MI, opNum, O);
+
+ if (MO.isExpr()) {
+ MO.getExpr()->print(O, &MAI);
+ return;
}
+
+ assert(MO.isImm() && "absolute memory addressing needs an immediate");
+ O << format("$%0" PRIx64, (uint64_t)MO.getImm());
}
void M68kInstPrinter::printPCDMem(const MCInst *MI, uint64_t Address,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100697.338284.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210417/3952a604/attachment.bin>
More information about the llvm-commits
mailing list