LLVM  14.0.0git
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 MCSymbolWasm;
25 class formatted_raw_ostream;
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  /// .tabletype
44  virtual void emitTableType(const MCSymbolWasm *Sym) = 0;
45  /// .tagtype
46  virtual void emitTagType(const MCSymbolWasm *Sym) = 0;
47  /// .import_module
48  virtual void emitImportModule(const MCSymbolWasm *Sym,
49  StringRef ImportModule) = 0;
50  /// .import_name
51  virtual void emitImportName(const MCSymbolWasm *Sym,
52  StringRef ImportName) = 0;
53  /// .export_name
54  virtual void emitExportName(const MCSymbolWasm *Sym,
55  StringRef ExportName) = 0;
56 
57 protected:
59 };
60 
61 /// This part is for ascii assembly output
64 
65 public:
67 
68  void emitLocal(ArrayRef<wasm::ValType> Types) override;
69  void emitEndFunc() override;
70  void emitFunctionType(const MCSymbolWasm *Sym) override;
71  void emitIndIdx(const MCExpr *Value) override;
72  void emitGlobalType(const MCSymbolWasm *Sym) override;
73  void emitTableType(const MCSymbolWasm *Sym) override;
74  void emitTagType(const MCSymbolWasm *Sym) override;
75  void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
76  void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
77  void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
78 };
79 
80 /// This part is for Wasm object output
82 public:
84 
85  void emitLocal(ArrayRef<wasm::ValType> Types) override;
86  void emitEndFunc() override;
87  void emitFunctionType(const MCSymbolWasm *Sym) override {}
88  void emitIndIdx(const MCExpr *Value) override;
89  void emitGlobalType(const MCSymbolWasm *Sym) override {}
90  void emitTableType(const MCSymbolWasm *Sym) override {}
91  void emitTagType(const MCSymbolWasm *Sym) override {}
92  void emitImportModule(const MCSymbolWasm *Sym,
93  StringRef ImportModule) override {}
94  void emitImportName(const MCSymbolWasm *Sym,
95  StringRef ImportName) override {}
96  void emitExportName(const MCSymbolWasm *Sym,
97  StringRef ExportName) override {}
98 };
99 
100 /// This part is for null output
102 public:
105 
107  void emitEndFunc() override {}
108  void emitFunctionType(const MCSymbolWasm *) override {}
109  void emitIndIdx(const MCExpr *) override {}
110  void emitGlobalType(const MCSymbolWasm *) override {}
111  void emitTableType(const MCSymbolWasm *) override {}
112  void emitTagType(const MCSymbolWasm *) override {}
113  void emitImportModule(const MCSymbolWasm *, StringRef) override {}
114  void emitImportName(const MCSymbolWasm *, StringRef) override {}
115  void emitExportName(const MCSymbolWasm *, StringRef) override {}
116 };
117 
118 } // end namespace llvm
119 
120 #endif
llvm::WebAssemblyTargetStreamer::emitLocal
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::WebAssemblyTargetStreamer
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
Definition: WebAssemblyTargetStreamer.h:29
llvm::WebAssemblyTargetWasmStreamer::emitIndIdx
void emitIndIdx(const MCExpr *Value) override
.indidx
Definition: WebAssemblyTargetStreamer.cpp:143
llvm::WebAssemblyTargetNullStreamer
This part is for null output.
Definition: WebAssemblyTargetStreamer.h:101
llvm::WebAssemblyTargetWasmStreamer::emitLocal
void emitLocal(ArrayRef< wasm::ValType > Types) override
.local
Definition: WebAssemblyTargetStreamer.cpp:123
llvm::WebAssemblyTargetAsmStreamer::emitImportName
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override
.import_name
Definition: WebAssemblyTargetStreamer.cpp:107
llvm::WebAssemblyTargetAsmStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *Sym) override
.functype
Definition: WebAssemblyTargetStreamer.cpp:63
llvm::WebAssemblyTargetStreamer::emitIndIdx
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx
llvm::WebAssemblyTargetWasmStreamer::emitEndFunc
void emitEndFunc() override
.endfunc
Definition: WebAssemblyTargetStreamer.cpp:139
llvm::WebAssemblyTargetNullStreamer::WebAssemblyTargetNullStreamer
WebAssemblyTargetNullStreamer(MCStreamer &S)
Definition: WebAssemblyTargetStreamer.h:103
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::WebAssemblyTargetAsmStreamer::emitEndFunc
void emitEndFunc() override
.endfunc
Definition: WebAssemblyTargetStreamer.cpp:61
llvm::WebAssemblyTargetNullStreamer::emitEndFunc
void emitEndFunc() override
.endfunc
Definition: WebAssemblyTargetStreamer.h:107
llvm::WebAssemblyTargetNullStreamer::emitImportName
void emitImportName(const MCSymbolWasm *, StringRef) override
.import_name
Definition: WebAssemblyTargetStreamer.h:114
llvm::WebAssemblyTargetWasmStreamer::emitExportName
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override
.export_name
Definition: WebAssemblyTargetStreamer.h:96
llvm::WebAssemblyTargetAsmStreamer::WebAssemblyTargetAsmStreamer
WebAssemblyTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
Definition: WebAssemblyTargetStreamer.cpp:34
llvm::WebAssemblyTargetStreamer::emitImportModule
virtual void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule)=0
.import_module
llvm::WebAssemblyTargetWasmStreamer::emitTableType
void emitTableType(const MCSymbolWasm *Sym) override
.tabletype
Definition: WebAssemblyTargetStreamer.h:90
MachineValueType.h
llvm::WebAssemblyTargetStreamer::emitFunctionType
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::WebAssemblyTargetStreamer::emitEndFunc
virtual void emitEndFunc()=0
.endfunc
llvm::WebAssemblyTargetStreamer::emitExportName
virtual void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName)=0
.export_name
llvm::WebAssemblyTargetStreamer::emitTableType
virtual void emitTableType(const MCSymbolWasm *Sym)=0
.tabletype
llvm::WebAssemblyTargetStreamer::emitImportName
virtual void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName)=0
.import_name
llvm::WebAssemblyTargetWasmStreamer::emitImportModule
void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override
.import_module
Definition: WebAssemblyTargetStreamer.h:92
llvm::wasm::ValType
ValType
Definition: Wasm.h:410
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
llvm::WebAssemblyTargetAsmStreamer::emitExportName
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override
.export_name
Definition: WebAssemblyTargetStreamer.cpp:113
llvm::WebAssemblyTargetNullStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *) override
.functype
Definition: WebAssemblyTargetStreamer.h:108
llvm::WebAssemblyTargetAsmStreamer::emitLocal
void emitLocal(ArrayRef< wasm::ValType > Types) override
.local
Definition: WebAssemblyTargetStreamer.cpp:54
llvm::WebAssemblyTargetNullStreamer::emitGlobalType
void emitGlobalType(const MCSymbolWasm *) override
.globaltype
Definition: WebAssemblyTargetStreamer.h:110
llvm::WebAssemblyTargetAsmStreamer::emitIndIdx
void emitIndIdx(const MCExpr *Value) override
.indidx
Definition: WebAssemblyTargetStreamer.cpp:119
llvm::MCSymbolWasm
Definition: MCSymbolWasm.h:16
llvm::WebAssemblyTargetWasmStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *Sym) override
.functype
Definition: WebAssemblyTargetStreamer.h:87
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
llvm::WebAssemblyTargetWasmStreamer::emitGlobalType
void emitGlobalType(const MCSymbolWasm *Sym) override
.globaltype
Definition: WebAssemblyTargetStreamer.h:89
llvm::WebAssemblyTargetAsmStreamer::emitTableType
void emitTableType(const MCSymbolWasm *Sym) override
.tabletype
Definition: WebAssemblyTargetStreamer.cpp:80
llvm::WebAssemblyTargetWasmStreamer::emitTagType
void emitTagType(const MCSymbolWasm *Sym) override
.tagtype
Definition: WebAssemblyTargetStreamer.h:91
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::WebAssemblyTargetNullStreamer::emitTableType
void emitTableType(const MCSymbolWasm *) override
.tabletype
Definition: WebAssemblyTargetStreamer.h:111
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::WebAssemblyTargetAsmStreamer::emitImportModule
void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override
.import_module
Definition: WebAssemblyTargetStreamer.cpp:101
llvm::WebAssemblyTargetStreamer::WebAssemblyTargetStreamer
WebAssemblyTargetStreamer(MCStreamer &S)
Definition: WebAssemblyTargetStreamer.cpp:27
llvm::WebAssemblyTargetWasmStreamer
This part is for Wasm object output.
Definition: WebAssemblyTargetStreamer.h:81
llvm::WebAssemblyTargetAsmStreamer::emitTagType
void emitTagType(const MCSymbolWasm *Sym) override
.tagtype
Definition: WebAssemblyTargetStreamer.cpp:94
llvm::WebAssemblyTargetNullStreamer::emitImportModule
void emitImportModule(const MCSymbolWasm *, StringRef) override
.import_module
Definition: WebAssemblyTargetStreamer.h:113
llvm::WebAssemblyTargetAsmStreamer
This part is for ascii assembly output.
Definition: WebAssemblyTargetStreamer.h:62
llvm::WebAssemblyTargetWasmStreamer::emitImportName
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override
.import_name
Definition: WebAssemblyTargetStreamer.h:94
Wasm.h
llvm::WebAssemblyTargetNullStreamer::emitLocal
void emitLocal(ArrayRef< wasm::ValType >) override
.local
Definition: WebAssemblyTargetStreamer.h:106
MCStreamer.h
llvm::WebAssemblyTargetNullStreamer::emitExportName
void emitExportName(const MCSymbolWasm *, StringRef) override
.export_name
Definition: WebAssemblyTargetStreamer.h:115
llvm::WebAssemblyTargetWasmStreamer::WebAssemblyTargetWasmStreamer
WebAssemblyTargetWasmStreamer(MCStreamer &S)
Definition: WebAssemblyTargetStreamer.cpp:38
llvm::WebAssemblyTargetStreamer::emitTagType
virtual void emitTagType(const MCSymbolWasm *Sym)=0
.tagtype
llvm::WebAssemblyTargetStreamer::emitValueType
void emitValueType(wasm::ValType Type)
Definition: WebAssemblyTargetStreamer.cpp:30
llvm::WebAssemblyTargetNullStreamer::emitTagType
void emitTagType(const MCSymbolWasm *) override
.tagtype
Definition: WebAssemblyTargetStreamer.h:112
llvm::WebAssemblyTargetStreamer::emitGlobalType
virtual void emitGlobalType(const MCSymbolWasm *Sym)=0
.globaltype
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::WebAssemblyTargetAsmStreamer::emitGlobalType
void emitGlobalType(const MCSymbolWasm *Sym) override
.globaltype
Definition: WebAssemblyTargetStreamer.cpp:70
llvm::WebAssemblyTargetNullStreamer::emitIndIdx
void emitIndIdx(const MCExpr *) override
.indidx
Definition: WebAssemblyTargetStreamer.h:109