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