MCStreamer.h revision cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86
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" 23cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86Daniel Dunbar#include <string> 2484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar 2525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbarnamespace llvm { 2678c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng class MCAsmBackend; 274a0abd80f18f9c2a10bf5b14cd6731d51972a426Daniel Dunbar class MCCodeEmitter; 2825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class MCContext; 29821e3334ed3390d931f497300e6a5f1dc21bcfb3Daniel Dunbar class MCExpr; 3025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class MCInst; 3190edac0e8b35f766599362b6301863229f0ddcdbChris Lattner class MCInstPrinter; 3225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class MCSection; 3325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class MCSymbol; 349a7e2ccf574368b60455f8c8975030475a1f3ce0Daniel Dunbar class StringRef; 3586e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner class Twine; 3625e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class raw_ostream; 3786e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner class formatted_raw_ostream; 3825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 39e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// MCStreamer - Streaming machine code generation interface. This interface 40e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// is intended to provide a programatic interface that is very similar to the 41e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// level that an assembler .s file provides. It has callbacks to emit bytes, 427092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar /// handle directives, etc. The implementation of this interface retains 43e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// state to know what the current section is etc. 44e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// 45e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// There are multiple implementations of this interface: one for writing out 46e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// a .s file, and implementations that write out .o files of various formats. 47e18e0c58dcd740c64e962fefde44249d685d0568Chris Lattner /// 4825e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar class MCStreamer { 4925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar MCContext &Context; 5025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 511f7210e808373fa92be3a2d4fa653a6f79d5088bCraig Topper MCStreamer(const MCStreamer&) LLVM_DELETED_FUNCTION; 521f7210e808373fa92be3a2d4fa653a6f79d5088bCraig Topper MCStreamer &operator=(const MCStreamer&) LLVM_DELETED_FUNCTION; 5325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 54f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola bool EmitEHFrame; 55f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola bool EmitDebugFrame; 56f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola 57d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola std::vector<MCDwarfFrameInfo> FrameInfos; 58d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola MCDwarfFrameInfo *getCurrentFrameInfo(); 59529a01df02ad221e8e55097a8ee36b85234eb078Rafael Espindola MCSymbol *EmitCFICommon(); 60d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola void EnsureValidFrame(); 61d7c8ccae8e48dce3ab7c3e9b4d8a309998c47961Rafael Espindola 62ca93138e11f404a19553049a569f1fa6ad491b67Charles Davis std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos; 6391d9a1c0f7c598d51c50f80bc9e8dfc1494f78c1Charles Davis MCWin64EHUnwindInfo *CurrentW64UnwindInfo; 6491d9a1c0f7c598d51c50f80bc9e8dfc1494f78c1Charles Davis void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame); 650855bc5b973320052c87bdcc2fa17b9711edc3deCharles Davis void EnsureValidW64UnwindInfo(); 660855bc5b973320052c87bdcc2fa17b9711edc3deCharles Davis 6749cb9b88867426d1a430f248550d3cc785a68fe4Rafael Espindola MCSymbol* LastSymbol; 68ed708f9c1facb9928ef2f79503e7030c8f25b00dRafael Espindola 697d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger /// SectionStack - This is stack of current and previous section 707d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger /// values saved by PushSection. 717d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger SmallVector<std::pair<const MCSection *, 727d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger const MCSection *>, 4> SectionStack; 737092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar 7407f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames bool AutoInitSections; 7507f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames 767768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola protected: 777768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola MCStreamer(MCContext &Ctx); 78a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola 79a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, 80a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola const MCSymbol *B); 81a37bd1d02c0e3d93474fdf30352bf4a425cbe25bRafael Espindola 82a6f2678f08299f053feb58337fc4322131d99bf4Rafael Espindola const MCExpr *ForceExpAbs(const MCExpr* Expr); 831674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer 84547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola void RecordProcStart(MCDwarfFrameInfo &Frame); 85547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); 861fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola void RecordProcEnd(MCDwarfFrameInfo &Frame); 871fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); 88c25dad8750083829d9a8935ce40d0734e5488f8eRafael Espindola void EmitFrames(bool usingCFI); 89c25dad8750083829d9a8935ce40d0734e5488f8eRafael Espindola 903185f5c35322cbd10040ab20f265042d477efe62Charles Davis MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;} 9138ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis void EmitW64Tables(); 923185f5c35322cbd10040ab20f265042d477efe62Charles Davis 93381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar public: 9425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar virtual ~MCStreamer(); 9525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 965399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas /// State management 975399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas /// 985399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas virtual void reset(); 995399d2502acaf96fe8420e61913e77f0b23650ffPedro Artigas 10025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar MCContext &getContext() const { return Context; } 10125e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 10289b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola unsigned getNumFrameInfos() { 10389b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola return FrameInfos.size(); 10489b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola } 10589b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola 10689b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola const MCDwarfFrameInfo &getFrameInfo(unsigned i) { 10789b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola return FrameInfos[i]; 10889b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola } 10989b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola 110dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling ArrayRef<MCDwarfFrameInfo> getFrameInfos() { 111dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling return FrameInfos; 112dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling } 113dda1bdc962a314bf4fca86f4cd4802ff6c55b172Bill Wendling 11438ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis unsigned getNumW64UnwindInfos() { 11538ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis return W64UnwindInfos.size(); 11638ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis } 11738ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis 11838ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) { 119ca93138e11f404a19553049a569f1fa6ad491b67Charles Davis return *W64UnwindInfos[i]; 12038ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis } 12138ea9eecd7c810e11f96c8306b241f9db88fc62fCharles Davis 1220fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner /// @name Assembly File Formatting. 1230fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner /// @{ 1240dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 12591bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// isVerboseAsm - Return true if this streamer supports verbose assembly 12691bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// and if it is enabled. 12756591ab218639d8a6e4c756ca37adaf20215c3b6Chris Lattner virtual bool isVerboseAsm() const { return false; } 1280dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 12991bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// hasRawTextSupport - Return true if this asm streamer supports emitting 13091bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// unformatted text to the .s file with EmitRawText. 13191bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner virtual bool hasRawTextSupport() const { return false; } 1320fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner 133d32c7cfa248f685e6e3064c0958dc2f0c31a4df6Chris Lattner /// AddComment - Add a comment that can be emitted to the generated .s 13486e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// file if applicable as a QoI issue to make the output of the compiler 13586e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// more readable. This only affects the MCAsmStreamer, and only when 13686e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// verbose assembly output is enabled. 13786e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// 13886e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// If the comment includes embedded \n's, they will each get the comment 13986e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner /// prefix as appropriate. The added comment should not end with a \n. 140d32c7cfa248f685e6e3064c0958dc2f0c31a4df6Chris Lattner virtual void AddComment(const Twine &T) {} 1410dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 142d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner /// GetCommentOS - Return a raw_ostream that comments can be written to. 143d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner /// Unlike AddComment, you are required to terminate comments with \n if you 144d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner /// use this method. 145d79d9dce47d505369662ae5111dba24f9ccdef68Chris Lattner virtual raw_ostream &GetCommentOS(); 1460dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 1470fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner /// AddBlankLine - Emit a blank line to a .s file to pretty it up. 1480fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner virtual void AddBlankLine() {} 1490dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 1500fd90fd8d1c2143a763dee509c66a5b3c74088b1Chris Lattner /// @} 1510dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 15284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @name Symbol & Section Management 15384a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @{ 1540dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 1556a4824c466bbfbcbe7dc4d95ec1e23a14ec73d87Dan Gohman /// getCurrentSection - Return the current section that the streamer is 1567092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar /// emitting code to. 1577768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola const MCSection *getCurrentSection() const { 1587d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger if (!SectionStack.empty()) 1597d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger return SectionStack.back().first; 1607768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola return NULL; 1617768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 16284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar 1631674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer /// getPreviousSection - Return the previous section that the streamer is 1641674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer /// emitting code to. 1657768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola const MCSection *getPreviousSection() const { 1667d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger if (!SectionStack.empty()) 1677d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger return SectionStack.back().second; 1687768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola return NULL; 1697768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 1707768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola 1717768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// ChangeSection - Update streamer for a new active section. 1727768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// 1737768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// This is called by PopSection and SwitchSection, if the current 1747768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// section changes. 1757768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola virtual void ChangeSection(const MCSection *) = 0; 1767768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola 1777768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// pushSection - Save the current and previous section on the 1787768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// section stack. 1797768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola void PushSection() { 1807d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger SectionStack.push_back(std::make_pair(getCurrentSection(), 1817d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger getPreviousSection())); 1827768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 1837768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola 1847768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// popSection - Restore the current and previous section from 1857768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// the section stack. Calls ChangeSection as needed. 1867768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// 1877768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola /// Returns false if the stack was empty. 1887768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola bool PopSection() { 1897d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger if (SectionStack.size() <= 1) 1907768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola return false; 1917d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger const MCSection *oldSection = SectionStack.pop_back_val().first; 1927d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger const MCSection *curSection = SectionStack.back().first; 1937768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola 1947768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola if (oldSection != curSection) 1957768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola ChangeSection(curSection); 1967768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola return true; 1977768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 1981674b0b0e4972b844833f253286cbf99a6e99d6eBenjamin Kramer 199381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// SwitchSection - Set the current section where code is being emitted to 200fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// @p Section. This is required to update CurSection. 201381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 202381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// This corresponds to assembler directives like .section, .text, etc. 2037768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola void SwitchSection(const MCSection *Section) { 2047768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola assert(Section && "Cannot switch to a null section!"); 2057d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger const MCSection *curSection = SectionStack.back().first; 2067d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger SectionStack.back().second = curSection; 2077768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola if (Section != curSection) { 2087d0805dcb82e9ba1d90ce8d702169683b9caded7Joerg Sonnenberger SectionStack.back().first = Section; 2097768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola ChangeSection(Section); 2107768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 2117768a9dce14431018133cd586f5c8ce3e057f069Rafael Espindola } 2120dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 213410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis /// SwitchSectionNoChange - Set the current section where code is being 214410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis /// emitted to @p Section. This is required to update CurSection. This 215410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis /// version does not call ChangeSection. 216410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis void SwitchSectionNoChange(const MCSection *Section) { 217410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis assert(Section && "Cannot switch to a null section!"); 218410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis const MCSection *curSection = SectionStack.back().first; 219410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis SectionStack.back().second = curSection; 220410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis if (Section != curSection) 221410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis SectionStack.back().first = Section; 222410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis } 223410ef2b263e92d3de1b2acff7437059400daed7dCharles Davis 22407f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames /// Initialize the streamer. 22507f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames void InitStreamer() { 22607f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames if (AutoInitSections) 22707f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames InitSections(); 22807f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames } 22907f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames 23007f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames /// Tell this MCStreamer to call InitSections upon initialization. 23107f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames void setAutoInitSections(bool AutoInitSections) { 23207f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames this->AutoInitSections = AutoInitSections; 23307f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames } 23407f6a4fde0a1b081fbefd986345c9b2f4f85e88aLang Hames 235d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola /// InitSections - Create the default sections and set the initial one. 236d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola virtual void InitSections() = 0; 237030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky 238030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky /// InitToTextSection - Create a text section and switch the streamer to it. 239030f63a397edc20f8f661bac62f7b90cb5cf57bcEli Bendersky virtual void InitToTextSection() = 0; 240d80781b98b771d370730ab7c630018f23e202b57Rafael Espindola 241fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitLabel - Emit a label for @p Symbol into the current section. 242381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 243381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// This corresponds to an assembler statement such as: 244381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// foo: 245381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 246381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// @param Symbol - The symbol to emit. A given symbol should only be 247381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// emitted as a label once, and symbols emitted as a label should never be 248381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// used in an assignment. 249ed708f9c1facb9928ef2f79503e7030c8f25b00dRafael Espindola virtual void EmitLabel(MCSymbol *Symbol); 250381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar 2512c3a4641a7785da78839caf574277df9cd93b52cReed Kotler virtual void EmitDebugLabel(MCSymbol *Symbol); 2522c3a4641a7785da78839caf574277df9cd93b52cReed Kotler 2538bca4106dfc2945723251db10e340183f3e372ddRafael Espindola virtual void EmitEHSymAttributes(const MCSymbol *Symbol, 2548bca4106dfc2945723251db10e340183f3e372ddRafael Espindola MCSymbol *EHSymbol); 2558bca4106dfc2945723251db10e340183f3e372ddRafael Espindola 2563e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach /// EmitAssemblerFlag - Note in the output the specified @p Flag. 257a5ad93a10a5435f21090b09edb6b3a7e44967648Chris Lattner virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; 258a5c783280f83df5c60a8ed9e32c61b05a11048e3Kevin Enderby 259cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86Daniel Dunbar /// EmitLinkerOptions - Emit the given list @p Options of strings as linker 260cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86Daniel Dunbar /// options into the output. 261cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86Daniel Dunbar virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {} 262cddd236e8a5acb80e9a0e79dc63f6cfaa8205b86Daniel Dunbar 2633e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach /// EmitDataRegion - Note in the output the specified region @p Kind. 2643e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach virtual void EmitDataRegion(MCDataRegionType Kind) {} 2653e96531186ba574b0c25a4be62d24b8b7d752c9fJim Grosbach 266ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach /// EmitThumbFunc - Note in the output that the specified @p Func is 267ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach /// a Thumb mode function (ARM target only). 268ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach virtual void EmitThumbFunc(MCSymbol *Func) = 0; 269ce79299f78bb04e76e1860ab119b85d69f3a19c7Jim Grosbach 270fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitAssignment - Emit an assignment of @p Value to @p Symbol. 271381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 272381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// This corresponds to an assembler statement such as: 273381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// symbol = value 274381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 275381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// The assignment generates no code, but has the side effect of binding the 276381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// value in the current context. For the assembly streamer, this prints the 277381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// binding into the .s file. 278381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 279381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// @param Symbol - The symbol being assigned to. 280381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// @param Value - The value for the symbol. 281821e3334ed3390d931f497300e6a5f1dc21bcfb3Daniel Dunbar virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0; 28225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 283484291c27319668ad99cb87def000254357736fbRafael Espindola /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol. 284484291c27319668ad99cb87def000254357736fbRafael Espindola /// 285484291c27319668ad99cb87def000254357736fbRafael Espindola /// This corresponds to an assembler statement such as: 286484291c27319668ad99cb87def000254357736fbRafael Espindola /// .weakref alias, symbol 287484291c27319668ad99cb87def000254357736fbRafael Espindola /// 288484291c27319668ad99cb87def000254357736fbRafael Espindola /// @param Alias - The alias that is being created. 289484291c27319668ad99cb87def000254357736fbRafael Espindola /// @param Symbol - The symbol being aliased. 290484291c27319668ad99cb87def000254357736fbRafael Espindola virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0; 291484291c27319668ad99cb87def000254357736fbRafael Espindola 292fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. 293a11af531ec48ad84f790b9511f003ac5c934a999Daniel Dunbar virtual void EmitSymbolAttribute(MCSymbol *Symbol, 294a5ad93a10a5435f21090b09edb6b3a7e44967648Chris Lattner MCSymbolAttr Attribute) = 0; 29525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 296fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. 29795cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby /// 29895cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby /// @param Symbol - The symbol to have its n_desc field set. 29995cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby /// @param DescValue - The value to set into the n_desc field. 30095cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0; 30195cf30c444707634bbd950f13405b6c8bcfe496bKevin Enderby 302b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// BeginCOFFSymbolDef - Start emitting COFF symbol definition 303b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// 304b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// @param Symbol - The symbol to have its External & Type fields set. 305b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0; 306b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner 307b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol. 308b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// 309b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// @param StorageClass - The storage class the symbol should have. 310b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0; 311b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner 312b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// EmitCOFFSymbolType - Emit the type of the symbol. 313b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// 314b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h) 315b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner virtual void EmitCOFFSymbolType(int Type) = 0; 316b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner 317b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner /// EndCOFFSymbolDef - Marks the end of the symbol definition. 318b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner virtual void EndCOFFSymbolDef() = 0; 319b54b9ddaaf2d258767d360583642ed1b91075fc9Chris Lattner 3208f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola /// EmitCOFFSecRel32 - Emits a COFF section relative relocation. 3218f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola /// 3228f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola /// @param Symbol - Symbol the section relative realocation should point to. 3238f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola virtual void EmitCOFFSecRel32(MCSymbol const *Symbol); 3248f7d12ccfd8feb258bdf4e582592bc00beacc7c6Rafael Espindola 32599328add833807f12a4950c7de29fb2a5df04703Chris Lattner /// EmitELFSize - Emit an ELF .size directive. 32699328add833807f12a4950c7de29fb2a5df04703Chris Lattner /// 32799328add833807f12a4950c7de29fb2a5df04703Chris Lattner /// This corresponds to an assembler statement such as: 32899328add833807f12a4950c7de29fb2a5df04703Chris Lattner /// .size symbol, expression 32999328add833807f12a4950c7de29fb2a5df04703Chris Lattner /// 33099328add833807f12a4950c7de29fb2a5df04703Chris Lattner virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0; 3310dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 3329eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// EmitCommonSymbol - Emit a common symbol. 3334e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner /// 3344e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner /// @param Symbol - The common symbol to emit. 3354e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner /// @param Size - The size of the common symbol. 3367092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar /// @param ByteAlignment - The alignment of the symbol if 3379eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// non-zero. This must be a power of 2. 3389eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 3397092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar unsigned ByteAlignment) = 0; 3404e4db7adfc9858a8f77f841c7467bc6fcbb8110eChris Lattner 3419eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. 3429eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// 3439eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// @param Symbol - The common symbol to emit. 3449eb158d5b4cd4f6fc80912e2dd77bdf13c3ca0e7Chris Lattner /// @param Size - The size of the common symbol. 34536a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer /// @param ByteAlignment - The alignment of the common symbol in bytes. 34636a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 34736a16015ac108e2f0dd2d6d96a6d364bc74c50d7Benjamin Kramer unsigned ByteAlignment) = 0; 3480dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 3490df4a80e2063424929bbfaa61dd7973062218ad4Eric Christopher /// EmitZerofill - Emit the zerofill section and an optional symbol. 3509be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner /// 3519be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner /// @param Section - The zerofill section to create and or to put the symbol 3529be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner /// @param Symbol - The zerofill symbol to emit, if non-NULL. 3539be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner /// @param Size - The size of the zerofill symbol. 3547092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar /// @param ByteAlignment - The alignment of the zerofill symbol if 3557092c7e1dcf9d05741b400dd54bbd7d3419773b2Daniel Dunbar /// non-zero. This must be a power of 2 on some targets. 3568751b94ffbd9c49df8949a37f78d6bd0be87b256Daniel Dunbar virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, 357c90a1fcf9f44858b20e0f5f7e0b98049aec7a1e0Evan Cheng uint64_t Size = 0,unsigned ByteAlignment = 0) = 0; 3589be3fee2bdc3126fb87e4e1b31935905f4bcc4d0Chris Lattner 359482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol. 360482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// 3614d01cbe93b0e1a349b5c2881f1b319963f9e0504Eric Christopher /// @param Section - The thread local common section. 362482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// @param Symbol - The thread local common symbol to emit. 363482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// @param Size - The size of the symbol. 364482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// @param ByteAlignment - The alignment of the thread local common symbol 365482eba054ab3543ee0e1f453d3d6441092f4b76dEric Christopher /// if non-zero. This must be a power of 2 on some targets. 3664d01cbe93b0e1a349b5c2881f1b319963f9e0504Eric Christopher virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, 3670dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach uint64_t Size, unsigned ByteAlignment = 0) = 0; 368ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis 36984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @} 37084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @name Generating Data 37184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @{ 37284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar 373c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// EmitBytes - Emit the bytes in \p Data into the output. 374381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 375381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// This is used to implement assembler directives such as .byte, .ascii, 376381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// etc. 377ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher virtual void EmitBytes(StringRef Data, unsigned AddrSpace = 0) = 0; 378381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar 379fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitValue - Emit the expression @p Value into the output as a native 380fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// integer of the given @p Size bytes. 381381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 382381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// This is used to implement assembler directives such as .word, .quad, 383381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// etc. 384381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// 385381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// @param Value - The value to emit. 386381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// @param Size - The size of the integer (in bytes) to emit. This must 387381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// match a native machine width. 38889b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, 389debd7e4e8bc5cfe61bfb71835ce2b1a3fbccc2beRafael Espindola unsigned AddrSpace) = 0; 39089b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola 39189b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0); 39289b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola 39332ae3fe0ba469240753e2342e36485f7c9acfb5cChris Lattner /// EmitIntValue - Special case of EmitValue that avoids the client having 39432ae3fe0ba469240753e2342e36485f7c9acfb5cChris Lattner /// to pass in a MCExpr for constant integers. 3952df042cb32ecb8d2e1d499dfa27d5074c8b40e13Rafael Espindola virtual void EmitIntValue(uint64_t Value, unsigned Size, 3962df042cb32ecb8d2e1d499dfa27d5074c8b40e13Rafael Espindola unsigned AddrSpace = 0); 3970dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 3980bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO 3990bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola /// this is done by producing 4000bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola /// foo = value 4010bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola /// .long foo 4020bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola void EmitAbsValue(const MCExpr *Value, unsigned Size, 4030bbe0b440ee2cef47dcb7b281825eb70341c16ddRafael Espindola unsigned AddrSpace = 0); 4043bb435301a2b5c901a993b0e151d05b596697038Kevin Enderby 405e8cfbd843d737e1f95c3032c7670c2be3838a6f6Rafael Espindola virtual void EmitULEB128Value(const MCExpr *Value) = 0; 4063ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola 407e8cfbd843d737e1f95c3032c7670c2be3838a6f6Rafael Espindola virtual void EmitSLEB128Value(const MCExpr *Value) = 0; 4083ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola 4093ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the 4103ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola /// client having to pass in a MCExpr for constant integers. 4111ced208be9cab0f994c5df9000da36bc313b2507Eric Christopher void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0, 4121ced208be9cab0f994c5df9000da36bc313b2507Eric Christopher unsigned AddrSpace = 0); 4133ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola 4143ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the 4153ff57094a7d176a759ddb1e1668489d89064f56cRafael Espindola /// client having to pass in a MCExpr for constant integers. 41671e7f9210d87fa29202d851c43b5e91bbbd2fa51Rafael Espindola void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0); 4173bb435301a2b5c901a993b0e151d05b596697038Kevin Enderby 4186cde3e6e993126df756e3be5b9ef43540b904644Chris Lattner /// EmitSymbolValue - Special case of EmitValue that avoids the client 4196cde3e6e993126df756e3be5b9ef43540b904644Chris Lattner /// having to pass in a MCExpr for MCSymbols. 420175ccab75f3a355285cf4533c201cbcecfd5928dRafael Espindola void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, 421175ccab75f3a355285cf4533c201cbcecfd5928dRafael Espindola unsigned AddrSpace = 0); 4220dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 4236c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka /// EmitGPRel64Value - Emit the expression @p Value into the output as a 4246c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka /// gprel64 (64-bit GP relative) value. 4256c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka /// 4266c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka /// This is used to implement assembler directives such as .gpdword on 4276c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka /// targets that support them. 4286c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka virtual void EmitGPRel64Value(const MCExpr *Value); 4296c2cf8b1fbcf70fd9db6fe44032c1ceaa2299760Akira Hatanaka 430fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitGPRel32Value - Emit the expression @p Value into the output as a 431718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner /// gprel32 (32-bit GP relative) value. 432718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner /// 433718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner /// This is used to implement assembler directives such as .gprel32 on 434718fb59801320b8cb22363d115b5fc5ec40dc1f5Chris Lattner /// targets that support them. 4353e03211625bba5bbb70a193c140ebf4dd8388bb7Rafael Espindola virtual void EmitGPRel32Value(const MCExpr *Value); 4360dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 437ddf6bdde44287b5b559bc403a02ff971e15e8303Chris Lattner /// EmitFill - Emit NumBytes bytes worth of the value specified by 438ddf6bdde44287b5b559bc403a02ff971e15e8303Chris Lattner /// FillValue. This implements directives such as '.space'. 439aaec205b87637cd0d59d4f11630db603686eb73dChris Lattner virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue, 440ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher unsigned AddrSpace = 0); 4410dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 4426449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner /// EmitZeros - Emit NumBytes worth of zeros. This is a convenience 4436449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner /// function that just wraps EmitFill. 444ca1dd05c3c12e857614ae6837f90894396225dd6Eric Christopher void EmitZeros(uint64_t NumBytes, unsigned AddrSpace = 0) { 4456449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner EmitFill(NumBytes, 0, AddrSpace); 4466449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner } 4476449abfbc86310edbbe0b5ffb3fad5c14301307fChris Lattner 448fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitValueToAlignment - Emit some number of copies of @p Value until 449fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// the byte alignment @p ByteAlignment is reached. 45084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// 45184a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// If the number of bytes need to emit for the alignment is not a multiple 452fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// of @p ValueSize, then the contents of the emitted fill bytes is 45384a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// undefined. 45484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// 45584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// This used to implement the .align assembler directive. 45684a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// 45784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @param ByteAlignment - The alignment to reach. This must be a power of 458c29dfa786a23c9ff0827ce4a56b5b178e4087aaaDaniel Dunbar /// two on some targets. 45984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @param Value - The value to use when filling bytes. 460fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// @param ValueSize - The size of the integer (in bytes) to emit for 461fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// @p Value. This must match a native machine width. 46284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If 46384a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// the alignment cannot be reached in this many bytes, no bytes are 46484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// emitted. 46584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, 46684a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar unsigned ValueSize = 1, 46784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar unsigned MaxBytesToEmit = 0) = 0; 4686e72048add2a6464e038121c6c275da37528aa0aKevin Enderby 4696e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment 4706e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// is reached. 4716e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// 4726e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// This used to align code where the alignment bytes may be executed. This 4736e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// can emit different bytes for different sizes to optimize execution. 4746e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// 4756e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// @param ByteAlignment - The alignment to reach. This must be a power of 4766e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// two on some targets. 4776e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If 4786e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// the alignment cannot be reached in this many bytes, no bytes are 4796e72048add2a6464e038121c6c275da37528aa0aKevin Enderby /// emitted. 4806e72048add2a6464e038121c6c275da37528aa0aKevin Enderby virtual void EmitCodeAlignment(unsigned ByteAlignment, 4816e72048add2a6464e038121c6c275da37528aa0aKevin Enderby unsigned MaxBytesToEmit = 0) = 0; 48284a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar 483fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitValueToOffset - Emit some number of copies of @p Value until the 484fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// byte offset @p Offset is reached. 48584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// 48684a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// This is used to implement assembler directives such as .org. 48784a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// 4884a1fadaf5207e46d19c64e5773ff8d9e65e607d7Daniel Dunbar /// @param Offset - The offset to reach. This may be an expression, but the 48984a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// expression must be associated with the current section. 49084a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @param Value - The value to use when filling bytes. 491ebd4c05c3cbd61215366d4d16f1c1a2e57e7156dJim Grosbach /// @return false on success, true if the offset was invalid. 492ebd4c05c3cbd61215366d4d16f1c1a2e57e7156dJim Grosbach virtual bool EmitValueToOffset(const MCExpr *Offset, 49384a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar unsigned char Value = 0) = 0; 4940dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 49584a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar /// @} 4960dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 497a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner /// EmitFileDirective - Switch to a new logical file. This is used to 498a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner /// implement the '.file "foo.c"' assembler directive. 499a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner virtual void EmitFileDirective(StringRef Filename) = 0; 5000dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 501a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner /// EmitDwarfFileDirective - Associate a filename with a specified logical 502a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler 503a6594fc7156c0afbe6fd5a6aab9b099aaf950c53Chris Lattner /// directive. 50444d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, 50544d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky StringRef Filename); 506af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola 507af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola /// EmitDwarfLocDirective - This implements the DWARF2 508af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola // '.loc fileno lineno ...' assembler directive. 509af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, 510af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola unsigned Column, unsigned Flags, 511af6b5808756d6ce335df9eb158efa33894b401c4Rafael Espindola unsigned Isa, 5123f3bf9387b75f4c932e4c59bd7af719d26ae4b99Devang Patel unsigned Discriminator, 5133f3bf9387b75f4c932e4c59bd7af719d26ae4b99Devang Patel StringRef FileName); 51484a2926fb7ab388d688a133b0b375a26e669fd55Daniel Dunbar 51532a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, 51632a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola const MCSymbol *LastLabel, 517672b93a3324cc1da6d374eed4c75c050a9cad7beEvan Cheng const MCSymbol *Label, 518672b93a3324cc1da6d374eed4c75c050a9cad7beEvan Cheng unsigned PointerSize) = 0; 51932a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola 520245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, 521245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola const MCSymbol *Label) { 522245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola } 523245a1e20419aa5a3c833d7a8e89168e19d5f4d2cRafael Espindola 52432a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label, 52532a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola int PointerSize); 52632a006e606742b1c5401e49607e33717bb5441f0Rafael Espindola 527d967578a8c506be341d20a1558eebb31484b8b6dBill Wendling virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding); 528f9efd83166401bca542c6702ea329f9901c4e04bRafael Espindola virtual void EmitCFISections(bool EH, bool Debug); 529547be2699c547b79a7735858a64921d8ccf180f7Rafael Espindola void EmitCFIStartProc(); 5301fe9737eb49ecb80fbb547f0e16e10a726cd53cfRafael Espindola void EmitCFIEndProc(); 531066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); 532066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIDefCfaOffset(int64_t Offset); 533066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIDefCfaRegister(int64_t Register); 534066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIOffset(int64_t Register, int64_t Offset); 535066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding); 536066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding); 537066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIRememberState(); 538066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIRestoreState(); 539066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFISameValue(int64_t Register); 540ed23bdb65fe86cdb7a38c8c1998ec965e6973966Rafael Espindola virtual void EmitCFIRestore(int64_t Register); 541066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); 542066c2f495ae396ce5335e374c45b1e4ace4f2470Rafael Espindola virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); 5436f0b181bc70318f8d5d4b9bdead7fc748677fe2aRafael Espindola virtual void EmitCFIEscape(StringRef Values); 54416d7d437e03ce87fdaef7971919302920d54a966Rafael Espindola virtual void EmitCFISignalFrame(); 545c8fec7e21f5c24303eab8a8592f3b8faff347d86Rafael Espindola virtual void EmitCFIUndefined(int64_t Register); 546f4f14f68f6078ea6681ee27b5bf42719d7db3441Rafael Espindola virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); 547cdfecc8759941c2996214070478d30084b79d463Rafael Espindola 548fbc539ff37ddd08c2480be9185e7a40919ce8940Charles Davis virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); 5499c77398d1c89f615735d304cd7eda3c3e9b1504fCharles Davis virtual void EmitWin64EHEndProc(); 550f07090134d06e0cf3508e8b8e87d775f0a7982c1Charles Davis virtual void EmitWin64EHStartChained(); 551f07090134d06e0cf3508e8b8e87d775f0a7982c1Charles Davis virtual void EmitWin64EHEndChained(); 552440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind, 553440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis bool Except); 554440596ffe5bb77a202acb36d5eadd158976ff39aCharles Davis virtual void EmitWin64EHHandlerData(); 555c3b162857a587c9877e903f038471b882b213232Charles Davis virtual void EmitWin64EHPushReg(unsigned Register); 556c3b162857a587c9877e903f038471b882b213232Charles Davis virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset); 557c3b162857a587c9877e903f038471b882b213232Charles Davis virtual void EmitWin64EHAllocStack(unsigned Size); 558c3b162857a587c9877e903f038471b882b213232Charles Davis virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset); 559c3b162857a587c9877e903f038471b882b213232Charles Davis virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset); 560ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis virtual void EmitWin64EHPushFrame(bool Code); 5619c77398d1c89f615735d304cd7eda3c3e9b1504fCharles Davis virtual void EmitWin64EHEndProlog(); 562ff96a12db635daf4f88cfea899e63a885dfaa9edCharles Davis 563fb76fe09297ee292129e44d723127f2408602a3dDan Gohman /// EmitInstruction - Emit the given @p Instruction into the current 564381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// section. 56525e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar virtual void EmitInstruction(const MCInst &Inst) = 0; 566ba1da8a7b10b8a7df04f3ca47ca36ad18adad80eDaniel Dunbar 5674766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky /// \brief Set the bundle alignment mode from now on in the section. 5684766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky /// The argument is the power of 2 to which the alignment is set. The 5694766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky /// value 0 means turn the bundle alignment off. 5704766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky virtual void EmitBundleAlignMode(unsigned AlignPow2) = 0; 5714766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky 5724766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky /// \brief The following instructions are a bundle-locked group. 5736c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky /// 5746c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky /// \param AlignToEnd - If true, the bundle-locked group will be aligned to 5756c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky /// the end of a bundle. 5766c1d4972cf1cd6b6072e31c05f97abb1ed7a8497Eli Bendersky virtual void EmitBundleLock(bool AlignToEnd) = 0; 5774766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky 5784766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky /// \brief Ends a bundle-locked group. 5794766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky virtual void EmitBundleUnlock() = 0; 5804766ef41b31e4f97bce1179c3b0398303bf65356Eli Bendersky 58191bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// EmitRawText - If this file is backed by a assembly streamer, this dumps 58291bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// the specified string in the output .s file. This capability is 58391bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner /// indicated by the hasRawTextSupport() predicate. By default this aborts. 58491bead790518fcf5cb26019fb1ebf2372e8a5b3fChris Lattner virtual void EmitRawText(StringRef String); 58558bc4dd4a91443ddd3120b0a2f1801ad4d6aae1cChris Lattner void EmitRawText(const Twine &String); 5860dd2c9331887b9d0aa06b1e201c5eda4361365fcJim Grosbach 587b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov /// ARM-related methods. 588b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov /// FIXME: Eventually we should have some "target MC streamer" and move 589b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov /// these methods there. 590b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov virtual void EmitFnStart(); 591b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov virtual void EmitFnEnd(); 592b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov virtual void EmitCantUnwind(); 593b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov virtual void EmitPersonality(const MCSymbol *Personality); 594b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov virtual void EmitHandlerData(); 59557caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0); 59657caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov virtual void EmitPad(int64_t Offset); 59757caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList, 59857caad7a33ff145b71545f10dcfbbf2fd0f595d3Anton Korobeynikov bool isVector); 599b5e16af9ea04cc1f94ca631104e5e6be96546aa1Anton Korobeynikov 600f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella /// PPC-related methods. 601f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella /// FIXME: Eventually replace it with some "target MC streamer" and move 602f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella /// these methods there. 603f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella virtual void EmitTCEntry(const MCSymbol &S); 604f35c62bf025411393c7df0803851010cc0e597baAdhemerval Zanella 60599b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola /// FinishImpl - Streamer specific finalization. 60699b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola virtual void FinishImpl() = 0; 6074b1000d117f1b7cc5411bc251d141fe182a4ae1cDan Gohman /// Finish - Finish emission of machine code. 60899b4237c1647156f0e1d3d7e03efdab23ed79778Rafael Espindola void Finish(); 60925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar }; 61025e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 611011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar /// createNullStreamer - Create a dummy machine code streamer, which does 612011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar /// nothing. This is useful for timing the assembler front end. 613011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar MCStreamer *createNullStreamer(MCContext &Ctx); 614011e4db845b5c4166142338c77adc8ac03e5e041Daniel Dunbar 615381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// createAsmStreamer - Create a machine code streamer which will print out 616381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// assembly for the native target, suitable for compiling with a native 617381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// assembler. 6189dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// 6199dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// \param InstPrint - If given, the instruction printer to use. If not given 6204c42a6de9f5456cc1b28f2d37db589f580f2adc7Chris Lattner /// the MCInst representation will be printed. This method takes ownership of 6214c42a6de9f5456cc1b28f2d37db589f580f2adc7Chris Lattner /// InstPrint. 6229dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// 6239dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// \param CE - If given, a code emitter to use to show the instruction 624c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// encoding inline with the assembly. This method takes ownership of \p CE. 6259dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// 626745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar /// \param TAB - If given, a target asm backend to use to show the fixup 627745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar /// information in conjunction with encoding information. This method takes 628c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// ownership of \p TAB. 629745dacc91d7ee9531bfba76b21beb5d4eef93a7dDaniel Dunbar /// 6309dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// \param ShowInst - Whether to show the MCInst representation inline with 6319dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar /// the assembly. 63286e2211d0a496f470ea1d320161c8dc43593c5c6Chris Lattner MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, 63389b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola bool isVerboseAsm, 63489b9372605db2ce3b0085c84089e389f7bc1fbddRafael Espindola bool useLoc, 635f1a5c7ec04002769f1638e64f7439589f0f926e6Rafael Espindola bool useCFI, 63644d798d9763bc32aaf49fe7c10d604845f4b6685Nick Lewycky bool useDwarfDirectory, 63790edac0e8b35f766599362b6301863229f0ddcdbChris Lattner MCInstPrinter *InstPrint = 0, 6389dee8e3009408fd08c656558397a8ac8604139baDaniel Dunbar MCCodeEmitter *CE = 0, 63978c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng MCAsmBackend *TAB = 0, 640e266ce6c6eaf52ebe2b18d85b5e23788cf2f6ef4Bill Wendling bool ShowInst = false); 641381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar 642d86e6ac9892ee61742d85f9f14f1179216d2e47bDan Gohman /// createMachOStreamer - Create a machine code streamer which will generate 643381e92c66a98ee766ea53039b0cd8ce3bde7be2dDaniel Dunbar /// Mach-O format object files. 6441abcd06856df324eac98d4bf5ba673fb77ae6a11Benjamin Kramer /// 645c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// Takes ownership of \p TAB and \p CE. 64678c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, 647ac2884a717daf3ad2aa8425320795d661e8a980bDaniel Dunbar raw_ostream &OS, MCCodeEmitter *CE, 648ac2884a717daf3ad2aa8425320795d661e8a980bDaniel Dunbar bool RelaxAll = false); 64925e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 650eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner /// createWinCOFFStreamer - Create a machine code streamer which will 651eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner /// generate Microsoft COFF format object files. 6521abcd06856df324eac98d4bf5ba673fb77ae6a11Benjamin Kramer /// 653c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// Takes ownership of \p TAB and \p CE. 654eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner MCStreamer *createWinCOFFStreamer(MCContext &Ctx, 65578c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng MCAsmBackend &TAB, 656e2195d8b357d7081edb5eb09d1d6e9d7b4bfc308Michael J. Spencer MCCodeEmitter &CE, raw_ostream &OS, 657e2195d8b357d7081edb5eb09d1d6e9d7b4bfc308Michael J. Spencer bool RelaxAll = false); 658eb72dcaef7423069cf8f9e802fa8de64dc8f8f30Chris Lattner 6596b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming /// createELFStreamer - Create a machine code streamer which will generate 6606b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming /// ELF format object files. 66178c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, 66291f2cce231debf43384fe4ee39c11ba8460503ebJim Grosbach raw_ostream &OS, MCCodeEmitter *CE, 66391f2cce231debf43384fe4ee39c11ba8460503ebJim Grosbach bool RelaxAll, bool NoExecStack); 6646b2e257e74b2c8e2f93bb244e0c80cb73005b74aMatt Fleming 665abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar /// createPureStreamer - Create a machine code streamer which will generate 666abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar /// "pure" MC object files, for use with MC-JIT and testing tools. 667abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar /// 668c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// Takes ownership of \p TAB and \p CE. 66978c10eeaa57d1c6c4b7781d3c0bcb0cfbbc43b5cEvan Cheng MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB, 670abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar raw_ostream &OS, MCCodeEmitter *CE); 671abc756216dbace87826398f8fa1e8e57e401cc86Daniel Dunbar 67225e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar} // end namespace llvm 67325e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar 67425e0d8f755736b0a17400adbdd367aee89fbecfcDaniel Dunbar#endif 675