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"
15 #include "MBlazeInstPrinter.h"
17 #include "llvm/MC/MCAsmInfo.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCInst.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,
30 printInstruction(MI, O);
31 printAnnotation(O, Annot);
34 void MBlazeInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
35 raw_ostream &O, const char *Modifier) {
36 assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
37 const MCOperand &Op = MI->getOperand(OpNo);
39 O << getRegisterName(Op.getReg());
40 } else if (Op.isImm()) {
41 O << (int32_t)Op.getImm();
43 assert(Op.isExpr() && "unknown operand kind in printOperand");
48 void MBlazeInstPrinter::printFSLImm(const MCInst *MI, int OpNo,
50 const MCOperand &MO = MI->getOperand(OpNo);
52 O << "rfsl" << MO.getImm();
54 printOperand(MI, OpNo, O, NULL);
57 void MBlazeInstPrinter::printUnsignedImm(const MCInst *MI, int OpNo,
59 const MCOperand &MO = MI->getOperand(OpNo);
61 O << (uint32_t)MO.getImm();
63 printOperand(MI, OpNo, O, NULL);
66 void MBlazeInstPrinter::printMemOperand(const MCInst *MI, int OpNo,
67 raw_ostream &O, const char *Modifier) {
68 printOperand(MI, OpNo, O, NULL);
70 printOperand(MI, OpNo+1, O, NULL);