Go to the documentation of this file.
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;
81 switch (
MI->getOpcode()) {
86 O <<
"\t.set\tpush\n";
87 O <<
"\t.set\tmips32r2\n";
91 printSaveRestore(
MI,
O);
92 O <<
" # 16 bit inst\n";
96 printSaveRestore(
MI,
O);
101 printSaveRestore(
MI,
O);
102 O <<
" # 16 bit inst\n";
104 case Mips::RestoreX16:
106 printSaveRestore(
MI,
O);
116 switch (
MI->getOpcode()) {
121 O <<
"\n\t.set\tpop";
125 void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
138 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
139 Op.getExpr()->print(
O, &
MAI,
true);
142 template <
unsigned Bits,
unsigned Offset>
146 uint64_t Imm = MO.
getImm();
148 Imm &= (1 <<
Bits) - 1;
154 printOperand(
MI, opNum,
O);
157 void MipsInstPrinter::
165 switch (
MI->getOpcode()) {
171 case Mips::SWM16_MMR6:
173 case Mips::LWM16_MMR6:
174 opNum =
MI->getNumOperands() - 2;
178 printOperand(
MI, opNum+1,
O);
180 printOperand(
MI, opNum,
O);
184 void MipsInstPrinter::
188 printOperand(
MI, opNum,
O);
190 printOperand(
MI, opNum+1,
O);
193 void MipsInstPrinter::
199 void MipsInstPrinter::
204 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
206 OS <<
"\t" << Str <<
"\t";
207 printOperand(&
MI, OpNo, OS);
211 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &
MI,
212 unsigned OpNo0,
unsigned OpNo1,
214 printAlias(Str,
MI, OpNo0, OS);
216 printOperand(&
MI, OpNo1, OS);
221 switch (
MI.getOpcode()) {
226 return (isReg<Mips::ZERO>(
MI, 0) && isReg<Mips::ZERO>(
MI, 1) &&
227 printAlias(
"b",
MI, 2, OS)) ||
228 (isReg<Mips::ZERO>(
MI, 1) && printAlias(
"beqz",
MI, 0, 2, OS));
231 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"beqz",
MI, 0, 2, OS);
235 return isReg<Mips::ZERO>(
MI, 1) && printAlias(
"bnez",
MI, 0, 2, OS);
238 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"bnez",
MI, 0, 2, OS);
241 return isReg<Mips::ZERO>(
MI, 0) && printAlias(
"bal",
MI, 1, OS);
244 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1t",
MI, 1, OS);
247 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1f",
MI, 1, OS);
250 return isReg<Mips::RA>(
MI, 0) && printAlias(
"jalr",
MI, 1, OS);
253 return isReg<Mips::RA_64>(
MI, 0) && printAlias(
"jalr",
MI, 1, OS);
258 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"not",
MI, 0, 1, OS);
261 return isReg<Mips::ZERO_64>(
MI, 2) && printAlias(
"not",
MI, 0, 1, OS);
264 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"move",
MI, 0, 1, OS);
265 default:
return false;
270 for (
unsigned i = 0,
e =
MI->getNumOperands();
i !=
e; ++
i) {
271 if (
i != 0)
O <<
", ";
272 if (
MI->getOperand(
i).isReg())
275 printUImm<16>(
MI,
i,
O);
279 void MipsInstPrinter::
283 for (
int i = opNum,
e =
MI->getNumOperands() - 2;
i !=
e; ++
i) {
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS)
Instances of this class represent a single low-level machine instruction.
static const char * getRegisterName(unsigned RegNo)
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
This class implements an extremely fast bulk output stream that can only output to a stream.
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
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.
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
LLVM_NODISCARD std::string lower() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isReg(const MCInst &MI, unsigned OpNo)
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const char * MipsFCCToString(Mips::CondCode CC)
Instances of this class represent operands of the MCInst class.
Generic base class for all target subtargets.