Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame^] | 1 | //===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_MC_MCWASMSTREAMER_H |
| 11 | #define LLVM_MC_MCWASMSTREAMER_H |
| 12 | |
| 13 | #include "MCAsmBackend.h" |
| 14 | #include "MCCodeEmitter.h" |
| 15 | #include "llvm/ADT/SmallPtrSet.h" |
| 16 | #include "llvm/MC/MCDirectives.h" |
| 17 | #include "llvm/MC/MCObjectStreamer.h" |
| 18 | #include "llvm/MC/SectionKind.h" |
| 19 | #include "llvm/Support/DataTypes.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class MCAssembler; |
| 23 | class MCExpr; |
| 24 | class MCInst; |
| 25 | class raw_ostream; |
| 26 | |
| 27 | class MCWasmStreamer : public MCObjectStreamer { |
| 28 | public: |
| 29 | MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB, |
| 30 | raw_pwrite_stream &OS, std::unique_ptr<MCCodeEmitter> Emitter) |
| 31 | : MCObjectStreamer(Context, std::move(TAB), OS, std::move(Emitter)), |
| 32 | SeenIdent(false) {} |
| 33 | |
| 34 | ~MCWasmStreamer() override; |
| 35 | |
| 36 | /// state management |
| 37 | void reset() override { |
| 38 | SeenIdent = false; |
| 39 | MCObjectStreamer::reset(); |
| 40 | } |
| 41 | |
| 42 | /// \name MCStreamer Interface |
| 43 | /// @{ |
| 44 | |
| 45 | void ChangeSection(MCSection *Section, const MCExpr *Subsection) override; |
| 46 | void EmitAssemblerFlag(MCAssemblerFlag Flag) override; |
| 47 | void EmitThumbFunc(MCSymbol *Func) override; |
| 48 | void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override; |
| 49 | bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; |
| 50 | void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; |
| 51 | void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 52 | unsigned ByteAlignment) override; |
| 53 | |
| 54 | void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; |
| 55 | |
| 56 | void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
| 57 | unsigned ByteAlignment) override; |
| 58 | |
| 59 | void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, |
| 60 | uint64_t Size = 0, unsigned ByteAlignment = 0) override; |
| 61 | void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, |
| 62 | unsigned ByteAlignment = 0) override; |
| 63 | void EmitValueImpl(const MCExpr *Value, unsigned Size, |
| 64 | SMLoc Loc = SMLoc()) override; |
| 65 | |
| 66 | void EmitIdent(StringRef IdentString) override; |
| 67 | |
| 68 | void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override; |
| 69 | |
| 70 | void FinishImpl() override; |
| 71 | |
| 72 | private: |
| 73 | void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override; |
| 74 | void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; |
| 75 | |
| 76 | /// \brief Merge the content of the fragment \p EF into the fragment \p DF. |
| 77 | void mergeFragment(MCDataFragment *, MCDataFragment *); |
| 78 | |
| 79 | bool SeenIdent; |
| 80 | }; |
| 81 | |
| 82 | } // end namespace llvm |
| 83 | |
| 84 | #endif |