1 //===-- MBlazeInstPrinter.cpp - Convert MBlaze MCInst to assembly syntax --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class prints an MBlaze MCInst to a .s file.
12 //===----------------------------------------------------------------------===//
14 #define DEBUG_TYPE "asm-printer"
16 #include "MBlazeInstPrinter.h"
17 #include "llvm/MC/MCInst.h"
18 #include "llvm/MC/MCAsmInfo.h"
19 #include "llvm/MC/MCExpr.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Support/FormattedStream.h"
25 // Include the auto-generated portion of the assembly writer.
26 #include "MBlazeGenAsmWriter.inc"
28 void MBlazeInstPrinter::printInst(const MCInst
*MI
, raw_ostream
&O
) {
29 printInstruction(MI
, O
);
32 void MBlazeInstPrinter::printOperand(const MCInst
*MI
, unsigned OpNo
,
33 raw_ostream
&O
, const char *Modifier
) {
34 assert((Modifier
== 0 || Modifier
[0] == 0) && "No modifiers supported");
35 const MCOperand
&Op
= MI
->getOperand(OpNo
);
37 O
<< getRegisterName(Op
.getReg());
38 } else if (Op
.isImm()) {
39 O
<< (int32_t)Op
.getImm();
41 assert(Op
.isExpr() && "unknown operand kind in printOperand");
46 void MBlazeInstPrinter::printFSLImm(const MCInst
*MI
, int OpNo
,
48 const MCOperand
&MO
= MI
->getOperand(OpNo
);
50 O
<< "rfsl" << MO
.getImm();
52 printOperand(MI
, OpNo
, O
, NULL
);
55 void MBlazeInstPrinter::printUnsignedImm(const MCInst
*MI
, int OpNo
,
57 const MCOperand
&MO
= MI
->getOperand(OpNo
);
59 O
<< (uint32_t)MO
.getImm();
61 printOperand(MI
, OpNo
, O
, NULL
);
64 void MBlazeInstPrinter::printMemOperand(const MCInst
*MI
, int OpNo
,
65 raw_ostream
&O
, const char *Modifier
) {
66 printOperand(MI
, OpNo
, O
, NULL
);
68 printOperand(MI
, OpNo
+1, O
, NULL
);