LLVM  8.0.1
WebAssemblyTargetStreamer.h
Go to the documentation of this file.
1 //==-- WebAssemblyTargetStreamer.h - WebAssembly Target Streamer -*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file declares WebAssembly-specific target streamer classes.
12 /// These are for implementing support for target-specific assembly directives.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
17 #define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYTARGETSTREAMER_H
18 
19 #include "llvm/BinaryFormat/Wasm.h"
20 #include "llvm/MC/MCStreamer.h"
22 
23 namespace llvm {
24 
25 class MCWasmStreamer;
26 class MCSymbolWasm;
27 
28 /// WebAssembly-specific streamer interface, to implement support
29 /// WebAssembly-specific assembly directives.
31 public:
33 
34  /// .local
35  virtual void emitLocal(ArrayRef<wasm::ValType> Types) = 0;
36  /// .endfunc
37  virtual void emitEndFunc() = 0;
38  /// .functype
39  virtual void emitFunctionType(const MCSymbolWasm *Sym) = 0;
40  /// .indidx
41  virtual void emitIndIdx(const MCExpr *Value) = 0;
42  /// .globaltype
43  virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;
44  /// .eventtype
45  virtual void emitEventType(const MCSymbolWasm *Sym) = 0;
46  /// .import_module
47  virtual void emitImportModule(const MCSymbolWasm *Sym,
48  StringRef ImportModule) = 0;
49  /// .import_name
50  virtual void emitImportName(const MCSymbolWasm *Sym,
51  StringRef ImportName) = 0;
52 
53 protected:
55 };
56 
57 /// This part is for ascii assembly output
60  void emitSignature(const wasm::WasmSignature *Sig);
61  void emitParamList(const wasm::WasmSignature *Sig);
62  void emitReturnList(const wasm::WasmSignature *Sig);
63 
64 public:
66 
67  void emitLocal(ArrayRef<wasm::ValType> Types) override;
68  void emitEndFunc() override;
69  void emitFunctionType(const MCSymbolWasm *Sym) override;
70  void emitIndIdx(const MCExpr *Value) override;
71  void emitGlobalType(const MCSymbolWasm *Sym) override;
72  void emitEventType(const MCSymbolWasm *Sym) override;
73  void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
74  void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
75 };
76 
77 /// This part is for Wasm object output
79 public:
81 
82  void emitLocal(ArrayRef<wasm::ValType> Types) override;
83  void emitEndFunc() override;
84  void emitFunctionType(const MCSymbolWasm *Sym) override {}
85  void emitIndIdx(const MCExpr *Value) override;
86  void emitGlobalType(const MCSymbolWasm *Sym) override {}
87  void emitEventType(const MCSymbolWasm *Sym) override {}
88  void emitImportModule(const MCSymbolWasm *Sym,
89  StringRef ImportModule) override {}
90  void emitImportName(const MCSymbolWasm *Sym,
91  StringRef ImportName) override {}
92 };
93 
94 /// This part is for null output
96 public:
99 
101  void emitEndFunc() override {}
102  void emitFunctionType(const MCSymbolWasm *) override {}
103  void emitIndIdx(const MCExpr *) override {}
104  void emitGlobalType(const MCSymbolWasm *) override {}
105  void emitEventType(const MCSymbolWasm *) override {}
106  void emitImportModule(const MCSymbolWasm *, StringRef) override {}
107  void emitImportName(const MCSymbolWasm *, StringRef) override {}
108 };
109 
110 } // end namespace llvm
111 
112 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override
.import_name
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:84
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule)=0
.import_module
void emitLocal(ArrayRef< wasm::ValType >) override
.local
void emitImportModule(const MCSymbolWasm *, StringRef) override
.import_module
void emitIndIdx(const MCExpr *) override
.indidx
void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override
.import_module
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
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:33
virtual void emitEndFunc()=0
.endfunc
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
Streaming machine code generation interface.
Definition: MCStreamer.h:189
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void emitEventType(const MCSymbolWasm *) override
.eventtype
This part is for ascii assembly output.
void emitImportName(const MCSymbolWasm *, StringRef) override
.import_name
void emitFunctionType(const MCSymbolWasm *) override
.functype
void emitGlobalType(const MCSymbolWasm *) override
.globaltype
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
virtual void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName)=0
.import_name
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:73
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx