Silence -Wunused-variable in release builds.
[llvm/stm8.git] / lib / Target / MBlaze / InstPrinter / MBlazeInstPrinter.cpp
bloba7fd287990b7f4d6fe635610084b37bf0b45b371
1 //===-- MBlazeInstPrinter.cpp - Convert MBlaze MCInst to assembly syntax --===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class prints an MBlaze MCInst to a .s file.
12 //===----------------------------------------------------------------------===//
14 #define DEBUG_TYPE "asm-printer"
15 #include "MBlaze.h"
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"
22 using namespace llvm;
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);
36 if (Op.isReg()) {
37 O << getRegisterName(Op.getReg());
38 } else if (Op.isImm()) {
39 O << (int32_t)Op.getImm();
40 } else {
41 assert(Op.isExpr() && "unknown operand kind in printOperand");
42 O << *Op.getExpr();
46 void MBlazeInstPrinter::printFSLImm(const MCInst *MI, int OpNo,
47 raw_ostream &O) {
48 const MCOperand &MO = MI->getOperand(OpNo);
49 if (MO.isImm())
50 O << "rfsl" << MO.getImm();
51 else
52 printOperand(MI, OpNo, O, NULL);
55 void MBlazeInstPrinter::printUnsignedImm(const MCInst *MI, int OpNo,
56 raw_ostream &O) {
57 const MCOperand &MO = MI->getOperand(OpNo);
58 if (MO.isImm())
59 O << (uint32_t)MO.getImm();
60 else
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);
67 O << ", ";
68 printOperand(MI, OpNo+1, O, NULL);