2009-09-14 03:43:38 +02:00
|
|
|
//===-- MCInstPrinter.h - Convert an MCInst to target assembly syntax -----===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCINSTPRINTER_H
|
|
|
|
#define LLVM_MC_MCINSTPRINTER_H
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MCInst;
|
|
|
|
class raw_ostream;
|
2009-09-14 03:49:26 +02:00
|
|
|
class MCAsmInfo;
|
2010-02-11 23:39:10 +01:00
|
|
|
class StringRef;
|
2009-09-14 03:49:26 +02:00
|
|
|
|
2009-09-14 03:43:38 +02:00
|
|
|
/// MCInstPrinter - This is an instance of a target assembly language printer
|
|
|
|
/// that converts an MCInst to valid target assembly syntax.
|
|
|
|
class MCInstPrinter {
|
2009-09-14 03:49:26 +02:00
|
|
|
protected:
|
2010-02-10 01:10:18 +01:00
|
|
|
/// CommentStream - a stream that comments can be emitted to if desired.
|
|
|
|
/// Each comment must end with a newline. This will be null if verbose
|
|
|
|
/// assembly emission is disable.
|
|
|
|
raw_ostream *CommentStream;
|
2009-09-14 03:49:26 +02:00
|
|
|
const MCAsmInfo &MAI;
|
2011-04-07 23:20:06 +02:00
|
|
|
|
|
|
|
/// The current set of available features.
|
|
|
|
unsigned AvailableFeatures;
|
2011-09-16 01:38:46 +02:00
|
|
|
|
|
|
|
/// Utility function for printing annotations.
|
|
|
|
void printAnnotation(raw_ostream &OS, StringRef Annot);
|
2009-09-14 03:43:38 +02:00
|
|
|
public:
|
2010-04-04 07:04:31 +02:00
|
|
|
MCInstPrinter(const MCAsmInfo &mai)
|
2011-04-07 23:20:06 +02:00
|
|
|
: CommentStream(0), MAI(mai), AvailableFeatures(0) {}
|
2010-09-17 23:23:56 +02:00
|
|
|
|
2009-09-14 03:43:38 +02:00
|
|
|
virtual ~MCInstPrinter();
|
2010-02-10 01:10:18 +01:00
|
|
|
|
|
|
|
/// setCommentStream - Specify a stream to emit comments to.
|
|
|
|
void setCommentStream(raw_ostream &OS) { CommentStream = &OS; }
|
2010-09-17 23:23:56 +02:00
|
|
|
|
2010-04-04 07:04:31 +02:00
|
|
|
/// printInst - Print the specified MCInst to the specified raw_ostream.
|
2009-09-14 03:43:38 +02:00
|
|
|
///
|
2011-09-16 01:38:46 +02:00
|
|
|
virtual void printInst(const MCInst *MI, raw_ostream &OS,
|
|
|
|
StringRef Annot) = 0;
|
2011-09-15 20:36:29 +02:00
|
|
|
|
2010-02-11 23:39:10 +01:00
|
|
|
/// getOpcodeName - Return the name of the specified opcode enum (e.g.
|
|
|
|
/// "MOV32ri") or empty if we can't resolve it.
|
|
|
|
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
2011-03-05 19:43:32 +01:00
|
|
|
|
2011-06-02 04:34:55 +02:00
|
|
|
/// printRegName - Print the assembler register name.
|
|
|
|
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
|
2011-04-07 23:20:06 +02:00
|
|
|
|
|
|
|
unsigned getAvailableFeatures() const { return AvailableFeatures; }
|
|
|
|
void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
|
2009-09-14 03:43:38 +02:00
|
|
|
};
|
2010-09-17 23:23:56 +02:00
|
|
|
|
2009-09-14 03:43:38 +02:00
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif
|