[llvm] 6de2628 - [M68k] Change printing of absolute memory references
Ricky Taylor via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 19 14:28:39 PDT 2021
Author: Ricky Taylor
Date: 2021-04-19T22:24:12+01:00
New Revision: 6de262827c292c510dc5c27c6b6ce15276295236
URL: https://github.com/llvm/llvm-project/commit/6de262827c292c510dc5c27c6b6ce15276295236
DIFF: https://github.com/llvm/llvm-project/commit/6de262827c292c510dc5c27c6b6ce15276295236.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
index 6667f5678145f..e5f5909b5d799 100644
--- a/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
+++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp
@@ -192,12 +192,14 @@ void M68kInstPrinter::printARIIMem(const MCInst *MI, unsigned opNum,
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,
diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h b/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
index b10449f9ef291..ec26bc4ddbfd7 100644
--- a/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
+++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h
@@ -65,7 +65,7 @@ class M68kInstPrinter : public MCInstPrinter {
//
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) {
More information about the llvm-commits
mailing list