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