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
19namespace llvm {
20class MCExpr;
21class MCInst;
22
23class MCWasmStreamer : public MCObjectStreamer {
24public:
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
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 emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
45 void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
46 uint64_t Offset) override;
47 void emitAssemblerFlag(MCAssemblerFlag Flag) override;
48 void emitThumbFunc(MCSymbol *Func) override;
49 void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
50 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
51 void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
52 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
53 Align ByteAlignment) override;
54
55 void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
56
57 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
58 Align ByteAlignment) override;
59
60 void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
61 uint64_t Size = 0, Align ByteAlignment = Align(1),
62 SMLoc Loc = SMLoc()) override;
63 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
64 Align ByteAlignment = Align(1)) override;
65
66 void emitIdent(StringRef IdentString) override;
67
68 void finishImpl() override;
69
70private:
71 void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
72 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
73
74 void fixSymbolsInTLSFixups(const MCExpr *expr);
75
76 /// 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
85

source code of llvm/include/llvm/MC/MCWasmStreamer.h