26#define DEBUG_TYPE "asm-printer"
28#define PRINT_ALIAS_INSTR
29#include "MipsGenAsmWriter.inc"
33 assert(
MI.getOperand(OpNo).isReg() &&
"Register operand expected.");
34 return MI.getOperand(OpNo).getReg() == R;
78 unsigned Encoding =
MRI.getEncodingValue(
MI->getOperand(OpNo).getReg());
92 switch (
MI->getOpcode()) {
97 O <<
"\t.set\tpush\n";
98 O <<
"\t.set\tmips32r2\n";
102 printSaveRestore(
MI, STI, O);
103 O <<
" # 16 bit inst\n";
107 printSaveRestore(
MI, STI, O);
110 case Mips::Restore16:
112 printSaveRestore(
MI, STI, O);
113 O <<
" # 16 bit inst\n";
115 case Mips::RestoreX16:
117 printSaveRestore(
MI, STI, O);
128 switch (
MI->getOpcode()) {
133 O <<
"\n\t.set\tpop";
137void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
150 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
151 MAI.printExpr(O, *
Op.getExpr());
154template <
unsigned FromEnd>
155void MipsInstPrinter::printOperandFromEnd(
const MCInst *
MI,
int OpNo,
158 printOperand(
MI,
MI->getNumOperands() - FromEnd, STI, O);
161void MipsInstPrinter::printJumpOperand(
const MCInst *
MI,
unsigned OpNo,
164 const MCOperand &
Op =
MI->getOperand(OpNo);
166 return printOperand(
MI, OpNo, STI, O);
178 const MCOperand &
Op =
MI->getOperand(OpNo);
180 return printOperand(
MI, OpNo, STI, O);
194template <
unsigned Bits,
unsigned Offset>
195void MipsInstPrinter::printUImm(
const MCInst *
MI,
int opNum,
197 const MCOperand &MO =
MI->getOperand(opNum);
207 printOperand(
MI, opNum, STI, O);
210void MipsInstPrinter::printMemOperand(
const MCInst *
MI,
int opNum,
218 printOperand(
MI, opNum + 1, STI, O);
220 printOperand(
MI, opNum, STI, O);
224void MipsInstPrinter::printFCCOperand(
const MCInst *
MI,
int opNum,
227 const MCOperand &MO =
MI->getOperand(opNum);
231void MipsInstPrinter::
236bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
240 OS <<
"\t" << Str <<
"\t";
242 printBranchOperand(&
MI,
Address, OpNo, STI, OS);
244 printOperand(&
MI, OpNo, STI, OS);
248bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
252 printAlias(Str,
MI,
Address, OpNo0, STI, OS, IsBranch);
255 printBranchOperand(&
MI,
Address, OpNo1, STI, OS);
257 printOperand(&
MI, OpNo1, STI, OS);
263 switch (
MI.getOpcode()) {
269 printAlias(
"b",
MI,
Address, 2, STI, OS,
true)) ||
271 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true));
275 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true);
280 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
284 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
288 printAlias(
"bal",
MI,
Address, 1, STI, OS,
true);
292 printAlias(
"bc1t",
MI,
Address, 1, STI, OS,
true);
296 printAlias(
"bc1f",
MI,
Address, 1, STI, OS,
true);
301 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
303 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
308 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
310 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
316 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
320 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
326 printAlias(
"move",
MI,
Address, 0, 1, STI, OS);
332void MipsInstPrinter::printSaveRestore(
const MCInst *
MI,
335 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
336 if (i != 0)
O <<
", ";
337 if (
MI->getOperand(i).isReg())
340 printUImm<16>(
MI, i, STI, O);
344void MipsInstPrinter::printRegisterList(
const MCInst *
MI,
int opNum,
349 for (
int i = opNum, e =
MI->getNumOperands() - 2; i != e; ++i) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isReg(const MCInst &MI, unsigned OpNo)
WithMarkup markup(raw_ostream &OS, Markup M)
format_object< int64_t > formatHex(int64_t Value) const
const MCRegisterInfo & MRI
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 printCOP0Operand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, raw_ostream &O)
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=Mips::NoRegAltName)
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.
bool printAliasInstr(const MCInst *MI, uint64_t Address, const MCSubtargetInfo &STI, raw_ostream &OS)
Represent a constant reference to a string, i.e.
LLVM_ABI std::string lower() const
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.
constexpr unsigned getCOP0RegNum(unsigned Encoding)
constexpr unsigned getCOP0Sel(unsigned Encoding)
const char * MipsFCCToString(Mips::CondCode CC)
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op