1 //==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- C++ -*-==//
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
7 //===----------------------------------------------------------------------===//
10 /// This file declares WebAssembly-specific target streamer classes.
11 /// These are for implementing support for target-specific assembly directives.
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"
27 /// WebAssembly-specific streamer interface, to implement support
28 /// WebAssembly-specific assembly directives.
29 class WebAssemblyTargetStreamer
: public MCTargetStreamer
{
31 explicit WebAssemblyTargetStreamer(MCStreamer
&S
);
34 virtual void emitLocal(ArrayRef
<wasm::ValType
> Types
) = 0;
36 virtual void emitEndFunc() = 0;
38 virtual void emitFunctionType(const MCSymbolWasm
*Sym
) = 0;
40 virtual void emitIndIdx(const MCExpr
*Value
) = 0;
42 virtual void emitGlobalType(const MCSymbolWasm
*Sym
) = 0;
44 virtual void emitEventType(const MCSymbolWasm
*Sym
) = 0;
46 virtual void emitImportModule(const MCSymbolWasm
*Sym
,
47 StringRef ImportModule
) = 0;
49 virtual void emitImportName(const MCSymbolWasm
*Sym
,
50 StringRef ImportName
) = 0;
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
;
61 WebAssemblyTargetAsmStreamer(MCStreamer
&S
, formatted_raw_ostream
&OS
);
63 void emitLocal(ArrayRef
<wasm::ValType
> Types
) override
;
64 void emitEndFunc() override
;
65 void emitFunctionType(const MCSymbolWasm
*Sym
) override
;
66 void emitIndIdx(const MCExpr
*Value
) override
;
67 void emitGlobalType(const MCSymbolWasm
*Sym
) override
;
68 void emitEventType(const MCSymbolWasm
*Sym
) override
;
69 void emitImportModule(const MCSymbolWasm
*Sym
, StringRef ImportModule
) override
;
70 void emitImportName(const MCSymbolWasm
*Sym
, StringRef ImportName
) override
;
73 /// This part is for Wasm object output
74 class WebAssemblyTargetWasmStreamer final
: public WebAssemblyTargetStreamer
{
76 explicit WebAssemblyTargetWasmStreamer(MCStreamer
&S
);
78 void emitLocal(ArrayRef
<wasm::ValType
> Types
) override
;
79 void emitEndFunc() override
;
80 void emitFunctionType(const MCSymbolWasm
*Sym
) override
{}
81 void emitIndIdx(const MCExpr
*Value
) override
;
82 void emitGlobalType(const MCSymbolWasm
*Sym
) override
{}
83 void emitEventType(const MCSymbolWasm
*Sym
) override
{}
84 void emitImportModule(const MCSymbolWasm
*Sym
,
85 StringRef ImportModule
) override
{}
86 void emitImportName(const MCSymbolWasm
*Sym
,
87 StringRef ImportName
) override
{}
90 /// This part is for null output
91 class WebAssemblyTargetNullStreamer final
: public WebAssemblyTargetStreamer
{
93 explicit WebAssemblyTargetNullStreamer(MCStreamer
&S
)
94 : WebAssemblyTargetStreamer(S
) {}
96 void emitLocal(ArrayRef
<wasm::ValType
>) override
{}
97 void emitEndFunc() override
{}
98 void emitFunctionType(const MCSymbolWasm
*) override
{}
99 void emitIndIdx(const MCExpr
*) override
{}
100 void emitGlobalType(const MCSymbolWasm
*) override
{}
101 void emitEventType(const MCSymbolWasm
*) override
{}
102 void emitImportModule(const MCSymbolWasm
*, StringRef
) override
{}
103 void emitImportName(const MCSymbolWasm
*, StringRef
) override
{}
106 } // end namespace llvm