2009-06-23 20:24:17 +00:00
|
|
|
//===- MCStreamer.h - High-level Streaming Machine Code Output --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-07-01 06:08:37 +00:00
|
|
|
//
|
|
|
|
// This file declares the MCStreamer class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-23 20:24:17 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSTREAMER_H
|
|
|
|
#define LLVM_MC_MCSTREAMER_H
|
|
|
|
|
2009-10-26 01:35:46 +00:00
|
|
|
#include "llvm/System/DataTypes.h"
|
2010-01-23 06:39:22 +00:00
|
|
|
#include "llvm/MC/MCDirectives.h"
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2009-06-23 20:24:17 +00:00
|
|
|
namespace llvm {
|
2009-08-27 00:51:57 +00:00
|
|
|
class MCAsmInfo;
|
|
|
|
class MCCodeEmitter;
|
2009-06-23 20:24:17 +00:00
|
|
|
class MCContext;
|
2009-08-31 08:09:28 +00:00
|
|
|
class MCExpr;
|
2009-06-23 20:24:17 +00:00
|
|
|
class MCInst;
|
2009-09-14 03:02:37 +00:00
|
|
|
class MCInstPrinter;
|
2009-06-23 20:24:17 +00:00
|
|
|
class MCSection;
|
|
|
|
class MCSymbol;
|
2009-07-27 21:49:56 +00:00
|
|
|
class StringRef;
|
2010-05-08 19:54:22 +00:00
|
|
|
class TargetAsmBackend;
|
2010-11-19 02:26:16 +00:00
|
|
|
class TargetLoweringObjectFile;
|
2010-01-22 07:29:22 +00:00
|
|
|
class Twine;
|
2009-06-23 20:24:17 +00:00
|
|
|
class raw_ostream;
|
2010-01-22 07:29:22 +00:00
|
|
|
class formatted_raw_ostream;
|
2009-06-23 20:24:17 +00:00
|
|
|
|
2009-07-01 06:08:37 +00:00
|
|
|
/// MCStreamer - Streaming machine code generation interface. This interface
|
|
|
|
/// is intended to provide a programatic interface that is very similar to the
|
|
|
|
/// level that an assembler .s file provides. It has callbacks to emit bytes,
|
2009-08-30 06:17:16 +00:00
|
|
|
/// handle directives, etc. The implementation of this interface retains
|
2009-07-01 06:08:37 +00:00
|
|
|
/// state to know what the current section is etc.
|
|
|
|
///
|
|
|
|
/// There are multiple implementations of this interface: one for writing out
|
|
|
|
/// a .s file, and implementations that write out .o files of various formats.
|
|
|
|
///
|
2009-06-23 20:24:17 +00:00
|
|
|
class MCStreamer {
|
|
|
|
MCContext &Context;
|
|
|
|
|
|
|
|
MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT
|
|
|
|
MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT
|
|
|
|
|
2009-06-23 23:02:31 +00:00
|
|
|
protected:
|
2009-06-23 20:24:17 +00:00
|
|
|
MCStreamer(MCContext &Ctx);
|
2009-06-23 23:02:31 +00:00
|
|
|
|
2009-08-18 06:15:16 +00:00
|
|
|
/// CurSection - This is the current section code is being emitted to, it is
|
|
|
|
/// kept up to date by SwitchSection.
|
|
|
|
const MCSection *CurSection;
|
2009-08-30 06:17:16 +00:00
|
|
|
|
2010-09-15 16:24:01 +00:00
|
|
|
/// PrevSection - This is the previous section code is being emitted to, it
|
|
|
|
/// is kept up to date by SwitchSection.
|
2010-09-02 18:53:37 +00:00
|
|
|
const MCSection *PrevSection;
|
|
|
|
|
2009-06-23 23:02:31 +00:00
|
|
|
public:
|
2009-06-23 20:24:17 +00:00
|
|
|
virtual ~MCStreamer();
|
|
|
|
|
|
|
|
MCContext &getContext() const { return Context; }
|
|
|
|
|
2010-01-22 19:52:01 +00:00
|
|
|
/// @name Assembly File Formatting.
|
|
|
|
/// @{
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-04-03 21:35:55 +00:00
|
|
|
/// isVerboseAsm - Return true if this streamer supports verbose assembly
|
|
|
|
/// and if it is enabled.
|
2010-02-02 23:37:42 +00:00
|
|
|
virtual bool isVerboseAsm() const { return false; }
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-04-03 21:35:55 +00:00
|
|
|
/// hasRawTextSupport - Return true if this asm streamer supports emitting
|
|
|
|
/// unformatted text to the .s file with EmitRawText.
|
|
|
|
virtual bool hasRawTextSupport() const { return false; }
|
2010-01-22 19:52:01 +00:00
|
|
|
|
2010-01-22 18:21:35 +00:00
|
|
|
/// AddComment - Add a comment that can be emitted to the generated .s
|
2010-01-22 07:29:22 +00:00
|
|
|
/// file if applicable as a QoI issue to make the output of the compiler
|
|
|
|
/// more readable. This only affects the MCAsmStreamer, and only when
|
|
|
|
/// verbose assembly output is enabled.
|
|
|
|
///
|
|
|
|
/// If the comment includes embedded \n's, they will each get the comment
|
|
|
|
/// prefix as appropriate. The added comment should not end with a \n.
|
2010-01-22 18:21:35 +00:00
|
|
|
virtual void AddComment(const Twine &T) {}
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-22 19:17:48 +00:00
|
|
|
/// GetCommentOS - Return a raw_ostream that comments can be written to.
|
|
|
|
/// Unlike AddComment, you are required to terminate comments with \n if you
|
|
|
|
/// use this method.
|
|
|
|
virtual raw_ostream &GetCommentOS();
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-22 19:52:01 +00:00
|
|
|
/// AddBlankLine - Emit a blank line to a .s file to pretty it up.
|
|
|
|
virtual void AddBlankLine() {}
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-22 19:52:01 +00:00
|
|
|
/// @}
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2009-06-24 19:25:34 +00:00
|
|
|
/// @name Symbol & Section Management
|
|
|
|
/// @{
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-03-25 00:03:04 +00:00
|
|
|
/// getCurrentSection - Return the current section that the streamer is
|
2009-08-30 06:17:16 +00:00
|
|
|
/// emitting code to.
|
|
|
|
const MCSection *getCurrentSection() const { return CurSection; }
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2010-09-02 18:53:37 +00:00
|
|
|
/// getPreviousSection - Return the previous section that the streamer is
|
|
|
|
/// emitting code to.
|
|
|
|
const MCSection *getPreviousSection() const { return PrevSection; }
|
|
|
|
|
2009-06-23 23:02:31 +00:00
|
|
|
/// SwitchSection - Set the current section where code is being emitted to
|
2010-02-22 04:10:52 +00:00
|
|
|
/// @p Section. This is required to update CurSection.
|
2009-06-23 23:02:31 +00:00
|
|
|
///
|
|
|
|
/// This corresponds to assembler directives like .section, .text, etc.
|
2009-08-17 05:49:08 +00:00
|
|
|
virtual void SwitchSection(const MCSection *Section) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-09-15 21:48:40 +00:00
|
|
|
/// InitSections - Create the default sections and set the initial one.
|
|
|
|
virtual void InitSections() = 0;
|
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitLabel - Emit a label for @p Symbol into the current section.
|
2009-06-23 23:02:31 +00:00
|
|
|
///
|
|
|
|
/// This corresponds to an assembler statement such as:
|
|
|
|
/// foo:
|
|
|
|
///
|
|
|
|
/// @param Symbol - The symbol to emit. A given symbol should only be
|
|
|
|
/// emitted as a label once, and symbols emitted as a label should never be
|
|
|
|
/// used in an assignment.
|
2009-06-23 23:39:15 +00:00
|
|
|
virtual void EmitLabel(MCSymbol *Symbol) = 0;
|
2009-06-23 23:02:31 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitAssemblerFlag - Note in the output the specified @p Flag
|
2010-01-23 06:39:22 +00:00
|
|
|
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0;
|
2009-07-13 21:03:15 +00:00
|
|
|
|
2010-11-05 22:08:08 +00:00
|
|
|
/// EmitThumbFunc - Note in the output that the specified @p Func is
|
|
|
|
/// a Thumb mode function (ARM target only).
|
|
|
|
virtual void EmitThumbFunc(MCSymbol *Func) = 0;
|
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitAssignment - Emit an assignment of @p Value to @p Symbol.
|
2009-06-23 23:02:31 +00:00
|
|
|
///
|
|
|
|
/// This corresponds to an assembler statement such as:
|
|
|
|
/// symbol = value
|
|
|
|
///
|
|
|
|
/// The assignment generates no code, but has the side effect of binding the
|
|
|
|
/// value in the current context. For the assembly streamer, this prints the
|
|
|
|
/// binding into the .s file.
|
|
|
|
///
|
|
|
|
/// @param Symbol - The symbol being assigned to.
|
|
|
|
/// @param Value - The value for the symbol.
|
2009-08-31 08:09:28 +00:00
|
|
|
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0;
|
2009-06-23 20:24:17 +00:00
|
|
|
|
2010-11-01 14:28:48 +00:00
|
|
|
/// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol.
|
|
|
|
///
|
|
|
|
/// This corresponds to an assembler statement such as:
|
|
|
|
/// .weakref alias, symbol
|
|
|
|
///
|
|
|
|
/// @param Alias - The alias that is being created.
|
|
|
|
/// @param Symbol - The symbol being aliased.
|
|
|
|
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0;
|
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol.
|
2009-06-24 01:03:06 +00:00
|
|
|
virtual void EmitSymbolAttribute(MCSymbol *Symbol,
|
2010-01-23 06:39:22 +00:00
|
|
|
MCSymbolAttr Attribute) = 0;
|
2009-06-23 20:24:17 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitSymbolDesc - Set the @p DescValue for the @p Symbol.
|
2009-07-14 18:17:10 +00:00
|
|
|
///
|
|
|
|
/// @param Symbol - The symbol to have its n_desc field set.
|
|
|
|
/// @param DescValue - The value to set into the n_desc field.
|
|
|
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0;
|
|
|
|
|
2010-05-08 19:54:22 +00:00
|
|
|
/// BeginCOFFSymbolDef - Start emitting COFF symbol definition
|
|
|
|
///
|
|
|
|
/// @param Symbol - The symbol to have its External & Type fields set.
|
|
|
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0;
|
|
|
|
|
|
|
|
/// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol.
|
|
|
|
///
|
|
|
|
/// @param StorageClass - The storage class the symbol should have.
|
|
|
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0;
|
|
|
|
|
|
|
|
/// EmitCOFFSymbolType - Emit the type of the symbol.
|
|
|
|
///
|
|
|
|
/// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h)
|
|
|
|
virtual void EmitCOFFSymbolType(int Type) = 0;
|
|
|
|
|
|
|
|
/// EndCOFFSymbolDef - Marks the end of the symbol definition.
|
|
|
|
virtual void EndCOFFSymbolDef() = 0;
|
|
|
|
|
2010-01-25 07:52:13 +00:00
|
|
|
/// EmitELFSize - Emit an ELF .size directive.
|
|
|
|
///
|
|
|
|
/// This corresponds to an assembler statement such as:
|
|
|
|
/// .size symbol, expression
|
|
|
|
///
|
|
|
|
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-23 07:47:02 +00:00
|
|
|
/// EmitCommonSymbol - Emit a common symbol.
|
2009-07-07 20:30:46 +00:00
|
|
|
///
|
|
|
|
/// @param Symbol - The common symbol to emit.
|
|
|
|
/// @param Size - The size of the common symbol.
|
2009-08-30 06:17:16 +00:00
|
|
|
/// @param ByteAlignment - The alignment of the symbol if
|
2010-01-23 07:47:02 +00:00
|
|
|
/// non-zero. This must be a power of 2.
|
|
|
|
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned ByteAlignment) = 0;
|
2009-07-07 20:30:46 +00:00
|
|
|
|
2010-01-23 07:47:02 +00:00
|
|
|
/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
|
|
|
|
///
|
|
|
|
/// @param Symbol - The common symbol to emit.
|
|
|
|
/// @param Size - The size of the common symbol.
|
|
|
|
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-05-21 22:39:11 +00:00
|
|
|
/// EmitZerofill - Emit the zerofill section and an optional symbol.
|
2009-07-10 22:20:30 +00:00
|
|
|
///
|
|
|
|
/// @param Section - The zerofill section to create and or to put the symbol
|
|
|
|
/// @param Symbol - The zerofill symbol to emit, if non-NULL.
|
|
|
|
/// @param Size - The size of the zerofill symbol.
|
2009-08-30 06:17:16 +00:00
|
|
|
/// @param ByteAlignment - The alignment of the zerofill symbol if
|
|
|
|
/// non-zero. This must be a power of 2 on some targets.
|
2009-08-28 05:48:22 +00:00
|
|
|
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned Size = 0,unsigned ByteAlignment = 0) = 0;
|
2009-07-10 22:20:30 +00:00
|
|
|
|
2010-05-14 01:50:28 +00:00
|
|
|
/// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol.
|
|
|
|
///
|
2010-05-18 21:16:04 +00:00
|
|
|
/// @param Section - The thread local common section.
|
2010-05-14 01:50:28 +00:00
|
|
|
/// @param Symbol - The thread local common symbol to emit.
|
|
|
|
/// @param Size - The size of the symbol.
|
|
|
|
/// @param ByteAlignment - The alignment of the thread local common symbol
|
|
|
|
/// if non-zero. This must be a power of 2 on some targets.
|
2010-05-18 21:16:04 +00:00
|
|
|
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
|
2010-09-15 16:24:01 +00:00
|
|
|
uint64_t Size, unsigned ByteAlignment = 0) = 0;
|
2009-06-24 19:25:34 +00:00
|
|
|
/// @}
|
|
|
|
/// @name Generating Data
|
|
|
|
/// @{
|
|
|
|
|
2009-08-30 06:17:16 +00:00
|
|
|
/// EmitBytes - Emit the bytes in \arg Data into the output.
|
2009-06-23 23:02:31 +00:00
|
|
|
///
|
|
|
|
/// This is used to implement assembler directives such as .byte, .ascii,
|
|
|
|
/// etc.
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitBytes(StringRef Data, unsigned AddrSpace) = 0;
|
2009-06-23 23:02:31 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitValue - Emit the expression @p Value into the output as a native
|
|
|
|
/// integer of the given @p Size bytes.
|
2009-06-23 23:02:31 +00:00
|
|
|
///
|
|
|
|
/// This is used to implement assembler directives such as .word, .quad,
|
|
|
|
/// etc.
|
|
|
|
///
|
|
|
|
/// @param Value - The value to emit.
|
|
|
|
/// @param Size - The size of the integer (in bytes) to emit. This must
|
|
|
|
/// match a native machine width.
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitValue(const MCExpr *Value, unsigned Size,
|
2010-08-06 21:24:05 +00:00
|
|
|
unsigned AddrSpace = 0) = 0;
|
2009-06-23 23:02:31 +00:00
|
|
|
|
2010-01-19 22:03:38 +00:00
|
|
|
/// EmitIntValue - Special case of EmitValue that avoids the client having
|
|
|
|
/// to pass in a MCExpr for constant integers.
|
2010-08-06 21:24:05 +00:00
|
|
|
virtual void EmitIntValue(uint64_t Value, unsigned Size,
|
|
|
|
unsigned AddrSpace = 0);
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-09-30 17:16:09 +00:00
|
|
|
|
2010-11-02 17:22:24 +00:00
|
|
|
virtual void EmitULEB128Value(const MCExpr *Value,
|
|
|
|
unsigned AddrSpace = 0) = 0;
|
|
|
|
|
|
|
|
virtual void EmitSLEB128Value(const MCExpr *Value,
|
|
|
|
unsigned AddrSpace = 0) = 0;
|
|
|
|
|
|
|
|
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
|
|
|
|
/// client having to pass in a MCExpr for constant integers.
|
|
|
|
virtual void EmitULEB128IntValue(uint64_t Value, unsigned AddrSpace = 0);
|
|
|
|
|
|
|
|
/// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
|
|
|
|
/// client having to pass in a MCExpr for constant integers.
|
|
|
|
virtual void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0);
|
2010-09-30 17:16:09 +00:00
|
|
|
|
2010-03-09 00:39:24 +00:00
|
|
|
/// EmitSymbolValue - Special case of EmitValue that avoids the client
|
|
|
|
/// having to pass in a MCExpr for MCSymbols.
|
|
|
|
virtual void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
|
2010-09-30 17:16:09 +00:00
|
|
|
unsigned AddrSpace = 0);
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitGPRel32Value - Emit the expression @p Value into the output as a
|
2010-01-25 21:28:50 +00:00
|
|
|
/// gprel32 (32-bit GP relative) value.
|
|
|
|
///
|
|
|
|
/// This is used to implement assembler directives such as .gprel32 on
|
|
|
|
/// targets that support them.
|
|
|
|
virtual void EmitGPRel32Value(const MCExpr *Value) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-19 18:45:47 +00:00
|
|
|
/// EmitFill - Emit NumBytes bytes worth of the value specified by
|
|
|
|
/// FillValue. This implements directives such as '.space'.
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
|
|
|
|
unsigned AddrSpace);
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-19 21:51:22 +00:00
|
|
|
/// EmitZeros - Emit NumBytes worth of zeros. This is a convenience
|
|
|
|
/// function that just wraps EmitFill.
|
|
|
|
void EmitZeros(uint64_t NumBytes, unsigned AddrSpace) {
|
|
|
|
EmitFill(NumBytes, 0, AddrSpace);
|
|
|
|
}
|
|
|
|
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitValueToAlignment - Emit some number of copies of @p Value until
|
|
|
|
/// the byte alignment @p ByteAlignment is reached.
|
2009-06-24 19:25:34 +00:00
|
|
|
///
|
|
|
|
/// If the number of bytes need to emit for the alignment is not a multiple
|
2010-02-22 04:10:52 +00:00
|
|
|
/// of @p ValueSize, then the contents of the emitted fill bytes is
|
2009-06-24 19:25:34 +00:00
|
|
|
/// undefined.
|
|
|
|
///
|
|
|
|
/// This used to implement the .align assembler directive.
|
|
|
|
///
|
|
|
|
/// @param ByteAlignment - The alignment to reach. This must be a power of
|
2009-06-29 23:46:59 +00:00
|
|
|
/// two on some targets.
|
2009-06-24 19:25:34 +00:00
|
|
|
/// @param Value - The value to use when filling bytes.
|
2010-02-22 04:10:52 +00:00
|
|
|
/// @param ValueSize - The size of the integer (in bytes) to emit for
|
|
|
|
/// @p Value. This must match a native machine width.
|
2009-06-24 19:25:34 +00:00
|
|
|
/// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
|
|
|
|
/// the alignment cannot be reached in this many bytes, no bytes are
|
|
|
|
/// emitted.
|
|
|
|
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
|
|
|
|
unsigned ValueSize = 1,
|
|
|
|
unsigned MaxBytesToEmit = 0) = 0;
|
2010-02-23 18:26:34 +00:00
|
|
|
|
|
|
|
/// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment
|
|
|
|
/// is reached.
|
|
|
|
///
|
|
|
|
/// This used to align code where the alignment bytes may be executed. This
|
|
|
|
/// can emit different bytes for different sizes to optimize execution.
|
|
|
|
///
|
|
|
|
/// @param ByteAlignment - The alignment to reach. This must be a power of
|
|
|
|
/// two on some targets.
|
|
|
|
/// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If
|
|
|
|
/// the alignment cannot be reached in this many bytes, no bytes are
|
|
|
|
/// emitted.
|
|
|
|
virtual void EmitCodeAlignment(unsigned ByteAlignment,
|
|
|
|
unsigned MaxBytesToEmit = 0) = 0;
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitValueToOffset - Emit some number of copies of @p Value until the
|
|
|
|
/// byte offset @p Offset is reached.
|
2009-06-24 19:25:34 +00:00
|
|
|
///
|
|
|
|
/// This is used to implement assembler directives such as .org.
|
|
|
|
///
|
2009-08-30 21:14:05 +00:00
|
|
|
/// @param Offset - The offset to reach. This may be an expression, but the
|
2009-06-24 19:25:34 +00:00
|
|
|
/// expression must be associated with the current section.
|
|
|
|
/// @param Value - The value to use when filling bytes.
|
2009-08-31 08:09:28 +00:00
|
|
|
virtual void EmitValueToOffset(const MCExpr *Offset,
|
2009-06-24 19:25:34 +00:00
|
|
|
unsigned char Value = 0) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2009-06-24 19:25:34 +00:00
|
|
|
/// @}
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
/// EmitFileDirective - Switch to a new logical file. This is used to
|
|
|
|
/// implement the '.file "foo.c"' assembler directive.
|
|
|
|
virtual void EmitFileDirective(StringRef Filename) = 0;
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
/// EmitDwarfFileDirective - Associate a filename with a specified logical
|
|
|
|
/// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler
|
|
|
|
/// directive.
|
2010-11-16 21:20:32 +00:00
|
|
|
virtual bool EmitDwarfFileDirective(unsigned FileNo,StringRef Filename);
|
|
|
|
|
|
|
|
/// EmitDwarfLocDirective - This implements the DWARF2
|
|
|
|
// '.loc fileno lineno ...' assembler directive.
|
|
|
|
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
|
|
|
unsigned Column, unsigned Flags,
|
|
|
|
unsigned Isa,
|
|
|
|
unsigned Discriminator);
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2010-11-22 14:27:24 +00:00
|
|
|
virtual bool EmitCFIStartProc();
|
|
|
|
virtual bool EmitCFIEndProc();
|
|
|
|
virtual bool EmitCFIDefCfaOffset(int64_t Offset);
|
|
|
|
virtual bool EmitCFIDefCfaRegister(int64_t Register);
|
|
|
|
virtual bool EmitCFIOffset(int64_t Register, int64_t Offset);
|
|
|
|
virtual bool EmitCFIPersonality(const MCSymbol *Sym);
|
|
|
|
virtual bool EmitCFILsda(const MCSymbol *Sym);
|
|
|
|
|
2010-02-22 04:10:52 +00:00
|
|
|
/// EmitInstruction - Emit the given @p Instruction into the current
|
2009-06-23 23:02:31 +00:00
|
|
|
/// section.
|
2009-06-23 20:24:17 +00:00
|
|
|
virtual void EmitInstruction(const MCInst &Inst) = 0;
|
2009-06-23 23:39:15 +00:00
|
|
|
|
2010-04-03 21:35:55 +00:00
|
|
|
/// EmitRawText - If this file is backed by a assembly streamer, this dumps
|
|
|
|
/// the specified string in the output .s file. This capability is
|
|
|
|
/// indicated by the hasRawTextSupport() predicate. By default this aborts.
|
|
|
|
virtual void EmitRawText(StringRef String);
|
2010-04-03 22:12:35 +00:00
|
|
|
void EmitRawText(const Twine &String);
|
2010-09-15 16:24:01 +00:00
|
|
|
|
2010-06-01 16:31:34 +00:00
|
|
|
/// Finish - Finish emission of machine code.
|
2009-06-23 23:39:15 +00:00
|
|
|
virtual void Finish() = 0;
|
2009-06-23 20:24:17 +00:00
|
|
|
};
|
|
|
|
|
2009-08-13 23:36:34 +00:00
|
|
|
/// createNullStreamer - Create a dummy machine code streamer, which does
|
|
|
|
/// nothing. This is useful for timing the assembler front end.
|
|
|
|
MCStreamer *createNullStreamer(MCContext &Ctx);
|
|
|
|
|
2009-06-23 23:02:31 +00:00
|
|
|
/// createAsmStreamer - Create a machine code streamer which will print out
|
|
|
|
/// assembly for the native target, suitable for compiling with a native
|
|
|
|
/// assembler.
|
2010-02-03 18:18:30 +00:00
|
|
|
///
|
|
|
|
/// \param InstPrint - If given, the instruction printer to use. If not given
|
2010-03-19 05:48:53 +00:00
|
|
|
/// the MCInst representation will be printed. This method takes ownership of
|
|
|
|
/// InstPrint.
|
2010-02-03 18:18:30 +00:00
|
|
|
///
|
|
|
|
/// \param CE - If given, a code emitter to use to show the instruction
|
2010-07-29 17:48:06 +00:00
|
|
|
/// encoding inline with the assembly. This method takes ownership of \arg CE.
|
2010-02-03 18:18:30 +00:00
|
|
|
///
|
|
|
|
/// \param ShowInst - Whether to show the MCInst representation inline with
|
|
|
|
/// the assembly.
|
2010-01-22 07:29:22 +00:00
|
|
|
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
2010-03-12 18:28:53 +00:00
|
|
|
bool isLittleEndian, bool isVerboseAsm,
|
2009-09-14 03:02:37 +00:00
|
|
|
MCInstPrinter *InstPrint = 0,
|
2010-02-03 18:18:30 +00:00
|
|
|
MCCodeEmitter *CE = 0,
|
2010-02-10 01:41:14 +00:00
|
|
|
bool ShowInst = false);
|
2009-06-23 23:02:31 +00:00
|
|
|
|
2010-11-19 02:26:16 +00:00
|
|
|
MCStreamer *createAsmStreamerNoLoc(MCContext &Ctx, formatted_raw_ostream &OS,
|
|
|
|
bool isLittleEndian, bool isVerboseAsm,
|
|
|
|
const TargetLoweringObjectFile *TLOF,
|
|
|
|
int PointerSize,
|
|
|
|
MCInstPrinter *InstPrint = 0,
|
|
|
|
MCCodeEmitter *CE = 0,
|
|
|
|
bool ShowInst = false);
|
|
|
|
|
2010-06-01 16:10:08 +00:00
|
|
|
/// createMachOStreamer - Create a machine code streamer which will generate
|
2009-06-23 23:02:31 +00:00
|
|
|
/// Mach-O format object files.
|
2010-07-29 17:48:06 +00:00
|
|
|
///
|
|
|
|
/// Takes ownership of \arg TAB and \arg CE.
|
2010-03-11 01:34:27 +00:00
|
|
|
MCStreamer *createMachOStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
|
2010-03-25 22:49:09 +00:00
|
|
|
raw_ostream &OS, MCCodeEmitter *CE,
|
|
|
|
bool RelaxAll = false);
|
2009-06-23 20:24:17 +00:00
|
|
|
|
2010-07-11 22:05:00 +00:00
|
|
|
/// createWinCOFFStreamer - Create a machine code streamer which will
|
|
|
|
/// generate Microsoft COFF format object files.
|
2010-07-29 17:48:06 +00:00
|
|
|
///
|
|
|
|
/// Takes ownership of \arg TAB and \arg CE.
|
2010-07-11 22:05:00 +00:00
|
|
|
MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
|
|
|
|
TargetAsmBackend &TAB,
|
2010-07-31 06:22:29 +00:00
|
|
|
MCCodeEmitter &CE, raw_ostream &OS,
|
|
|
|
bool RelaxAll = false);
|
2010-07-11 22:05:00 +00:00
|
|
|
|
2010-08-16 18:35:43 +00:00
|
|
|
/// createELFStreamer - Create a machine code streamer which will generate
|
|
|
|
/// ELF format object files.
|
|
|
|
MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
|
|
|
|
raw_ostream &OS, MCCodeEmitter *CE,
|
|
|
|
bool RelaxAll = false);
|
|
|
|
|
2010-05-23 17:44:06 +00:00
|
|
|
/// createLoggingStreamer - Create a machine code streamer which just logs the
|
|
|
|
/// API calls and then dispatches to another streamer.
|
|
|
|
///
|
|
|
|
/// The new streamer takes ownership of the \arg Child.
|
|
|
|
MCStreamer *createLoggingStreamer(MCStreamer *Child, raw_ostream &OS);
|
|
|
|
|
2010-11-17 16:06:47 +00:00
|
|
|
/// createPureStreamer - Create a machine code streamer which will generate
|
|
|
|
/// "pure" MC object files, for use with MC-JIT and testing tools.
|
|
|
|
///
|
|
|
|
/// Takes ownership of \arg TAB and \arg CE.
|
|
|
|
MCStreamer *createPureStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
|
|
|
|
raw_ostream &OS, MCCodeEmitter *CE);
|
|
|
|
|
2009-06-23 20:24:17 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|