1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- MCInstPrinter.h - Convert an MCInst to target assembly syntax -----===//
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//                     The LLVM Compiler Infrastructure
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details.
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===//
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_MC_MCINSTPRINTER_H
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_MC_MCINSTPRINTER_H
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm {
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass MCInst;
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass raw_ostream;
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass MCAsmInfo;
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass StringRef;
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// MCInstPrinter - This is an instance of a target assembly language printer
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// that converts an MCInst to valid target assembly syntax.
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass MCInstPrinter {
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanprotected:
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// CommentStream - a stream that comments can be emitted to if desired.
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// Each comment must end with a newline.  This will be null if verbose
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// assembly emission is disable.
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  raw_ostream *CommentStream;
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  const MCAsmInfo &MAI;
2819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
2919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// The current set of available features.
3019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  unsigned AvailableFeatures;
3119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
3219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// Utility function for printing annotations.
3319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  void printAnnotation(raw_ostream &OS, StringRef Annot);
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanpublic:
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  MCInstPrinter(const MCAsmInfo &mai)
3619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman    : CommentStream(0), MAI(mai), AvailableFeatures(0) {}
3719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  virtual ~MCInstPrinter();
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// setCommentStream - Specify a stream to emit comments to.
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void setCommentStream(raw_ostream &OS) { CommentStream = &OS; }
4219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// printInst - Print the specified MCInst to the specified raw_ostream.
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ///
4519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  virtual void printInst(const MCInst *MI, raw_ostream &OS,
4619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman                         StringRef Annot) = 0;
4719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// getOpcodeName - Return the name of the specified opcode enum (e.g.
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /// "MOV32ri") or empty if we can't resolve it.
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  virtual StringRef getOpcodeName(unsigned Opcode) const;
5119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
5219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  /// printRegName - Print the assembler register name.
5319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
5419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
5519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  unsigned getAvailableFeatures() const { return AvailableFeatures; }
5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman  void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman};
5819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman
59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // namespace llvm
60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
62