//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file declares the MCStreamer class. // //===----------------------------------------------------------------------===// #ifndef LLVM_MC_MCSTREAMER_H #define LLVM_MC_MCSTREAMER_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCFragment.h" #include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCPseudoProbe.h" #include "llvm/MC/MCWinEH.h" #include "llvm/Support/Error.h" #include "llvm/Support/MD5.h" #include "llvm/Support/SMLoc.h" #include "llvm/Support/VersionTuple.h" #include "llvm/TargetParser/ARMTargetParser.h" #include <cassert> #include <cstdint> #include <memory> #include <optional> #include <string> #include <utility> #include <vector> namespace llvm { class APInt; class AssemblerConstantPools; class MCAsmBackend; class MCAssembler; class MCContext; class MCExpr; class MCFragment; class MCInst; class MCInstPrinter; class MCRegister; class MCSection; class MCStreamer; class MCSubtargetInfo; class MCSymbol; class MCSymbolRefExpr; class Triple; class Twine; class raw_ostream; namespace codeview { struct DefRangeRegisterRelHeader; struct DefRangeSubfieldRegisterHeader; struct DefRangeRegisterHeader; struct DefRangeFramePointerRelHeader; } MCSectionSubPair; /// Target specific streamer interface. This is used so that targets can /// implement support for target specific assembly directives. /// /// If target foo wants to use this, it should implement 3 classes: /// * FooTargetStreamer : public MCTargetStreamer /// * FooTargetAsmStreamer : public FooTargetStreamer /// * FooTargetELFStreamer : public FooTargetStreamer /// /// FooTargetStreamer should have a pure virtual method for each directive. For /// example, for a ".bar symbol_name" directive, it should have /// virtual emitBar(const MCSymbol &Symbol) = 0; /// /// The FooTargetAsmStreamer and FooTargetELFStreamer classes implement the /// method. The assembly streamer just prints ".bar symbol_name". The object /// streamer does whatever is needed to implement .bar in the object file. /// /// In the assembly printer and parser the target streamer can be used by /// calling getTargetStreamer and casting it to FooTargetStreamer: /// /// MCTargetStreamer &TS = OutStreamer.getTargetStreamer(); /// FooTargetStreamer &ATS = static_cast<FooTargetStreamer &>(TS); /// /// The base classes FooTargetAsmStreamer and FooTargetELFStreamer should /// *never* be treated differently. Callers should always talk to a /// FooTargetStreamer. class MCTargetStreamer { … }; // FIXME: declared here because it is used from // lib/CodeGen/AsmPrinter/ARMException.cpp. class ARMTargetStreamer : public MCTargetStreamer { … }; /// Streaming machine code generation interface. /// /// This interface is intended to provide a programmatic interface that is very /// similar to the level that an assembler .s file provides. It has callbacks /// to emit bytes, handle directives, etc. The implementation of this interface /// retains state to know what the current section is etc. /// /// There are multiple implementations of this interface: one for writing out /// a .s file, and implementations that write out .o files of various formats. /// class MCStreamer { … }; /// Create a dummy machine code streamer, which does nothing. This is useful for /// timing the assembler front end. MCStreamer *createNullStreamer(MCContext &Ctx); } // end namespace llvm #endif // LLVM_MC_MCSTREAMER_H