1 //===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_MC_MCWASMSTREAMER_H 10 #define LLVM_MC_MCWASMSTREAMER_H 11 12 #include "MCAsmBackend.h" 13 #include "MCCodeEmitter.h" 14 #include "llvm/MC/MCDirectives.h" 15 #include "llvm/MC/MCObjectStreamer.h" 16 #include "llvm/MC/MCObjectWriter.h" 17 #include "llvm/Support/DataTypes.h" 18 19 namespace llvm { 20 class MCExpr; 21 class MCInst; 22 23 class MCWasmStreamer : public MCObjectStreamer { 24 public: MCWasmStreamer(MCContext & Context,std::unique_ptr<MCAsmBackend> TAB,std::unique_ptr<MCObjectWriter> OW,std::unique_ptr<MCCodeEmitter> Emitter)25 MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB, 26 std::unique_ptr<MCObjectWriter> OW, 27 std::unique_ptr<MCCodeEmitter> Emitter) 28 : MCObjectStreamer(Context, std::move(TAB), std::move(OW), 29 std::move(Emitter)), 30 SeenIdent(false) {} 31 32 ~MCWasmStreamer() override; 33 34 /// state management reset()35 void reset() override { 36 SeenIdent = false; 37 MCObjectStreamer::reset(); 38 } 39 40 /// \name MCStreamer Interface 41 /// @{ 42 43 void changeSection(MCSection *Section, const MCExpr *Subsection) override; 44 void emitAssemblerFlag(MCAssemblerFlag Flag) override; 45 void emitThumbFunc(MCSymbol *Func) override; 46 void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override; 47 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; 48 void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override; 49 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, 50 unsigned ByteAlignment) override; 51 52 void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; 53 54 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 55 unsigned ByteAlignment) override; 56 57 void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, 58 uint64_t Size = 0, unsigned ByteAlignment = 0, 59 SMLoc Loc = SMLoc()) override; 60 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, 61 unsigned ByteAlignment = 0) override; 62 void emitValueImpl(const MCExpr *Value, unsigned Size, 63 SMLoc Loc = SMLoc()) override; 64 65 void emitIdent(StringRef IdentString) override; 66 67 void emitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override; 68 69 void finishImpl() override; 70 71 private: 72 void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override; 73 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; 74 75 /// Merge the content of the fragment \p EF into the fragment \p DF. 76 void mergeFragment(MCDataFragment *, MCDataFragment *); 77 78 bool SeenIdent; 79 }; 80 81 } // end namespace llvm 82 83 #endif 84