LLVM  15.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  /// .functype
36  virtual void emitFunctionType(const MCSymbolWasm *Sym) = 0;
37  /// .indidx
38  virtual void emitIndIdx(const MCExpr *Value) = 0;
39  /// .globaltype
40  virtual void emitGlobalType(const MCSymbolWasm *Sym) = 0;
41  /// .tabletype
42  virtual void emitTableType(const MCSymbolWasm *Sym) = 0;
43  /// .tagtype
44  virtual void emitTagType(const MCSymbolWasm *Sym) = 0;
45  /// .import_module
46  virtual void emitImportModule(const MCSymbolWasm *Sym,
47  StringRef ImportModule) = 0;
48  /// .import_name
49  virtual void emitImportName(const MCSymbolWasm *Sym,
50  StringRef ImportName) = 0;
51  /// .export_name
52  virtual void emitExportName(const MCSymbolWasm *Sym,
53  StringRef ExportName) = 0;
54 
55 protected:
57 };
58 
59 /// This part is for ascii assembly output
62 
63 public:
65 
66  void emitLocal(ArrayRef<wasm::ValType> Types) override;
67  void emitFunctionType(const MCSymbolWasm *Sym) override;
68  void emitIndIdx(const MCExpr *Value) override;
69  void emitGlobalType(const MCSymbolWasm *Sym) override;
70  void emitTableType(const MCSymbolWasm *Sym) override;
71  void emitTagType(const MCSymbolWasm *Sym) override;
72  void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
73  void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
74  void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
75 };
76 
77 /// This part is for Wasm object output
79 public:
81 
82  void emitLocal(ArrayRef<wasm::ValType> Types) override;
83  void emitFunctionType(const MCSymbolWasm *Sym) override {}
84  void emitIndIdx(const MCExpr *Value) override;
85  void emitGlobalType(const MCSymbolWasm *Sym) override {}
86  void emitTableType(const MCSymbolWasm *Sym) override {}
87  void emitTagType(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  void emitExportName(const MCSymbolWasm *Sym,
93  StringRef ExportName) override {}
94 };
95 
96 /// This part is for null output
98 public:
101 
103  void emitFunctionType(const MCSymbolWasm *) override {}
104  void emitIndIdx(const MCExpr *) override {}
105  void emitGlobalType(const MCSymbolWasm *) override {}
106  void emitTableType(const MCSymbolWasm *) override {}
107  void emitTagType(const MCSymbolWasm *) override {}
108  void emitImportModule(const MCSymbolWasm *, StringRef) override {}
109  void emitImportName(const MCSymbolWasm *, StringRef) override {}
110  void emitExportName(const MCSymbolWasm *, StringRef) override {}
111 };
112 
113 } // end namespace llvm
114 
115 #endif
llvm::WebAssemblyTargetStreamer::emitLocal
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
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:137
llvm::WebAssemblyTargetNullStreamer
This part is for null output.
Definition: WebAssemblyTargetStreamer.h:97
llvm::WebAssemblyTargetWasmStreamer::emitLocal
void emitLocal(ArrayRef< wasm::ValType > Types) override
.local
Definition: WebAssemblyTargetStreamer.cpp:121
llvm::WebAssemblyTargetAsmStreamer::emitImportName
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override
.import_name
Definition: WebAssemblyTargetStreamer.cpp:105
llvm::WebAssemblyTargetAsmStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *Sym) override
.functype
Definition: WebAssemblyTargetStreamer.cpp:61
llvm::WebAssemblyTargetStreamer::emitIndIdx
virtual void emitIndIdx(const MCExpr *Value)=0
.indidx
llvm::WebAssemblyTargetNullStreamer::WebAssemblyTargetNullStreamer
WebAssemblyTargetNullStreamer(MCStreamer &S)
Definition: WebAssemblyTargetStreamer.h:99
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::WebAssemblyTargetNullStreamer::emitImportName
void emitImportName(const MCSymbolWasm *, StringRef) override
.import_name
Definition: WebAssemblyTargetStreamer.h:109
llvm::WebAssemblyTargetWasmStreamer::emitExportName
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override
.export_name
Definition: WebAssemblyTargetStreamer.h:92
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:86
MachineValueType.h
llvm::WebAssemblyTargetStreamer::emitFunctionType
virtual void emitFunctionType(const MCSymbolWasm *Sym)=0
.functype
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
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:88
llvm::wasm::ValType
ValType
Definition: Wasm.h:424
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:93
llvm::WebAssemblyTargetAsmStreamer::emitExportName
void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override
.export_name
Definition: WebAssemblyTargetStreamer.cpp:111
llvm::WebAssemblyTargetNullStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *) override
.functype
Definition: WebAssemblyTargetStreamer.h:103
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:105
llvm::WebAssemblyTargetAsmStreamer::emitIndIdx
void emitIndIdx(const MCExpr *Value) override
.indidx
Definition: WebAssemblyTargetStreamer.cpp:117
llvm::MCSymbolWasm
Definition: MCSymbolWasm.h:16
llvm::WebAssemblyTargetWasmStreamer::emitFunctionType
void emitFunctionType(const MCSymbolWasm *Sym) override
.functype
Definition: WebAssemblyTargetStreamer.h:83
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:85
llvm::WebAssemblyTargetAsmStreamer::emitTableType
void emitTableType(const MCSymbolWasm *Sym) override
.tabletype
Definition: WebAssemblyTargetStreamer.cpp:78
llvm::WebAssemblyTargetWasmStreamer::emitTagType
void emitTagType(const MCSymbolWasm *Sym) override
.tagtype
Definition: WebAssemblyTargetStreamer.h:87
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:106
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:99
llvm::WebAssemblyTargetStreamer::WebAssemblyTargetStreamer
WebAssemblyTargetStreamer(MCStreamer &S)
Definition: WebAssemblyTargetStreamer.cpp:27
llvm::WebAssemblyTargetWasmStreamer
This part is for Wasm object output.
Definition: WebAssemblyTargetStreamer.h:78
llvm::WebAssemblyTargetAsmStreamer::emitTagType
void emitTagType(const MCSymbolWasm *Sym) override
.tagtype
Definition: WebAssemblyTargetStreamer.cpp:92
llvm::WebAssemblyTargetNullStreamer::emitImportModule
void emitImportModule(const MCSymbolWasm *, StringRef) override
.import_module
Definition: WebAssemblyTargetStreamer.h:108
llvm::WebAssemblyTargetAsmStreamer
This part is for ascii assembly output.
Definition: WebAssemblyTargetStreamer.h:60
llvm::WebAssemblyTargetWasmStreamer::emitImportName
void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override
.import_name
Definition: WebAssemblyTargetStreamer.h:90
Wasm.h
llvm::WebAssemblyTargetNullStreamer::emitLocal
void emitLocal(ArrayRef< wasm::ValType >) override
.local
Definition: WebAssemblyTargetStreamer.h:102
MCStreamer.h
llvm::WebAssemblyTargetNullStreamer::emitExportName
void emitExportName(const MCSymbolWasm *, StringRef) override
.export_name
Definition: WebAssemblyTargetStreamer.h:110
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:107
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:68
llvm::WebAssemblyTargetNullStreamer::emitIndIdx
void emitIndIdx(const MCExpr *) override
.indidx
Definition: WebAssemblyTargetStreamer.h:104