10b57cec5SDimitry Andric //===-- MipsInstPrinter.cpp - Convert Mips MCInst to assembly syntax ------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This class prints an Mips MCInst to a .s file. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #include "MipsInstPrinter.h" 14*5f757f3fSDimitry Andric #include "Mips.h" 150b57cec5SDimitry Andric #include "MipsMCExpr.h" 160b57cec5SDimitry Andric #include "llvm/ADT/StringExtras.h" 170b57cec5SDimitry Andric #include "llvm/MC/MCExpr.h" 180b57cec5SDimitry Andric #include "llvm/MC/MCInst.h" 190b57cec5SDimitry Andric #include "llvm/MC/MCInstrInfo.h" 20*5f757f3fSDimitry Andric #include "llvm/MC/MCSubtargetInfo.h" 210b57cec5SDimitry Andric #include "llvm/MC/MCSymbol.h" 220b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 230b57cec5SDimitry Andric #include "llvm/Support/raw_ostream.h" 240b57cec5SDimitry Andric using namespace llvm; 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric #define DEBUG_TYPE "asm-printer" 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric #define PRINT_ALIAS_INSTR 290b57cec5SDimitry Andric #include "MipsGenAsmWriter.inc" 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric template<unsigned R> 320b57cec5SDimitry Andric static bool isReg(const MCInst &MI, unsigned OpNo) { 330b57cec5SDimitry Andric assert(MI.getOperand(OpNo).isReg() && "Register operand expected."); 340b57cec5SDimitry Andric return MI.getOperand(OpNo).getReg() == R; 350b57cec5SDimitry Andric } 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric const char* Mips::MipsFCCToString(Mips::CondCode CC) { 380b57cec5SDimitry Andric switch (CC) { 390b57cec5SDimitry Andric case FCOND_F: 400b57cec5SDimitry Andric case FCOND_T: return "f"; 410b57cec5SDimitry Andric case FCOND_UN: 420b57cec5SDimitry Andric case FCOND_OR: return "un"; 430b57cec5SDimitry Andric case FCOND_OEQ: 440b57cec5SDimitry Andric case FCOND_UNE: return "eq"; 450b57cec5SDimitry Andric case FCOND_UEQ: 460b57cec5SDimitry Andric case FCOND_ONE: return "ueq"; 470b57cec5SDimitry Andric case FCOND_OLT: 480b57cec5SDimitry Andric case FCOND_UGE: return "olt"; 490b57cec5SDimitry Andric case FCOND_ULT: 500b57cec5SDimitry Andric case FCOND_OGE: return "ult"; 510b57cec5SDimitry Andric case FCOND_OLE: 520b57cec5SDimitry Andric case FCOND_UGT: return "ole"; 530b57cec5SDimitry Andric case FCOND_ULE: 540b57cec5SDimitry Andric case FCOND_OGT: return "ule"; 550b57cec5SDimitry Andric case FCOND_SF: 560b57cec5SDimitry Andric case FCOND_ST: return "sf"; 570b57cec5SDimitry Andric case FCOND_NGLE: 580b57cec5SDimitry Andric case FCOND_GLE: return "ngle"; 590b57cec5SDimitry Andric case FCOND_SEQ: 600b57cec5SDimitry Andric case FCOND_SNE: return "seq"; 610b57cec5SDimitry Andric case FCOND_NGL: 620b57cec5SDimitry Andric case FCOND_GL: return "ngl"; 630b57cec5SDimitry Andric case FCOND_LT: 640b57cec5SDimitry Andric case FCOND_NLT: return "lt"; 650b57cec5SDimitry Andric case FCOND_NGE: 660b57cec5SDimitry Andric case FCOND_GE: return "nge"; 670b57cec5SDimitry Andric case FCOND_LE: 680b57cec5SDimitry Andric case FCOND_NLE: return "le"; 690b57cec5SDimitry Andric case FCOND_NGT: 700b57cec5SDimitry Andric case FCOND_GT: return "ngt"; 710b57cec5SDimitry Andric } 720b57cec5SDimitry Andric llvm_unreachable("Impossible condition code!"); 730b57cec5SDimitry Andric } 740b57cec5SDimitry Andric 75bdd1243dSDimitry Andric void MipsInstPrinter::printRegName(raw_ostream &OS, MCRegister Reg) const { 76*5f757f3fSDimitry Andric markup(OS, Markup::Register) 77*5f757f3fSDimitry Andric << '$' << StringRef(getRegisterName(Reg)).lower(); 780b57cec5SDimitry Andric } 790b57cec5SDimitry Andric 80480093f4SDimitry Andric void MipsInstPrinter::printInst(const MCInst *MI, uint64_t Address, 81480093f4SDimitry Andric StringRef Annot, const MCSubtargetInfo &STI, 82480093f4SDimitry Andric raw_ostream &O) { 830b57cec5SDimitry Andric switch (MI->getOpcode()) { 840b57cec5SDimitry Andric default: 850b57cec5SDimitry Andric break; 860b57cec5SDimitry Andric case Mips::RDHWR: 870b57cec5SDimitry Andric case Mips::RDHWR64: 880b57cec5SDimitry Andric O << "\t.set\tpush\n"; 890b57cec5SDimitry Andric O << "\t.set\tmips32r2\n"; 900b57cec5SDimitry Andric break; 910b57cec5SDimitry Andric case Mips::Save16: 920b57cec5SDimitry Andric O << "\tsave\t"; 9381ad6265SDimitry Andric printSaveRestore(MI, STI, O); 940b57cec5SDimitry Andric O << " # 16 bit inst\n"; 950b57cec5SDimitry Andric return; 960b57cec5SDimitry Andric case Mips::SaveX16: 970b57cec5SDimitry Andric O << "\tsave\t"; 9881ad6265SDimitry Andric printSaveRestore(MI, STI, O); 990b57cec5SDimitry Andric O << "\n"; 1000b57cec5SDimitry Andric return; 1010b57cec5SDimitry Andric case Mips::Restore16: 1020b57cec5SDimitry Andric O << "\trestore\t"; 10381ad6265SDimitry Andric printSaveRestore(MI, STI, O); 1040b57cec5SDimitry Andric O << " # 16 bit inst\n"; 1050b57cec5SDimitry Andric return; 1060b57cec5SDimitry Andric case Mips::RestoreX16: 1070b57cec5SDimitry Andric O << "\trestore\t"; 10881ad6265SDimitry Andric printSaveRestore(MI, STI, O); 1090b57cec5SDimitry Andric O << "\n"; 1100b57cec5SDimitry Andric return; 1110b57cec5SDimitry Andric } 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric // Try to print any aliases first. 11481ad6265SDimitry Andric if (!printAliasInstr(MI, Address, STI, O) && 11581ad6265SDimitry Andric !printAlias(*MI, Address, STI, O)) 11681ad6265SDimitry Andric printInstruction(MI, Address, STI, O); 1170b57cec5SDimitry Andric printAnnotation(O, Annot); 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric switch (MI->getOpcode()) { 1200b57cec5SDimitry Andric default: 1210b57cec5SDimitry Andric break; 1220b57cec5SDimitry Andric case Mips::RDHWR: 1230b57cec5SDimitry Andric case Mips::RDHWR64: 1240b57cec5SDimitry Andric O << "\n\t.set\tpop"; 1250b57cec5SDimitry Andric } 1260b57cec5SDimitry Andric } 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, 12981ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) { 1300b57cec5SDimitry Andric const MCOperand &Op = MI->getOperand(OpNo); 1310b57cec5SDimitry Andric if (Op.isReg()) { 1320b57cec5SDimitry Andric printRegName(O, Op.getReg()); 1330b57cec5SDimitry Andric return; 1340b57cec5SDimitry Andric } 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andric if (Op.isImm()) { 137*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatImm(Op.getImm()); 1380b57cec5SDimitry Andric return; 1390b57cec5SDimitry Andric } 1400b57cec5SDimitry Andric 1410b57cec5SDimitry Andric assert(Op.isExpr() && "unknown operand kind in printOperand"); 1420b57cec5SDimitry Andric Op.getExpr()->print(O, &MAI, true); 1430b57cec5SDimitry Andric } 1440b57cec5SDimitry Andric 14581ad6265SDimitry Andric void MipsInstPrinter::printJumpOperand(const MCInst *MI, unsigned OpNo, 14681ad6265SDimitry Andric const MCSubtargetInfo &STI, 14781ad6265SDimitry Andric raw_ostream &O) { 14881ad6265SDimitry Andric const MCOperand &Op = MI->getOperand(OpNo); 14981ad6265SDimitry Andric if (!Op.isImm()) 15081ad6265SDimitry Andric return printOperand(MI, OpNo, STI, O); 15181ad6265SDimitry Andric 15281ad6265SDimitry Andric if (PrintBranchImmAsAddress) 153*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatHex(Op.getImm()); 15481ad6265SDimitry Andric else 155*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatImm(Op.getImm()); 15681ad6265SDimitry Andric } 15781ad6265SDimitry Andric 15881ad6265SDimitry Andric void MipsInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address, 15981ad6265SDimitry Andric unsigned OpNo, 16081ad6265SDimitry Andric const MCSubtargetInfo &STI, 16181ad6265SDimitry Andric raw_ostream &O) { 16281ad6265SDimitry Andric const MCOperand &Op = MI->getOperand(OpNo); 16381ad6265SDimitry Andric if (!Op.isImm()) 16481ad6265SDimitry Andric return printOperand(MI, OpNo, STI, O); 16581ad6265SDimitry Andric 16681ad6265SDimitry Andric if (PrintBranchImmAsAddress) { 16781ad6265SDimitry Andric uint64_t Target = Address + Op.getImm(); 16881ad6265SDimitry Andric if (STI.hasFeature(Mips::FeatureMips32)) 16981ad6265SDimitry Andric Target &= 0xffffffff; 17081ad6265SDimitry Andric else if (STI.hasFeature(Mips::FeatureMips16)) 17181ad6265SDimitry Andric Target &= 0xffff; 172*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatHex(Target); 17381ad6265SDimitry Andric } else { 174*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatImm(Op.getImm()); 17581ad6265SDimitry Andric } 17681ad6265SDimitry Andric } 17781ad6265SDimitry Andric 1780b57cec5SDimitry Andric template <unsigned Bits, unsigned Offset> 17981ad6265SDimitry Andric void MipsInstPrinter::printUImm(const MCInst *MI, int opNum, 18081ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) { 1810b57cec5SDimitry Andric const MCOperand &MO = MI->getOperand(opNum); 1820b57cec5SDimitry Andric if (MO.isImm()) { 1830b57cec5SDimitry Andric uint64_t Imm = MO.getImm(); 1840b57cec5SDimitry Andric Imm -= Offset; 1850b57cec5SDimitry Andric Imm &= (1 << Bits) - 1; 1860b57cec5SDimitry Andric Imm += Offset; 187*5f757f3fSDimitry Andric markup(O, Markup::Immediate) << formatImm(Imm); 1880b57cec5SDimitry Andric return; 1890b57cec5SDimitry Andric } 1900b57cec5SDimitry Andric 19181ad6265SDimitry Andric printOperand(MI, opNum, STI, O); 1920b57cec5SDimitry Andric } 1930b57cec5SDimitry Andric 19481ad6265SDimitry Andric void MipsInstPrinter::printMemOperand(const MCInst *MI, int opNum, 19581ad6265SDimitry Andric const MCSubtargetInfo &STI, 19681ad6265SDimitry Andric raw_ostream &O) { 1970b57cec5SDimitry Andric // Load/Store memory operands -- imm($reg) 1980b57cec5SDimitry Andric // If PIC target the target is loaded as the 1990b57cec5SDimitry Andric // pattern lw $25,%call16($28) 2000b57cec5SDimitry Andric 2010b57cec5SDimitry Andric // opNum can be invalid if instruction had reglist as operand. 2020b57cec5SDimitry Andric // MemOperand is always last operand of instruction (base + offset). 2030b57cec5SDimitry Andric switch (MI->getOpcode()) { 2040b57cec5SDimitry Andric default: 2050b57cec5SDimitry Andric break; 2060b57cec5SDimitry Andric case Mips::SWM32_MM: 2070b57cec5SDimitry Andric case Mips::LWM32_MM: 2080b57cec5SDimitry Andric case Mips::SWM16_MM: 2090b57cec5SDimitry Andric case Mips::SWM16_MMR6: 2100b57cec5SDimitry Andric case Mips::LWM16_MM: 2110b57cec5SDimitry Andric case Mips::LWM16_MMR6: 2120b57cec5SDimitry Andric opNum = MI->getNumOperands() - 2; 2130b57cec5SDimitry Andric break; 2140b57cec5SDimitry Andric } 2150b57cec5SDimitry Andric 216*5f757f3fSDimitry Andric WithMarkup M = markup(O, Markup::Memory); 21781ad6265SDimitry Andric printOperand(MI, opNum + 1, STI, O); 2180b57cec5SDimitry Andric O << "("; 21981ad6265SDimitry Andric printOperand(MI, opNum, STI, O); 2200b57cec5SDimitry Andric O << ")"; 2210b57cec5SDimitry Andric } 2220b57cec5SDimitry Andric 22381ad6265SDimitry Andric void MipsInstPrinter::printMemOperandEA(const MCInst *MI, int opNum, 22481ad6265SDimitry Andric const MCSubtargetInfo &STI, 22581ad6265SDimitry Andric raw_ostream &O) { 2260b57cec5SDimitry Andric // when using stack locations for not load/store instructions 2270b57cec5SDimitry Andric // print the same way as all normal 3 operand instructions. 22881ad6265SDimitry Andric printOperand(MI, opNum, STI, O); 2290b57cec5SDimitry Andric O << ", "; 23081ad6265SDimitry Andric printOperand(MI, opNum + 1, STI, O); 2310b57cec5SDimitry Andric } 2320b57cec5SDimitry Andric 23381ad6265SDimitry Andric void MipsInstPrinter::printFCCOperand(const MCInst *MI, int opNum, 23481ad6265SDimitry Andric const MCSubtargetInfo & /* STI */, 23581ad6265SDimitry Andric raw_ostream &O) { 2360b57cec5SDimitry Andric const MCOperand &MO = MI->getOperand(opNum); 2370b57cec5SDimitry Andric O << MipsFCCToString((Mips::CondCode)MO.getImm()); 2380b57cec5SDimitry Andric } 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andric void MipsInstPrinter:: 2410b57cec5SDimitry Andric printSHFMask(const MCInst *MI, int opNum, raw_ostream &O) { 2420b57cec5SDimitry Andric llvm_unreachable("TODO"); 2430b57cec5SDimitry Andric } 2440b57cec5SDimitry Andric 2450b57cec5SDimitry Andric bool MipsInstPrinter::printAlias(const char *Str, const MCInst &MI, 24681ad6265SDimitry Andric uint64_t Address, unsigned OpNo, 24781ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &OS, 24881ad6265SDimitry Andric bool IsBranch) { 2490b57cec5SDimitry Andric OS << "\t" << Str << "\t"; 25081ad6265SDimitry Andric if (IsBranch) 25181ad6265SDimitry Andric printBranchOperand(&MI, Address, OpNo, STI, OS); 25281ad6265SDimitry Andric else 25381ad6265SDimitry Andric printOperand(&MI, OpNo, STI, OS); 2540b57cec5SDimitry Andric return true; 2550b57cec5SDimitry Andric } 2560b57cec5SDimitry Andric 2570b57cec5SDimitry Andric bool MipsInstPrinter::printAlias(const char *Str, const MCInst &MI, 25881ad6265SDimitry Andric uint64_t Address, unsigned OpNo0, 25981ad6265SDimitry Andric unsigned OpNo1, const MCSubtargetInfo &STI, 26081ad6265SDimitry Andric raw_ostream &OS, bool IsBranch) { 26181ad6265SDimitry Andric printAlias(Str, MI, Address, OpNo0, STI, OS, IsBranch); 2620b57cec5SDimitry Andric OS << ", "; 26381ad6265SDimitry Andric if (IsBranch) 26481ad6265SDimitry Andric printBranchOperand(&MI, Address, OpNo1, STI, OS); 26581ad6265SDimitry Andric else 26681ad6265SDimitry Andric printOperand(&MI, OpNo1, STI, OS); 2670b57cec5SDimitry Andric return true; 2680b57cec5SDimitry Andric } 2690b57cec5SDimitry Andric 27081ad6265SDimitry Andric bool MipsInstPrinter::printAlias(const MCInst &MI, uint64_t Address, 27181ad6265SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &OS) { 2720b57cec5SDimitry Andric switch (MI.getOpcode()) { 2730b57cec5SDimitry Andric case Mips::BEQ: 2740b57cec5SDimitry Andric case Mips::BEQ_MM: 2750b57cec5SDimitry Andric // beq $zero, $zero, $L2 => b $L2 2760b57cec5SDimitry Andric // beq $r0, $zero, $L2 => beqz $r0, $L2 2770b57cec5SDimitry Andric return (isReg<Mips::ZERO>(MI, 0) && isReg<Mips::ZERO>(MI, 1) && 27881ad6265SDimitry Andric printAlias("b", MI, Address, 2, STI, OS, true)) || 27981ad6265SDimitry Andric (isReg<Mips::ZERO>(MI, 1) && 28081ad6265SDimitry Andric printAlias("beqz", MI, Address, 0, 2, STI, OS, true)); 2810b57cec5SDimitry Andric case Mips::BEQ64: 2820b57cec5SDimitry Andric // beq $r0, $zero, $L2 => beqz $r0, $L2 28381ad6265SDimitry Andric return isReg<Mips::ZERO_64>(MI, 1) && 28481ad6265SDimitry Andric printAlias("beqz", MI, Address, 0, 2, STI, OS, true); 2850b57cec5SDimitry Andric case Mips::BNE: 2860b57cec5SDimitry Andric case Mips::BNE_MM: 2870b57cec5SDimitry Andric // bne $r0, $zero, $L2 => bnez $r0, $L2 28881ad6265SDimitry Andric return isReg<Mips::ZERO>(MI, 1) && 28981ad6265SDimitry Andric printAlias("bnez", MI, Address, 0, 2, STI, OS, true); 2900b57cec5SDimitry Andric case Mips::BNE64: 2910b57cec5SDimitry Andric // bne $r0, $zero, $L2 => bnez $r0, $L2 29281ad6265SDimitry Andric return isReg<Mips::ZERO_64>(MI, 1) && 29381ad6265SDimitry Andric printAlias("bnez", MI, Address, 0, 2, STI, OS, true); 2940b57cec5SDimitry Andric case Mips::BGEZAL: 2950b57cec5SDimitry Andric // bgezal $zero, $L1 => bal $L1 29681ad6265SDimitry Andric return isReg<Mips::ZERO>(MI, 0) && 29781ad6265SDimitry Andric printAlias("bal", MI, Address, 1, STI, OS, true); 2980b57cec5SDimitry Andric case Mips::BC1T: 2990b57cec5SDimitry Andric // bc1t $fcc0, $L1 => bc1t $L1 30081ad6265SDimitry Andric return isReg<Mips::FCC0>(MI, 0) && 30181ad6265SDimitry Andric printAlias("bc1t", MI, Address, 1, STI, OS, true); 3020b57cec5SDimitry Andric case Mips::BC1F: 3030b57cec5SDimitry Andric // bc1f $fcc0, $L1 => bc1f $L1 30481ad6265SDimitry Andric return isReg<Mips::FCC0>(MI, 0) && 30581ad6265SDimitry Andric printAlias("bc1f", MI, Address, 1, STI, OS, true); 3060b57cec5SDimitry Andric case Mips::JALR: 30781ad6265SDimitry Andric // jalr $zero, $r1 => jr $r1 3080b57cec5SDimitry Andric // jalr $ra, $r1 => jalr $r1 30981ad6265SDimitry Andric return (isReg<Mips::ZERO>(MI, 0) && 31081ad6265SDimitry Andric printAlias("jr", MI, Address, 1, STI, OS)) || 31181ad6265SDimitry Andric (isReg<Mips::RA>(MI, 0) && 31281ad6265SDimitry Andric printAlias("jalr", MI, Address, 1, STI, OS)); 3130b57cec5SDimitry Andric case Mips::JALR64: 31481ad6265SDimitry Andric // jalr $zero, $r1 => jr $r1 3150b57cec5SDimitry Andric // jalr $ra, $r1 => jalr $r1 31681ad6265SDimitry Andric return (isReg<Mips::ZERO_64>(MI, 0) && 31781ad6265SDimitry Andric printAlias("jr", MI, Address, 1, STI, OS)) || 31881ad6265SDimitry Andric (isReg<Mips::RA_64>(MI, 0) && 31981ad6265SDimitry Andric printAlias("jalr", MI, Address, 1, STI, OS)); 3200b57cec5SDimitry Andric case Mips::NOR: 3210b57cec5SDimitry Andric case Mips::NOR_MM: 3220b57cec5SDimitry Andric case Mips::NOR_MMR6: 3230b57cec5SDimitry Andric // nor $r0, $r1, $zero => not $r0, $r1 32481ad6265SDimitry Andric return isReg<Mips::ZERO>(MI, 2) && 32581ad6265SDimitry Andric printAlias("not", MI, Address, 0, 1, STI, OS); 3260b57cec5SDimitry Andric case Mips::NOR64: 3270b57cec5SDimitry Andric // nor $r0, $r1, $zero => not $r0, $r1 32881ad6265SDimitry Andric return isReg<Mips::ZERO_64>(MI, 2) && 32981ad6265SDimitry Andric printAlias("not", MI, Address, 0, 1, STI, OS); 3300b57cec5SDimitry Andric case Mips::OR: 33181ad6265SDimitry Andric case Mips::ADDu: 3320b57cec5SDimitry Andric // or $r0, $r1, $zero => move $r0, $r1 33381ad6265SDimitry Andric // addu $r0, $r1, $zero => move $r0, $r1 33481ad6265SDimitry Andric return isReg<Mips::ZERO>(MI, 2) && 33581ad6265SDimitry Andric printAlias("move", MI, Address, 0, 1, STI, OS); 33681ad6265SDimitry Andric default: 33781ad6265SDimitry Andric return false; 3380b57cec5SDimitry Andric } 3390b57cec5SDimitry Andric } 3400b57cec5SDimitry Andric 34181ad6265SDimitry Andric void MipsInstPrinter::printSaveRestore(const MCInst *MI, 34281ad6265SDimitry Andric const MCSubtargetInfo &STI, 34381ad6265SDimitry Andric raw_ostream &O) { 3440b57cec5SDimitry Andric for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { 3450b57cec5SDimitry Andric if (i != 0) O << ", "; 3460b57cec5SDimitry Andric if (MI->getOperand(i).isReg()) 3470b57cec5SDimitry Andric printRegName(O, MI->getOperand(i).getReg()); 3480b57cec5SDimitry Andric else 34981ad6265SDimitry Andric printUImm<16>(MI, i, STI, O); 3500b57cec5SDimitry Andric } 3510b57cec5SDimitry Andric } 3520b57cec5SDimitry Andric 35381ad6265SDimitry Andric void MipsInstPrinter::printRegisterList(const MCInst *MI, int opNum, 35481ad6265SDimitry Andric const MCSubtargetInfo & /* STI */, 35581ad6265SDimitry Andric raw_ostream &O) { 3560b57cec5SDimitry Andric // - 2 because register List is always first operand of instruction and it is 3570b57cec5SDimitry Andric // always followed by memory operand (base + offset). 3580b57cec5SDimitry Andric for (int i = opNum, e = MI->getNumOperands() - 2; i != e; ++i) { 3590b57cec5SDimitry Andric if (i != opNum) 3600b57cec5SDimitry Andric O << ", "; 3610b57cec5SDimitry Andric printRegName(O, MI->getOperand(i).getReg()); 3620b57cec5SDimitry Andric } 3630b57cec5SDimitry Andric } 364