blob: 2d7f2b9975c9d5293f55a8773177163daaaa656e [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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/ADT/SmallPtrSet.h"
15#include "llvm/MC/MCDirectives.h"
16#include "llvm/MC/MCObjectStreamer.h"
Andrew Scullcdfcccc2018-10-05 20:58:37 +010017#include "llvm/MC/MCObjectWriter.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010018#include "llvm/MC/SectionKind.h"
19#include "llvm/Support/DataTypes.h"
20
21namespace llvm {
22class MCAssembler;
23class MCExpr;
24class MCInst;
25class raw_ostream;
26
27class MCWasmStreamer : public MCObjectStreamer {
28public:
29 MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010030 std::unique_ptr<MCObjectWriter> OW,
31 std::unique_ptr<MCCodeEmitter> Emitter)
32 : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
33 std::move(Emitter)),
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010034 SeenIdent(false) {}
35
36 ~MCWasmStreamer() override;
37
38 /// state management
39 void reset() override {
40 SeenIdent = false;
41 MCObjectStreamer::reset();
42 }
43
44 /// \name MCStreamer Interface
45 /// @{
46
47 void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
48 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
49 void EmitThumbFunc(MCSymbol *Func) override;
50 void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
51 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
52 void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
53 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
54 unsigned ByteAlignment) override;
55
56 void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
57
58 void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
59 unsigned ByteAlignment) override;
60
61 void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010062 uint64_t Size = 0, unsigned ByteAlignment = 0,
63 SMLoc Loc = SMLoc()) override;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010064 void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
65 unsigned ByteAlignment = 0) override;
66 void EmitValueImpl(const MCExpr *Value, unsigned Size,
67 SMLoc Loc = SMLoc()) override;
68
69 void EmitIdent(StringRef IdentString) override;
70
71 void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
72
73 void FinishImpl() override;
74
75private:
76 void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
77 void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
78
Andrew Scullcdfcccc2018-10-05 20:58:37 +010079 /// Merge the content of the fragment \p EF into the fragment \p DF.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010080 void mergeFragment(MCDataFragment *, MCDataFragment *);
81
82 bool SeenIdent;
83};
84
85} // end namespace llvm
86
87#endif