[PATCH] D31494: [PowerPC] Pretty-print CR bits the way the binutils disassembler does

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 11:03:43 PDT 2017


hfinkel added a comment.

This seems like a good thing to do.



================
Comment at: lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp:451
+static const char *stripRegisterPrefix(const char *RegName, unsigned RegNum) {
+  if (FullRegNames || ShowVSRNumsAsVR) {
+    if (RegNum >= PPC::CR0EQ && RegNum <= PPC::CR7UN) {
----------------
This ShowVSRNumsAsVR seems broken ; should we just get rid of it?


================
Comment at: lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp:453
+    if (RegNum >= PPC::CR0EQ && RegNum <= PPC::CR7UN) {
+      unsigned BitNo = atoi(RegName);
+      const char *CRBits[] =
----------------
Hrmm. Is TRI available here? The real way of doing this is to get the encoding value for the register. From PPCAsmPrinter.cpp, for example, we have this:

      unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
                              ->getEncodingValue(MI->getOperand(0).getReg());

It is possible that just using MRI.getEncodingValue(RegNum) will work here. It looks like it might (MCInstPrinter has an MRI protected member, and because the encoding values come from TableGen, I think that MCRegisterInfo should have them).



Repository:
  rL LLVM

https://reviews.llvm.org/D31494





More information about the llvm-commits mailing list