27#define DEBUG_TYPE "asm-printer"
29#define PRINT_ALIAS_INSTR
30#include "MipsGenAsmWriter.inc"
34 assert(
MI.getOperand(OpNo).isReg() &&
"Register operand expected.");
35 return MI.getOperand(OpNo).getReg() == R;
79 unsigned Encoding =
MRI.getEncodingValue(
MI->getOperand(OpNo).getReg());
93 switch (
MI->getOpcode()) {
98 O <<
"\t.set\tpush\n";
99 O <<
"\t.set\tmips32r2\n";
103 printSaveRestore(
MI, STI, O);
104 O <<
" # 16 bit inst\n";
108 printSaveRestore(
MI, STI, O);
111 case Mips::Restore16:
113 printSaveRestore(
MI, STI, O);
114 O <<
" # 16 bit inst\n";
116 case Mips::RestoreX16:
118 printSaveRestore(
MI, STI, O);
129 switch (
MI->getOpcode()) {
134 O <<
"\n\t.set\tpop";
138void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
151 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
152 MAI.printExpr(O, *
Op.getExpr());
155template <
unsigned FromEnd>
156void MipsInstPrinter::printOperandFromEnd(
const MCInst *
MI,
int OpNo,
159 printOperand(
MI,
MI->getNumOperands() - FromEnd, STI, O);
162void MipsInstPrinter::printJumpOperand(
const MCInst *
MI,
unsigned OpNo,
165 const MCOperand &
Op =
MI->getOperand(OpNo);
167 return printOperand(
MI, OpNo, STI, O);
179 const MCOperand &
Op =
MI->getOperand(OpNo);
181 return printOperand(
MI, OpNo, STI, O);
195template <
unsigned Bits,
unsigned Offset>
196void MipsInstPrinter::printUImm(
const MCInst *
MI,
int opNum,
198 const MCOperand &MO =
MI->getOperand(opNum);
208 printOperand(
MI, opNum, STI, O);
211void MipsInstPrinter::printMemOperand(
const MCInst *
MI,
int opNum,
219 printOperand(
MI, opNum + 1, STI, O);
221 printOperand(
MI, opNum, STI, O);
225void MipsInstPrinter::printFCCOperand(
const MCInst *
MI,
int opNum,
228 const MCOperand &MO =
MI->getOperand(opNum);
232void MipsInstPrinter::
237bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
241 OS <<
"\t" << Str <<
"\t";
243 printBranchOperand(&
MI,
Address, OpNo, STI, OS);
245 printOperand(&
MI, OpNo, STI, OS);
249bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
253 printAlias(Str,
MI,
Address, OpNo0, STI, OS, IsBranch);
256 printBranchOperand(&
MI,
Address, OpNo1, STI, OS);
258 printOperand(&
MI, OpNo1, STI, OS);
264 switch (
MI.getOpcode()) {
270 printAlias(
"b",
MI,
Address, 2, STI, OS,
true)) ||
272 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true));
276 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true);
281 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
285 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
289 printAlias(
"bal",
MI,
Address, 1, STI, OS,
true);
293 printAlias(
"bc1t",
MI,
Address, 1, STI, OS,
true);
297 printAlias(
"bc1f",
MI,
Address, 1, STI, OS,
true);
302 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
304 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
309 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
311 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
317 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
321 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
327 printAlias(
"move",
MI,
Address, 0, 1, STI, OS);
333void MipsInstPrinter::printSaveRestore(
const MCInst *
MI,
336 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
337 if (i != 0)
O <<
", ";
338 if (
MI->getOperand(i).isReg())
341 printUImm<16>(
MI, i, STI, O);
345void MipsInstPrinter::printRegisterList(
const MCInst *
MI,
int opNum,
350 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