Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / Target / WebAssembly / MCTargetDesc / WebAssemblyTargetStreamer.h
blob5ea62b179d22f6ac9312e25ec951afeccf3c2f9d
1 //==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- 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 /// \file
10 /// This file declares WebAssembly-specific target streamer classes.
11 /// These are for implementing support for target-specific assembly directives.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
18 #include "llvm/BinaryFormat/Wasm.h"
19 #include "llvm/MC/MCStreamer.h"
20 #include "llvm/Support/MachineValueType.h"
22 namespace llvm {
24 class MCWasmStreamer;
25 class MCSymbolWasm;
27 /// WebAssembly-specific streamer interface, to implement support
28 /// WebAssembly-specific assembly directives.
29 class WebAssemblyTargetStreamer : public MCTargetStreamer {
30 public:
31 explicit WebAssemblyTargetStreamer(MCStreamer &S);
33 /// .local
34 virtual void emitLocal(ArrayRef<wasm::ValType> Types) = 0;
35 /// .endfunc
36 virtual void emitEndFunc() = 0;
37 /// .functype
38 virtual void emitFunctionType(const MCSymbolWasm *Sym) = 0;
39 /// .indidx
40 virtual void emitIndIdx(const MCExpr *Value) = 0;
41 /// .globaltype
42 virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;
43 /// .eventtype
44 virtual void emitEventType(const MCSymbolWasm *Sym) = 0;
45 /// .import_module
46 virtual void emitImportModule(const MCSymbolWasm *Sym,
47 StringRef ImportModule) = 0;
48 /// .import_name
49 virtual void emitImportName(const MCSymbolWasm *Sym,
50 StringRef ImportName) = 0;
52 protected:
53 void emitValueType(wasm::ValType Type);
56 /// This part is for ascii assembly output
57 class WebAssemblyTargetAsmStreamer final : public WebAssemblyTargetStreamer {
58 formatted_raw_ostream &OS;
59 void emitSignature(const wasm::WasmSignature *Sig);
60 void emitParamList(const wasm::WasmSignature *Sig);
61 void emitReturnList(const wasm::WasmSignature *Sig);
63 public:
64 WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
66 void emitLocal(ArrayRef<wasm::ValType> Types) override;
67 void emitEndFunc() override;
68 void emitFunctionType(const MCSymbolWasm *Sym) override;
69 void emitIndIdx(const MCExpr *Value) override;
70 void emitGlobalType(const MCSymbolWasm *Sym) override;
71 void emitEventType(const MCSymbolWasm *Sym) override;
72 void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
73 void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
76 /// This part is for Wasm object output
77 class WebAssemblyTargetWasmStreamer final : public WebAssemblyTargetStreamer {
78 public:
79 explicit WebAssemblyTargetWasmStreamer(MCStreamer &S);
81 void emitLocal(ArrayRef<wasm::ValType> Types) override;
82 void emitEndFunc() override;
83 void emitFunctionType(const MCSymbolWasm *Sym) override {}
84 void emitIndIdx(const MCExpr *Value) override;
85 void emitGlobalType(const MCSymbolWasm *Sym) override {}
86 void emitEventType(const MCSymbolWasm *Sym) override {}
87 void emitImportModule(const MCSymbolWasm *Sym,
88 StringRef ImportModule) override {}
89 void emitImportName(const MCSymbolWasm *Sym,
90 StringRef ImportName) override {}
93 /// This part is for null output
94 class WebAssemblyTargetNullStreamer final : public WebAssemblyTargetStreamer {
95 public:
96 explicit WebAssemblyTargetNullStreamer(MCStreamer &S)
97 : WebAssemblyTargetStreamer(S) {}
99 void emitLocal(ArrayRef<wasm::ValType>) override {}
100 void emitEndFunc() override {}
101 void emitFunctionType(const MCSymbolWasm *) override {}
102 void emitIndIdx(const MCExpr *) override {}
103 void emitGlobalType(const MCSymbolWasm *) override {}
104 void emitEventType(const MCSymbolWasm *) override {}
105 void emitImportModule(const MCSymbolWasm *, StringRef) override {}
106 void emitImportName(const MCSymbolWasm *, StringRef) override {}
109 } // end namespace llvm
111 #endif