25#define DEBUG_TYPE "asm-printer"
27#define PRINT_ALIAS_INSTR
28#include "MipsGenAsmWriter.inc"
32 assert(
MI.getOperand(OpNo).isReg() &&
"Register operand expected.");
33 return MI.getOperand(OpNo).getReg() == R;
82 switch (
MI->getOpcode()) {
87 O <<
"\t.set\tpush\n";
88 O <<
"\t.set\tmips32r2\n";
92 printSaveRestore(
MI, STI, O);
93 O <<
" # 16 bit inst\n";
97 printSaveRestore(
MI, STI, O);
100 case Mips::Restore16:
102 printSaveRestore(
MI, STI, O);
103 O <<
" # 16 bit inst\n";
105 case Mips::RestoreX16:
107 printSaveRestore(
MI, STI, O);
118 switch (
MI->getOpcode()) {
123 O <<
"\n\t.set\tpop";
127void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
140 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
144void MipsInstPrinter::printJumpOperand(
const MCInst *
MI,
unsigned OpNo,
149 return printOperand(
MI, OpNo, STI, O);
163 return printOperand(
MI, OpNo, STI, O);
177template <
unsigned Bits,
unsigned Offset>
178void MipsInstPrinter::printUImm(
const MCInst *
MI,
int opNum,
190 printOperand(
MI, opNum, STI, O);
193void MipsInstPrinter::printMemOperand(
const MCInst *
MI,
int opNum,
202 switch (
MI->getOpcode()) {
208 case Mips::SWM16_MMR6:
210 case Mips::LWM16_MMR6:
211 opNum =
MI->getNumOperands() - 2;
216 printOperand(
MI, opNum + 1, STI, O);
218 printOperand(
MI, opNum, STI, O);
222void MipsInstPrinter::printMemOperandEA(
const MCInst *
MI,
int opNum,
227 printOperand(
MI, opNum, STI, O);
229 printOperand(
MI, opNum + 1, STI, O);
232void MipsInstPrinter::printFCCOperand(
const MCInst *
MI,
int opNum,
239void MipsInstPrinter::
244bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
248 OS <<
"\t" << Str <<
"\t";
252 printOperand(&
MI, OpNo, STI,
OS);
256bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
260 printAlias(Str,
MI,
Address, OpNo0, STI,
OS, IsBranch);
265 printOperand(&
MI, OpNo1, STI,
OS);
271 switch (
MI.getOpcode()) {
276 return (isReg<Mips::ZERO>(
MI, 0) && isReg<Mips::ZERO>(
MI, 1) &&
278 (isReg<Mips::ZERO>(
MI, 1) &&
279 printAlias(
"beqz",
MI,
Address, 0, 2, STI,
OS,
true));
282 return isReg<Mips::ZERO_64>(
MI, 1) &&
283 printAlias(
"beqz",
MI,
Address, 0, 2, STI,
OS,
true);
287 return isReg<Mips::ZERO>(
MI, 1) &&
288 printAlias(
"bnez",
MI,
Address, 0, 2, STI,
OS,
true);
291 return isReg<Mips::ZERO_64>(
MI, 1) &&
292 printAlias(
"bnez",
MI,
Address, 0, 2, STI,
OS,
true);
295 return isReg<Mips::ZERO>(
MI, 0) &&
299 return isReg<Mips::FCC0>(
MI, 0) &&
303 return isReg<Mips::FCC0>(
MI, 0) &&
308 return (isReg<Mips::ZERO>(
MI, 0) &&
310 (isReg<Mips::RA>(
MI, 0) &&
315 return (isReg<Mips::ZERO_64>(
MI, 0) &&
317 (isReg<Mips::RA_64>(
MI, 0) &&
323 return isReg<Mips::ZERO>(
MI, 2) &&
327 return isReg<Mips::ZERO_64>(
MI, 2) &&
333 return isReg<Mips::ZERO>(
MI, 2) &&
340void MipsInstPrinter::printSaveRestore(
const MCInst *
MI,
343 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
344 if (i != 0)
O <<
", ";
345 if (
MI->getOperand(i).isReg())
348 printUImm<16>(
MI, i, STI, O);
352void MipsInstPrinter::printRegisterList(
const MCInst *
MI,
int opNum,
357 for (
int i = opNum, e =
MI->getNumOperands() - 2; i != e; ++i) {
static bool isReg(const MCInst &MI, unsigned OpNo)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an Operation in the Expression.
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
WithMarkup markup(raw_ostream &OS, Markup M)
format_object< int64_t > formatHex(int64_t Value) const
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
bool PrintBranchImmAsAddress
If true, a branch immediate (e.g.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent operands of the MCInst class.
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
void printRegName(raw_ostream &OS, MCRegister Reg) override
Print the assembler register name.
void printInstruction(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &O)
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
static const char * getRegisterName(MCRegister Reg)
bool printAliasInstr(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &OS)
StringRef - Represent a constant reference to a string, i.e.
std::string lower() const
Target - Wrapper for Target specific information.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const char * MipsFCCToString(Mips::CondCode CC)
This is an optimization pass for GlobalISel generic memory operations.