2012-02-17 16:55:11 +08:00
|
|
|
//===-- MipsInstPrinter.cpp - Convert Mips MCInst to assembly syntax ------===//
|
2011-07-08 07:56:50 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This class prints an Mips MCInst to a .s file.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MipsInstPrinter.h"
|
2014-02-05 02:41:57 +08:00
|
|
|
#include "MCTargetDesc/MipsMCExpr.h"
|
2014-03-04 18:07:28 +08:00
|
|
|
#include "MipsInstrInfo.h"
|
2011-11-09 06:26:47 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2011-07-08 07:56:50 +08:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCInst.h"
|
2012-04-02 15:01:04 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2011-11-09 06:26:47 +08:00
|
|
|
#include "llvm/MC/MCSymbol.h"
|
2011-07-09 04:18:13 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2011-07-08 07:56:50 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "asm-printer"
|
|
|
|
|
2013-02-05 16:32:10 +08:00
|
|
|
#define PRINT_ALIAS_INSTR
|
2011-07-08 07:56:50 +08:00
|
|
|
#include "MipsGenAsmWriter.inc"
|
|
|
|
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
template<unsigned R>
|
|
|
|
static bool isReg(const MCInst &MI, unsigned OpNo) {
|
|
|
|
assert(MI.getOperand(OpNo).isReg() && "Register operand expected.");
|
|
|
|
return MI.getOperand(OpNo).getReg() == R;
|
|
|
|
}
|
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
const char* Mips::MipsFCCToString(Mips::CondCode CC) {
|
|
|
|
switch (CC) {
|
|
|
|
case FCOND_F:
|
|
|
|
case FCOND_T: return "f";
|
|
|
|
case FCOND_UN:
|
|
|
|
case FCOND_OR: return "un";
|
|
|
|
case FCOND_OEQ:
|
|
|
|
case FCOND_UNE: return "eq";
|
|
|
|
case FCOND_UEQ:
|
|
|
|
case FCOND_ONE: return "ueq";
|
|
|
|
case FCOND_OLT:
|
|
|
|
case FCOND_UGE: return "olt";
|
|
|
|
case FCOND_ULT:
|
|
|
|
case FCOND_OGE: return "ult";
|
|
|
|
case FCOND_OLE:
|
|
|
|
case FCOND_UGT: return "ole";
|
|
|
|
case FCOND_ULE:
|
|
|
|
case FCOND_OGT: return "ule";
|
|
|
|
case FCOND_SF:
|
|
|
|
case FCOND_ST: return "sf";
|
|
|
|
case FCOND_NGLE:
|
|
|
|
case FCOND_GLE: return "ngle";
|
|
|
|
case FCOND_SEQ:
|
|
|
|
case FCOND_SNE: return "seq";
|
|
|
|
case FCOND_NGL:
|
|
|
|
case FCOND_GL: return "ngl";
|
|
|
|
case FCOND_LT:
|
|
|
|
case FCOND_NLT: return "lt";
|
|
|
|
case FCOND_NGE:
|
|
|
|
case FCOND_GE: return "nge";
|
|
|
|
case FCOND_LE:
|
|
|
|
case FCOND_NLE: return "le";
|
|
|
|
case FCOND_NGT:
|
|
|
|
case FCOND_GT: return "ngt";
|
|
|
|
}
|
2011-07-09 04:18:13 +08:00
|
|
|
llvm_unreachable("Impossible condition code!");
|
2011-07-08 07:56:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MipsInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
|
2011-11-07 04:37:06 +08:00
|
|
|
OS << '$' << StringRef(getRegisterName(RegNo)).lower();
|
2011-07-08 07:56:50 +08:00
|
|
|
}
|
|
|
|
|
2011-09-16 07:38:46 +08:00
|
|
|
void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
|
|
|
StringRef Annot) {
|
2012-07-06 03:26:38 +08:00
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Mips::RDHWR:
|
|
|
|
case Mips::RDHWR64:
|
|
|
|
O << "\t.set\tpush\n";
|
|
|
|
O << "\t.set\tmips32r2\n";
|
2013-12-09 00:51:52 +08:00
|
|
|
break;
|
|
|
|
case Mips::Save16:
|
2013-12-11 11:32:44 +08:00
|
|
|
O << "\tsave\t";
|
|
|
|
printSaveRestore(MI, O);
|
|
|
|
O << " # 16 bit inst\n";
|
|
|
|
return;
|
2013-12-09 00:51:52 +08:00
|
|
|
case Mips::SaveX16:
|
|
|
|
O << "\tsave\t";
|
|
|
|
printSaveRestore(MI, O);
|
|
|
|
O << "\n";
|
|
|
|
return;
|
|
|
|
case Mips::Restore16:
|
2013-12-11 11:32:44 +08:00
|
|
|
O << "\trestore\t";
|
|
|
|
printSaveRestore(MI, O);
|
|
|
|
O << " # 16 bit inst\n";
|
|
|
|
return;
|
2013-12-09 00:51:52 +08:00
|
|
|
case Mips::RestoreX16:
|
|
|
|
O << "\trestore\t";
|
|
|
|
printSaveRestore(MI, O);
|
|
|
|
O << "\n";
|
|
|
|
return;
|
2012-07-06 03:26:38 +08:00
|
|
|
}
|
|
|
|
|
2013-02-05 16:32:10 +08:00
|
|
|
// Try to print any aliases first.
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
if (!printAliasInstr(MI, O) && !printAlias(*MI, O))
|
2013-02-05 16:32:10 +08:00
|
|
|
printInstruction(MI, O);
|
2011-09-22 01:58:45 +08:00
|
|
|
printAnnotation(O, Annot);
|
2012-07-06 03:26:38 +08:00
|
|
|
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Mips::RDHWR:
|
|
|
|
case Mips::RDHWR64:
|
|
|
|
O << "\n\t.set\tpop";
|
|
|
|
}
|
2011-07-08 07:56:50 +08:00
|
|
|
}
|
|
|
|
|
2011-11-09 06:26:47 +08:00
|
|
|
static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
|
|
|
int Offset = 0;
|
|
|
|
const MCSymbolRefExpr *SRE;
|
|
|
|
|
|
|
|
if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) {
|
|
|
|
SRE = dyn_cast<MCSymbolRefExpr>(BE->getLHS());
|
|
|
|
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(BE->getRHS());
|
|
|
|
assert(SRE && CE && "Binary expression must be sym+const.");
|
|
|
|
Offset = CE->getValue();
|
2014-02-05 02:41:57 +08:00
|
|
|
} else if (const MipsMCExpr *ME = dyn_cast<MipsMCExpr>(Expr)) {
|
|
|
|
ME->print(OS);
|
|
|
|
return;
|
2015-01-05 18:15:49 +08:00
|
|
|
} else
|
|
|
|
SRE = cast<MCSymbolRefExpr>(Expr);
|
2011-11-09 06:26:47 +08:00
|
|
|
|
|
|
|
MCSymbolRefExpr::VariantKind Kind = SRE->getKind();
|
|
|
|
|
|
|
|
switch (Kind) {
|
2012-02-07 10:50:20 +08:00
|
|
|
default: llvm_unreachable("Invalid kind!");
|
2011-12-20 03:52:25 +08:00
|
|
|
case MCSymbolRefExpr::VK_None: break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GPREL: OS << "%gp_rel("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_CALL: OS << "%call16("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT16: OS << "%got("; break;
|
2014-03-31 22:34:36 +08:00
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT: OS << "%got("; break;
|
2011-12-20 03:52:25 +08:00
|
|
|
case MCSymbolRefExpr::VK_Mips_ABS_HI: OS << "%hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_ABS_LO: OS << "%lo("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_TLSGD: OS << "%tlsgd("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_TLSLDM: OS << "%tlsldm("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_DTPREL_HI: OS << "%dtprel_hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_DTPREL_LO: OS << "%dtprel_lo("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOTTPREL: OS << "%gottprel("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_TPREL_HI: OS << "%tprel_hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_TPREL_LO: OS << "%tprel_lo("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GPOFF_HI: OS << "%hi(%neg(%gp_rel("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GPOFF_LO: OS << "%lo(%neg(%gp_rel("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_DISP: OS << "%got_disp("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_PAGE: OS << "%got_page("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_OFST: OS << "%got_ofst("; break;
|
2012-07-21 11:09:04 +08:00
|
|
|
case MCSymbolRefExpr::VK_Mips_HIGHER: OS << "%higher("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_HIGHEST: OS << "%highest("; break;
|
2012-11-22 04:40:38 +08:00
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_HI16: OS << "%got_hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_GOT_LO16: OS << "%got_lo("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_CALL_HI16: OS << "%call_hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_CALL_LO16: OS << "%call_lo("; break;
|
2014-05-27 22:58:51 +08:00
|
|
|
case MCSymbolRefExpr::VK_Mips_PCREL_HI16: OS << "%pcrel_hi("; break;
|
|
|
|
case MCSymbolRefExpr::VK_Mips_PCREL_LO16: OS << "%pcrel_lo("; break;
|
2011-11-09 06:26:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OS << SRE->getSymbol();
|
|
|
|
|
|
|
|
if (Offset) {
|
|
|
|
if (Offset > 0)
|
|
|
|
OS << '+';
|
|
|
|
OS << Offset;
|
|
|
|
}
|
|
|
|
|
2011-11-11 11:58:36 +08:00
|
|
|
if ((Kind == MCSymbolRefExpr::VK_Mips_GPOFF_HI) ||
|
|
|
|
(Kind == MCSymbolRefExpr::VK_Mips_GPOFF_LO))
|
|
|
|
OS << ")))";
|
|
|
|
else if (Kind != MCSymbolRefExpr::VK_None)
|
2011-11-09 06:26:47 +08:00
|
|
|
OS << ')';
|
|
|
|
}
|
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
|
|
if (Op.isReg()) {
|
|
|
|
printRegName(O, Op.getReg());
|
|
|
|
return;
|
|
|
|
}
|
2012-02-28 15:46:26 +08:00
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
if (Op.isImm()) {
|
|
|
|
O << Op.getImm();
|
|
|
|
return;
|
|
|
|
}
|
2012-02-28 15:46:26 +08:00
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
2011-11-09 06:26:47 +08:00
|
|
|
printExpr(Op.getExpr(), O);
|
2011-07-08 07:56:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MipsInstPrinter::printUnsignedImm(const MCInst *MI, int opNum,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &MO = MI->getOperand(opNum);
|
|
|
|
if (MO.isImm())
|
|
|
|
O << (unsigned short int)MO.getImm();
|
|
|
|
else
|
|
|
|
printOperand(MI, opNum, O);
|
|
|
|
}
|
|
|
|
|
2013-09-27 19:48:57 +08:00
|
|
|
void MipsInstPrinter::printUnsignedImm8(const MCInst *MI, int opNum,
|
|
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &MO = MI->getOperand(opNum);
|
|
|
|
if (MO.isImm())
|
|
|
|
O << (unsigned short int)(unsigned char)MO.getImm();
|
|
|
|
else
|
|
|
|
printOperand(MI, opNum, O);
|
|
|
|
}
|
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
void MipsInstPrinter::
|
|
|
|
printMemOperand(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
// Load/Store memory operands -- imm($reg)
|
|
|
|
// If PIC target the target is loaded as the
|
|
|
|
// pattern lw $25,%call16($28)
|
2014-11-20 00:44:02 +08:00
|
|
|
|
|
|
|
// opNum can be invalid if instruction had reglist as operand.
|
|
|
|
// MemOperand is always last operand of instruction (base + offset).
|
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Mips::SWM32_MM:
|
|
|
|
case Mips::LWM32_MM:
|
2014-11-28 02:28:59 +08:00
|
|
|
case Mips::SWM16_MM:
|
|
|
|
case Mips::LWM16_MM:
|
2014-11-20 00:44:02 +08:00
|
|
|
opNum = MI->getNumOperands() - 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-08 07:56:50 +08:00
|
|
|
printOperand(MI, opNum+1, O);
|
|
|
|
O << "(";
|
|
|
|
printOperand(MI, opNum, O);
|
|
|
|
O << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
void MipsInstPrinter::
|
|
|
|
printMemOperandEA(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
// when using stack locations for not load/store instructions
|
|
|
|
// print the same way as all normal 3 operand instructions.
|
|
|
|
printOperand(MI, opNum, O);
|
|
|
|
O << ", ";
|
|
|
|
printOperand(MI, opNum+1, O);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MipsInstPrinter::
|
|
|
|
printFCCOperand(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
const MCOperand& MO = MI->getOperand(opNum);
|
|
|
|
O << MipsFCCToString((Mips::CondCode)MO.getImm());
|
|
|
|
}
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
|
2014-12-16 22:59:10 +08:00
|
|
|
void MipsInstPrinter::
|
|
|
|
printRegisterPair(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
printRegName(O, MI->getOperand(opNum).getReg());
|
|
|
|
}
|
|
|
|
|
2013-09-24 22:20:00 +08:00
|
|
|
void MipsInstPrinter::
|
|
|
|
printSHFMask(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
llvm_unreachable("TODO");
|
|
|
|
}
|
|
|
|
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
bool MipsInstPrinter::printAlias(const char *Str, const MCInst &MI,
|
|
|
|
unsigned OpNo, raw_ostream &OS) {
|
|
|
|
OS << "\t" << Str << "\t";
|
|
|
|
printOperand(&MI, OpNo, OS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsInstPrinter::printAlias(const char *Str, const MCInst &MI,
|
|
|
|
unsigned OpNo0, unsigned OpNo1,
|
|
|
|
raw_ostream &OS) {
|
|
|
|
printAlias(Str, MI, OpNo0, OS);
|
|
|
|
OS << ", ";
|
|
|
|
printOperand(&MI, OpNo1, OS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsInstPrinter::printAlias(const MCInst &MI, raw_ostream &OS) {
|
|
|
|
switch (MI.getOpcode()) {
|
|
|
|
case Mips::BEQ:
|
2013-09-07 07:40:15 +08:00
|
|
|
// beq $zero, $zero, $L2 => b $L2
|
2013-07-30 03:08:34 +08:00
|
|
|
// beq $r0, $zero, $L2 => beqz $r0, $L2
|
2013-09-07 08:26:26 +08:00
|
|
|
return (isReg<Mips::ZERO>(MI, 0) && isReg<Mips::ZERO>(MI, 1) &&
|
|
|
|
printAlias("b", MI, 2, OS)) ||
|
|
|
|
(isReg<Mips::ZERO>(MI, 1) && printAlias("beqz", MI, 0, 2, OS));
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
case Mips::BEQ64:
|
2013-07-30 03:08:34 +08:00
|
|
|
// beq $r0, $zero, $L2 => beqz $r0, $L2
|
|
|
|
return isReg<Mips::ZERO_64>(MI, 1) && printAlias("beqz", MI, 0, 2, OS);
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
case Mips::BNE:
|
2013-07-30 03:08:34 +08:00
|
|
|
// bne $r0, $zero, $L2 => bnez $r0, $L2
|
|
|
|
return isReg<Mips::ZERO>(MI, 1) && printAlias("bnez", MI, 0, 2, OS);
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
case Mips::BNE64:
|
2013-07-30 03:08:34 +08:00
|
|
|
// bne $r0, $zero, $L2 => bnez $r0, $L2
|
|
|
|
return isReg<Mips::ZERO_64>(MI, 1) && printAlias("bnez", MI, 0, 2, OS);
|
2013-07-31 04:24:24 +08:00
|
|
|
case Mips::BGEZAL:
|
|
|
|
// bgezal $zero, $L1 => bal $L1
|
|
|
|
return isReg<Mips::ZERO>(MI, 0) && printAlias("bal", MI, 1, OS);
|
2013-07-27 04:13:47 +08:00
|
|
|
case Mips::BC1T:
|
2013-07-30 03:08:34 +08:00
|
|
|
// bc1t $fcc0, $L1 => bc1t $L1
|
|
|
|
return isReg<Mips::FCC0>(MI, 0) && printAlias("bc1t", MI, 1, OS);
|
2013-07-27 04:13:47 +08:00
|
|
|
case Mips::BC1F:
|
2013-07-30 03:08:34 +08:00
|
|
|
// bc1f $fcc0, $L1 => bc1f $L1
|
|
|
|
return isReg<Mips::FCC0>(MI, 0) && printAlias("bc1f", MI, 1, OS);
|
2013-08-07 06:20:40 +08:00
|
|
|
case Mips::JALR:
|
|
|
|
// jalr $ra, $r1 => jalr $r1
|
|
|
|
return isReg<Mips::RA>(MI, 0) && printAlias("jalr", MI, 1, OS);
|
|
|
|
case Mips::JALR64:
|
|
|
|
// jalr $ra, $r1 => jalr $r1
|
|
|
|
return isReg<Mips::RA_64>(MI, 0) && printAlias("jalr", MI, 1, OS);
|
2013-08-07 06:35:29 +08:00
|
|
|
case Mips::NOR:
|
2013-08-21 09:18:46 +08:00
|
|
|
case Mips::NOR_MM:
|
2013-08-07 06:35:29 +08:00
|
|
|
// nor $r0, $r1, $zero => not $r0, $r1
|
|
|
|
return isReg<Mips::ZERO>(MI, 2) && printAlias("not", MI, 0, 1, OS);
|
|
|
|
case Mips::NOR64:
|
|
|
|
// nor $r0, $r1, $zero => not $r0, $r1
|
|
|
|
return isReg<Mips::ZERO_64>(MI, 2) && printAlias("not", MI, 0, 1, OS);
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
case Mips::OR:
|
2013-07-30 03:08:34 +08:00
|
|
|
// or $r0, $r1, $zero => move $r0, $r1
|
|
|
|
return isReg<Mips::ZERO>(MI, 2) && printAlias("move", MI, 0, 1, OS);
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
llvm-svn: 187229
2013-07-27 02:34:25 +08:00
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
}
|
2013-12-09 00:51:52 +08:00
|
|
|
|
|
|
|
void MipsInstPrinter::printSaveRestore(const MCInst *MI, raw_ostream &O) {
|
|
|
|
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
|
|
|
if (i != 0) O << ", ";
|
|
|
|
if (MI->getOperand(i).isReg())
|
|
|
|
printRegName(O, MI->getOperand(i).getReg());
|
|
|
|
else
|
|
|
|
printUnsignedImm(MI, i, O);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-20 00:44:02 +08:00
|
|
|
void MipsInstPrinter::
|
|
|
|
printRegisterList(const MCInst *MI, int opNum, raw_ostream &O) {
|
|
|
|
// - 2 because register List is always first operand of instruction and it is
|
|
|
|
// always followed by memory operand (base + offset).
|
|
|
|
for (int i = opNum, e = MI->getNumOperands() - 2; i != e; ++i) {
|
|
|
|
if (i != opNum)
|
|
|
|
O << ", ";
|
|
|
|
printRegName(O, MI->getOperand(i).getReg());
|
|
|
|
}
|
|
|
|
}
|