1 //===-- Nios2InstPrinter.cpp - Convert Nios2 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 Nios2 MCInst to a .s file.
12 //===----------------------------------------------------------------------===//
14 #include "Nios2InstPrinter.h"
16 #include "Nios2InstrInfo.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/Support/raw_ostream.h"
23 #define DEBUG_TYPE "asm-printer"
25 #define PRINT_ALIAS_INSTR
26 #include "Nios2GenAsmWriter.inc"
28 void Nios2InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
29 OS << getRegisterName(RegNo);
32 void Nios2InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
33 StringRef Annot, const MCSubtargetInfo &STI) {
34 // Try to print any aliases first.
35 if (!printAliasInstr(MI, STI, O))
36 printInstruction(MI, STI, O);
37 printAnnotation(O, Annot);
40 void Nios2InstPrinter::printOperand(const MCInst *MI, int OpNo,
41 const MCSubtargetInfo &STI,
43 const MCOperand &Op = MI->getOperand(OpNo);
45 printRegName(O, Op.getReg());
54 assert(Op.isExpr() && "unknown operand kind in printOperand");
55 Op.getExpr()->print(O, &MAI, true);
58 void Nios2InstPrinter::printMemOperand(const MCInst *MI, int opNum,
59 const MCSubtargetInfo &STI,
60 raw_ostream &O, const char *Modifier) {
61 // Load/Store memory operands -- imm($reg)
62 printOperand(MI, opNum + 1, STI, O);
64 printOperand(MI, opNum, STI, O);