Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_MC_MCWASMSTREAMER_H |
| 10 | #define LLVM_MC_MCWASMSTREAMER_H |
| 11 | |
| 12 | #include "MCAsmBackend.h" |
| 13 | #include "MCCodeEmitter.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 14 | #include "llvm/MC/MCDirectives.h" |
| 15 | #include "llvm/MC/MCObjectStreamer.h" |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 16 | #include "llvm/MC/MCObjectWriter.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 17 | #include "llvm/Support/DataTypes.h" |
| 18 | |
| 19 | namespace llvm { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 20 | class MCExpr; |
| 21 | class MCInst; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 22 | |
| 23 | class MCWasmStreamer : public MCObjectStreamer { |
| 24 | public: |
| 25 | MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 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)), |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 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, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 50 | unsigned ByteAlignment) override; |
| 51 | |
| 52 | void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override; |
| 53 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 54 | void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 55 | unsigned ByteAlignment) override; |
| 56 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 57 | void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 58 | uint64_t Size = 0, unsigned ByteAlignment = 0, |
| 59 | SMLoc Loc = SMLoc()) override; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 60 | void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 61 | unsigned ByteAlignment = 0) override; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 62 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 63 | void emitIdent(StringRef IdentString) override; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 64 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 65 | void finishImpl() override; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 66 | |
| 67 | private: |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 68 | void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override; |
| 69 | void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 70 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 71 | /// Merge the content of the fragment \p EF into the fragment \p DF. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 72 | void mergeFragment(MCDataFragment *, MCDataFragment *); |
| 73 | |
| 74 | bool SeenIdent; |
| 75 | }; |
| 76 | |
| 77 | } // end namespace llvm |
| 78 | |
| 79 | #endif |