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