blob: 6651f071f799dcbdbe43e8b4dc2edea20c3957b5 [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"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010014#include "llvm/MC/MCDirectives.h"
15#include "llvm/MC/MCObjectStreamer.h"
Andrew Scullcdfcccc2018-10-05 20:58:37 +010016#include "llvm/MC/MCObjectWriter.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010017#include "llvm/Support/DataTypes.h"
18
19namespace llvm {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010020class MCExpr;
21class MCInst;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022
23class MCWasmStreamer : public MCObjectStreamer {
24public:
25 MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010026 std::unique_ptr<MCObjectWriter> OW,
27 std::unique_ptr<MCCodeEmitter> Emitter)
28 : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
29 std::move(Emitter)),
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010030 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
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020043 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,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010050 unsigned ByteAlignment) override;
51
52 void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
53
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020054 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010055 unsigned ByteAlignment) override;
56
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020057 void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
Andrew Scullcdfcccc2018-10-05 20:58:37 +010058 uint64_t Size = 0, unsigned ByteAlignment = 0,
59 SMLoc Loc = SMLoc()) override;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020060 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010061 unsigned ByteAlignment = 0) override;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010062
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020063 void emitIdent(StringRef IdentString) override;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010064
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020065 void finishImpl() override;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010066
67private:
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020068 void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
69 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010070
Andrew Scullcdfcccc2018-10-05 20:58:37 +010071 /// Merge the content of the fragment \p EF into the fragment \p DF.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010072 void mergeFragment(MCDataFragment *, MCDataFragment *);
73
74 bool SeenIdent;
75};
76
77} // end namespace llvm
78
79#endif