1 //===-- MCInstPrinter.cpp - Convert an MCInst to target 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 #include "llvm/MC/MCInstPrinter.h"
11 #include "llvm/ADT/StringRef.h"
12 #include "llvm/MC/MCAsmInfo.h"
13 #include "llvm/MC/MCInstrInfo.h"
14 #include "llvm/Support/ErrorHandling.h"
15 #include "llvm/Support/Format.h"
16 #include "llvm/Support/raw_ostream.h"
19 MCInstPrinter::~MCInstPrinter() {
22 /// getOpcodeName - Return the name of the specified opcode enum (e.g.
23 /// "MOV32ri") or empty if we can't resolve it.
24 StringRef MCInstPrinter::getOpcodeName(unsigned Opcode) const {
25 return MII.getName(Opcode);
28 void MCInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const {
29 llvm_unreachable("Target should implement this");
32 void MCInstPrinter::printAnnotation(raw_ostream &OS, StringRef Annot) {
35 (*CommentStream) << Annot;
37 OS << " " << MAI.getCommentString() << " " << Annot;
41 /// Utility functions to make adding mark ups simpler.
42 StringRef MCInstPrinter::markup(StringRef s) const {
48 StringRef MCInstPrinter::markup(StringRef a, StringRef b) const {
55 /// Utility function to print immediates in decimal or hex.
56 format_object1<int64_t> MCInstPrinter::formatImm(const int64_t Value) const {
58 return format("0x%" PRIx64, Value);
60 return format("%" PRId64, Value);