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 63 void emitIdent(StringRef IdentString) override; 64 65 void finishImpl() override; 66 67 private: 68 void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override; 69 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; 70 71 /// Merge the content of the fragment \p EF into the fragment \p DF. 72 void mergeFragment(MCDataFragment *, MCDataFragment *); 73 74 bool SeenIdent; 75 }; 76 77 } // end namespace llvm 78 79 #endif 80