14 #define DEBUG_TYPE "asm-printer"
26 #define PRINT_ALIAS_INSTR
27 #include "MipsGenAsmWriter.inc"
84 O <<
"\t.set\tpush\n";
85 O <<
"\t.set\tmips32r2\n";
106 if (
const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) {
109 assert(SRE && CE &&
"Binary expression must be sym+const.");
110 Offset = CE->getValue();
112 else if (!(SRE = dyn_cast<MCSymbolRefExpr>(Expr)))
113 assert(
false &&
"Unexpected MCExpr type.");
161 void MipsInstPrinter::printOperand(
const MCInst *
MI,
unsigned OpNo,
174 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
178 void MipsInstPrinter::printUnsignedImm(
const MCInst *MI,
int opNum,
182 O << (
unsigned short int)MO.
getImm();
184 printOperand(MI, opNum, O);
187 void MipsInstPrinter::printUnsignedImm8(
const MCInst *MI,
int opNum,
191 O << (
unsigned short int)(
unsigned char)MO.
getImm();
193 printOperand(MI, opNum, O);
196 void MipsInstPrinter::
201 printOperand(MI, opNum+1, O);
203 printOperand(MI, opNum, O);
207 void MipsInstPrinter::
211 printOperand(MI, opNum, O);
213 printOperand(MI, opNum+1, O);
217 void MipsInstPrinter::
223 void MipsInstPrinter::
228 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &MI,
230 OS <<
"\t" << Str <<
"\t";
231 printOperand(&MI, OpNo, OS);
235 bool MipsInstPrinter::printAlias(
const char *Str,
const MCInst &MI,
236 unsigned OpNo0,
unsigned OpNo1,
238 printAlias(Str, MI, OpNo0, OS);
240 printOperand(&MI, OpNo1, OS);
249 return (isReg<Mips::ZERO>(MI, 0) && isReg<Mips::ZERO>(
MI, 1) &&
250 printAlias(
"b", MI, 2, OS)) ||
251 (isReg<Mips::ZERO>(MI, 1) && printAlias(
"beqz", MI, 0, 2, OS));
254 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"beqz", MI, 0, 2, OS);
257 return isReg<Mips::ZERO>(
MI, 1) && printAlias(
"bnez", MI, 0, 2, OS);
260 return isReg<Mips::ZERO_64>(
MI, 1) && printAlias(
"bnez", MI, 0, 2, OS);
263 return isReg<Mips::ZERO>(
MI, 0) && printAlias(
"bal", MI, 1, OS);
266 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1t", MI, 1, OS);
269 return isReg<Mips::FCC0>(
MI, 0) && printAlias(
"bc1f", MI, 1, OS);
272 return isReg<Mips::RA>(
MI, 0) && printAlias(
"jalr", MI, 1, OS);
275 return isReg<Mips::RA_64>(
MI, 0) && printAlias(
"jalr", MI, 1, OS);
279 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"not", MI, 0, 1, OS);
282 return isReg<Mips::ZERO_64>(
MI, 2) && printAlias(
"not", MI, 0, 1, OS);
285 return isReg<Mips::ZERO>(
MI, 2) && printAlias(
"move", MI, 0, 1, OS);
286 default:
return false;
static bool isReg(const MCInst &MI, unsigned OpNo)
bool printAliasInstr(const MCInst *MI, raw_ostream &OS)
const MCSymbol & getSymbol() const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
#define llvm_unreachable(msg)
unsigned getReg() const
getReg - Returns the register number.
const MCExpr * getExpr() const
MCBinaryExpr - Binary assembler expressions.
unsigned getOpcode() const
const char * MipsFCCToString(Mips::CondCode CC)
static void printExpr(const MCExpr *Expr, raw_ostream &OS)
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const
printRegName - Print the assembler register name.
VariantKind getKind() const
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)
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot)
std::string lower() const
const MCOperand & getOperand(unsigned i) const