LLVM API Documentation

MCELFStreamer.h
Go to the documentation of this file.
00001 //===- MCELFStreamer.h - MCStreamer ELF Object File Interface ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_MC_MCELFSTREAMER_H
00011 #define LLVM_MC_MCELFSTREAMER_H
00012 
00013 #include "llvm/ADT/SmallPtrSet.h"
00014 #include "llvm/MC/MCDirectives.h"
00015 #include "llvm/MC/MCObjectStreamer.h"
00016 #include "llvm/MC/SectionKind.h"
00017 #include "llvm/Support/DataTypes.h"
00018 #include <vector>
00019 
00020 namespace llvm {
00021 class MCAsmBackend;
00022 class MCAssembler;
00023 class MCCodeEmitter;
00024 class MCExpr;
00025 class MCInst;
00026 class MCSymbol;
00027 class MCSymbolData;
00028 class raw_ostream;
00029 
00030 class MCELFStreamer : public MCObjectStreamer {
00031 public:
00032   MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
00033                 MCCodeEmitter *Emitter)
00034       : MCObjectStreamer(Context, TAB, OS, Emitter),
00035         SeenIdent(false) {}
00036 
00037   MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
00038                 MCCodeEmitter *Emitter, MCAssembler *Assembler)
00039       : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler),
00040         SeenIdent(false) {}
00041 
00042   virtual ~MCELFStreamer();
00043 
00044   /// state management
00045   void reset() override {
00046     LocalCommons.clear();
00047     BindingExplicitlySet.clear();
00048     SeenIdent = false;
00049     MCObjectStreamer::reset();
00050   }
00051 
00052   /// @name MCStreamer Interface
00053   /// @{
00054 
00055   void InitSections() override;
00056   void ChangeSection(const MCSection *Section,
00057                      const MCExpr *Subsection) override;
00058   void EmitLabel(MCSymbol *Symbol) override;
00059   void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
00060   void EmitThumbFunc(MCSymbol *Func) override;
00061   void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
00062   bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
00063   void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
00064   void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
00065                         unsigned ByteAlignment) override;
00066   void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
00067   void EmitCOFFSymbolStorageClass(int StorageClass) override;
00068   void EmitCOFFSymbolType(int Type) override;
00069   void EndCOFFSymbolDef() override;
00070 
00071   void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
00072 
00073   void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
00074                              unsigned ByteAlignment) override;
00075 
00076   void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = nullptr,
00077                     uint64_t Size = 0, unsigned ByteAlignment = 0) override;
00078   void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
00079                       uint64_t Size, unsigned ByteAlignment = 0) override;
00080   void EmitValueImpl(const MCExpr *Value, unsigned Size,
00081                      const SMLoc &Loc = SMLoc()) override;
00082 
00083   void EmitFileDirective(StringRef Filename) override;
00084 
00085   void EmitIdent(StringRef IdentString) override;
00086 
00087   void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
00088 
00089   void Flush() override;
00090 
00091   void FinishImpl() override;
00092 
00093   void EmitBundleAlignMode(unsigned AlignPow2) override;
00094   void EmitBundleLock(bool AlignToEnd) override;
00095   void EmitBundleUnlock() override;
00096 
00097 private:
00098   void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
00099   void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
00100 
00101   void fixSymbolsInTLSFixups(const MCExpr *expr);
00102 
00103   bool SeenIdent;
00104 
00105   struct LocalCommon {
00106     MCSymbolData *SD;
00107     uint64_t Size;
00108     unsigned ByteAlignment;
00109   };
00110 
00111   std::vector<LocalCommon> LocalCommons;
00112 
00113   SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
00114 };
00115 
00116 MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
00117                                     raw_ostream &OS, MCCodeEmitter *Emitter,
00118                                     bool RelaxAll, bool NoExecStack,
00119                                     bool IsThumb);
00120 
00121 } // end namespace llvm
00122 
00123 #endif