MCStreamer.h revision 030f63a397edc20f8f661bac62f7b90cb5cf57bc
125e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//
325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//                     The LLVM Compiler Infrastructure
425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//
525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar// This file is distributed under the University of Illinois Open Source
625e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar// License. See LICENSE.TXT for details.
725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//
825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar//===----------------------------------------------------------------------===//
9e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner//
10e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner// This file declares the MCStreamer class.
11e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner//
12e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner//===----------------------------------------------------------------------===//
1325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
1425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar#ifndef LLVM_MC_MCSTREAMER_H
1525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar#define LLVM_MC_MCSTREAMER_H
1625e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
17255f89faee13dc491cb64fbeae3c763e7e2ea4e6Chandler Carruth#include "llvm/ADT/ArrayRef.h"
18255f89faee13dc491cb64fbeae3c763e7e2ea4e6Chandler Carruth#include "llvm/ADT/SmallVector.h"
19a5ad93a10a5435f21090b09edb6b3a7e44967648Chris Lattner#include "llvm/MC/MCDirectives.h"
2089b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola#include "llvm/MC/MCDwarf.h"
210855bc5b973320052c87bdcc2fa17b9711edc3deCharles Davis#include "llvm/MC/MCWin64EH.h"
22255f89faee13dc491cb64fbeae3c763e7e2ea4e6Chandler Carruth#include "llvm/Support/DataTypes.h"
2384a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar
2425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbarnamespace llvm {
2578c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng  class MCAsmBackend;
264a0abd80f18f9c2a10bf5b14cd6731d51972a426Daniel Dunbar  class MCCodeEmitter;
2725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class MCContext;
28821e3334ed3390d931f497300e6a5f1dc21bcfb3Daniel Dunbar  class MCExpr;
2925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class MCInst;
3090edac0e8b35f766599362b6301863229f0ddcdbChris Lattner  class MCInstPrinter;
3125e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class MCSection;
3225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class MCSymbol;
339a7e2ccf574368b60455f8c8975030475a1f3ce0Daniel Dunbar  class StringRef;
3486e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner  class Twine;
3525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class raw_ostream;
3686e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner  class formatted_raw_ostream;
3725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
38e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// MCStreamer - Streaming machine code generation interface.  This interface
39e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// is intended to provide a programatic interface that is very similar to the
40e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// level that an assembler .s file provides.  It has callbacks to emit bytes,
417092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar  /// handle directives, etc.  The implementation of this interface retains
42e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// state to know what the current section is etc.
43e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  ///
44e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// There are multiple implementations of this interface: one for writing out
45e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  /// a .s file, and implementations that write out .o files of various formats.
46e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner  ///
4725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  class MCStreamer {
4825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar    MCContext &Context;
4925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
501f7210e808373fa92be3a2d4fa653a6f79d5088bCraig Topper    MCStreamer(const MCStreamer&) LLVM_DELETED_FUNCTION;
511f7210e808373fa92be3a2d4fa653a6f79d5088bCraig Topper    MCStreamer &operator=(const MCStreamer&) LLVM_DELETED_FUNCTION;
5225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
53f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola    bool EmitEHFrame;
54f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola    bool EmitDebugFrame;
55f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola
56d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola    std::vector<MCDwarfFrameInfo> FrameInfos;
57d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola    MCDwarfFrameInfo *getCurrentFrameInfo();
58529a01df02ad221e8e55097a8ee36b85234eb078Rafael Espindola    MCSymbol *EmitCFICommon();
59d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola    void EnsureValidFrame();
60d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola
61ca93138e11f404a19553049a569f1fa6ad491b67Charles Davis    std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos;
6291d9a1c0f7c598d51c50f80bc9e8dfc1494f78c1Charles Davis    MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
6391d9a1c0f7c598d51c50f80bc9e8dfc1494f78c1Charles Davis    void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
640855bc5b973320052c87bdcc2fa17b9711edc3deCharles Davis    void EnsureValidW64UnwindInfo();
650855bc5b973320052c87bdcc2fa17b9711edc3deCharles Davis
6649cb9b88867426d1a430f248550d3cc785a68fe4Rafael Espindola    MCSymbol* LastSymbol;
67ed708f9c1facb9928ef2f79503e7030c8f25b00dRafael Espindola
687d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger    /// SectionStack - This is stack of current and previous section
697d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger    /// values saved by PushSection.
707d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger    SmallVector<std::pair<const MCSection *,
717d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger                const MCSection *>, 4> SectionStack;
727092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar
7307f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    bool AutoInitSections;
7407f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames
757768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola  protected:
767768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    MCStreamer(MCContext &Ctx);
77a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola
78a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola    const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
79a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola                                  const MCSymbol *B);
80a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola
81a6f2678f08299f053feb58337fc4322131d99bf4Rafael Espindola    const MCExpr *ForceExpAbs(const MCExpr* Expr);
821674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer
83547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola    void RecordProcStart(MCDwarfFrameInfo &Frame);
84547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola    virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
851fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola    void RecordProcEnd(MCDwarfFrameInfo &Frame);
861fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola    virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
87c25dad8750083829d9a8935ce40d0734e5488f8eRafael Espindola    void EmitFrames(bool usingCFI);
88c25dad8750083829d9a8935ce40d0734e5488f8eRafael Espindola
893185f5c35322cbd10040ab20f265042d477efe62Charles Davis    MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;}
9038ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis    void EmitW64Tables();
913185f5c35322cbd10040ab20f265042d477efe62Charles Davis
92381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar  public:
9325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar    virtual ~MCStreamer();
9425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
955399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas    /// State management
965399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas    ///
975399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas    virtual void reset();
985399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas
9925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar    MCContext &getContext() const { return Context; }
10025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
10189b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    unsigned getNumFrameInfos() {
10289b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola      return FrameInfos.size();
10389b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    }
10489b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola
10589b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    const MCDwarfFrameInfo &getFrameInfo(unsigned i) {
10689b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola      return FrameInfos[i];
10789b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    }
10889b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola
109dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling    ArrayRef<MCDwarfFrameInfo> getFrameInfos() {
110dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling      return FrameInfos;
111dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling    }
112dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling
11338ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis    unsigned getNumW64UnwindInfos() {
11438ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis      return W64UnwindInfos.size();
11538ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis    }
11638ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis
11738ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis    MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) {
118ca93138e11f404a19553049a569f1fa6ad491b67Charles Davis      return *W64UnwindInfos[i];
11938ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis    }
12038ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis
1210fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner    /// @name Assembly File Formatting.
1220fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner    /// @{
1230dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
12491bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// isVerboseAsm - Return true if this streamer supports verbose assembly
12591bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// and if it is enabled.
12656591ab218639d8a6e4c756ca37adaf20215c3b6Chris Lattner    virtual bool isVerboseAsm() const { return false; }
1270dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
12891bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// hasRawTextSupport - Return true if this asm streamer supports emitting
12991bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// unformatted text to the .s file with EmitRawText.
13091bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    virtual bool hasRawTextSupport() const { return false; }
1310fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner
132d32c7cfa248f685e6e3064c0958dc2f0c31a4df6Chris Lattner    /// AddComment - Add a comment that can be emitted to the generated .s
13386e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    /// file if applicable as a QoI issue to make the output of the compiler
13486e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    /// more readable.  This only affects the MCAsmStreamer, and only when
13586e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    /// verbose assembly output is enabled.
13686e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    ///
13786e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    /// If the comment includes embedded \n's, they will each get the comment
13886e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner    /// prefix as appropriate.  The added comment should not end with a \n.
139d32c7cfa248f685e6e3064c0958dc2f0c31a4df6Chris Lattner    virtual void AddComment(const Twine &T) {}
1400dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
141d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner    /// GetCommentOS - Return a raw_ostream that comments can be written to.
142d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner    /// Unlike AddComment, you are required to terminate comments with \n if you
143d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner    /// use this method.
144d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner    virtual raw_ostream &GetCommentOS();
1450dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
1460fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner    /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
1470fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner    virtual void AddBlankLine() {}
1480dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
1490fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner    /// @}
1500dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
15184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @name Symbol & Section Management
15284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @{
1530dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
1546a4824c466bbfbcbe7dc4d95ec1e23a14ec73d87Dan Gohman    /// getCurrentSection - Return the current section that the streamer is
1557092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar    /// emitting code to.
1567768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    const MCSection *getCurrentSection() const {
1577d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      if (!SectionStack.empty())
1587d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger        return SectionStack.back().first;
1597768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      return NULL;
1607768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    }
16184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar
1621674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer    /// getPreviousSection - Return the previous section that the streamer is
1631674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer    /// emitting code to.
1647768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    const MCSection *getPreviousSection() const {
1657d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      if (!SectionStack.empty())
1667d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger        return SectionStack.back().second;
1677768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      return NULL;
1687768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    }
1697768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola
1707768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// ChangeSection - Update streamer for a new active section.
1717768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    ///
1727768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// This is called by PopSection and SwitchSection, if the current
1737768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// section changes.
1747768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    virtual void ChangeSection(const MCSection *) = 0;
1757768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola
1767768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// pushSection - Save the current and previous section on the
1777768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// section stack.
1787768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    void PushSection() {
1797d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      SectionStack.push_back(std::make_pair(getCurrentSection(),
1807d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger                                            getPreviousSection()));
1817768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    }
1827768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola
1837768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// popSection - Restore the current and previous section from
1847768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// the section stack.  Calls ChangeSection as needed.
1857768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    ///
1867768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    /// Returns false if the stack was empty.
1877768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    bool PopSection() {
1887d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      if (SectionStack.size() <= 1)
1897768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola        return false;
1907d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      const MCSection *oldSection = SectionStack.pop_back_val().first;
1917d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      const MCSection *curSection = SectionStack.back().first;
1927768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola
1937768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      if (oldSection != curSection)
1947768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola        ChangeSection(curSection);
1957768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      return true;
1967768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    }
1971674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer
198381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// SwitchSection - Set the current section where code is being emitted to
199fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// @p Section.  This is required to update CurSection.
200381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
201381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// This corresponds to assembler directives like .section, .text, etc.
2027768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    void SwitchSection(const MCSection *Section) {
2037768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      assert(Section && "Cannot switch to a null section!");
2047d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      const MCSection *curSection = SectionStack.back().first;
2057d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger      SectionStack.back().second = curSection;
2067768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      if (Section != curSection) {
2077d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger        SectionStack.back().first = Section;
2087768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola        ChangeSection(Section);
2097768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola      }
2107768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola    }
2110dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
212410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis    /// SwitchSectionNoChange - Set the current section where code is being
213410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis    /// emitted to @p Section.  This is required to update CurSection. This
214410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis    /// version does not call ChangeSection.
215410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis    void SwitchSectionNoChange(const MCSection *Section) {
216410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis      assert(Section && "Cannot switch to a null section!");
217410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis      const MCSection *curSection = SectionStack.back().first;
218410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis      SectionStack.back().second = curSection;
219410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis      if (Section != curSection)
220410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis        SectionStack.back().first = Section;
221410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis    }
222410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis
22307f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    /// Initialize the streamer.
22407f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    void InitStreamer() {
22507f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames      if (AutoInitSections)
22607f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames        InitSections();
22707f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    }
22807f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames
22907f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    /// Tell this MCStreamer to call InitSections upon initialization.
23007f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    void setAutoInitSections(bool AutoInitSections) {
23107f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames      this->AutoInitSections = AutoInitSections;
23207f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames    }
23307f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames
234d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola    /// InitSections - Create the default sections and set the initial one.
235d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola    virtual void InitSections() = 0;
236030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky
237030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky    /// InitToTextSection - Create a text section and switch the streamer to it.
238030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky    virtual void InitToTextSection() = 0;
239d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola
240fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitLabel - Emit a label for @p Symbol into the current section.
241381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
242381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// This corresponds to an assembler statement such as:
243381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///   foo:
244381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
245381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// @param Symbol - The symbol to emit. A given symbol should only be
246381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// emitted as a label once, and symbols emitted as a label should never be
247381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// used in an assignment.
248ed708f9c1facb9928ef2f79503e7030c8f25b00dRafael Espindola    virtual void EmitLabel(MCSymbol *Symbol);
249381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar
2502c3a4641a7785da78839caf574277df9cd93b52cReed Kotler    virtual void EmitDebugLabel(MCSymbol *Symbol);
2512c3a4641a7785da78839caf574277df9cd93b52cReed Kotler
2528bca4106dfc2945723251db10e340183f3e372ddRafael Espindola    virtual void EmitEHSymAttributes(const MCSymbol *Symbol,
2538bca4106dfc2945723251db10e340183f3e372ddRafael Espindola                                     MCSymbol *EHSymbol);
2548bca4106dfc2945723251db10e340183f3e372ddRafael Espindola
2553e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach    /// EmitAssemblerFlag - Note in the output the specified @p Flag.
256a5ad93a10a5435f21090b09edb6b3a7e44967648Chris Lattner    virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0;
257a5c783280f83df5c60a8ed9e32c61b05a11048e3Kevin Enderby
2583e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach    /// EmitDataRegion - Note in the output the specified region @p Kind.
2593e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach    virtual void EmitDataRegion(MCDataRegionType Kind) {}
2603e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach
261ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach    /// EmitThumbFunc - Note in the output that the specified @p Func is
262ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach    /// a Thumb mode function (ARM target only).
263ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach    virtual void EmitThumbFunc(MCSymbol *Func) = 0;
264ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach
265fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitAssignment - Emit an assignment of @p Value to @p Symbol.
266381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
267381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// This corresponds to an assembler statement such as:
268381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///  symbol = value
269381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
270381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// The assignment generates no code, but has the side effect of binding the
271381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// value in the current context. For the assembly streamer, this prints the
272381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// binding into the .s file.
273381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
274381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// @param Symbol - The symbol being assigned to.
275381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// @param Value - The value for the symbol.
276821e3334ed3390d931f497300e6a5f1dc21bcfb3Daniel Dunbar    virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0;
27725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
278484291c27319668ad99cb87def000254357736fbRafael Espindola    /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol.
279484291c27319668ad99cb87def000254357736fbRafael Espindola    ///
280484291c27319668ad99cb87def000254357736fbRafael Espindola    /// This corresponds to an assembler statement such as:
281484291c27319668ad99cb87def000254357736fbRafael Espindola    ///  .weakref alias, symbol
282484291c27319668ad99cb87def000254357736fbRafael Espindola    ///
283484291c27319668ad99cb87def000254357736fbRafael Espindola    /// @param Alias - The alias that is being created.
284484291c27319668ad99cb87def000254357736fbRafael Espindola    /// @param Symbol - The symbol being aliased.
285484291c27319668ad99cb87def000254357736fbRafael Espindola    virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0;
286484291c27319668ad99cb87def000254357736fbRafael Espindola
287fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol.
288a11af531ec48ad84f790b9511f003ac5c934a999Daniel Dunbar    virtual void EmitSymbolAttribute(MCSymbol *Symbol,
289a5ad93a10a5435f21090b09edb6b3a7e44967648Chris Lattner                                     MCSymbolAttr Attribute) = 0;
29025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
291fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol.
29295cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby    ///
29395cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby    /// @param Symbol - The symbol to have its n_desc field set.
29495cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby    /// @param DescValue - The value to set into the n_desc field.
29595cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby    virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
29695cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby
297b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// BeginCOFFSymbolDef - Start emitting COFF symbol definition
298b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    ///
299b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// @param Symbol - The symbol to have its External & Type fields set.
300b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0;
301b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner
302b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol.
303b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    ///
304b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// @param StorageClass - The storage class the symbol should have.
305b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0;
306b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner
307b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// EmitCOFFSymbolType - Emit the type of the symbol.
308b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    ///
309b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
310b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    virtual void EmitCOFFSymbolType(int Type) = 0;
311b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner
312b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    /// EndCOFFSymbolDef - Marks the end of the symbol definition.
313b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner    virtual void EndCOFFSymbolDef() = 0;
314b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner
3158f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola    /// EmitCOFFSecRel32 - Emits a COFF section relative relocation.
3168f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola    ///
3178f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola    /// @param Symbol - Symbol the section relative realocation should point to.
3188f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola    virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);
3198f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola
32099328add833807f12a4950c7de29fb2a5df04703Chris Lattner    /// EmitELFSize - Emit an ELF .size directive.
32199328add833807f12a4950c7de29fb2a5df04703Chris Lattner    ///
32299328add833807f12a4950c7de29fb2a5df04703Chris Lattner    /// This corresponds to an assembler statement such as:
32399328add833807f12a4950c7de29fb2a5df04703Chris Lattner    ///  .size symbol, expression
32499328add833807f12a4950c7de29fb2a5df04703Chris Lattner    ///
32599328add833807f12a4950c7de29fb2a5df04703Chris Lattner    virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0;
3260dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
3279eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    /// EmitCommonSymbol - Emit a common symbol.
3284e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner    ///
3294e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner    /// @param Symbol - The common symbol to emit.
3304e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner    /// @param Size - The size of the common symbol.
3317092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar    /// @param ByteAlignment - The alignment of the symbol if
3329eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    /// non-zero. This must be a power of 2.
3339eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
3347092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar                                  unsigned ByteAlignment) = 0;
3354e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner
3369eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
3379eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    ///
3389eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    /// @param Symbol - The common symbol to emit.
3399eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner    /// @param Size - The size of the common symbol.
34036a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer    /// @param ByteAlignment - The alignment of the common symbol in bytes.
34136a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer    virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
34236a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer                                       unsigned ByteAlignment) = 0;
3430dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
3440df4a80e2063424929bbfaa61dd7973062218ad4Eric Christopher    /// EmitZerofill - Emit the zerofill section and an optional symbol.
3459be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner    ///
3469be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner    /// @param Section - The zerofill section to create and or to put the symbol
3479be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner    /// @param Symbol - The zerofill symbol to emit, if non-NULL.
3489be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner    /// @param Size - The size of the zerofill symbol.
3497092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar    /// @param ByteAlignment - The alignment of the zerofill symbol if
3507092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar    /// non-zero. This must be a power of 2 on some targets.
3518751b94ffbd9c49df8949a37f78d6bd0be87b256Daniel Dunbar    virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
352c90a1fcf9f44858b20e0f5f7e0b98049aec7a1e0Evan Cheng                              uint64_t Size = 0,unsigned ByteAlignment = 0) = 0;
3539be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner
354482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol.
355482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    ///
3564d01cbe93b0e1a349b5c2881f1b319963f9e0504Eric Christopher    /// @param Section - The thread local common section.
357482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    /// @param Symbol - The thread local common symbol to emit.
358482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    /// @param Size - The size of the symbol.
359482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    /// @param ByteAlignment - The alignment of the thread local common symbol
360482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher    /// if non-zero.  This must be a power of 2 on some targets.
3614d01cbe93b0e1a349b5c2881f1b319963f9e0504Eric Christopher    virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
3620dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach                                uint64_t Size, unsigned ByteAlignment = 0) = 0;
363ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis
36484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @}
36584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @name Generating Data
36684a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @{
36784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar
368c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko    /// EmitBytes - Emit the bytes in \p Data into the output.
369381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
370381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// This is used to implement assembler directives such as .byte, .ascii,
371381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// etc.
372ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher    virtual void EmitBytes(StringRef Data, unsigned AddrSpace = 0) = 0;
373381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar
374fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitValue - Emit the expression @p Value into the output as a native
375fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// integer of the given @p Size bytes.
376381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
377381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// This is used to implement assembler directives such as .word, .quad,
378381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// etc.
379381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    ///
380381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// @param Value - The value to emit.
381381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// @param Size - The size of the integer (in bytes) to emit. This must
382381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// match a native machine width.
38389b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
384debd7e4e8bc5cfe61bfb71835ce2b1a3fbccc2beRafael Espindola                               unsigned AddrSpace) = 0;
38589b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola
38689b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola    void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0);
38789b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola
38832ae3fe0ba469240753e2342e36485f7c9acfb5cChris Lattner    /// EmitIntValue - Special case of EmitValue that avoids the client having
38932ae3fe0ba469240753e2342e36485f7c9acfb5cChris Lattner    /// to pass in a MCExpr for constant integers.
3902df042cb32ecb8d2e1d499dfa27d5074c8b40e13Rafael Espindola    virtual void EmitIntValue(uint64_t Value, unsigned Size,
3912df042cb32ecb8d2e1d499dfa27d5074c8b40e13Rafael Espindola                              unsigned AddrSpace = 0);
3920dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
3930bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola    /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
3940bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola    /// this is done by producing
3950bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola    /// foo = value
3960bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola    /// .long foo
3970bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola    void EmitAbsValue(const MCExpr *Value, unsigned Size,
3980bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola                      unsigned AddrSpace = 0);
3993bb435301a2b5c901a993b0e151d05b596697038Kevin Enderby
400e8cfbd843d737e1f95c3032c7670c2be3838a6f6Rafael Espindola    virtual void EmitULEB128Value(const MCExpr *Value) = 0;
4013ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola
402e8cfbd843d737e1f95c3032c7670c2be3838a6f6Rafael Espindola    virtual void EmitSLEB128Value(const MCExpr *Value) = 0;
4033ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola
4043ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola    /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
4053ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola    /// client having to pass in a MCExpr for constant integers.
4061ced208be9cab0f994c5df9000da36bc313b2507Eric Christopher    void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0,
4071ced208be9cab0f994c5df9000da36bc313b2507Eric Christopher			     unsigned AddrSpace = 0);
4083ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola
4093ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola    /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
4103ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola    /// client having to pass in a MCExpr for constant integers.
41171e7f9210d87fa29202d851c43b5e91bbbd2fa51Rafael Espindola    void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0);
4123bb435301a2b5c901a993b0e151d05b596697038Kevin Enderby
4136cde3e6e993126df756e3be5b9ef43540b904644Chris Lattner    /// EmitSymbolValue - Special case of EmitValue that avoids the client
4146cde3e6e993126df756e3be5b9ef43540b904644Chris Lattner    /// having to pass in a MCExpr for MCSymbols.
415175ccab75f3a355285cf4533c201cbcecfd5928dRafael Espindola    void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
416175ccab75f3a355285cf4533c201cbcecfd5928dRafael Espindola                         unsigned AddrSpace = 0);
4170dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
4186c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    /// EmitGPRel64Value - Emit the expression @p Value into the output as a
4196c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    /// gprel64 (64-bit GP relative) value.
4206c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    ///
4216c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    /// This is used to implement assembler directives such as .gpdword on
4226c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    /// targets that support them.
4236c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka    virtual void EmitGPRel64Value(const MCExpr *Value);
4246c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka
425fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitGPRel32Value - Emit the expression @p Value into the output as a
426718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner    /// gprel32 (32-bit GP relative) value.
427718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner    ///
428718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner    /// This is used to implement assembler directives such as .gprel32 on
429718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner    /// targets that support them.
4303e03211625bba5bbb70a193c140ebf4dd8388bb7Rafael Espindola    virtual void EmitGPRel32Value(const MCExpr *Value);
4310dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
432ddf6bdde44287b5b559bc403a02ff971e15e8303Chris Lattner    /// EmitFill - Emit NumBytes bytes worth of the value specified by
433ddf6bdde44287b5b559bc403a02ff971e15e8303Chris Lattner    /// FillValue.  This implements directives such as '.space'.
434aaec205b87637cd0d59d4f11630db603686eb73dChris Lattner    virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
435ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher                          unsigned AddrSpace = 0);
4360dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
4376449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner    /// EmitZeros - Emit NumBytes worth of zeros.  This is a convenience
4386449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner    /// function that just wraps EmitFill.
439ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher    void EmitZeros(uint64_t NumBytes, unsigned AddrSpace = 0) {
4406449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner      EmitFill(NumBytes, 0, AddrSpace);
4416449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner    }
4426449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner
443fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitValueToAlignment - Emit some number of copies of @p Value until
444fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// the byte alignment @p ByteAlignment is reached.
44584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    ///
44684a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// If the number of bytes need to emit for the alignment is not a multiple
447fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// of @p ValueSize, then the contents of the emitted fill bytes is
44884a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// undefined.
44984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    ///
45084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// This used to implement the .align assembler directive.
45184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    ///
45284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @param ByteAlignment - The alignment to reach. This must be a power of
453c29dfa786a23c9ff0827ce4a56b5b178e4087aaaDaniel Dunbar    /// two on some targets.
45484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @param Value - The value to use when filling bytes.
455fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// @param ValueSize - The size of the integer (in bytes) to emit for
456fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// @p Value. This must match a native machine width.
45784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
45884a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// the alignment cannot be reached in this many bytes, no bytes are
45984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// emitted.
46084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
46184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar                                      unsigned ValueSize = 1,
46284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar                                      unsigned MaxBytesToEmit = 0) = 0;
4636e72048add2a6464e038121c6c275da37528aa0aKevin Enderby
4646e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment
4656e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// is reached.
4666e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    ///
4676e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// This used to align code where the alignment bytes may be executed.  This
4686e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// can emit different bytes for different sizes to optimize execution.
4696e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    ///
4706e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// @param ByteAlignment - The alignment to reach. This must be a power of
4716e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// two on some targets.
4726e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
4736e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// the alignment cannot be reached in this many bytes, no bytes are
4746e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    /// emitted.
4756e72048add2a6464e038121c6c275da37528aa0aKevin Enderby    virtual void EmitCodeAlignment(unsigned ByteAlignment,
4766e72048add2a6464e038121c6c275da37528aa0aKevin Enderby                                   unsigned MaxBytesToEmit = 0) = 0;
47784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar
478fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitValueToOffset - Emit some number of copies of @p Value until the
479fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// byte offset @p Offset is reached.
48084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    ///
48184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// This is used to implement assembler directives such as .org.
48284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    ///
4834a1fadaf5207e46d19c64e5773ff8d9e65e607d7Daniel Dunbar    /// @param Offset - The offset to reach. This may be an expression, but the
48484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// expression must be associated with the current section.
48584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @param Value - The value to use when filling bytes.
486ebd4c05c3cbd61215366d4d16f1c1a2e57e7156dJim Grosbach    /// @return false on success, true if the offset was invalid.
487ebd4c05c3cbd61215366d4d16f1c1a2e57e7156dJim Grosbach    virtual bool EmitValueToOffset(const MCExpr *Offset,
48884a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar                                   unsigned char Value = 0) = 0;
4890dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
49084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar    /// @}
4910dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
492a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    /// EmitFileDirective - Switch to a new logical file.  This is used to
493a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    /// implement the '.file "foo.c"' assembler directive.
494a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    virtual void EmitFileDirective(StringRef Filename) = 0;
4950dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
496a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    /// EmitDwarfFileDirective - Associate a filename with a specified logical
497a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    /// file number.  This implements the DWARF2 '.file 4 "foo.c"' assembler
498a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner    /// directive.
49944d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky    virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
50044d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky                                        StringRef Filename);
501af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola
502af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola    /// EmitDwarfLocDirective - This implements the DWARF2
503af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola    // '.loc fileno lineno ...' assembler directive.
504af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola    virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
505af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola                                       unsigned Column, unsigned Flags,
506af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola                                       unsigned Isa,
5073f3bf9387b75f4c932e4c59bd7af719d26ae4b99Devang Patel                                       unsigned Discriminator,
5083f3bf9387b75f4c932e4c59bd7af719d26ae4b99Devang Patel                                       StringRef FileName);
50984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar
51032a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola    virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
51132a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola                                          const MCSymbol *LastLabel,
512672b93a3324cc1da6d374eed4c75c050a9cad7beEvan Cheng                                          const MCSymbol *Label,
513672b93a3324cc1da6d374eed4c75c050a9cad7beEvan Cheng                                          unsigned PointerSize) = 0;
51432a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola
515245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola    virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
516245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola                                           const MCSymbol *Label) {
517245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola    }
518245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola
51932a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola    void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
52032a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola                              int PointerSize);
52132a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola
522d967578a8c506be341d20a1558eebb31484b8b6dBill Wendling    virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding);
523f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola    virtual void EmitCFISections(bool EH, bool Debug);
524547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola    void EmitCFIStartProc();
5251fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola    void EmitCFIEndProc();
526066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
527066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIDefCfaOffset(int64_t Offset);
528066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIDefCfaRegister(int64_t Register);
529066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
530066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
531066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
532066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIRememberState();
533066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIRestoreState();
534066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFISameValue(int64_t Register);
535ed23bdb65fe86cdb7a38c8c1998ec965e6973966Rafael Espindola    virtual void EmitCFIRestore(int64_t Register);
536066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
537066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola    virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
5386f0b181bc70318f8d5d4b9bdead7fc748677fe2aRafael Espindola    virtual void EmitCFIEscape(StringRef Values);
53916d7d437e03ce87fdaef7971919302920d54a966Rafael Espindola    virtual void EmitCFISignalFrame();
540c8fec7e21f5c24303eab8a8592f3b8faff347d86Rafael Espindola    virtual void EmitCFIUndefined(int64_t Register);
541f4f14f68f6078ea6681ee27b5bf42719d7db3441Rafael Espindola    virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
542cdfecc8759941c2996214070478d30084b79d463Rafael Espindola
543fbc539ff37ddd08c2480be9185e7a40919ce8940Charles Davis    virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
5449c77398d1c89f615735d304cd7eda3c3e9b1504fCharles Davis    virtual void EmitWin64EHEndProc();
545f07090134d06e0cf3508e8b8e87d775f0a7982c1Charles Davis    virtual void EmitWin64EHStartChained();
546f07090134d06e0cf3508e8b8e87d775f0a7982c1Charles Davis    virtual void EmitWin64EHEndChained();
547440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis    virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
548440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis                                    bool Except);
549440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis    virtual void EmitWin64EHHandlerData();
550c3b162857a587c9877e903f038471b882b213232Charles Davis    virtual void EmitWin64EHPushReg(unsigned Register);
551c3b162857a587c9877e903f038471b882b213232Charles Davis    virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset);
552c3b162857a587c9877e903f038471b882b213232Charles Davis    virtual void EmitWin64EHAllocStack(unsigned Size);
553c3b162857a587c9877e903f038471b882b213232Charles Davis    virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset);
554c3b162857a587c9877e903f038471b882b213232Charles Davis    virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset);
555ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis    virtual void EmitWin64EHPushFrame(bool Code);
5569c77398d1c89f615735d304cd7eda3c3e9b1504fCharles Davis    virtual void EmitWin64EHEndProlog();
557ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis
558fb76fe09297ee292129e44d723127f2408602a3dDan Gohman    /// EmitInstruction - Emit the given @p Instruction into the current
559381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar    /// section.
56025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar    virtual void EmitInstruction(const MCInst &Inst) = 0;
561ba1da8a7b10b8a7df04f3ca47ca36ad18adad80eDaniel Dunbar
5624766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    /// \brief Set the bundle alignment mode from now on in the section.
5634766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    /// The argument is the power of 2 to which the alignment is set. The
5644766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    /// value 0 means turn the bundle alignment off.
5654766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    virtual void EmitBundleAlignMode(unsigned AlignPow2) = 0;
5664766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky
5674766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    /// \brief The following instructions are a bundle-locked group.
5686c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky    ///
5696c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky    /// \param AlignToEnd - If true, the bundle-locked group will be aligned to
5706c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky    ///                     the end of a bundle.
5716c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky    virtual void EmitBundleLock(bool AlignToEnd) = 0;
5724766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky
5734766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    /// \brief Ends a bundle-locked group.
5744766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky    virtual void EmitBundleUnlock() = 0;
5754766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky
57691bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// EmitRawText - If this file is backed by a assembly streamer, this dumps
57791bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// the specified string in the output .s file.  This capability is
57891bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    /// indicated by the hasRawTextSupport() predicate.  By default this aborts.
57991bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner    virtual void EmitRawText(StringRef String);
58058bc4dd4a91443ddd3120b0a2f1801ad4d6aae1cChris Lattner    void EmitRawText(const Twine &String);
5810dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach
582b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    /// ARM-related methods.
583b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    /// FIXME: Eventually we should have some "target MC streamer" and move
584b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    /// these methods there.
585b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    virtual void EmitFnStart();
586b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    virtual void EmitFnEnd();
587b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    virtual void EmitCantUnwind();
588b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    virtual void EmitPersonality(const MCSymbol *Personality);
589b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov    virtual void EmitHandlerData();
59057caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov    virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0);
59157caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov    virtual void EmitPad(int64_t Offset);
59257caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov    virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
59357caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov                             bool isVector);
594b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov
595f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella    /// PPC-related methods.
596f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella    /// FIXME: Eventually replace it with some "target MC streamer" and move
597f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella    /// these methods there.
598f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella    virtual void EmitTCEntry(const MCSymbol &S);
599f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella
60099b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola    /// FinishImpl - Streamer specific finalization.
60199b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola    virtual void FinishImpl() = 0;
6024b1000d117f1b7cc5411bc251d141fe182a4ae1cDan Gohman    /// Finish - Finish emission of machine code.
60399b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola    void Finish();
60425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar  };
60525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
606011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar  /// createNullStreamer - Create a dummy machine code streamer, which does
607011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar  /// nothing. This is useful for timing the assembler front end.
608011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar  MCStreamer *createNullStreamer(MCContext &Ctx);
609011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar
610381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar  /// createAsmStreamer - Create a machine code streamer which will print out
611381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar  /// assembly for the native target, suitable for compiling with a native
612381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar  /// assembler.
6139dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  ///
6149dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  /// \param InstPrint - If given, the instruction printer to use. If not given
6154c42a6de9f5456cc1b28f2d37db589f580f2adc7Chris Lattner  /// the MCInst representation will be printed.  This method takes ownership of
6164c42a6de9f5456cc1b28f2d37db589f580f2adc7Chris Lattner  /// InstPrint.
6179dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  ///
6189dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  /// \param CE - If given, a code emitter to use to show the instruction
619c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko  /// encoding inline with the assembly. This method takes ownership of \p CE.
6209dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  ///
621745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar  /// \param TAB - If given, a target asm backend to use to show the fixup
622745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar  /// information in conjunction with encoding information. This method takes
623c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko  /// ownership of \p TAB.
624745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar  ///
6259dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  /// \param ShowInst - Whether to show the MCInst representation inline with
6269dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar  /// the assembly.
62786e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner  MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
62889b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola                                bool isVerboseAsm,
62989b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola                                bool useLoc,
630f1a5c7ec04002769f1638e64f7439589f0f926e6Rafael Espindola                                bool useCFI,
63144d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky                                bool useDwarfDirectory,
63290edac0e8b35f766599362b6301863229f0ddcdbChris Lattner                                MCInstPrinter *InstPrint = 0,
6339dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar                                MCCodeEmitter *CE = 0,
63478c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng                                MCAsmBackend *TAB = 0,
635e266ce6c6eaf52ebe2b18d85b5e23788cf2f6ef4Bill Wendling                                bool ShowInst = false);
636381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar
637d86e6ac9892ee61742d85f9f14f1179216d2e47bDan Gohman  /// createMachOStreamer - Create a machine code streamer which will generate
638381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar  /// Mach-O format object files.
6391abcd06856df324eac98d4bf5ba673fb77ae6a11Benjamin Kramer  ///
640c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko  /// Takes ownership of \p TAB and \p CE.
64178c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng  MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
642ac2884a717daf3ad2aa8425320795d661e8a980bDaniel Dunbar                                  raw_ostream &OS, MCCodeEmitter *CE,
643ac2884a717daf3ad2aa8425320795d661e8a980bDaniel Dunbar                                  bool RelaxAll = false);
64425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
645eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner  /// createWinCOFFStreamer - Create a machine code streamer which will
646eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner  /// generate Microsoft COFF format object files.
6471abcd06856df324eac98d4bf5ba673fb77ae6a11Benjamin Kramer  ///
648c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko  /// Takes ownership of \p TAB and \p CE.
649eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner  MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
65078c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng                                    MCAsmBackend &TAB,
651e2195d8b357d7081edb5eb09d1d6e9d7b4bfc308Michael J. Spencer                                    MCCodeEmitter &CE, raw_ostream &OS,
652e2195d8b357d7081edb5eb09d1d6e9d7b4bfc308Michael J. Spencer                                    bool RelaxAll = false);
653eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner
6546b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming  /// createELFStreamer - Create a machine code streamer which will generate
6556b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming  /// ELF format object files.
65678c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng  MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
65791f2cce231debf43384fe4ee39c11ba8460503ebJim Grosbach                                raw_ostream &OS, MCCodeEmitter *CE,
65891f2cce231debf43384fe4ee39c11ba8460503ebJim Grosbach                                bool RelaxAll, bool NoExecStack);
6596b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming
660abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar  /// createPureStreamer - Create a machine code streamer which will generate
661abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar  /// "pure" MC object files, for use with MC-JIT and testing tools.
662abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar  ///
663c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko  /// Takes ownership of \p TAB and \p CE.
66478c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng  MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
665abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar                                 raw_ostream &OS, MCCodeEmitter *CE);
666abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar
66725e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar} // end namespace llvm
66825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar
66925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar#endif
670