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;
83 switch (
MI->getOpcode()) {
88 O <<
"\t.set\tpush\n";
89 O <<
"\t.set\tmips32r2\n";
93 printSaveRestore(
MI, STI, O);
94 O <<
" # 16 bit inst\n";
98 printSaveRestore(
MI, STI, O);
101 case Mips::Restore16:
103 printSaveRestore(
MI, STI, O);
104 O <<
" # 16 bit inst\n";
106 case Mips::RestoreX16:
108 printSaveRestore(
MI, STI, O);
119 switch (
MI->getOpcode()) {
124 O <<
"\n\t.set\tpop";
128void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
141 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
142 MAI.printExpr(O, *
Op.getExpr());
145void MipsInstPrinter::printJumpOperand(
const MCInst *
MI,
unsigned OpNo,
148 const MCOperand &
Op =
MI->getOperand(OpNo);
150 return printOperand(
MI, OpNo, STI, O);
158void MipsInstPrinter::printBranchOperand(
const MCInst *
MI, uint64_t
Address,
162 const MCOperand &
Op =
MI->getOperand(OpNo);
164 return printOperand(
MI, OpNo, STI, O);
178template <
unsigned Bits,
unsigned Offset>
179void MipsInstPrinter::printUImm(
const MCInst *
MI,
int opNum,
181 const MCOperand &MO =
MI->getOperand(opNum);
191 printOperand(
MI, opNum, STI, O);
194void MipsInstPrinter::printMemOperand(
const MCInst *
MI,
int opNum,
203 switch (
MI->getOpcode()) {
209 case Mips::SWM16_MMR6:
211 case Mips::LWM16_MMR6:
212 opNum =
MI->getNumOperands() - 2;
217 printOperand(
MI, opNum + 1, STI, O);
219 printOperand(
MI, opNum, STI, O);
223void MipsInstPrinter::printMemOperandEA(
const MCInst *
MI,
int opNum,
228 printOperand(
MI, opNum, STI, O);
230 printOperand(
MI, opNum + 1, STI, O);
233void MipsInstPrinter::printFCCOperand(
const MCInst *
MI,
int opNum,
236 const MCOperand &MO =
MI->getOperand(opNum);
240void MipsInstPrinter::
245bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
246 uint64_t
Address,
unsigned OpNo,
249 OS <<
"\t" << Str <<
"\t";
251 printBranchOperand(&
MI,
Address, OpNo, STI, OS);
253 printOperand(&
MI, OpNo, STI, OS);
257bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
258 uint64_t
Address,
unsigned OpNo0,
261 printAlias(Str,
MI,
Address, OpNo0, STI, OS, IsBranch);
264 printBranchOperand(&
MI,
Address, OpNo1, STI, OS);
266 printOperand(&
MI, OpNo1, STI, OS);
272 switch (
MI.getOpcode()) {
278 printAlias(
"b",
MI,
Address, 2, STI, OS,
true)) ||
280 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true));
284 printAlias(
"beqz",
MI,
Address, 0, 2, STI, OS,
true);
289 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
293 printAlias(
"bnez",
MI,
Address, 0, 2, STI, OS,
true);
297 printAlias(
"bal",
MI,
Address, 1, STI, OS,
true);
301 printAlias(
"bc1t",
MI,
Address, 1, STI, OS,
true);
305 printAlias(
"bc1f",
MI,
Address, 1, STI, OS,
true);
310 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
312 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
317 printAlias(
"jr",
MI,
Address, 1, STI, OS)) ||
319 printAlias(
"jalr",
MI,
Address, 1, STI, OS));
325 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
329 printAlias(
"not",
MI,
Address, 0, 1, STI, OS);
335 printAlias(
"move",
MI,
Address, 0, 1, STI, OS);
341void MipsInstPrinter::printSaveRestore(
const MCInst *
MI,
344 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
345 if (i != 0)
O <<
", ";
346 if (
MI->getOperand(i).isReg())
349 printUImm<16>(
MI, i, STI, O);
353void MipsInstPrinter::printRegisterList(
const MCInst *
MI,
int opNum,
358 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
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.
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.
const char * MipsFCCToString(Mips::CondCode CC)
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op