MCStreamer.h revision 07f6a4fde0a1b081fbefd986345c9b2f4f85e88a
1//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file declares the MCStreamer class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_MC_MCSTREAMER_H 15#define LLVM_MC_MCSTREAMER_H 16 17#include "llvm/ADT/ArrayRef.h" 18#include "llvm/ADT/SmallVector.h" 19#include "llvm/MC/MCDirectives.h" 20#include "llvm/MC/MCDwarf.h" 21#include "llvm/MC/MCWin64EH.h" 22#include "llvm/Support/DataTypes.h" 23 24namespace llvm { 25 class MCAsmBackend; 26 class MCCodeEmitter; 27 class MCContext; 28 class MCExpr; 29 class MCInst; 30 class MCInstPrinter; 31 class MCSection; 32 class MCSymbol; 33 class StringRef; 34 class Twine; 35 class raw_ostream; 36 class formatted_raw_ostream; 37 38 /// MCStreamer - Streaming machine code generation interface. This interface 39 /// is intended to provide a programatic interface that is very similar to the 40 /// level that an assembler .s file provides. It has callbacks to emit bytes, 41 /// handle directives, etc. The implementation of this interface retains 42 /// state to know what the current section is etc. 43 /// 44 /// There are multiple implementations of this interface: one for writing out 45 /// a .s file, and implementations that write out .o files of various formats. 46 /// 47 class MCStreamer { 48 MCContext &Context; 49 50 MCStreamer(const MCStreamer&) LLVM_DELETED_FUNCTION; 51 MCStreamer &operator=(const MCStreamer&) LLVM_DELETED_FUNCTION; 52 53 bool EmitEHFrame; 54 bool EmitDebugFrame; 55 56 std::vector<MCDwarfFrameInfo> FrameInfos; 57 MCDwarfFrameInfo *getCurrentFrameInfo(); 58 MCSymbol *EmitCFICommon(); 59 void EnsureValidFrame(); 60 61 std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos; 62 MCWin64EHUnwindInfo *CurrentW64UnwindInfo; 63 void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame); 64 void EnsureValidW64UnwindInfo(); 65 66 MCSymbol* LastSymbol; 67 68 /// SectionStack - This is stack of current and previous section 69 /// values saved by PushSection. 70 SmallVector<std::pair<const MCSection *, 71 const MCSection *>, 4> SectionStack; 72 73 bool AutoInitSections; 74 75 protected: 76 MCStreamer(MCContext &Ctx); 77 78 const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, 79 const MCSymbol *B); 80 81 const MCExpr *ForceExpAbs(const MCExpr* Expr); 82 83 void RecordProcStart(MCDwarfFrameInfo &Frame); 84 virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); 85 void RecordProcEnd(MCDwarfFrameInfo &Frame); 86 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); 87 void EmitFrames(bool usingCFI); 88 89 MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;} 90 void EmitW64Tables(); 91 92 public: 93 virtual ~MCStreamer(); 94 95 MCContext &getContext() const { return Context; } 96 97 unsigned getNumFrameInfos() { 98 return FrameInfos.size(); 99 } 100 101 const MCDwarfFrameInfo &getFrameInfo(unsigned i) { 102 return FrameInfos[i]; 103 } 104 105 ArrayRef<MCDwarfFrameInfo> getFrameInfos() { 106 return FrameInfos; 107 } 108 109 unsigned getNumW64UnwindInfos() { 110 return W64UnwindInfos.size(); 111 } 112 113 MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) { 114 return *W64UnwindInfos[i]; 115 } 116 117 /// @name Assembly File Formatting. 118 /// @{ 119 120 /// isVerboseAsm - Return true if this streamer supports verbose assembly 121 /// and if it is enabled. 122 virtual bool isVerboseAsm() const { return false; } 123 124 /// hasRawTextSupport - Return true if this asm streamer supports emitting 125 /// unformatted text to the .s file with EmitRawText. 126 virtual bool hasRawTextSupport() const { return false; } 127 128 /// AddComment - Add a comment that can be emitted to the generated .s 129 /// file if applicable as a QoI issue to make the output of the compiler 130 /// more readable. This only affects the MCAsmStreamer, and only when 131 /// verbose assembly output is enabled. 132 /// 133 /// If the comment includes embedded \n's, they will each get the comment 134 /// prefix as appropriate. The added comment should not end with a \n. 135 virtual void AddComment(const Twine &T) {} 136 137 /// GetCommentOS - Return a raw_ostream that comments can be written to. 138 /// Unlike AddComment, you are required to terminate comments with \n if you 139 /// use this method. 140 virtual raw_ostream &GetCommentOS(); 141 142 /// AddBlankLine - Emit a blank line to a .s file to pretty it up. 143 virtual void AddBlankLine() {} 144 145 /// @} 146 147 /// @name Symbol & Section Management 148 /// @{ 149 150 /// getCurrentSection - Return the current section that the streamer is 151 /// emitting code to. 152 const MCSection *getCurrentSection() const { 153 if (!SectionStack.empty()) 154 return SectionStack.back().first; 155 return NULL; 156 } 157 158 /// getPreviousSection - Return the previous section that the streamer is 159 /// emitting code to. 160 const MCSection *getPreviousSection() const { 161 if (!SectionStack.empty()) 162 return SectionStack.back().second; 163 return NULL; 164 } 165 166 /// ChangeSection - Update streamer for a new active section. 167 /// 168 /// This is called by PopSection and SwitchSection, if the current 169 /// section changes. 170 virtual void ChangeSection(const MCSection *) = 0; 171 172 /// pushSection - Save the current and previous section on the 173 /// section stack. 174 void PushSection() { 175 SectionStack.push_back(std::make_pair(getCurrentSection(), 176 getPreviousSection())); 177 } 178 179 /// popSection - Restore the current and previous section from 180 /// the section stack. Calls ChangeSection as needed. 181 /// 182 /// Returns false if the stack was empty. 183 bool PopSection() { 184 if (SectionStack.size() <= 1) 185 return false; 186 const MCSection *oldSection = SectionStack.pop_back_val().first; 187 const MCSection *curSection = SectionStack.back().first; 188 189 if (oldSection != curSection) 190 ChangeSection(curSection); 191 return true; 192 } 193 194 /// SwitchSection - Set the current section where code is being emitted to 195 /// @p Section. This is required to update CurSection. 196 /// 197 /// This corresponds to assembler directives like .section, .text, etc. 198 void SwitchSection(const MCSection *Section) { 199 assert(Section && "Cannot switch to a null section!"); 200 const MCSection *curSection = SectionStack.back().first; 201 SectionStack.back().second = curSection; 202 if (Section != curSection) { 203 SectionStack.back().first = Section; 204 ChangeSection(Section); 205 } 206 } 207 208 /// SwitchSectionNoChange - Set the current section where code is being 209 /// emitted to @p Section. This is required to update CurSection. This 210 /// version does not call ChangeSection. 211 void SwitchSectionNoChange(const MCSection *Section) { 212 assert(Section && "Cannot switch to a null section!"); 213 const MCSection *curSection = SectionStack.back().first; 214 SectionStack.back().second = curSection; 215 if (Section != curSection) 216 SectionStack.back().first = Section; 217 } 218 219 /// Initialize the streamer. 220 void InitStreamer() { 221 if (AutoInitSections) 222 InitSections(); 223 } 224 225 /// Tell this MCStreamer to call InitSections upon initialization. 226 void setAutoInitSections(bool AutoInitSections) { 227 this->AutoInitSections = AutoInitSections; 228 } 229 230 /// InitSections - Create the default sections and set the initial one. 231 virtual void InitSections() = 0; 232 233 /// EmitLabel - Emit a label for @p Symbol into the current section. 234 /// 235 /// This corresponds to an assembler statement such as: 236 /// foo: 237 /// 238 /// @param Symbol - The symbol to emit. A given symbol should only be 239 /// emitted as a label once, and symbols emitted as a label should never be 240 /// used in an assignment. 241 virtual void EmitLabel(MCSymbol *Symbol); 242 243 virtual void EmitEHSymAttributes(const MCSymbol *Symbol, 244 MCSymbol *EHSymbol); 245 246 /// EmitAssemblerFlag - Note in the output the specified @p Flag. 247 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; 248 249 /// EmitDataRegion - Note in the output the specified region @p Kind. 250 virtual void EmitDataRegion(MCDataRegionType Kind) {} 251 252 /// EmitThumbFunc - Note in the output that the specified @p Func is 253 /// a Thumb mode function (ARM target only). 254 virtual void EmitThumbFunc(MCSymbol *Func) = 0; 255 256 /// EmitAssignment - Emit an assignment of @p Value to @p Symbol. 257 /// 258 /// This corresponds to an assembler statement such as: 259 /// symbol = value 260 /// 261 /// The assignment generates no code, but has the side effect of binding the 262 /// value in the current context. For the assembly streamer, this prints the 263 /// binding into the .s file. 264 /// 265 /// @param Symbol - The symbol being assigned to. 266 /// @param Value - The value for the symbol. 267 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0; 268 269 /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol. 270 /// 271 /// This corresponds to an assembler statement such as: 272 /// .weakref alias, symbol 273 /// 274 /// @param Alias - The alias that is being created. 275 /// @param Symbol - The symbol being aliased. 276 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0; 277 278 /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. 279 virtual void EmitSymbolAttribute(MCSymbol *Symbol, 280 MCSymbolAttr Attribute) = 0; 281 282 /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. 283 /// 284 /// @param Symbol - The symbol to have its n_desc field set. 285 /// @param DescValue - The value to set into the n_desc field. 286 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0; 287 288 /// BeginCOFFSymbolDef - Start emitting COFF symbol definition 289 /// 290 /// @param Symbol - The symbol to have its External & Type fields set. 291 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0; 292 293 /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol. 294 /// 295 /// @param StorageClass - The storage class the symbol should have. 296 virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0; 297 298 /// EmitCOFFSymbolType - Emit the type of the symbol. 299 /// 300 /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h) 301 virtual void EmitCOFFSymbolType(int Type) = 0; 302 303 /// EndCOFFSymbolDef - Marks the end of the symbol definition. 304 virtual void EndCOFFSymbolDef() = 0; 305 306 /// EmitCOFFSecRel32 - Emits a COFF section relative relocation. 307 /// 308 /// @param Symbol - Symbol the section relative realocation should point to. 309 virtual void EmitCOFFSecRel32(MCSymbol const *Symbol); 310 311 /// EmitELFSize - Emit an ELF .size directive. 312 /// 313 /// This corresponds to an assembler statement such as: 314 /// .size symbol, expression 315 /// 316 virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0; 317 318 /// EmitCommonSymbol - Emit a common symbol. 319 /// 320 /// @param Symbol - The common symbol to emit. 321 /// @param Size - The size of the common symbol. 322 /// @param ByteAlignment - The alignment of the symbol if 323 /// non-zero. This must be a power of 2. 324 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 325 unsigned ByteAlignment) = 0; 326 327 /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. 328 /// 329 /// @param Symbol - The common symbol to emit. 330 /// @param Size - The size of the common symbol. 331 /// @param ByteAlignment - The alignment of the common symbol in bytes. 332 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 333 unsigned ByteAlignment) = 0; 334 335 /// EmitZerofill - Emit the zerofill section and an optional symbol. 336 /// 337 /// @param Section - The zerofill section to create and or to put the symbol 338 /// @param Symbol - The zerofill symbol to emit, if non-NULL. 339 /// @param Size - The size of the zerofill symbol. 340 /// @param ByteAlignment - The alignment of the zerofill symbol if 341 /// non-zero. This must be a power of 2 on some targets. 342 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, 343 uint64_t Size = 0,unsigned ByteAlignment = 0) = 0; 344 345 /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol. 346 /// 347 /// @param Section - The thread local common section. 348 /// @param Symbol - The thread local common symbol to emit. 349 /// @param Size - The size of the symbol. 350 /// @param ByteAlignment - The alignment of the thread local common symbol 351 /// if non-zero. This must be a power of 2 on some targets. 352 virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, 353 uint64_t Size, unsigned ByteAlignment = 0) = 0; 354 355 /// @} 356 /// @name Generating Data 357 /// @{ 358 359 /// EmitBytes - Emit the bytes in \p Data into the output. 360 /// 361 /// This is used to implement assembler directives such as .byte, .ascii, 362 /// etc. 363 virtual void EmitBytes(StringRef Data, unsigned AddrSpace) = 0; 364 365 /// EmitValue - Emit the expression @p Value into the output as a native 366 /// integer of the given @p Size bytes. 367 /// 368 /// This is used to implement assembler directives such as .word, .quad, 369 /// etc. 370 /// 371 /// @param Value - The value to emit. 372 /// @param Size - The size of the integer (in bytes) to emit. This must 373 /// match a native machine width. 374 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, 375 unsigned AddrSpace) = 0; 376 377 void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0); 378 379 /// EmitIntValue - Special case of EmitValue that avoids the client having 380 /// to pass in a MCExpr for constant integers. 381 virtual void EmitIntValue(uint64_t Value, unsigned Size, 382 unsigned AddrSpace = 0); 383 384 /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO 385 /// this is done by producing 386 /// foo = value 387 /// .long foo 388 void EmitAbsValue(const MCExpr *Value, unsigned Size, 389 unsigned AddrSpace = 0); 390 391 virtual void EmitULEB128Value(const MCExpr *Value) = 0; 392 393 virtual void EmitSLEB128Value(const MCExpr *Value) = 0; 394 395 /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the 396 /// client having to pass in a MCExpr for constant integers. 397 void EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace = 0, 398 unsigned Padding = 0); 399 400 /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the 401 /// client having to pass in a MCExpr for constant integers. 402 void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0); 403 404 /// EmitSymbolValue - Special case of EmitValue that avoids the client 405 /// having to pass in a MCExpr for MCSymbols. 406 void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, 407 unsigned AddrSpace = 0); 408 409 /// EmitGPRel64Value - Emit the expression @p Value into the output as a 410 /// gprel64 (64-bit GP relative) value. 411 /// 412 /// This is used to implement assembler directives such as .gpdword on 413 /// targets that support them. 414 virtual void EmitGPRel64Value(const MCExpr *Value); 415 416 /// EmitGPRel32Value - Emit the expression @p Value into the output as a 417 /// gprel32 (32-bit GP relative) value. 418 /// 419 /// This is used to implement assembler directives such as .gprel32 on 420 /// targets that support them. 421 virtual void EmitGPRel32Value(const MCExpr *Value); 422 423 /// EmitFill - Emit NumBytes bytes worth of the value specified by 424 /// FillValue. This implements directives such as '.space'. 425 virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue, 426 unsigned AddrSpace); 427 428 /// EmitZeros - Emit NumBytes worth of zeros. This is a convenience 429 /// function that just wraps EmitFill. 430 void EmitZeros(uint64_t NumBytes, unsigned AddrSpace) { 431 EmitFill(NumBytes, 0, AddrSpace); 432 } 433 434 435 /// EmitValueToAlignment - Emit some number of copies of @p Value until 436 /// the byte alignment @p ByteAlignment is reached. 437 /// 438 /// If the number of bytes need to emit for the alignment is not a multiple 439 /// of @p ValueSize, then the contents of the emitted fill bytes is 440 /// undefined. 441 /// 442 /// This used to implement the .align assembler directive. 443 /// 444 /// @param ByteAlignment - The alignment to reach. This must be a power of 445 /// two on some targets. 446 /// @param Value - The value to use when filling bytes. 447 /// @param ValueSize - The size of the integer (in bytes) to emit for 448 /// @p Value. This must match a native machine width. 449 /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If 450 /// the alignment cannot be reached in this many bytes, no bytes are 451 /// emitted. 452 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, 453 unsigned ValueSize = 1, 454 unsigned MaxBytesToEmit = 0) = 0; 455 456 /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment 457 /// is reached. 458 /// 459 /// This used to align code where the alignment bytes may be executed. This 460 /// can emit different bytes for different sizes to optimize execution. 461 /// 462 /// @param ByteAlignment - The alignment to reach. This must be a power of 463 /// two on some targets. 464 /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If 465 /// the alignment cannot be reached in this many bytes, no bytes are 466 /// emitted. 467 virtual void EmitCodeAlignment(unsigned ByteAlignment, 468 unsigned MaxBytesToEmit = 0) = 0; 469 470 /// EmitValueToOffset - Emit some number of copies of @p Value until the 471 /// byte offset @p Offset is reached. 472 /// 473 /// This is used to implement assembler directives such as .org. 474 /// 475 /// @param Offset - The offset to reach. This may be an expression, but the 476 /// expression must be associated with the current section. 477 /// @param Value - The value to use when filling bytes. 478 /// @return false on success, true if the offset was invalid. 479 virtual bool EmitValueToOffset(const MCExpr *Offset, 480 unsigned char Value = 0) = 0; 481 482 /// @} 483 484 /// EmitFileDirective - Switch to a new logical file. This is used to 485 /// implement the '.file "foo.c"' assembler directive. 486 virtual void EmitFileDirective(StringRef Filename) = 0; 487 488 /// EmitDwarfFileDirective - Associate a filename with a specified logical 489 /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler 490 /// directive. 491 virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, 492 StringRef Filename); 493 494 /// EmitDwarfLocDirective - This implements the DWARF2 495 // '.loc fileno lineno ...' assembler directive. 496 virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, 497 unsigned Column, unsigned Flags, 498 unsigned Isa, 499 unsigned Discriminator, 500 StringRef FileName); 501 502 virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, 503 const MCSymbol *LastLabel, 504 const MCSymbol *Label, 505 unsigned PointerSize) = 0; 506 507 virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, 508 const MCSymbol *Label) { 509 } 510 511 void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label, 512 int PointerSize); 513 514 virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding); 515 virtual void EmitCFISections(bool EH, bool Debug); 516 void EmitCFIStartProc(); 517 void EmitCFIEndProc(); 518 virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); 519 virtual void EmitCFIDefCfaOffset(int64_t Offset); 520 virtual void EmitCFIDefCfaRegister(int64_t Register); 521 virtual void EmitCFIOffset(int64_t Register, int64_t Offset); 522 virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding); 523 virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding); 524 virtual void EmitCFIRememberState(); 525 virtual void EmitCFIRestoreState(); 526 virtual void EmitCFISameValue(int64_t Register); 527 virtual void EmitCFIRestore(int64_t Register); 528 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); 529 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); 530 virtual void EmitCFIEscape(StringRef Values); 531 virtual void EmitCFISignalFrame(); 532 virtual void EmitCFIUndefined(int64_t Register); 533 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); 534 535 virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); 536 virtual void EmitWin64EHEndProc(); 537 virtual void EmitWin64EHStartChained(); 538 virtual void EmitWin64EHEndChained(); 539 virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind, 540 bool Except); 541 virtual void EmitWin64EHHandlerData(); 542 virtual void EmitWin64EHPushReg(unsigned Register); 543 virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset); 544 virtual void EmitWin64EHAllocStack(unsigned Size); 545 virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset); 546 virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset); 547 virtual void EmitWin64EHPushFrame(bool Code); 548 virtual void EmitWin64EHEndProlog(); 549 550 /// EmitInstruction - Emit the given @p Instruction into the current 551 /// section. 552 virtual void EmitInstruction(const MCInst &Inst) = 0; 553 554 /// EmitRawText - If this file is backed by a assembly streamer, this dumps 555 /// the specified string in the output .s file. This capability is 556 /// indicated by the hasRawTextSupport() predicate. By default this aborts. 557 virtual void EmitRawText(StringRef String); 558 void EmitRawText(const Twine &String); 559 560 /// ARM-related methods. 561 /// FIXME: Eventually we should have some "target MC streamer" and move 562 /// these methods there. 563 virtual void EmitFnStart(); 564 virtual void EmitFnEnd(); 565 virtual void EmitCantUnwind(); 566 virtual void EmitPersonality(const MCSymbol *Personality); 567 virtual void EmitHandlerData(); 568 virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0); 569 virtual void EmitPad(int64_t Offset); 570 virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList, 571 bool isVector); 572 573 /// PPC-related methods. 574 /// FIXME: Eventually replace it with some "target MC streamer" and move 575 /// these methods there. 576 virtual void EmitTCEntry(const MCSymbol &S); 577 578 /// FinishImpl - Streamer specific finalization. 579 virtual void FinishImpl() = 0; 580 /// Finish - Finish emission of machine code. 581 void Finish(); 582 }; 583 584 /// createNullStreamer - Create a dummy machine code streamer, which does 585 /// nothing. This is useful for timing the assembler front end. 586 MCStreamer *createNullStreamer(MCContext &Ctx); 587 588 /// createAsmStreamer - Create a machine code streamer which will print out 589 /// assembly for the native target, suitable for compiling with a native 590 /// assembler. 591 /// 592 /// \param InstPrint - If given, the instruction printer to use. If not given 593 /// the MCInst representation will be printed. This method takes ownership of 594 /// InstPrint. 595 /// 596 /// \param CE - If given, a code emitter to use to show the instruction 597 /// encoding inline with the assembly. This method takes ownership of \p CE. 598 /// 599 /// \param TAB - If given, a target asm backend to use to show the fixup 600 /// information in conjunction with encoding information. This method takes 601 /// ownership of \p TAB. 602 /// 603 /// \param ShowInst - Whether to show the MCInst representation inline with 604 /// the assembly. 605 MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, 606 bool isVerboseAsm, 607 bool useLoc, 608 bool useCFI, 609 bool useDwarfDirectory, 610 MCInstPrinter *InstPrint = 0, 611 MCCodeEmitter *CE = 0, 612 MCAsmBackend *TAB = 0, 613 bool ShowInst = false); 614 615 /// createMachOStreamer - Create a machine code streamer which will generate 616 /// Mach-O format object files. 617 /// 618 /// Takes ownership of \p TAB and \p CE. 619 MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, 620 raw_ostream &OS, MCCodeEmitter *CE, 621 bool RelaxAll = false); 622 623 /// createWinCOFFStreamer - Create a machine code streamer which will 624 /// generate Microsoft COFF format object files. 625 /// 626 /// Takes ownership of \p TAB and \p CE. 627 MCStreamer *createWinCOFFStreamer(MCContext &Ctx, 628 MCAsmBackend &TAB, 629 MCCodeEmitter &CE, raw_ostream &OS, 630 bool RelaxAll = false); 631 632 /// createELFStreamer - Create a machine code streamer which will generate 633 /// ELF format object files. 634 MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, 635 raw_ostream &OS, MCCodeEmitter *CE, 636 bool RelaxAll, bool NoExecStack); 637 638 /// createPureStreamer - Create a machine code streamer which will generate 639 /// "pure" MC object files, for use with MC-JIT and testing tools. 640 /// 641 /// Takes ownership of \p TAB and \p CE. 642 MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB, 643 raw_ostream &OS, MCCodeEmitter *CE); 644 645} // end namespace llvm 646 647#endif 648