Path: blob/main/contrib/llvm-project/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
35294 views
//===-- PPCInstPrinter.cpp - Convert PPC MCInst to assembly syntax --------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This class prints an PPC MCInst to a .s file.9//10//===----------------------------------------------------------------------===//1112#include "MCTargetDesc/PPCInstPrinter.h"13#include "MCTargetDesc/PPCMCTargetDesc.h"14#include "MCTargetDesc/PPCPredicates.h"15#include "llvm/MC/MCAsmInfo.h"16#include "llvm/MC/MCExpr.h"17#include "llvm/MC/MCInst.h"18#include "llvm/MC/MCInstrInfo.h"19#include "llvm/MC/MCRegisterInfo.h"20#include "llvm/MC/MCSubtargetInfo.h"21#include "llvm/MC/MCSymbol.h"22#include "llvm/Support/Casting.h"23#include "llvm/Support/CommandLine.h"24#include "llvm/Support/raw_ostream.h"25using namespace llvm;2627#define DEBUG_TYPE "asm-printer"2829// FIXME: Once the integrated assembler supports full register names, tie this30// to the verbose-asm setting.31static cl::opt<bool>32FullRegNames("ppc-asm-full-reg-names", cl::Hidden, cl::init(false),33cl::desc("Use full register names when printing assembly"));3435// Useful for testing purposes. Prints vs{31-63} as v{0-31} respectively.36static cl::opt<bool>37ShowVSRNumsAsVR("ppc-vsr-nums-as-vr", cl::Hidden, cl::init(false),38cl::desc("Prints full register names with vs{31-63} as v{0-31}"));3940// Prints full register names with percent symbol.41static cl::opt<bool>42FullRegNamesWithPercent("ppc-reg-with-percent-prefix", cl::Hidden,43cl::init(false),44cl::desc("Prints full register names with percent"));4546#define PRINT_ALIAS_INSTR47#include "PPCGenAsmWriter.inc"4849void PPCInstPrinter::printRegName(raw_ostream &OS, MCRegister Reg) const {50const char *RegName = getRegisterName(Reg);51OS << RegName;52}5354void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,55StringRef Annot, const MCSubtargetInfo &STI,56raw_ostream &O) {57// Customize printing of the addis instruction on AIX. When an operand is a58// symbol reference, the instruction syntax is changed to look like a load59// operation, i.e:60// Transform: addis $rD, $rA, $src --> addis $rD, $src($rA).61if (TT.isOSAIX() &&62(MI->getOpcode() == PPC::ADDIS8 || MI->getOpcode() == PPC::ADDIS) &&63MI->getOperand(2).isExpr()) {64assert((MI->getOperand(0).isReg() && MI->getOperand(1).isReg()) &&65"The first and the second operand of an addis instruction"66" should be registers.");6768assert(isa<MCSymbolRefExpr>(MI->getOperand(2).getExpr()) &&69"The third operand of an addis instruction should be a symbol "70"reference expression if it is an expression at all.");7172O << "\taddis ";73printOperand(MI, 0, STI, O);74O << ", ";75printOperand(MI, 2, STI, O);76O << "(";77printOperand(MI, 1, STI, O);78O << ")";79return;80}8182// Check if the last operand is an expression with the variant kind83// VK_PPC_PCREL_OPT. If this is the case then this is a linker optimization84// relocation and the .reloc directive needs to be added.85unsigned LastOp = MI->getNumOperands() - 1;86if (MI->getNumOperands() > 1) {87const MCOperand &Operand = MI->getOperand(LastOp);88if (Operand.isExpr()) {89const MCExpr *Expr = Operand.getExpr();90const MCSymbolRefExpr *SymExpr =91static_cast<const MCSymbolRefExpr *>(Expr);9293if (SymExpr && SymExpr->getKind() == MCSymbolRefExpr::VK_PPC_PCREL_OPT) {94const MCSymbol &Symbol = SymExpr->getSymbol();95if (MI->getOpcode() == PPC::PLDpc) {96printInstruction(MI, Address, STI, O);97O << "\n";98Symbol.print(O, &MAI);99O << ":";100return;101} else {102O << "\t.reloc ";103Symbol.print(O, &MAI);104O << "-8,R_PPC64_PCREL_OPT,.-(";105Symbol.print(O, &MAI);106O << "-8)\n";107}108}109}110}111112// Check for slwi/srwi mnemonics.113if (MI->getOpcode() == PPC::RLWINM) {114unsigned char SH = MI->getOperand(2).getImm();115unsigned char MB = MI->getOperand(3).getImm();116unsigned char ME = MI->getOperand(4).getImm();117bool useSubstituteMnemonic = false;118if (SH <= 31 && MB == 0 && ME == (31-SH)) {119O << "\tslwi "; useSubstituteMnemonic = true;120}121if (SH <= 31 && MB == (32-SH) && ME == 31) {122O << "\tsrwi "; useSubstituteMnemonic = true;123SH = 32-SH;124}125if (useSubstituteMnemonic) {126printOperand(MI, 0, STI, O);127O << ", ";128printOperand(MI, 1, STI, O);129O << ", " << (unsigned int)SH;130131printAnnotation(O, Annot);132return;133}134}135136if (MI->getOpcode() == PPC::RLDICR ||137MI->getOpcode() == PPC::RLDICR_32) {138unsigned char SH = MI->getOperand(2).getImm();139unsigned char ME = MI->getOperand(3).getImm();140// rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH141if (63-SH == ME) {142O << "\tsldi ";143printOperand(MI, 0, STI, O);144O << ", ";145printOperand(MI, 1, STI, O);146O << ", " << (unsigned int)SH;147printAnnotation(O, Annot);148return;149}150}151152// dcbt[st] is printed manually here because:153// 1. The assembly syntax is different between embedded and server targets154// 2. We must print the short mnemonics for TH == 0 because the155// embedded/server syntax default will not be stable across assemblers156// The syntax for dcbt is:157// dcbt ra, rb, th [server]158// dcbt th, ra, rb [embedded]159// where th can be omitted when it is 0. dcbtst is the same.160// On AIX, only emit the extended mnemonics for dcbt and dcbtst if161// the "modern assembler" is available.162if ((MI->getOpcode() == PPC::DCBT || MI->getOpcode() == PPC::DCBTST) &&163(!TT.isOSAIX() || STI.hasFeature(PPC::FeatureModernAIXAs))) {164unsigned char TH = MI->getOperand(0).getImm();165O << "\tdcbt";166if (MI->getOpcode() == PPC::DCBTST)167O << "st";168if (TH == 16)169O << "t";170O << " ";171172bool IsBookE = STI.hasFeature(PPC::FeatureBookE);173if (IsBookE && TH != 0 && TH != 16)174O << (unsigned int) TH << ", ";175176printOperand(MI, 1, STI, O);177O << ", ";178printOperand(MI, 2, STI, O);179180if (!IsBookE && TH != 0 && TH != 16)181O << ", " << (unsigned int) TH;182183printAnnotation(O, Annot);184return;185}186187if (MI->getOpcode() == PPC::DCBF) {188unsigned char L = MI->getOperand(0).getImm();189if (!L || L == 1 || L == 3 || L == 4 || L == 6) {190O << "\tdcb";191if (L != 6)192O << "f";193if (L == 1)194O << "l";195if (L == 3)196O << "lp";197if (L == 4)198O << "ps";199if (L == 6)200O << "stps";201O << " ";202203printOperand(MI, 1, STI, O);204O << ", ";205printOperand(MI, 2, STI, O);206207printAnnotation(O, Annot);208return;209}210}211212if (!printAliasInstr(MI, Address, STI, O))213printInstruction(MI, Address, STI, O);214printAnnotation(O, Annot);215}216217void PPCInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNo,218const MCSubtargetInfo &STI,219raw_ostream &O,220const char *Modifier) {221unsigned Code = MI->getOperand(OpNo).getImm();222223if (StringRef(Modifier) == "cc") {224switch ((PPC::Predicate)Code) {225case PPC::PRED_LT_MINUS:226case PPC::PRED_LT_PLUS:227case PPC::PRED_LT:228O << "lt";229return;230case PPC::PRED_LE_MINUS:231case PPC::PRED_LE_PLUS:232case PPC::PRED_LE:233O << "le";234return;235case PPC::PRED_EQ_MINUS:236case PPC::PRED_EQ_PLUS:237case PPC::PRED_EQ:238O << "eq";239return;240case PPC::PRED_GE_MINUS:241case PPC::PRED_GE_PLUS:242case PPC::PRED_GE:243O << "ge";244return;245case PPC::PRED_GT_MINUS:246case PPC::PRED_GT_PLUS:247case PPC::PRED_GT:248O << "gt";249return;250case PPC::PRED_NE_MINUS:251case PPC::PRED_NE_PLUS:252case PPC::PRED_NE:253O << "ne";254return;255case PPC::PRED_UN_MINUS:256case PPC::PRED_UN_PLUS:257case PPC::PRED_UN:258O << "un";259return;260case PPC::PRED_NU_MINUS:261case PPC::PRED_NU_PLUS:262case PPC::PRED_NU:263O << "nu";264return;265case PPC::PRED_BIT_SET:266case PPC::PRED_BIT_UNSET:267llvm_unreachable("Invalid use of bit predicate code");268}269llvm_unreachable("Invalid predicate code");270}271272if (StringRef(Modifier) == "pm") {273switch ((PPC::Predicate)Code) {274case PPC::PRED_LT:275case PPC::PRED_LE:276case PPC::PRED_EQ:277case PPC::PRED_GE:278case PPC::PRED_GT:279case PPC::PRED_NE:280case PPC::PRED_UN:281case PPC::PRED_NU:282return;283case PPC::PRED_LT_MINUS:284case PPC::PRED_LE_MINUS:285case PPC::PRED_EQ_MINUS:286case PPC::PRED_GE_MINUS:287case PPC::PRED_GT_MINUS:288case PPC::PRED_NE_MINUS:289case PPC::PRED_UN_MINUS:290case PPC::PRED_NU_MINUS:291O << "-";292return;293case PPC::PRED_LT_PLUS:294case PPC::PRED_LE_PLUS:295case PPC::PRED_EQ_PLUS:296case PPC::PRED_GE_PLUS:297case PPC::PRED_GT_PLUS:298case PPC::PRED_NE_PLUS:299case PPC::PRED_UN_PLUS:300case PPC::PRED_NU_PLUS:301O << "+";302return;303case PPC::PRED_BIT_SET:304case PPC::PRED_BIT_UNSET:305llvm_unreachable("Invalid use of bit predicate code");306}307llvm_unreachable("Invalid predicate code");308}309310assert(StringRef(Modifier) == "reg" &&311"Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!");312printOperand(MI, OpNo + 1, STI, O);313}314315void PPCInstPrinter::printATBitsAsHint(const MCInst *MI, unsigned OpNo,316const MCSubtargetInfo &STI,317raw_ostream &O) {318unsigned Code = MI->getOperand(OpNo).getImm();319if (Code == 2)320O << "-";321else if (Code == 3)322O << "+";323}324325void PPCInstPrinter::printU1ImmOperand(const MCInst *MI, unsigned OpNo,326const MCSubtargetInfo &STI,327raw_ostream &O) {328unsigned int Value = MI->getOperand(OpNo).getImm();329assert(Value <= 1 && "Invalid u1imm argument!");330O << (unsigned int)Value;331}332333void PPCInstPrinter::printU2ImmOperand(const MCInst *MI, unsigned OpNo,334const MCSubtargetInfo &STI,335raw_ostream &O) {336unsigned int Value = MI->getOperand(OpNo).getImm();337assert(Value <= 3 && "Invalid u2imm argument!");338O << (unsigned int)Value;339}340341void PPCInstPrinter::printU3ImmOperand(const MCInst *MI, unsigned OpNo,342const MCSubtargetInfo &STI,343raw_ostream &O) {344unsigned int Value = MI->getOperand(OpNo).getImm();345assert(Value <= 8 && "Invalid u3imm argument!");346O << (unsigned int)Value;347}348349void PPCInstPrinter::printU4ImmOperand(const MCInst *MI, unsigned OpNo,350const MCSubtargetInfo &STI,351raw_ostream &O) {352unsigned int Value = MI->getOperand(OpNo).getImm();353assert(Value <= 15 && "Invalid u4imm argument!");354O << (unsigned int)Value;355}356357void PPCInstPrinter::printS5ImmOperand(const MCInst *MI, unsigned OpNo,358const MCSubtargetInfo &STI,359raw_ostream &O) {360int Value = MI->getOperand(OpNo).getImm();361Value = SignExtend32<5>(Value);362O << (int)Value;363}364365void PPCInstPrinter::printImmZeroOperand(const MCInst *MI, unsigned OpNo,366const MCSubtargetInfo &STI,367raw_ostream &O) {368unsigned int Value = MI->getOperand(OpNo).getImm();369assert(Value == 0 && "Operand must be zero");370O << (unsigned int)Value;371}372373void PPCInstPrinter::printU5ImmOperand(const MCInst *MI, unsigned OpNo,374const MCSubtargetInfo &STI,375raw_ostream &O) {376unsigned int Value = MI->getOperand(OpNo).getImm();377assert(Value <= 31 && "Invalid u5imm argument!");378O << (unsigned int)Value;379}380381void PPCInstPrinter::printU6ImmOperand(const MCInst *MI, unsigned OpNo,382const MCSubtargetInfo &STI,383raw_ostream &O) {384unsigned int Value = MI->getOperand(OpNo).getImm();385assert(Value <= 63 && "Invalid u6imm argument!");386O << (unsigned int)Value;387}388389void PPCInstPrinter::printU7ImmOperand(const MCInst *MI, unsigned OpNo,390const MCSubtargetInfo &STI,391raw_ostream &O) {392unsigned int Value = MI->getOperand(OpNo).getImm();393assert(Value <= 127 && "Invalid u7imm argument!");394O << (unsigned int)Value;395}396397// Operands of BUILD_VECTOR are signed and we use this to print operands398// of XXSPLTIB which are unsigned. So we simply truncate to 8 bits and399// print as unsigned.400void PPCInstPrinter::printU8ImmOperand(const MCInst *MI, unsigned OpNo,401const MCSubtargetInfo &STI,402raw_ostream &O) {403unsigned char Value = MI->getOperand(OpNo).getImm();404O << (unsigned int)Value;405}406407void PPCInstPrinter::printU10ImmOperand(const MCInst *MI, unsigned OpNo,408const MCSubtargetInfo &STI,409raw_ostream &O) {410unsigned short Value = MI->getOperand(OpNo).getImm();411assert(Value <= 1023 && "Invalid u10imm argument!");412O << (unsigned short)Value;413}414415void PPCInstPrinter::printU12ImmOperand(const MCInst *MI, unsigned OpNo,416const MCSubtargetInfo &STI,417raw_ostream &O) {418unsigned short Value = MI->getOperand(OpNo).getImm();419assert(Value <= 4095 && "Invalid u12imm argument!");420O << (unsigned short)Value;421}422423void PPCInstPrinter::printS16ImmOperand(const MCInst *MI, unsigned OpNo,424const MCSubtargetInfo &STI,425raw_ostream &O) {426if (MI->getOperand(OpNo).isImm())427O << (short)MI->getOperand(OpNo).getImm();428else429printOperand(MI, OpNo, STI, O);430}431432void PPCInstPrinter::printS34ImmOperand(const MCInst *MI, unsigned OpNo,433const MCSubtargetInfo &STI,434raw_ostream &O) {435if (MI->getOperand(OpNo).isImm()) {436long long Value = MI->getOperand(OpNo).getImm();437assert(isInt<34>(Value) && "Invalid s34imm argument!");438O << (long long)Value;439}440else441printOperand(MI, OpNo, STI, O);442}443444void PPCInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,445const MCSubtargetInfo &STI,446raw_ostream &O) {447if (MI->getOperand(OpNo).isImm())448O << (unsigned short)MI->getOperand(OpNo).getImm();449else450printOperand(MI, OpNo, STI, O);451}452453void PPCInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address,454unsigned OpNo,455const MCSubtargetInfo &STI,456raw_ostream &O) {457if (!MI->getOperand(OpNo).isImm())458return printOperand(MI, OpNo, STI, O);459int32_t Imm = SignExtend32<32>((unsigned)MI->getOperand(OpNo).getImm() << 2);460if (PrintBranchImmAsAddress) {461uint64_t Target = Address + Imm;462if (!TT.isPPC64())463Target &= 0xffffffff;464O << formatHex(Target);465} else {466// Branches can take an immediate operand. This is used by the branch467// selection pass to print, for example `.+8` (for ELF) or `$+8` (for AIX)468// to express an eight byte displacement from the program counter.469if (!TT.isOSAIX())470O << ".";471else472O << "$";473474if (Imm >= 0)475O << "+";476O << Imm;477}478}479480void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,481const MCSubtargetInfo &STI,482raw_ostream &O) {483if (!MI->getOperand(OpNo).isImm())484return printOperand(MI, OpNo, STI, O);485486uint64_t Imm = static_cast<uint64_t>(MI->getOperand(OpNo).getImm()) << 2;487if (!TT.isPPC64())488Imm = static_cast<uint32_t>(Imm);489O << formatHex(Imm);490}491492void PPCInstPrinter::printcrbitm(const MCInst *MI, unsigned OpNo,493const MCSubtargetInfo &STI, raw_ostream &O) {494unsigned CCReg = MI->getOperand(OpNo).getReg();495unsigned RegNo;496switch (CCReg) {497default: llvm_unreachable("Unknown CR register");498case PPC::CR0: RegNo = 0; break;499case PPC::CR1: RegNo = 1; break;500case PPC::CR2: RegNo = 2; break;501case PPC::CR3: RegNo = 3; break;502case PPC::CR4: RegNo = 4; break;503case PPC::CR5: RegNo = 5; break;504case PPC::CR6: RegNo = 6; break;505case PPC::CR7: RegNo = 7; break;506}507O << (0x80 >> RegNo);508}509510void PPCInstPrinter::printMemRegImm(const MCInst *MI, unsigned OpNo,511const MCSubtargetInfo &STI,512raw_ostream &O) {513printS16ImmOperand(MI, OpNo, STI, O);514O << '(';515if (MI->getOperand(OpNo+1).getReg() == PPC::R0)516O << "0";517else518printOperand(MI, OpNo + 1, STI, O);519O << ')';520}521522void PPCInstPrinter::printMemRegImmHash(const MCInst *MI, unsigned OpNo,523const MCSubtargetInfo &STI,524raw_ostream &O) {525O << MI->getOperand(OpNo).getImm();526O << '(';527printOperand(MI, OpNo + 1, STI, O);528O << ')';529}530531void PPCInstPrinter::printMemRegImm34PCRel(const MCInst *MI, unsigned OpNo,532const MCSubtargetInfo &STI,533raw_ostream &O) {534printS34ImmOperand(MI, OpNo, STI, O);535O << '(';536printImmZeroOperand(MI, OpNo + 1, STI, O);537O << ')';538}539540void PPCInstPrinter::printMemRegImm34(const MCInst *MI, unsigned OpNo,541const MCSubtargetInfo &STI,542raw_ostream &O) {543printS34ImmOperand(MI, OpNo, STI, O);544O << '(';545printOperand(MI, OpNo + 1, STI, O);546O << ')';547}548549void PPCInstPrinter::printMemRegReg(const MCInst *MI, unsigned OpNo,550const MCSubtargetInfo &STI,551raw_ostream &O) {552// When used as the base register, r0 reads constant zero rather than553// the value contained in the register. For this reason, the darwin554// assembler requires that we print r0 as 0 (no r) when used as the base.555if (MI->getOperand(OpNo).getReg() == PPC::R0)556O << "0";557else558printOperand(MI, OpNo, STI, O);559O << ", ";560printOperand(MI, OpNo + 1, STI, O);561}562563void PPCInstPrinter::printTLSCall(const MCInst *MI, unsigned OpNo,564const MCSubtargetInfo &STI, raw_ostream &O) {565// On PPC64, VariantKind is VK_None, but on PPC32, it's VK_PLT, and it must566// come at the _end_ of the expression.567const MCOperand &Op = MI->getOperand(OpNo);568const MCSymbolRefExpr *RefExp = nullptr;569const MCExpr *Rhs = nullptr;570if (const MCBinaryExpr *BinExpr = dyn_cast<MCBinaryExpr>(Op.getExpr())) {571RefExp = cast<MCSymbolRefExpr>(BinExpr->getLHS());572Rhs = BinExpr->getRHS();573} else574RefExp = cast<MCSymbolRefExpr>(Op.getExpr());575576O << RefExp->getSymbol().getName();577// The variant kind VK_PPC_NOTOC needs to be handled as a special case578// because we do not want the assembly to print out the @notoc at the579// end like __tls_get_addr(x@tlsgd)@notoc. Instead we want it to look580// like __tls_get_addr@notoc(x@tlsgd).581if (RefExp->getKind() == MCSymbolRefExpr::VK_PPC_NOTOC)582O << '@' << MCSymbolRefExpr::getVariantKindName(RefExp->getKind());583O << '(';584printOperand(MI, OpNo + 1, STI, O);585O << ')';586if (RefExp->getKind() != MCSymbolRefExpr::VK_None &&587RefExp->getKind() != MCSymbolRefExpr::VK_PPC_NOTOC)588O << '@' << MCSymbolRefExpr::getVariantKindName(RefExp->getKind());589if (Rhs) {590SmallString<0> Buf;591raw_svector_ostream Tmp(Buf);592Rhs->print(Tmp, &MAI);593if (isdigit(Buf[0]))594O << '+';595O << Buf;596}597}598599/// showRegistersWithPercentPrefix - Check if this register name should be600/// printed with a percentage symbol as prefix.601bool PPCInstPrinter::showRegistersWithPercentPrefix(const char *RegName) const {602if ((!FullRegNamesWithPercent && !MAI.useFullRegisterNames()) ||603TT.getOS() == Triple::AIX)604return false;605606switch (RegName[0]) {607default:608return false;609case 'r':610case 'f':611case 'q':612case 'v':613case 'c':614return true;615}616}617618/// getVerboseConditionalRegName - This method expands the condition register619/// when requested explicitly or targetting Darwin.620const char *621PPCInstPrinter::getVerboseConditionRegName(unsigned RegNum,622unsigned RegEncoding) const {623if (!FullRegNames && !MAI.useFullRegisterNames())624return nullptr;625if (RegNum < PPC::CR0EQ || RegNum > PPC::CR7UN)626return nullptr;627const char *CRBits[] = {628"lt", "gt", "eq", "un",629"4*cr1+lt", "4*cr1+gt", "4*cr1+eq", "4*cr1+un",630"4*cr2+lt", "4*cr2+gt", "4*cr2+eq", "4*cr2+un",631"4*cr3+lt", "4*cr3+gt", "4*cr3+eq", "4*cr3+un",632"4*cr4+lt", "4*cr4+gt", "4*cr4+eq", "4*cr4+un",633"4*cr5+lt", "4*cr5+gt", "4*cr5+eq", "4*cr5+un",634"4*cr6+lt", "4*cr6+gt", "4*cr6+eq", "4*cr6+un",635"4*cr7+lt", "4*cr7+gt", "4*cr7+eq", "4*cr7+un"636};637return CRBits[RegEncoding];638}639640// showRegistersWithPrefix - This method determines whether registers641// should be number-only or include the prefix.642bool PPCInstPrinter::showRegistersWithPrefix() const {643return FullRegNamesWithPercent || FullRegNames || MAI.useFullRegisterNames();644}645646void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,647const MCSubtargetInfo &STI, raw_ostream &O) {648const MCOperand &Op = MI->getOperand(OpNo);649if (Op.isReg()) {650unsigned Reg = Op.getReg();651if (!ShowVSRNumsAsVR)652Reg = PPC::getRegNumForOperand(MII.get(MI->getOpcode()), Reg, OpNo);653654const char *RegName;655RegName = getVerboseConditionRegName(Reg, MRI.getEncodingValue(Reg));656if (RegName == nullptr)657RegName = getRegisterName(Reg);658if (showRegistersWithPercentPrefix(RegName))659O << "%";660if (!showRegistersWithPrefix())661RegName = PPC::stripRegisterPrefix(RegName);662663O << RegName;664return;665}666667if (Op.isImm()) {668O << Op.getImm();669return;670}671672assert(Op.isExpr() && "unknown operand kind in printOperand");673Op.getExpr()->print(O, &MAI);674}675676677