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 {
40 BindingExplicitlySet.clear();
42 MCObjectStreamer::reset();
45 /// \name MCStreamer Interface
48 void InitSections(bool NoExecStack) override;
49 void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
50 void EmitLabel(MCSymbol *Symbol) override;
51 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
52 void EmitThumbFunc(MCSymbol *Func) override;
53 void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
54 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
55 void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
56 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
57 unsigned ByteAlignment) override;
58 void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
59 void EmitCOFFSymbolStorageClass(int StorageClass) override;
60 void EmitCOFFSymbolType(int Type) override;
61 void EndCOFFSymbolDef() override;
63 void emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) override;
65 void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
66 unsigned ByteAlignment) override;
68 void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
69 uint64_t Size = 0, unsigned ByteAlignment = 0) override;
70 void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
71 unsigned ByteAlignment = 0) override;
72 void EmitValueImpl(const MCExpr *Value, unsigned Size,
73 const SMLoc &Loc = SMLoc()) override;
75 void EmitFileDirective(StringRef Filename) override;
77 void EmitIdent(StringRef IdentString) override;
79 void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
81 void Flush() override;
83 void FinishImpl() override;
85 void EmitBundleAlignMode(unsigned AlignPow2) override;
86 void EmitBundleLock(bool AlignToEnd) override;
87 void EmitBundleUnlock() override;
90 bool isBundleLocked() const;
91 void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
92 void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
94 void fixSymbolsInTLSFixups(const MCExpr *expr);
96 /// \brief Merge the content of the fragment \p EF into the fragment \p DF.
97 void mergeFragment(MCDataFragment *, MCEncodedFragmentWithFixups *);
102 const MCSymbol *Symbol;
104 unsigned ByteAlignment;
107 std::vector<LocalCommon> LocalCommons;
109 SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
111 /// BundleGroups - The stack of fragments holding the bundle-locked
113 llvm::SmallVector<MCDataFragment *, 4> BundleGroups;
116 MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
117 raw_pwrite_stream &OS,
118 MCCodeEmitter *Emitter, bool RelaxAll,
121 } // end namespace llvm