From 173bc2bb7f75aab38c2c5a1f8d82704ef830a33e Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Fri, 23 Nov 2018 14:27:21 +0000 Subject: [PATCH] [ARM][AsmParser] Improve debug printing of parsed asm operands In ARMOperand::print: - Print human-readable register names, instead of numbers. - Print the correct names for IT condition masks (these were in the wrong order before). - Print all parts of memory operands, not just the base register. This makes the output of llvm-mc -show-inst-operands more readable. Differential revision: https://reviews.llvm.org/D54850 llvm-svn: 347494 --- .../lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index f837db56264c..a28831911782 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "ARMFeatures.h" +#include "InstPrinter/ARMInstPrinter.h" #include "Utils/ARMBaseInfo.h" #include "MCTargetDesc/ARMAddressingModes.h" #include "MCTargetDesc/ARMBaseInfo.h" @@ -3205,17 +3206,26 @@ public: } // end anonymous namespace. void ARMOperand::print(raw_ostream &OS) const { + auto RegName = [](unsigned Reg) { + if (Reg) + return ARMInstPrinter::getRegisterName(Reg); + else + return "noreg"; + }; + switch (Kind) { case k_CondCode: OS << ""; break; case k_CCOut: - OS << ""; + OS << ""; break; case k_ITCondMask: { static const char *const MaskStr[] = { - "()", "(t)", "(e)", "(tt)", "(et)", "(te)", "(ee)", "(ttt)", "(ett)", - "(tet)", "(eet)", "(tte)", "(ete)", "(tee)", "(eee)" + "(invalid)", "(teee)", "(tee)", "(teet)", + "(te)", "(tete)", "(tet)", "(tett)", + "(t)", "(ttee)", "(tte)", "(ttet)", + "(tt)", "(ttte)", "(ttt)", "(tttt)" }; assert((ITMask.Mask & 0xf) == ITMask.Mask); OS << ""; @@ -3249,13 +3259,25 @@ void ARMOperand::print(raw_ostream &OS) const { OS << ""; break; case k_Memory: - OS << ""; break; case k_PostIndexRegister: OS << "post-idx register " << (PostIdxReg.isAdd ? "" : "-") - << PostIdxReg.RegNum; + << RegName(PostIdxReg.RegNum); if (PostIdxReg.ShiftTy != ARM_AM::no_shift) OS << ARM_AM::getShiftOpcStr(PostIdxReg.ShiftTy) << " " << PostIdxReg.ShiftImm; @@ -3271,23 +3293,21 @@ void ARMOperand::print(raw_ostream &OS) const { break; } case k_Register: - OS << ""; + OS << ""; break; case k_ShifterImmediate: OS << ""; break; case k_ShiftedRegister: - OS << ""; + OS << ""; break; case k_ShiftedImmediate: - OS << ""; + OS << ""; break; case k_RotateImmediate: OS << ""; @@ -3311,7 +3331,7 @@ void ARMOperand::print(raw_ostream &OS) const { const SmallVectorImpl &RegList = getRegList(); for (SmallVectorImpl::const_iterator I = RegList.begin(), E = RegList.end(); I != E; ) { - OS << *I; + OS << RegName(*I); if (++I < E) OS << ", "; } @@ -3320,15 +3340,15 @@ void ARMOperand::print(raw_ostream &OS) const { } case k_VectorList: OS << ""; + << RegName(VectorList.RegNum) << ">"; break; case k_VectorListAllLanes: OS << ""; + << RegName(VectorList.RegNum) << ">"; break; case k_VectorListIndexed: OS << ""; + << VectorList.Count << " * " << RegName(VectorList.RegNum) << ">"; break; case k_Token: OS << "'" << getToken() << "'";