LLVM 23.0.0git
MCAsmStreamer.h
Go to the documentation of this file.
1//===- MCAsmStreamer.h - Base Class for Asm Streamers -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the MCAsmBaseStreamer class, a base class for streamers
10// which emits assembly text.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_MC_MCASMSTREAMER_H
15#define LLVM_MC_MCASMSTREAMER_H
16
18#include "llvm/MC/MCAssembler.h"
20#include "llvm/MC/MCStreamer.h"
22#include <memory>
23
24namespace llvm {
25
26class MCAsmBackend;
27class MCAsmInfo;
28class MCAssembler;
29class MCCodeEmitter;
30class MCContext;
31class MCInst;
32class MCSubtargetInfo;
33
35protected:
36 std::unique_ptr<MCAssembler> Assembler;
40
41 MCAsmBaseStreamer(MCContext &Context, std::unique_ptr<MCCodeEmitter> Emitter,
42 std::unique_ptr<MCAsmBackend> AsmBackend);
43
44public:
45 /// Return a raw_ostream that comments can be written to.
46 /// Unlike AddComment, you are required to terminate comments with \n if you
47 /// use this method.
49 if (!isVerboseAsm())
50 return nulls(); // Discard comments unless in verbose asm mode.
51 return CommentStream;
52 }
53
54 /// Add a comment showing the encoding of an instruction.
55 /// \param Inst - The instruction to encode.
56 /// \param STI - Subtarget information.
57 void addEncodingComment(const MCInst &Inst, const MCSubtargetInfo &STI);
58
60};
61
62} // end namespace llvm
63
64#endif // LLVM_MC_MCASMSTREAMER_H
dxil DXContainer Global Emitter
Generic interface to target specific assembler backends.
void addEncodingComment(const MCInst &Inst, const MCSubtargetInfo &STI)
Add a comment showing the encoding of an instruction.
std::unique_ptr< MCAssembler > Assembler
SmallString< 128 > CommentToEmit
MCAssembler & getAssembler()
raw_ostream & getCommentOS() override
Return a raw_ostream that comments can be written to.
raw_null_ostream NullStream
MCAsmBaseStreamer(MCContext &Context, std::unique_ptr< MCCodeEmitter > Emitter, std::unique_ptr< MCAsmBackend > AsmBackend)
raw_svector_ostream CommentStream
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:66
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
Definition MCStreamer.h:381
MCStreamer(MCContext &Ctx)
Generic base class for all target subtargets.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
A raw_ostream that discards all output.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
A raw_ostream that writes to an SmallVector or SmallString.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.