[PATCH] D129867: [MipsInstPrinter] Introduce markup tags emission
Antonio Frighetto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 07:44:04 PDT 2022
antoniofrighetto updated this revision to Diff 455908.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129867/new/
https://reviews.llvm.org/D129867
Files:
llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
llvm/test/MC/Disassembler/Mips/mips1/marked-up.txt
Index: llvm/test/MC/Disassembler/Mips/mips1/marked-up.txt
===================================================================
--- /dev/null
+++ llvm/test/MC/Disassembler/Mips/mips1/marked-up.txt
@@ -0,0 +1,11 @@
+# RUN: llvm-mc --mdis %s -triple=mips-unknown-linux -mcpu=mips1 2>&1 | FileCheck %s
+
+# CHECK: j <imm:80478376>
+0x09 0x33 0x00 0x2a
+# CHECK: addi <reg:$13>, <reg:$9>, <imm:26322>
+0x21 0x2d 0x66 0xd2
+# CHECK: xor <reg:$18>, <reg:$4>, <reg:$fp>
+0x00 0x9e 0x90 0x26
+# CHECK: lwr <reg:$zero>, <mem:<imm:-19147>(<reg:$gp>)>
+0x9b 0x80 0xb5 0x35
+
Index: llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
===================================================================
--- llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
+++ llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.cpp
@@ -72,7 +72,8 @@
}
void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
- OS << '$' << StringRef(getRegisterName(RegNo)).lower();
+ OS << markup("<reg:") << '$' << StringRef(getRegisterName(RegNo)).lower()
+ << markup(">");
}
void MipsInstPrinter::printInst(const MCInst *MI, uint64_t Address,
@@ -132,7 +133,7 @@
}
if (Op.isImm()) {
- O << formatImm(Op.getImm());
+ O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
return;
}
@@ -148,9 +149,9 @@
return printOperand(MI, OpNo, STI, O);
if (PrintBranchImmAsAddress)
- O << formatHex(Op.getImm());
+ O << markup("<imm:") << formatHex(Op.getImm()) << markup(">");
else
- O << formatImm(Op.getImm());
+ O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
}
void MipsInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address,
@@ -167,9 +168,9 @@
Target &= 0xffffffff;
else if (STI.hasFeature(Mips::FeatureMips16))
Target &= 0xffff;
- O << formatHex(Target);
+ O << markup("<imm:") << formatHex(Target) << markup(">");
} else {
- O << formatImm(Op.getImm());
+ O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
}
}
@@ -182,7 +183,7 @@
Imm -= Offset;
Imm &= (1 << Bits) - 1;
Imm += Offset;
- O << formatImm(Imm);
+ O << markup("<imm:") << formatImm(Imm) << markup(">");
return;
}
@@ -211,10 +212,12 @@
break;
}
+ O << markup("<mem:");
printOperand(MI, opNum + 1, STI, O);
O << "(";
printOperand(MI, opNum, STI, O);
O << ")";
+ O << markup(">");
}
void MipsInstPrinter::printMemOperandEA(const MCInst *MI, int opNum,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129867.455908.patch
Type: text/x-patch
Size: 2502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220826/a2a53c4c/attachment.bin>
More information about the llvm-commits
mailing list