LLVM  9.0.0svn
WebAssemblyTargetStreamer.h
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
16 #define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
17 
18 #include "llvm/BinaryFormat/Wasm.h"
19 #include "llvm/MC/MCStreamer.h"
21 
22 namespace llvm {
23 
24 class MCWasmStreamer;
25 class MCSymbolWasm;
26 
27 /// WebAssembly-specific streamer interface, to implement support
28 /// WebAssembly-specific assembly directives.
30 public:
32 
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 ModuleName) = 0;
48 
49 protected:
51 };
52 
53 /// This part is for ascii assembly output
56  void emitSignature(const wasm::WasmSignature *Sig);
57  void emitParamList(const wasm::WasmSignature *Sig);
58  void emitReturnList(const wasm::WasmSignature *Sig);
59 
60 public:
62 
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 ModuleName) override;
70 };
71 
72 /// This part is for Wasm object output
74 public:
76 
77  void emitLocal(ArrayRef<wasm::ValType> Types) override;
78  void emitEndFunc() override;
79  void emitFunctionType(const MCSymbolWasm *Sym) override {}
80  void emitIndIdx(const MCExpr *Value) override;
81  void emitGlobalType(const MCSymbolWasm *Sym) override {}
82  void emitEventType(const MCSymbolWasm *Sym) override {}
83  void emitImportModule(const MCSymbolWasm *Sym,
84  StringRef ModuleName) override {}
85 };
86 
87 /// This part is for null output
89 public:
92 
94  void emitEndFunc() override {}
95  void emitFunctionType(const MCSymbolWasm *) override {}
96  void emitIndIdx(const MCExpr *) override {}
97  void emitGlobalType(const MCSymbolWasm *) override {}
98  void emitEventType(const MCSymbolWasm *) override {}
99  void emitImportModule(const MCSymbolWasm *, StringRef) override {}
100 };
101 
102 } // end namespace llvm
103 
104 #endif
void emitImportModule(const MCSymbolWasm *Sym, StringRef ModuleName) override
.import_module
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void emitGlobalType(const MCSymbolWasm *Sym) override
.globaltype
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
virtual void emitGlobalType(const MCSymbolWasm *Sym)=0
.globaltype
Target specific streamer interface.
Definition: MCStreamer.h:83
void emitLocal(ArrayRef< wasm::ValType >) override
.local
void emitImportModule(const MCSymbolWasm *, StringRef) override
.import_module
void emitIndIdx(const MCExpr *) override
.indidx
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
void emitEventType(const MCSymbolWasm *Sym) override
.eventtype
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
virtual void emitEndFunc()=0
.endfunc
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
Streaming machine code generation interface.
Definition: MCStreamer.h:188
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
void emitEventType(const MCSymbolWasm *) override
.eventtype
This part is for ascii assembly output.
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ModuleName)=0
.import_module
void emitFunctionType(const MCSymbolWasm *) override
.functype
void emitGlobalType(const MCSymbolWasm *) override
.globaltype
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
This part is for Wasm object output.
void emitFunctionType(const MCSymbolWasm *Sym) override
.functype
virtual void emitEventType(const MCSymbolWasm *Sym)=0
.eventtype
LLVM Value Representation.
Definition: Value.h:72
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx