blob: 243a5e1f3ed0d21ee4699d3c14e8e441596876bf [file] [log] [blame]
Anton Korobeynikov425a9382009-10-21 00:10:30 +00001//===-- MSP430InstPrinter.cpp - Convert MSP430 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 MSP430 MCInst to a .s file.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "asm-printer"
15#include "MSP430InstPrinter.h"
16#include "llvm/MC/MCInst.h"
17#include "llvm/MC/MCAsmInfo.h"
18#include "llvm/MC/MCExpr.h"
19#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/FormattedStream.h"
21#include "MSP430GenInstrNames.inc"
22using namespace llvm;
23
24
25// Include the auto-generated portion of the assembly writer.
26#define MachineInstr MCInst
27#define MSP430AsmPrinter MSP430InstPrinter // FIXME: REMOVE.
28#define NO_ASM_WRITER_BOILERPLATE
29#include "MSP430GenAsmWriter.inc"
30#undef MachineInstr
31#undef MSP430AsmPrinter
32
33void MSP430InstPrinter::printInst(const MCInst *MI) {
34 printInstruction(MI);
35}
Anton Korobeynikov0f66de42009-10-21 00:11:27 +000036
37void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
38 const char *Modifier) {
39 assert((Modifier == 0 || Modifier[0] == 0) && "Cannot print modifiers");
40
41 const MCOperand &Op = MI->getOperand(OpNo);
42 if (Op.isReg()) {
43 O << getRegisterName(Op.getReg());
44 } else if (Op.isImm()) {
45 O << '#' << Op.getImm();
46 } else {
47 assert(Op.isExpr() && "unknown operand kind in printOperand");
48 assert(0 && "Unimplemented!");
49 }
50}