]>
git.proxmox.com Git - rustc.git/blob - src/llvm/include/llvm/MC/MCInstPrinter.h
1 //===- MCInstPrinter.h - MCInst to target assembly syntax -------*- C++ -*-===//
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 #ifndef LLVM_MC_MCINSTPRINTER_H
11 #define LLVM_MC_MCINSTPRINTER_H
13 #include "llvm/Support/DataTypes.h"
14 #include "llvm/Support/Format.h"
31 /// MCInstPrinter - This is an instance of a target assembly language printer
32 /// that converts an MCInst to valid target assembly syntax.
35 /// CommentStream - a stream that comments can be emitted to if desired.
36 /// Each comment must end with a newline. This will be null if verbose
37 /// assembly emission is disable.
38 raw_ostream
*CommentStream
;
40 const MCInstrInfo
&MII
;
41 const MCRegisterInfo
&MRI
;
43 /// The current set of available features.
44 uint64_t AvailableFeatures
;
46 /// True if we are printing marked up assembly.
49 /// True if we are printing immediates as hex.
52 /// Which style to use for printing hexadecimal values.
53 HexStyle::Style PrintHexStyle
;
55 /// Utility function for printing annotations.
56 void printAnnotation(raw_ostream
&OS
, StringRef Annot
);
58 MCInstPrinter(const MCAsmInfo
&mai
, const MCInstrInfo
&mii
,
59 const MCRegisterInfo
&mri
)
60 : CommentStream(nullptr), MAI(mai
), MII(mii
), MRI(mri
),
61 AvailableFeatures(0), UseMarkup(0), PrintImmHex(0),
62 PrintHexStyle(HexStyle::C
) {}
64 virtual ~MCInstPrinter();
66 /// setCommentStream - Specify a stream to emit comments to.
67 void setCommentStream(raw_ostream
&OS
) { CommentStream
= &OS
; }
69 /// printInst - Print the specified MCInst to the specified raw_ostream.
71 virtual void printInst(const MCInst
*MI
, raw_ostream
&OS
,
74 /// getOpcodeName - Return the name of the specified opcode enum (e.g.
75 /// "MOV32ri") or empty if we can't resolve it.
76 StringRef
getOpcodeName(unsigned Opcode
) const;
78 /// printRegName - Print the assembler register name.
79 virtual void printRegName(raw_ostream
&OS
, unsigned RegNo
) const;
81 uint64_t getAvailableFeatures() const { return AvailableFeatures
; }
82 void setAvailableFeatures(uint64_t Value
) { AvailableFeatures
= Value
; }
84 bool getUseMarkup() const { return UseMarkup
; }
85 void setUseMarkup(bool Value
) { UseMarkup
= Value
; }
87 /// Utility functions to make adding mark ups simpler.
88 StringRef
markup(StringRef s
) const;
89 StringRef
markup(StringRef a
, StringRef b
) const;
91 bool getPrintImmHex() const { return PrintImmHex
; }
92 void setPrintImmHex(bool Value
) { PrintImmHex
= Value
; }
94 HexStyle::Style
getPrintHexStyleHex() const { return PrintHexStyle
; }
95 void setPrintImmHex(HexStyle::Style Value
) { PrintHexStyle
= Value
; }
97 /// Utility function to print immediates in decimal or hex.
98 format_object1
<int64_t> formatImm(const int64_t Value
) const { return PrintImmHex
? formatHex(Value
) : formatDec(Value
); }
100 /// Utility functions to print decimal/hexadecimal values.
101 format_object1
<int64_t> formatDec(const int64_t Value
) const;
102 format_object1
<int64_t> formatHex(const int64_t Value
) const;
103 format_object1
<uint64_t> formatHex(const uint64_t Value
) const;