Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file declares the MCStreamer class. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_MC_MCSTREAMER_H |
| 14 | #define LLVM_MC_MCSTREAMER_H |
| 15 | |
| 16 | #include "llvm/ADT/ArrayRef.h" |
| 17 | #include "llvm/ADT/DenseMap.h" |
| 18 | #include "llvm/ADT/Optional.h" |
| 19 | #include "llvm/ADT/SmallVector.h" |
| 20 | #include "llvm/ADT/StringRef.h" |
| 21 | #include "llvm/MC/MCDirectives.h" |
| 22 | #include "llvm/MC/MCDwarf.h" |
| 23 | #include "llvm/MC/MCLinkerOptimizationHint.h" |
| 24 | #include "llvm/MC/MCSymbol.h" |
| 25 | #include "llvm/MC/MCWinEH.h" |
| 26 | #include "llvm/Support/Error.h" |
| 27 | #include "llvm/Support/MD5.h" |
| 28 | #include "llvm/Support/SMLoc.h" |
| 29 | #include "llvm/Support/TargetParser.h" |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 30 | #include "llvm/Support/VersionTuple.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 31 | #include <cassert> |
| 32 | #include <cstdint> |
| 33 | #include <memory> |
| 34 | #include <string> |
| 35 | #include <utility> |
| 36 | #include <vector> |
| 37 | |
| 38 | namespace llvm { |
| 39 | |
| 40 | class AssemblerConstantPools; |
| 41 | class formatted_raw_ostream; |
| 42 | class MCAsmBackend; |
| 43 | class MCCodeEmitter; |
| 44 | struct MCCodePaddingContext; |
| 45 | class MCContext; |
| 46 | class MCExpr; |
| 47 | class MCInst; |
| 48 | class MCInstPrinter; |
| 49 | class MCSection; |
| 50 | class MCStreamer; |
| 51 | class MCSymbolRefExpr; |
| 52 | class MCSubtargetInfo; |
| 53 | class raw_ostream; |
| 54 | class Twine; |
| 55 | |
| 56 | using MCSectionSubPair = std::pair<MCSection *, const MCExpr *>; |
| 57 | |
| 58 | /// Target specific streamer interface. This is used so that targets can |
| 59 | /// implement support for target specific assembly directives. |
| 60 | /// |
| 61 | /// If target foo wants to use this, it should implement 3 classes: |
| 62 | /// * FooTargetStreamer : public MCTargetStreamer |
| 63 | /// * FooTargetAsmStreamer : public FooTargetStreamer |
| 64 | /// * FooTargetELFStreamer : public FooTargetStreamer |
| 65 | /// |
| 66 | /// FooTargetStreamer should have a pure virtual method for each directive. For |
| 67 | /// example, for a ".bar symbol_name" directive, it should have |
| 68 | /// virtual emitBar(const MCSymbol &Symbol) = 0; |
| 69 | /// |
| 70 | /// The FooTargetAsmStreamer and FooTargetELFStreamer classes implement the |
| 71 | /// method. The assembly streamer just prints ".bar symbol_name". The object |
| 72 | /// streamer does whatever is needed to implement .bar in the object file. |
| 73 | /// |
| 74 | /// In the assembly printer and parser the target streamer can be used by |
| 75 | /// calling getTargetStreamer and casting it to FooTargetStreamer: |
| 76 | /// |
| 77 | /// MCTargetStreamer &TS = OutStreamer.getTargetStreamer(); |
| 78 | /// FooTargetStreamer &ATS = static_cast<FooTargetStreamer &>(TS); |
| 79 | /// |
| 80 | /// The base classes FooTargetAsmStreamer and FooTargetELFStreamer should |
| 81 | /// *never* be treated differently. Callers should always talk to a |
| 82 | /// FooTargetStreamer. |
| 83 | class MCTargetStreamer { |
| 84 | protected: |
| 85 | MCStreamer &Streamer; |
| 86 | |
| 87 | public: |
| 88 | MCTargetStreamer(MCStreamer &S); |
| 89 | virtual ~MCTargetStreamer(); |
| 90 | |
| 91 | MCStreamer &getStreamer() { return Streamer; } |
| 92 | |
| 93 | // Allow a target to add behavior to the EmitLabel of MCStreamer. |
| 94 | virtual void emitLabel(MCSymbol *Symbol); |
| 95 | // Allow a target to add behavior to the emitAssignment of MCStreamer. |
| 96 | virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value); |
| 97 | |
| 98 | virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, |
| 99 | const MCInst &Inst, const MCSubtargetInfo &STI); |
| 100 | |
| 101 | virtual void emitDwarfFileDirective(StringRef Directive); |
| 102 | |
| 103 | /// Update streamer for a new active section. |
| 104 | /// |
| 105 | /// This is called by PopSection and SwitchSection, if the current |
| 106 | /// section changes. |
| 107 | virtual void changeSection(const MCSection *CurSection, MCSection *Section, |
| 108 | const MCExpr *SubSection, raw_ostream &OS); |
| 109 | |
| 110 | virtual void emitValue(const MCExpr *Value); |
| 111 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 112 | /// Emit the bytes in \p Data into the output. |
| 113 | /// |
| 114 | /// This is used to emit bytes in \p Data as sequence of .byte directives. |
| 115 | virtual void emitRawBytes(StringRef Data); |
| 116 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 117 | virtual void finish(); |
| 118 | }; |
| 119 | |
| 120 | // FIXME: declared here because it is used from |
| 121 | // lib/CodeGen/AsmPrinter/ARMException.cpp. |
| 122 | class ARMTargetStreamer : public MCTargetStreamer { |
| 123 | public: |
| 124 | ARMTargetStreamer(MCStreamer &S); |
| 125 | ~ARMTargetStreamer() override; |
| 126 | |
| 127 | virtual void emitFnStart(); |
| 128 | virtual void emitFnEnd(); |
| 129 | virtual void emitCantUnwind(); |
| 130 | virtual void emitPersonality(const MCSymbol *Personality); |
| 131 | virtual void emitPersonalityIndex(unsigned Index); |
| 132 | virtual void emitHandlerData(); |
| 133 | virtual void emitSetFP(unsigned FpReg, unsigned SpReg, |
| 134 | int64_t Offset = 0); |
| 135 | virtual void emitMovSP(unsigned Reg, int64_t Offset = 0); |
| 136 | virtual void emitPad(int64_t Offset); |
| 137 | virtual void emitRegSave(const SmallVectorImpl<unsigned> &RegList, |
| 138 | bool isVector); |
| 139 | virtual void emitUnwindRaw(int64_t StackOffset, |
| 140 | const SmallVectorImpl<uint8_t> &Opcodes); |
| 141 | |
| 142 | virtual void switchVendor(StringRef Vendor); |
| 143 | virtual void emitAttribute(unsigned Attribute, unsigned Value); |
| 144 | virtual void emitTextAttribute(unsigned Attribute, StringRef String); |
| 145 | virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, |
| 146 | StringRef StringValue = ""); |
| 147 | virtual void emitFPU(unsigned FPU); |
| 148 | virtual void emitArch(ARM::ArchKind Arch); |
| 149 | virtual void emitArchExtension(unsigned ArchExt); |
| 150 | virtual void emitObjectArch(ARM::ArchKind Arch); |
| 151 | void emitTargetAttributes(const MCSubtargetInfo &STI); |
| 152 | virtual void finishAttributeSection(); |
| 153 | virtual void emitInst(uint32_t Inst, char Suffix = '\0'); |
| 154 | |
| 155 | virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE); |
| 156 | |
| 157 | virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value); |
| 158 | |
| 159 | void finish() override; |
| 160 | |
| 161 | /// Reset any state between object emissions, i.e. the equivalent of |
| 162 | /// MCStreamer's reset method. |
| 163 | virtual void reset(); |
| 164 | |
| 165 | /// Callback used to implement the ldr= pseudo. |
| 166 | /// Add a new entry to the constant pool for the current section and return an |
| 167 | /// MCExpr that can be used to refer to the constant pool location. |
| 168 | const MCExpr *addConstantPoolEntry(const MCExpr *, SMLoc Loc); |
| 169 | |
| 170 | /// Callback used to implemnt the .ltorg directive. |
| 171 | /// Emit contents of constant pool for the current section. |
| 172 | void emitCurrentConstantPool(); |
| 173 | |
| 174 | private: |
| 175 | std::unique_ptr<AssemblerConstantPools> ConstantPools; |
| 176 | }; |
| 177 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 178 | /// Streaming machine code generation interface. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 179 | /// |
| 180 | /// This interface is intended to provide a programatic interface that is very |
| 181 | /// similar to the level that an assembler .s file provides. It has callbacks |
| 182 | /// to emit bytes, handle directives, etc. The implementation of this interface |
| 183 | /// retains state to know what the current section is etc. |
| 184 | /// |
| 185 | /// There are multiple implementations of this interface: one for writing out |
| 186 | /// a .s file, and implementations that write out .o files of various formats. |
| 187 | /// |
| 188 | class MCStreamer { |
| 189 | MCContext &Context; |
| 190 | std::unique_ptr<MCTargetStreamer> TargetStreamer; |
| 191 | |
| 192 | std::vector<MCDwarfFrameInfo> DwarfFrameInfos; |
| 193 | MCDwarfFrameInfo *getCurrentDwarfFrameInfo(); |
| 194 | |
| 195 | /// Similar to DwarfFrameInfos, but for SEH unwind info. Chained frames may |
| 196 | /// refer to each other, so use std::unique_ptr to provide pointer stability. |
| 197 | std::vector<std::unique_ptr<WinEH::FrameInfo>> WinFrameInfos; |
| 198 | |
| 199 | WinEH::FrameInfo *CurrentWinFrameInfo; |
| 200 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 201 | /// Tracks an index to represent the order a symbol was emitted in. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 202 | /// Zero means we did not emit that symbol. |
| 203 | DenseMap<const MCSymbol *, unsigned> SymbolOrdering; |
| 204 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 205 | /// This is stack of current and previous section values saved by |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 206 | /// PushSection. |
| 207 | SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack; |
| 208 | |
| 209 | /// The next unique ID to use when creating a WinCFI-related section (.pdata |
| 210 | /// or .xdata). This ID ensures that we have a one-to-one mapping from |
| 211 | /// code section to unwind info section, which MSVC's incremental linker |
| 212 | /// requires. |
| 213 | unsigned NextWinCFIID = 0; |
| 214 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 215 | bool UseAssemblerInfoForParsing; |
| 216 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 217 | protected: |
| 218 | MCStreamer(MCContext &Ctx); |
| 219 | |
| 220 | virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); |
| 221 | virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); |
| 222 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 223 | WinEH::FrameInfo *getCurrentWinFrameInfo() { |
| 224 | return CurrentWinFrameInfo; |
| 225 | } |
| 226 | |
| 227 | virtual void EmitWindowsUnwindTables(); |
| 228 | |
| 229 | virtual void EmitRawTextImpl(StringRef String); |
| 230 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 231 | /// Returns true if the the .cv_loc directive is in the right section. |
| 232 | bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc); |
| 233 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 234 | public: |
| 235 | MCStreamer(const MCStreamer &) = delete; |
| 236 | MCStreamer &operator=(const MCStreamer &) = delete; |
| 237 | virtual ~MCStreamer(); |
| 238 | |
| 239 | void visitUsedExpr(const MCExpr &Expr); |
| 240 | virtual void visitUsedSymbol(const MCSymbol &Sym); |
| 241 | |
| 242 | void setTargetStreamer(MCTargetStreamer *TS) { |
| 243 | TargetStreamer.reset(TS); |
| 244 | } |
| 245 | |
| 246 | /// State management |
| 247 | /// |
| 248 | virtual void reset(); |
| 249 | |
| 250 | MCContext &getContext() const { return Context; } |
| 251 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 252 | virtual MCAssembler *getAssemblerPtr() { return nullptr; } |
| 253 | |
| 254 | void setUseAssemblerInfoForParsing(bool v) { UseAssemblerInfoForParsing = v; } |
| 255 | bool getUseAssemblerInfoForParsing() { return UseAssemblerInfoForParsing; } |
| 256 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 257 | MCTargetStreamer *getTargetStreamer() { |
| 258 | return TargetStreamer.get(); |
| 259 | } |
| 260 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 261 | /// When emitting an object file, create and emit a real label. When emitting |
| 262 | /// textual assembly, this should do nothing to avoid polluting our output. |
| 263 | virtual MCSymbol *EmitCFILabel(); |
| 264 | |
| 265 | /// Retreive the current frame info if one is available and it is not yet |
| 266 | /// closed. Otherwise, issue an error and return null. |
| 267 | WinEH::FrameInfo *EnsureValidWinFrameInfo(SMLoc Loc); |
| 268 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 269 | unsigned getNumFrameInfos() { return DwarfFrameInfos.size(); } |
| 270 | ArrayRef<MCDwarfFrameInfo> getDwarfFrameInfos() const { |
| 271 | return DwarfFrameInfos; |
| 272 | } |
| 273 | |
| 274 | bool hasUnfinishedDwarfFrameInfo(); |
| 275 | |
| 276 | unsigned getNumWinFrameInfos() { return WinFrameInfos.size(); } |
| 277 | ArrayRef<std::unique_ptr<WinEH::FrameInfo>> getWinFrameInfos() const { |
| 278 | return WinFrameInfos; |
| 279 | } |
| 280 | |
| 281 | void generateCompactUnwindEncodings(MCAsmBackend *MAB); |
| 282 | |
| 283 | /// \name Assembly File Formatting. |
| 284 | /// @{ |
| 285 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 286 | /// Return true if this streamer supports verbose assembly and if it is |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 287 | /// enabled. |
| 288 | virtual bool isVerboseAsm() const { return false; } |
| 289 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 290 | /// Return true if this asm streamer supports emitting unformatted text |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 291 | /// to the .s file with EmitRawText. |
| 292 | virtual bool hasRawTextSupport() const { return false; } |
| 293 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 294 | /// Is the integrated assembler required for this streamer to function |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 295 | /// correctly? |
| 296 | virtual bool isIntegratedAssemblerRequired() const { return false; } |
| 297 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 298 | /// Add a textual comment. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 299 | /// |
| 300 | /// Typically for comments that can be emitted to the generated .s |
| 301 | /// file if applicable as a QoI issue to make the output of the compiler |
| 302 | /// more readable. This only affects the MCAsmStreamer, and only when |
| 303 | /// verbose assembly output is enabled. |
| 304 | /// |
| 305 | /// If the comment includes embedded \n's, they will each get the comment |
| 306 | /// prefix as appropriate. The added comment should not end with a \n. |
| 307 | /// By default, each comment is terminated with an end of line, i.e. the |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 308 | /// EOL param is set to true by default. If one prefers not to end the |
| 309 | /// comment with a new line then the EOL param should be passed |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 310 | /// with a false value. |
| 311 | virtual void AddComment(const Twine &T, bool EOL = true) {} |
| 312 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 313 | /// Return a raw_ostream that comments can be written to. Unlike |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 314 | /// AddComment, you are required to terminate comments with \n if you use this |
| 315 | /// method. |
| 316 | virtual raw_ostream &GetCommentOS(); |
| 317 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 318 | /// Print T and prefix it with the comment string (normally #) and |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 319 | /// optionally a tab. This prints the comment immediately, not at the end of |
| 320 | /// the current line. It is basically a safe version of EmitRawText: since it |
| 321 | /// only prints comments, the object streamer ignores it instead of asserting. |
| 322 | virtual void emitRawComment(const Twine &T, bool TabPrefix = true); |
| 323 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 324 | /// Add explicit comment T. T is required to be a valid |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 325 | /// comment in the output and does not need to be escaped. |
| 326 | virtual void addExplicitComment(const Twine &T); |
| 327 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 328 | /// Emit added explicit comments. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 329 | virtual void emitExplicitComments(); |
| 330 | |
| 331 | /// AddBlankLine - Emit a blank line to a .s file to pretty it up. |
| 332 | virtual void AddBlankLine() {} |
| 333 | |
| 334 | /// @} |
| 335 | |
| 336 | /// \name Symbol & Section Management |
| 337 | /// @{ |
| 338 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 339 | /// Return the current section that the streamer is emitting code to. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 340 | MCSectionSubPair getCurrentSection() const { |
| 341 | if (!SectionStack.empty()) |
| 342 | return SectionStack.back().first; |
| 343 | return MCSectionSubPair(); |
| 344 | } |
| 345 | MCSection *getCurrentSectionOnly() const { return getCurrentSection().first; } |
| 346 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 347 | /// Return the previous section that the streamer is emitting code to. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 348 | MCSectionSubPair getPreviousSection() const { |
| 349 | if (!SectionStack.empty()) |
| 350 | return SectionStack.back().second; |
| 351 | return MCSectionSubPair(); |
| 352 | } |
| 353 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 354 | /// Returns an index to represent the order a symbol was emitted in. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 355 | /// (zero if we did not emit that symbol) |
| 356 | unsigned GetSymbolOrder(const MCSymbol *Sym) const { |
| 357 | return SymbolOrdering.lookup(Sym); |
| 358 | } |
| 359 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 360 | /// Update streamer for a new active section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 361 | /// |
| 362 | /// This is called by PopSection and SwitchSection, if the current |
| 363 | /// section changes. |
| 364 | virtual void ChangeSection(MCSection *, const MCExpr *); |
| 365 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 366 | /// Save the current and previous section on the section stack. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 367 | void PushSection() { |
| 368 | SectionStack.push_back( |
| 369 | std::make_pair(getCurrentSection(), getPreviousSection())); |
| 370 | } |
| 371 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 372 | /// Restore the current and previous section from the section stack. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 373 | /// Calls ChangeSection as needed. |
| 374 | /// |
| 375 | /// Returns false if the stack was empty. |
| 376 | bool PopSection() { |
| 377 | if (SectionStack.size() <= 1) |
| 378 | return false; |
| 379 | auto I = SectionStack.end(); |
| 380 | --I; |
| 381 | MCSectionSubPair OldSection = I->first; |
| 382 | --I; |
| 383 | MCSectionSubPair NewSection = I->first; |
| 384 | |
| 385 | if (OldSection != NewSection) |
| 386 | ChangeSection(NewSection.first, NewSection.second); |
| 387 | SectionStack.pop_back(); |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | bool SubSection(const MCExpr *Subsection) { |
| 392 | if (SectionStack.empty()) |
| 393 | return false; |
| 394 | |
| 395 | SwitchSection(SectionStack.back().first.first, Subsection); |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | /// Set the current section where code is being emitted to \p Section. This |
| 400 | /// is required to update CurSection. |
| 401 | /// |
| 402 | /// This corresponds to assembler directives like .section, .text, etc. |
| 403 | virtual void SwitchSection(MCSection *Section, |
| 404 | const MCExpr *Subsection = nullptr); |
| 405 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 406 | /// Set the current section where code is being emitted to \p Section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 407 | /// This is required to update CurSection. This version does not call |
| 408 | /// ChangeSection. |
| 409 | void SwitchSectionNoChange(MCSection *Section, |
| 410 | const MCExpr *Subsection = nullptr) { |
| 411 | assert(Section && "Cannot switch to a null section!"); |
| 412 | MCSectionSubPair curSection = SectionStack.back().first; |
| 413 | SectionStack.back().second = curSection; |
| 414 | if (MCSectionSubPair(Section, Subsection) != curSection) |
| 415 | SectionStack.back().first = MCSectionSubPair(Section, Subsection); |
| 416 | } |
| 417 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 418 | /// Create the default sections and set the initial one. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 419 | virtual void InitSections(bool NoExecStack); |
| 420 | |
| 421 | MCSymbol *endSection(MCSection *Section); |
| 422 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 423 | /// Sets the symbol's section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 424 | /// |
| 425 | /// Each emitted symbol will be tracked in the ordering table, |
| 426 | /// so we can sort on them later. |
| 427 | void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment); |
| 428 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 429 | /// Emit a label for \p Symbol into the current section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 430 | /// |
| 431 | /// This corresponds to an assembler statement such as: |
| 432 | /// foo: |
| 433 | /// |
| 434 | /// \param Symbol - The symbol to emit. A given symbol should only be |
| 435 | /// emitted as a label once, and symbols emitted as a label should never be |
| 436 | /// used in an assignment. |
| 437 | // FIXME: These emission are non-const because we mutate the symbol to |
| 438 | // add the section we're emitting it to later. |
| 439 | virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()); |
| 440 | |
| 441 | virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol); |
| 442 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 443 | /// Note in the output the specified \p Flag. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 444 | virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); |
| 445 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 446 | /// Emit the given list \p Options of strings as linker |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 447 | /// options into the output. |
| 448 | virtual void EmitLinkerOptions(ArrayRef<std::string> Kind) {} |
| 449 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 450 | /// Note in the output the specified region \p Kind. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 451 | virtual void EmitDataRegion(MCDataRegionType Kind) {} |
| 452 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 453 | /// Specify the Mach-O minimum deployment target version. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 454 | virtual void EmitVersionMin(MCVersionMinType Type, unsigned Major, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 455 | unsigned Minor, unsigned Update, |
| 456 | VersionTuple SDKVersion) {} |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 457 | |
| 458 | /// Emit/Specify Mach-O build version command. |
| 459 | /// \p Platform should be one of MachO::PlatformType. |
| 460 | virtual void EmitBuildVersion(unsigned Platform, unsigned Major, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 461 | unsigned Minor, unsigned Update, |
| 462 | VersionTuple SDKVersion) {} |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 463 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 464 | void EmitVersionForTarget(const Triple &Target, |
| 465 | const VersionTuple &SDKVersion); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 466 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 467 | /// Note in the output that the specified \p Func is a Thumb mode |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 468 | /// function (ARM target only). |
| 469 | virtual void EmitThumbFunc(MCSymbol *Func); |
| 470 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 471 | /// Emit an assignment of \p Value to \p Symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 472 | /// |
| 473 | /// This corresponds to an assembler statement such as: |
| 474 | /// symbol = value |
| 475 | /// |
| 476 | /// The assignment generates no code, but has the side effect of binding the |
| 477 | /// value in the current context. For the assembly streamer, this prints the |
| 478 | /// binding into the .s file. |
| 479 | /// |
| 480 | /// \param Symbol - The symbol being assigned to. |
| 481 | /// \param Value - The value for the symbol. |
| 482 | virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value); |
| 483 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 484 | /// Emit an weak reference from \p Alias to \p Symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 485 | /// |
| 486 | /// This corresponds to an assembler statement such as: |
| 487 | /// .weakref alias, symbol |
| 488 | /// |
| 489 | /// \param Alias - The alias that is being created. |
| 490 | /// \param Symbol - The symbol being aliased. |
| 491 | virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); |
| 492 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 493 | /// Add the given \p Attribute to \p Symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 494 | virtual bool EmitSymbolAttribute(MCSymbol *Symbol, |
| 495 | MCSymbolAttr Attribute) = 0; |
| 496 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 497 | /// Set the \p DescValue for the \p Symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 498 | /// |
| 499 | /// \param Symbol - The symbol to have its n_desc field set. |
| 500 | /// \param DescValue - The value to set into the n_desc field. |
| 501 | virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); |
| 502 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 503 | /// Start emitting COFF symbol definition |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 504 | /// |
| 505 | /// \param Symbol - The symbol to have its External & Type fields set. |
| 506 | virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol); |
| 507 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 508 | /// Emit the storage class of the symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 509 | /// |
| 510 | /// \param StorageClass - The storage class the symbol should have. |
| 511 | virtual void EmitCOFFSymbolStorageClass(int StorageClass); |
| 512 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 513 | /// Emit the type of the symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 514 | /// |
| 515 | /// \param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h) |
| 516 | virtual void EmitCOFFSymbolType(int Type); |
| 517 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 518 | /// Marks the end of the symbol definition. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 519 | virtual void EndCOFFSymbolDef(); |
| 520 | |
| 521 | virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol); |
| 522 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 523 | /// Emits the symbol table index of a Symbol into the current section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 524 | virtual void EmitCOFFSymbolIndex(MCSymbol const *Symbol); |
| 525 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 526 | /// Emits a COFF section index. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 527 | /// |
| 528 | /// \param Symbol - Symbol the section number relocation should point to. |
| 529 | virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol); |
| 530 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 531 | /// Emits a COFF section relative relocation. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 532 | /// |
| 533 | /// \param Symbol - Symbol the section relative relocation should point to. |
| 534 | virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset); |
| 535 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 536 | /// Emits a COFF image relative relocation. |
| 537 | /// |
| 538 | /// \param Symbol - Symbol the image relative relocation should point to. |
| 539 | virtual void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset); |
| 540 | |
| 541 | /// Emit an ELF .size directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 542 | /// |
| 543 | /// This corresponds to an assembler statement such as: |
| 544 | /// .size symbol, expression |
| 545 | virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value); |
| 546 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 547 | /// Emit an ELF .symver directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 548 | /// |
| 549 | /// This corresponds to an assembler statement such as: |
| 550 | /// .symver _start, foo@@SOME_VERSION |
| 551 | /// \param AliasName - The versioned alias (i.e. "foo@@SOME_VERSION") |
| 552 | /// \param Aliasee - The aliased symbol (i.e. "_start") |
| 553 | virtual void emitELFSymverDirective(StringRef AliasName, |
| 554 | const MCSymbol *Aliasee); |
| 555 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 556 | /// Emit a Linker Optimization Hint (LOH) directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 557 | /// \param Args - Arguments of the LOH. |
| 558 | virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {} |
| 559 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 560 | /// Emit a common symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 561 | /// |
| 562 | /// \param Symbol - The common symbol to emit. |
| 563 | /// \param Size - The size of the common symbol. |
| 564 | /// \param ByteAlignment - The alignment of the symbol if |
| 565 | /// non-zero. This must be a power of 2. |
| 566 | virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 567 | unsigned ByteAlignment) = 0; |
| 568 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 569 | /// Emit a local common (.lcomm) symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 570 | /// |
| 571 | /// \param Symbol - The common symbol to emit. |
| 572 | /// \param Size - The size of the common symbol. |
| 573 | /// \param ByteAlignment - The alignment of the common symbol in bytes. |
| 574 | virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 575 | unsigned ByteAlignment); |
| 576 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 577 | /// Emit the zerofill section and an optional symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 578 | /// |
| 579 | /// \param Section - The zerofill section to create and or to put the symbol |
| 580 | /// \param Symbol - The zerofill symbol to emit, if non-NULL. |
| 581 | /// \param Size - The size of the zerofill symbol. |
| 582 | /// \param ByteAlignment - The alignment of the zerofill symbol if |
| 583 | /// non-zero. This must be a power of 2 on some targets. |
| 584 | virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 585 | uint64_t Size = 0, unsigned ByteAlignment = 0, |
| 586 | SMLoc Loc = SMLoc()) = 0; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 587 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 588 | /// Emit a thread local bss (.tbss) symbol. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 589 | /// |
| 590 | /// \param Section - The thread local common section. |
| 591 | /// \param Symbol - The thread local common symbol to emit. |
| 592 | /// \param Size - The size of the symbol. |
| 593 | /// \param ByteAlignment - The alignment of the thread local common symbol |
| 594 | /// if non-zero. This must be a power of 2 on some targets. |
| 595 | virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, |
| 596 | uint64_t Size, unsigned ByteAlignment = 0); |
| 597 | |
| 598 | /// @} |
| 599 | /// \name Generating Data |
| 600 | /// @{ |
| 601 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 602 | /// Emit the bytes in \p Data into the output. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 603 | /// |
| 604 | /// This is used to implement assembler directives such as .byte, .ascii, |
| 605 | /// etc. |
| 606 | virtual void EmitBytes(StringRef Data); |
| 607 | |
| 608 | /// Functionally identical to EmitBytes. When emitting textual assembly, this |
| 609 | /// method uses .byte directives instead of .ascii or .asciz for readability. |
| 610 | virtual void EmitBinaryData(StringRef Data); |
| 611 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 612 | /// Emit the expression \p Value into the output as a native |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 613 | /// integer of the given \p Size bytes. |
| 614 | /// |
| 615 | /// This is used to implement assembler directives such as .word, .quad, |
| 616 | /// etc. |
| 617 | /// |
| 618 | /// \param Value - The value to emit. |
| 619 | /// \param Size - The size of the integer (in bytes) to emit. This must |
| 620 | /// match a native machine width. |
| 621 | /// \param Loc - The location of the expression for error reporting. |
| 622 | virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, |
| 623 | SMLoc Loc = SMLoc()); |
| 624 | |
| 625 | void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc()); |
| 626 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 627 | /// Special case of EmitValue that avoids the client having |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 628 | /// to pass in a MCExpr for constant integers. |
| 629 | virtual void EmitIntValue(uint64_t Value, unsigned Size); |
| 630 | |
| 631 | virtual void EmitULEB128Value(const MCExpr *Value); |
| 632 | |
| 633 | virtual void EmitSLEB128Value(const MCExpr *Value); |
| 634 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 635 | /// Special case of EmitULEB128Value that avoids the client having to |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 636 | /// pass in a MCExpr for constant integers. |
| 637 | void EmitULEB128IntValue(uint64_t Value); |
| 638 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 639 | /// Special case of EmitSLEB128Value that avoids the client having to |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 640 | /// pass in a MCExpr for constant integers. |
| 641 | void EmitSLEB128IntValue(int64_t Value); |
| 642 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 643 | /// Special case of EmitValue that avoids the client having to pass in |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 644 | /// a MCExpr for MCSymbols. |
| 645 | void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, |
| 646 | bool IsSectionRelative = false); |
| 647 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 648 | /// Emit the expression \p Value into the output as a dtprel |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 649 | /// (64-bit DTP relative) value. |
| 650 | /// |
| 651 | /// This is used to implement assembler directives such as .dtpreldword on |
| 652 | /// targets that support them. |
| 653 | virtual void EmitDTPRel64Value(const MCExpr *Value); |
| 654 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 655 | /// Emit the expression \p Value into the output as a dtprel |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 656 | /// (32-bit DTP relative) value. |
| 657 | /// |
| 658 | /// This is used to implement assembler directives such as .dtprelword on |
| 659 | /// targets that support them. |
| 660 | virtual void EmitDTPRel32Value(const MCExpr *Value); |
| 661 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 662 | /// Emit the expression \p Value into the output as a tprel |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 663 | /// (64-bit TP relative) value. |
| 664 | /// |
| 665 | /// This is used to implement assembler directives such as .tpreldword on |
| 666 | /// targets that support them. |
| 667 | virtual void EmitTPRel64Value(const MCExpr *Value); |
| 668 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 669 | /// Emit the expression \p Value into the output as a tprel |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 670 | /// (32-bit TP relative) value. |
| 671 | /// |
| 672 | /// This is used to implement assembler directives such as .tprelword on |
| 673 | /// targets that support them. |
| 674 | virtual void EmitTPRel32Value(const MCExpr *Value); |
| 675 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 676 | /// Emit the expression \p Value into the output as a gprel64 (64-bit |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 677 | /// GP relative) value. |
| 678 | /// |
| 679 | /// This is used to implement assembler directives such as .gpdword on |
| 680 | /// targets that support them. |
| 681 | virtual void EmitGPRel64Value(const MCExpr *Value); |
| 682 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 683 | /// Emit the expression \p Value into the output as a gprel32 (32-bit |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 684 | /// GP relative) value. |
| 685 | /// |
| 686 | /// This is used to implement assembler directives such as .gprel32 on |
| 687 | /// targets that support them. |
| 688 | virtual void EmitGPRel32Value(const MCExpr *Value); |
| 689 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 690 | /// Emit NumBytes bytes worth of the value specified by FillValue. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 691 | /// This implements directives such as '.space'. |
| 692 | void emitFill(uint64_t NumBytes, uint8_t FillValue); |
| 693 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 694 | /// Emit \p Size bytes worth of the value specified by \p FillValue. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 695 | /// |
| 696 | /// This is used to implement assembler directives such as .space or .skip. |
| 697 | /// |
| 698 | /// \param NumBytes - The number of bytes to emit. |
| 699 | /// \param FillValue - The value to use when filling bytes. |
| 700 | /// \param Loc - The location of the expression for error reporting. |
| 701 | virtual void emitFill(const MCExpr &NumBytes, uint64_t FillValue, |
| 702 | SMLoc Loc = SMLoc()); |
| 703 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 704 | /// Emit \p NumValues copies of \p Size bytes. Each \p Size bytes is |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 705 | /// taken from the lowest order 4 bytes of \p Expr expression. |
| 706 | /// |
| 707 | /// This is used to implement assembler directives such as .fill. |
| 708 | /// |
| 709 | /// \param NumValues - The number of copies of \p Size bytes to emit. |
| 710 | /// \param Size - The size (in bytes) of each repeated value. |
| 711 | /// \param Expr - The expression from which \p Size bytes are used. |
| 712 | virtual void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr, |
| 713 | SMLoc Loc = SMLoc()); |
| 714 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 715 | /// Emit NumBytes worth of zeros. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 716 | /// This function properly handles data in virtual sections. |
| 717 | void EmitZeros(uint64_t NumBytes); |
| 718 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 719 | /// Emit some number of copies of \p Value until the byte alignment \p |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 720 | /// ByteAlignment is reached. |
| 721 | /// |
| 722 | /// If the number of bytes need to emit for the alignment is not a multiple |
| 723 | /// of \p ValueSize, then the contents of the emitted fill bytes is |
| 724 | /// undefined. |
| 725 | /// |
| 726 | /// This used to implement the .align assembler directive. |
| 727 | /// |
| 728 | /// \param ByteAlignment - The alignment to reach. This must be a power of |
| 729 | /// two on some targets. |
| 730 | /// \param Value - The value to use when filling bytes. |
| 731 | /// \param ValueSize - The size of the integer (in bytes) to emit for |
| 732 | /// \p Value. This must match a native machine width. |
| 733 | /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If |
| 734 | /// the alignment cannot be reached in this many bytes, no bytes are |
| 735 | /// emitted. |
| 736 | virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, |
| 737 | unsigned ValueSize = 1, |
| 738 | unsigned MaxBytesToEmit = 0); |
| 739 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 740 | /// Emit nops until the byte alignment \p ByteAlignment is reached. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 741 | /// |
| 742 | /// This used to align code where the alignment bytes may be executed. This |
| 743 | /// can emit different bytes for different sizes to optimize execution. |
| 744 | /// |
| 745 | /// \param ByteAlignment - The alignment to reach. This must be a power of |
| 746 | /// two on some targets. |
| 747 | /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If |
| 748 | /// the alignment cannot be reached in this many bytes, no bytes are |
| 749 | /// emitted. |
| 750 | virtual void EmitCodeAlignment(unsigned ByteAlignment, |
| 751 | unsigned MaxBytesToEmit = 0); |
| 752 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 753 | /// Emit some number of copies of \p Value until the byte offset \p |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 754 | /// Offset is reached. |
| 755 | /// |
| 756 | /// This is used to implement assembler directives such as .org. |
| 757 | /// |
| 758 | /// \param Offset - The offset to reach. This may be an expression, but the |
| 759 | /// expression must be associated with the current section. |
| 760 | /// \param Value - The value to use when filling bytes. |
| 761 | virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, |
| 762 | SMLoc Loc); |
| 763 | |
| 764 | virtual void |
| 765 | EmitCodePaddingBasicBlockStart(const MCCodePaddingContext &Context) {} |
| 766 | |
| 767 | virtual void |
| 768 | EmitCodePaddingBasicBlockEnd(const MCCodePaddingContext &Context) {} |
| 769 | |
| 770 | /// @} |
| 771 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 772 | /// Switch to a new logical file. This is used to implement the '.file |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 773 | /// "foo.c"' assembler directive. |
| 774 | virtual void EmitFileDirective(StringRef Filename); |
| 775 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 776 | /// Emit the "identifiers" directive. This implements the |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 777 | /// '.ident "version foo"' assembler directive. |
| 778 | virtual void EmitIdent(StringRef IdentString) {} |
| 779 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 780 | /// Associate a filename with a specified logical file number. This |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 781 | /// implements the DWARF2 '.file 4 "foo.c"' assembler directive. |
| 782 | unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, |
| 783 | StringRef Filename, |
| 784 | MD5::MD5Result *Checksum = nullptr, |
| 785 | Optional<StringRef> Source = None, |
| 786 | unsigned CUID = 0) { |
| 787 | return cantFail( |
| 788 | tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum, |
| 789 | Source, CUID)); |
| 790 | } |
| 791 | |
| 792 | /// Associate a filename with a specified logical file number. |
| 793 | /// Also associate a directory, optional checksum, and optional source |
| 794 | /// text with the logical file. This implements the DWARF2 |
| 795 | /// '.file 4 "dir/foo.c"' assembler directive, and the DWARF5 |
| 796 | /// '.file 4 "dir/foo.c" md5 "..." source "..."' assembler directive. |
| 797 | virtual Expected<unsigned> tryEmitDwarfFileDirective( |
| 798 | unsigned FileNo, StringRef Directory, StringRef Filename, |
| 799 | MD5::MD5Result *Checksum = nullptr, Optional<StringRef> Source = None, |
| 800 | unsigned CUID = 0); |
| 801 | |
| 802 | /// Specify the "root" file of the compilation, using the ".file 0" extension. |
| 803 | virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, |
| 804 | MD5::MD5Result *Checksum, |
| 805 | Optional<StringRef> Source, |
| 806 | unsigned CUID = 0); |
| 807 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 808 | virtual void EmitCFIBKeyFrame(); |
| 809 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 810 | /// This implements the DWARF2 '.loc fileno lineno ...' assembler |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 811 | /// directive. |
| 812 | virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, |
| 813 | unsigned Column, unsigned Flags, |
| 814 | unsigned Isa, unsigned Discriminator, |
| 815 | StringRef FileName); |
| 816 | |
| 817 | /// Associate a filename with a specified logical file number, and also |
| 818 | /// specify that file's checksum information. This implements the '.cv_file 4 |
| 819 | /// "foo.c"' assembler directive. Returns true on success. |
| 820 | virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename, |
| 821 | ArrayRef<uint8_t> Checksum, |
| 822 | unsigned ChecksumKind); |
| 823 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 824 | /// Introduces a function id for use with .cv_loc. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 825 | virtual bool EmitCVFuncIdDirective(unsigned FunctionId); |
| 826 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 827 | /// Introduces an inline call site id for use with .cv_loc. Includes |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 828 | /// extra information for inline line table generation. |
| 829 | virtual bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, |
| 830 | unsigned IAFile, unsigned IALine, |
| 831 | unsigned IACol, SMLoc Loc); |
| 832 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 833 | /// This implements the CodeView '.cv_loc' assembler directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 834 | virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, |
| 835 | unsigned Line, unsigned Column, |
| 836 | bool PrologueEnd, bool IsStmt, |
| 837 | StringRef FileName, SMLoc Loc); |
| 838 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 839 | /// This implements the CodeView '.cv_linetable' assembler directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 840 | virtual void EmitCVLinetableDirective(unsigned FunctionId, |
| 841 | const MCSymbol *FnStart, |
| 842 | const MCSymbol *FnEnd); |
| 843 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 844 | /// This implements the CodeView '.cv_inline_linetable' assembler |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 845 | /// directive. |
| 846 | virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, |
| 847 | unsigned SourceFileId, |
| 848 | unsigned SourceLineNum, |
| 849 | const MCSymbol *FnStartSym, |
| 850 | const MCSymbol *FnEndSym); |
| 851 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 852 | /// This implements the CodeView '.cv_def_range' assembler |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 853 | /// directive. |
| 854 | virtual void EmitCVDefRangeDirective( |
| 855 | ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges, |
| 856 | StringRef FixedSizePortion); |
| 857 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 858 | /// This implements the CodeView '.cv_stringtable' assembler directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 859 | virtual void EmitCVStringTableDirective() {} |
| 860 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 861 | /// This implements the CodeView '.cv_filechecksums' assembler directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 862 | virtual void EmitCVFileChecksumsDirective() {} |
| 863 | |
| 864 | /// This implements the CodeView '.cv_filechecksumoffset' assembler |
| 865 | /// directive. |
| 866 | virtual void EmitCVFileChecksumOffsetDirective(unsigned FileNo) {} |
| 867 | |
| 868 | /// This implements the CodeView '.cv_fpo_data' assembler directive. |
| 869 | virtual void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc = {}) {} |
| 870 | |
| 871 | /// Emit the absolute difference between two symbols. |
| 872 | /// |
| 873 | /// \pre Offset of \c Hi is greater than the offset \c Lo. |
| 874 | virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, |
| 875 | unsigned Size); |
| 876 | |
| 877 | /// Emit the absolute difference between two symbols encoded with ULEB128. |
| 878 | virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, |
| 879 | const MCSymbol *Lo); |
| 880 | |
| 881 | virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID); |
| 882 | virtual void EmitCFISections(bool EH, bool Debug); |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 883 | void EmitCFIStartProc(bool IsSimple, SMLoc Loc = SMLoc()); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 884 | void EmitCFIEndProc(); |
| 885 | virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); |
| 886 | virtual void EmitCFIDefCfaOffset(int64_t Offset); |
| 887 | virtual void EmitCFIDefCfaRegister(int64_t Register); |
| 888 | virtual void EmitCFIOffset(int64_t Register, int64_t Offset); |
| 889 | virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding); |
| 890 | virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding); |
| 891 | virtual void EmitCFIRememberState(); |
| 892 | virtual void EmitCFIRestoreState(); |
| 893 | virtual void EmitCFISameValue(int64_t Register); |
| 894 | virtual void EmitCFIRestore(int64_t Register); |
| 895 | virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); |
| 896 | virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); |
| 897 | virtual void EmitCFIEscape(StringRef Values); |
| 898 | virtual void EmitCFIReturnColumn(int64_t Register); |
| 899 | virtual void EmitCFIGnuArgsSize(int64_t Size); |
| 900 | virtual void EmitCFISignalFrame(); |
| 901 | virtual void EmitCFIUndefined(int64_t Register); |
| 902 | virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); |
| 903 | virtual void EmitCFIWindowSave(); |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 904 | virtual void EmitCFINegateRAState(); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 905 | |
| 906 | virtual void EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc = SMLoc()); |
| 907 | virtual void EmitWinCFIEndProc(SMLoc Loc = SMLoc()); |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 908 | /// This is used on platforms, such as Windows on ARM64, that require function |
| 909 | /// or funclet sizes to be emitted in .xdata before the End marker is emitted |
| 910 | /// for the frame. We cannot use the End marker, as it is not set at the |
| 911 | /// point of emitting .xdata, in order to indicate that the frame is active. |
| 912 | virtual void EmitWinCFIFuncletOrFuncEnd(SMLoc Loc = SMLoc()); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 913 | virtual void EmitWinCFIStartChained(SMLoc Loc = SMLoc()); |
| 914 | virtual void EmitWinCFIEndChained(SMLoc Loc = SMLoc()); |
| 915 | virtual void EmitWinCFIPushReg(unsigned Register, SMLoc Loc = SMLoc()); |
| 916 | virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset, |
| 917 | SMLoc Loc = SMLoc()); |
| 918 | virtual void EmitWinCFIAllocStack(unsigned Size, SMLoc Loc = SMLoc()); |
| 919 | virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset, |
| 920 | SMLoc Loc = SMLoc()); |
| 921 | virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset, |
| 922 | SMLoc Loc = SMLoc()); |
| 923 | virtual void EmitWinCFIPushFrame(bool Code, SMLoc Loc = SMLoc()); |
| 924 | virtual void EmitWinCFIEndProlog(SMLoc Loc = SMLoc()); |
| 925 | virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, |
| 926 | SMLoc Loc = SMLoc()); |
| 927 | virtual void EmitWinEHHandlerData(SMLoc Loc = SMLoc()); |
| 928 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 929 | virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, |
| 930 | const MCSymbolRefExpr *To, uint64_t Count); |
| 931 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 932 | /// Get the .pdata section used for the given section. Typically the given |
| 933 | /// section is either the main .text section or some other COMDAT .text |
| 934 | /// section, but it may be any section containing code. |
| 935 | MCSection *getAssociatedPDataSection(const MCSection *TextSec); |
| 936 | |
| 937 | /// Get the .xdata section used for the given section. |
| 938 | MCSection *getAssociatedXDataSection(const MCSection *TextSec); |
| 939 | |
| 940 | virtual void EmitSyntaxDirective(); |
| 941 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 942 | /// Emit a .reloc directive. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 943 | /// Returns true if the relocation could not be emitted because Name is not |
| 944 | /// known. |
| 945 | virtual bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 946 | const MCExpr *Expr, SMLoc Loc, |
| 947 | const MCSubtargetInfo &STI) { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 948 | return true; |
| 949 | } |
| 950 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 951 | virtual void EmitAddrsig() {} |
| 952 | virtual void EmitAddrsigSym(const MCSymbol *Sym) {} |
| 953 | |
| 954 | /// Emit the given \p Instruction into the current section. |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 955 | virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 956 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 957 | /// Set the bundle alignment mode from now on in the section. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 958 | /// The argument is the power of 2 to which the alignment is set. The |
| 959 | /// value 0 means turn the bundle alignment off. |
| 960 | virtual void EmitBundleAlignMode(unsigned AlignPow2); |
| 961 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 962 | /// The following instructions are a bundle-locked group. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 963 | /// |
| 964 | /// \param AlignToEnd - If true, the bundle-locked group will be aligned to |
| 965 | /// the end of a bundle. |
| 966 | virtual void EmitBundleLock(bool AlignToEnd); |
| 967 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 968 | /// Ends a bundle-locked group. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 969 | virtual void EmitBundleUnlock(); |
| 970 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 971 | /// If this file is backed by a assembly streamer, this dumps the |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 972 | /// specified string in the output .s file. This capability is indicated by |
| 973 | /// the hasRawTextSupport() predicate. By default this aborts. |
| 974 | void EmitRawText(const Twine &String); |
| 975 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 976 | /// Streamer specific finalization. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 977 | virtual void FinishImpl(); |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 978 | /// Finish emission of machine code. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 979 | void Finish(); |
| 980 | |
| 981 | virtual bool mayHaveInstructions(MCSection &Sec) const { return true; } |
| 982 | }; |
| 983 | |
| 984 | /// Create a dummy machine code streamer, which does nothing. This is useful for |
| 985 | /// timing the assembler front end. |
| 986 | MCStreamer *createNullStreamer(MCContext &Ctx); |
| 987 | |
| 988 | /// Create a machine code streamer which will print out assembly for the native |
| 989 | /// target, suitable for compiling with a native assembler. |
| 990 | /// |
| 991 | /// \param InstPrint - If given, the instruction printer to use. If not given |
| 992 | /// the MCInst representation will be printed. This method takes ownership of |
| 993 | /// InstPrint. |
| 994 | /// |
| 995 | /// \param CE - If given, a code emitter to use to show the instruction |
| 996 | /// encoding inline with the assembly. This method takes ownership of \p CE. |
| 997 | /// |
| 998 | /// \param TAB - If given, a target asm backend to use to show the fixup |
| 999 | /// information in conjunction with encoding information. This method takes |
| 1000 | /// ownership of \p TAB. |
| 1001 | /// |
| 1002 | /// \param ShowInst - Whether to show the MCInst representation inline with |
| 1003 | /// the assembly. |
| 1004 | MCStreamer *createAsmStreamer(MCContext &Ctx, |
| 1005 | std::unique_ptr<formatted_raw_ostream> OS, |
| 1006 | bool isVerboseAsm, bool useDwarfDirectory, |
| 1007 | MCInstPrinter *InstPrint, MCCodeEmitter *CE, |
| 1008 | MCAsmBackend *TAB, bool ShowInst); |
| 1009 | |
| 1010 | } // end namespace llvm |
| 1011 | |
| 1012 | #endif // LLVM_MC_MCSTREAMER_H |