26 #define DEBUG_TYPE "asm-printer"
28 #define PRINT_ALIAS_INSTR
29 #include "MipsGenAsmWriter.inc"
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);
121 O <<
"\n\t.set\tpop";
130 if (
const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) {
133 assert(SRE && CE &&
"Binary expression must be sym+const.");
134 Offset = CE->getValue();
135 }
else if (
const MipsMCExpr *ME = dyn_cast<MipsMCExpr>(Expr)) {
139 SRE = cast<MCSymbolRefExpr>(Expr);
189 void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
202 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
206 void MipsInstPrinter::printUnsignedImm(
const MCInst *MI,
int opNum,
210 O << (
unsigned short int)MO.
getImm();
212 printOperand(MI, opNum, O);
215 void MipsInstPrinter::printUnsignedImm8(
const MCInst *MI,
int opNum,
219 O << (
unsigned short int)(
unsigned char)MO.
getImm();
221 printOperand(MI, opNum, O);
224 void MipsInstPrinter::
243 printOperand(MI, opNum+1, O);
245 printOperand(MI, opNum, O);
249 void MipsInstPrinter::
253 printOperand(MI, opNum, O);
255 printOperand(MI, opNum+1, O);
259 void MipsInstPrinter::
265 void MipsInstPrinter::
270 void MipsInstPrinter::
275 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &MI,
277 OS <<
"\t" << Str <<
"\t";
278 printOperand(&MI, OpNo, OS);
282 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &MI,
283 unsigned OpNo0,
unsigned OpNo1,
285 printAlias(Str, MI, OpNo0, OS);
287 printOperand(&MI, OpNo1, OS);
297 return (isReg<Mips::ZERO>(MI, 0) && isReg<Mips::ZERO>(
MI, 1) &&
298 printAlias(
"b", MI, 2, OS)) ||
299 (isReg<Mips::ZERO>(MI, 1) && printAlias(
"beqz", MI, 0, 2, OS));
302 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"beqz", MI, 0, 2, OS);
305 return isReg<Mips::ZERO>(
MI, 1) && printAlias(
"bnez", MI, 0, 2, OS);
308 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"bnez", MI, 0, 2, OS);
311 return isReg<Mips::ZERO>(
MI, 0) && printAlias(
"bal", MI, 1, OS);
314 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1t", MI, 1, OS);
317 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1f", MI, 1, OS);
320 return isReg<Mips::RA>(
MI, 0) && printAlias(
"jalr", MI, 1, OS);
323 return isReg<Mips::RA_64>(
MI, 0) && printAlias(
"jalr", MI, 1, OS);
327 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"not", MI, 0, 1, OS);
330 return isReg<Mips::ZERO_64>(
MI, 2) && printAlias(
"not", MI, 0, 1, OS);
333 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"move", MI, 0, 1, OS);
334 default:
return false;
340 if (i != 0) O <<
", ";
344 printUnsignedImm(MI, i, O);
348 void MipsInstPrinter::
static bool isReg(const MCInst &MI, unsigned OpNo)
bool printAliasInstr(const MCInst *MI, raw_ostream &OS)
const MCSymbol & getSymbol() const
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
unsigned getReg() const
Returns the register number.
Instances of this class represent a single low-level machine instruction.
This class is intended to be used as a base class for asm properties and features specific to the tar...
const MCExpr * getExpr() const
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
Binary assembler expressions.
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI, raw_ostream &OS)
unsigned getOpcode() const
const char * MipsFCCToString(Mips::CondCode CC)
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
MCSubtargetInfo - Generic base class for all target subtargets.
VariantKind getKind() const
const ARM::ArchExtKind Kind
static const char * getRegisterName(unsigned RegNo)
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
void printInstruction(const MCInst *MI, raw_ostream &O)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Instances of this class represent operands of the MCInst class.
std::string lower() const
const MCOperand & getOperand(unsigned i) const