diff options
Diffstat (limited to 'llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp index dbdfb6e906bb..ccbb650c6536 100644 --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp @@ -13,14 +13,14 @@ #include "MCTargetDesc/PPCInstPrinter.h" #include "MCTargetDesc/PPCMCTargetDesc.h" #include "MCTargetDesc/PPCPredicates.h" -#include "PPCInstrInfo.h" -#include "llvm/CodeGen/TargetOpcodes.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -564,10 +564,10 @@ void PPCInstPrinter::printTLSCall(const MCInst *MI, unsigned OpNo, // come at the _end_ of the expression. const MCOperand &Op = MI->getOperand(OpNo); const MCSymbolRefExpr *RefExp = nullptr; - const MCConstantExpr *ConstExp = nullptr; + const MCExpr *Rhs = nullptr; if (const MCBinaryExpr *BinExpr = dyn_cast<MCBinaryExpr>(Op.getExpr())) { RefExp = cast<MCSymbolRefExpr>(BinExpr->getLHS()); - ConstExp = cast<MCConstantExpr>(BinExpr->getRHS()); + Rhs = BinExpr->getRHS(); } else RefExp = cast<MCSymbolRefExpr>(Op.getExpr()); @@ -584,14 +584,21 @@ void PPCInstPrinter::printTLSCall(const MCInst *MI, unsigned OpNo, if (RefExp->getKind() != MCSymbolRefExpr::VK_None && RefExp->getKind() != MCSymbolRefExpr::VK_PPC_NOTOC) O << '@' << MCSymbolRefExpr::getVariantKindName(RefExp->getKind()); - if (ConstExp != nullptr) - O << '+' << ConstExp->getValue(); + if (Rhs) { + SmallString<0> Buf; + raw_svector_ostream Tmp(Buf); + Rhs->print(Tmp, &MAI); + if (isdigit(Buf[0])) + O << '+'; + O << Buf; + } } /// showRegistersWithPercentPrefix - Check if this register name should be /// printed with a percentage symbol as prefix. bool PPCInstPrinter::showRegistersWithPercentPrefix(const char *RegName) const { - if (!FullRegNamesWithPercent || TT.getOS() == Triple::AIX) + if ((!FullRegNamesWithPercent && !MAI.useFullRegisterNames()) || + TT.getOS() == Triple::AIX) return false; switch (RegName[0]) { @@ -608,10 +615,10 @@ bool PPCInstPrinter::showRegistersWithPercentPrefix(const char *RegName) const { /// getVerboseConditionalRegName - This method expands the condition register /// when requested explicitly or targetting Darwin. -const char *PPCInstPrinter::getVerboseConditionRegName(unsigned RegNum, - unsigned RegEncoding) - const { - if (!FullRegNames) +const char * +PPCInstPrinter::getVerboseConditionRegName(unsigned RegNum, + unsigned RegEncoding) const { + if (!FullRegNames && !MAI.useFullRegisterNames()) return nullptr; if (RegNum < PPC::CR0EQ || RegNum > PPC::CR7UN) return nullptr; @@ -631,7 +638,7 @@ const char *PPCInstPrinter::getVerboseConditionRegName(unsigned RegNum, // showRegistersWithPrefix - This method determines whether registers // should be number-only or include the prefix. bool PPCInstPrinter::showRegistersWithPrefix() const { - return FullRegNamesWithPercent || FullRegNames; + return FullRegNamesWithPercent || FullRegNames || MAI.useFullRegisterNames(); } void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, @@ -640,8 +647,7 @@ void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, if (Op.isReg()) { unsigned Reg = Op.getReg(); if (!ShowVSRNumsAsVR) - Reg = PPCInstrInfo::getRegNumForOperand(MII.get(MI->getOpcode()), - Reg, OpNo); + Reg = PPC::getRegNumForOperand(MII.get(MI->getOpcode()), Reg, OpNo); const char *RegName; RegName = getVerboseConditionRegName(Reg, MRI.getEncodingValue(Reg)); @@ -650,7 +656,7 @@ void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, if (showRegistersWithPercentPrefix(RegName)) O << "%"; if (!showRegistersWithPrefix()) - RegName = PPCRegisterInfo::stripRegisterPrefix(RegName); + RegName = PPC::stripRegisterPrefix(RegName); O << RegName; return; |
