LLVM  5.0.0
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 /// \brief 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"
21 #include "llvm/MC/MCStreamer.h"
22 
23 namespace llvm {
24 
25 class MCELFStreamer;
26 class MCWasmStreamer;
27 
28 /// WebAssembly-specific streamer interface, to implement support
29 /// WebAssembly-specific assembly directives.
31 public:
33 
34  /// .param
35  virtual void emitParam(MCSymbol *Symbol, ArrayRef<MVT> Types) = 0;
36  /// .result
37  virtual void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) = 0;
38  /// .local
39  virtual void emitLocal(ArrayRef<MVT> Types) = 0;
40  /// .globalvar
41  virtual void emitGlobal(ArrayRef<wasm::Global> Globals) = 0;
42  /// .stack_pointer
43  virtual void emitStackPointer(uint32_t Index) = 0;
44  /// .endfunc
45  virtual void emitEndFunc() = 0;
46  /// .functype
47  virtual void emitIndirectFunctionType(MCSymbol *Symbol,
48  SmallVectorImpl<MVT> &Params,
50  /// .indidx
51  virtual void emitIndIdx(const MCExpr *Value) = 0;
52  /// .import_global
53  virtual void emitGlobalImport(StringRef name) = 0;
54 
55 protected:
57 };
58 
59 /// This part is for ascii assembly output
62 
63 public:
65 
66  void emitParam(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
67  void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
68  void emitLocal(ArrayRef<MVT> Types) override;
69  void emitGlobal(ArrayRef<wasm::Global> Globals) override;
70  void emitStackPointer(uint32_t Index) override;
71  void emitEndFunc() override;
73  SmallVectorImpl<MVT> &Params,
74  SmallVectorImpl<MVT> &Results) override;
75  void emitIndIdx(const MCExpr *Value) override;
76  void emitGlobalImport(StringRef name) override;
77 };
78 
79 /// This part is for ELF object output
81 public:
83 
84  void emitParam(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
85  void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
86  void emitLocal(ArrayRef<MVT> Types) override;
87  void emitGlobal(ArrayRef<wasm::Global> Globals) override;
88  void emitStackPointer(uint32_t Index) override;
89  void emitEndFunc() override;
91  SmallVectorImpl<MVT> &Params,
92  SmallVectorImpl<MVT> &Results) override;
93  void emitIndIdx(const MCExpr *Value) override;
94  void emitGlobalImport(StringRef name) override;
95 };
96 
97 /// This part is for Wasm object output
99 public:
101 
102  void emitParam(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
103  void emitResult(MCSymbol *Symbol, ArrayRef<MVT> Types) override;
104  void emitLocal(ArrayRef<MVT> Types) override;
105  void emitGlobal(ArrayRef<wasm::Global> Globals) override;
106  void emitStackPointer(uint32_t Index) override;
107  void emitEndFunc() override;
108  void emitIndirectFunctionType(MCSymbol *Symbol,
109  SmallVectorImpl<MVT> &Params,
110  SmallVectorImpl<MVT> &Results) override;
111  void emitIndIdx(const MCExpr *Value) override;
112  void emitGlobalImport(StringRef name) override;
113 };
114 
115 } // end namespace llvm
116 
117 #endif
void emitLocal(ArrayRef< MVT > Types) override
.local
void emitIndirectFunctionType(MCSymbol *Symbol, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results) override
.functype
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target specific streamer interface.
Definition: MCStreamer.h:78
virtual void emitGlobalImport(StringRef name)=0
.import_global
Function Alias Analysis Results
void emitGlobalImport(StringRef name) override
.import_global
void emitLocal(ArrayRef< MVT > Types) override
.local
virtual void emitGlobal(ArrayRef< wasm::Global > Globals)=0
.globalvar
void emitParam(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.param
virtual void emitStackPointer(uint32_t Index)=0
.stack_pointer
void emitIndirectFunctionType(MCSymbol *Symbol, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results) override
.functype
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
void emitGlobal(ArrayRef< wasm::Global > Globals) override
.globalvar
void emitIndIdx(const MCExpr *Value) override
.indidx
void emitGlobalImport(StringRef name) override
.import_global
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
virtual void emitEndFunc()=0
.endfunc
void emitGlobal(ArrayRef< wasm::Global > Globals) override
.globalvar
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
void emitGlobal(ArrayRef< wasm::Global > Globals) override
.globalvar
Streaming machine code generation interface.
Definition: MCStreamer.h:167
virtual void emitResult(MCSymbol *Symbol, ArrayRef< MVT > Types)=0
.result
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void emitIndIdx(const MCExpr *Value) override
.indidx
void emitIndIdx(const MCExpr *Value) override
.indidx
This part is for ELF object output.
void emitStackPointer(uint32_t Index) override
.stack_pointer
void emitResult(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.result
This part is for ascii assembly output.
WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
virtual void emitIndirectFunctionType(MCSymbol *Symbol, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results)=0
.functype
void emitStackPointer(uint32_t Index) override
.stack_pointer
void emitParam(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.param
void emitIndirectFunctionType(MCSymbol *Symbol, SmallVectorImpl< MVT > &Params, SmallVectorImpl< MVT > &Results) override
.functype
This part is for Wasm object output.
void emitParam(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.param
virtual void emitParam(MCSymbol *Symbol, ArrayRef< MVT > Types)=0
.param
void emitLocal(ArrayRef< MVT > Types) override
.local
void emitGlobalImport(StringRef name) override
.import_global
void emitResult(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.result
LLVM Value Representation.
Definition: Value.h:73
static const char * name
void emitResult(MCSymbol *Symbol, ArrayRef< MVT > Types) override
.result
virtual void emitLocal(ArrayRef< MVT > Types)=0
.local
void emitStackPointer(uint32_t Index) override
.stack_pointer
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx