1 //===- MCELFStreamer.h - MCStreamer ELF Object File Interface ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCELFSTREAMER_H
11 #define LLVM_MC_MCELFSTREAMER_H
13 #include "llvm/ADT/SmallPtrSet.h"
14 #include "llvm/MC/MCDirectives.h"
15 #include "llvm/MC/MCObjectStreamer.h"
16 #include "llvm/MC/SectionKind.h"
17 #include "llvm/Support/DataTypes.h"
28 class MCELFStreamer : public MCObjectStreamer {
30 MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS,
31 MCCodeEmitter *Emitter)
32 : MCObjectStreamer(Context, TAB, OS, Emitter), SeenIdent(false) {}
34 ~MCELFStreamer() override;
37 void reset() override {
41 MCObjectStreamer::reset();
44 /// \name MCStreamer Interface
47 void InitSections(bool NoExecStack) override;
48 void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
49 void EmitLabel(MCSymbol *Symbol) override;
50 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
51 void EmitThumbFunc(MCSymbol *Func) override;
52 void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
53 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
54 void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
55 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
56 unsigned ByteAlignment) override;
57 void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
58 void EmitCOFFSymbolStorageClass(int StorageClass) override;
59 void EmitCOFFSymbolType(int Type) override;
60 void EndCOFFSymbolDef() override;
62 void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) override;
64 void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
65 unsigned ByteAlignment) override;
67 void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
68 uint64_t Size = 0, unsigned ByteAlignment = 0) override;
69 void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
70 unsigned ByteAlignment = 0) override;
71 void EmitValueImpl(const MCExpr *Value, unsigned Size,
72 const SMLoc &Loc = SMLoc()) override;
74 void EmitFileDirective(StringRef Filename) override;
76 void EmitIdent(StringRef IdentString) override;
78 void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
80 void Flush() override;
82 void FinishImpl() override;
84 void EmitBundleAlignMode(unsigned AlignPow2) override;
85 void EmitBundleLock(bool AlignToEnd) override;
86 void EmitBundleUnlock() override;
89 bool isBundleLocked() const;
90 void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
91 void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
93 void fixSymbolsInTLSFixups(const MCExpr *expr);
95 /// \brief Merge the content of the fragment \p EF into the fragment \p DF.
96 void mergeFragment(MCDataFragment *, MCEncodedFragmentWithFixups *);
101 const MCSymbol *Symbol;
103 unsigned ByteAlignment;
106 std::vector<LocalCommon> LocalCommons;
108 /// BundleGroups - The stack of fragments holding the bundle-locked
110 llvm::SmallVector<MCDataFragment *, 4> BundleGroups;
113 MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
114 raw_pwrite_stream &OS,
115 MCCodeEmitter *Emitter, bool RelaxAll,
118 } // end namespace llvm