MCObjectStreamer.h revision 7768a9dce14431018133cd586f5c8ce3e057f069
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===- MCObjectStreamer.h - MCStreamer Object File Interface ----*- C++ -*-===// 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// The LLVM Compiler Infrastructure 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// License. See LICENSE.TXT for details. 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===----------------------------------------------------------------------===// 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef LLVM_MC_MCOBJECTSTREAMER_H 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define LLVM_MC_MCOBJECTSTREAMER_H 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "llvm/MC/MCStreamer.h" 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace llvm { 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class MCAssembler; 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class MCCodeEmitter; 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class MCSectionData; 19class MCExpr; 20class MCFragment; 21class MCDataFragment; 22class TargetAsmBackend; 23class raw_ostream; 24 25/// \brief Streaming object file generation interface. 26/// 27/// This class provides an implementation of the MCStreamer interface which is 28/// suitable for use with the assembler backend. Specific object file formats 29/// are expected to subclass this interface to implement directives specific 30/// to that file format or custom semantics expected by the object writer 31/// implementation. 32class MCObjectStreamer : public MCStreamer { 33 MCAssembler *Assembler; 34 MCSectionData *CurSectionData; 35 36 virtual void EmitInstToData(const MCInst &Inst) = 0; 37 38protected: 39 MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, 40 raw_ostream &_OS, MCCodeEmitter *_Emitter); 41 ~MCObjectStreamer(); 42 43 MCSectionData *getCurrentSectionData() const { 44 return CurSectionData; 45 } 46 47 MCFragment *getCurrentFragment() const; 48 49 /// Get a data fragment to write into, creating a new one if the current 50 /// fragment is not a data fragment. 51 MCDataFragment *getOrCreateDataFragment() const; 52 53 const MCExpr *AddValueSymbols(const MCExpr *Value); 54 55public: 56 MCAssembler &getAssembler() { return *Assembler; } 57 58 /// @name MCStreamer Interface 59 /// @{ 60 61 virtual void EmitLabel(MCSymbol *Symbol); 62 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, 63 bool isPCRel, unsigned AddrSpace); 64 virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); 65 virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); 66 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); 67 virtual void ChangeSection(const MCSection *Section); 68 virtual void EmitInstruction(const MCInst &Inst); 69 virtual void EmitInstToFragment(const MCInst &Inst); 70 virtual void EmitValueToOffset(const MCExpr *Offset, unsigned char Value); 71 virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, 72 const MCSymbol *LastLabel, 73 const MCSymbol *Label); 74 virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, 75 const MCSymbol *Label); 76 virtual void Finish(); 77 78 /// @} 79}; 80 81} // end namespace llvm 82 83#endif 84