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