LLVM  14.0.0git
Wasm.h
Go to the documentation of this file.
1 //===- Wasm.h - Wasm object file format -------------------------*- 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 // This file defines manifest constants for the wasm object file format.
10 // See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_BINARYFORMAT_WASM_H
15 #define LLVM_BINARYFORMAT_WASM_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringRef.h"
21 
22 namespace llvm {
23 namespace wasm {
24 
25 // Object file magic string.
26 const char WasmMagic[] = {'\0', 'a', 's', 'm'};
27 // Wasm binary format version
28 const uint32_t WasmVersion = 0x1;
29 // Wasm linking metadata version
31 // Wasm uses a 64k page size
32 const uint32_t WasmPageSize = 65536;
33 
37 };
38 
40  uint32_t MemorySize; // Memory size in bytes
41  uint32_t MemoryAlignment; // P2 alignment of memory
42  uint32_t TableSize; // Table size in elements
43  uint32_t TableAlignment; // P2 alignment of table
44  std::vector<StringRef> Needed; // Shared library dependencies
45 };
46 
48  std::vector<std::pair<std::string, std::string>> Languages;
49  std::vector<std::pair<std::string, std::string>> Tools;
50  std::vector<std::pair<std::string, std::string>> SDKs;
51 };
52 
54  uint8_t Prefix;
55  std::string Name;
56 };
57 
58 struct WasmExport {
60  uint8_t Kind;
62 };
63 
64 struct WasmLimits {
65  uint8_t Flags;
68 };
69 
70 struct WasmTableType {
71  uint8_t ElemType;
73 };
74 
75 struct WasmTable {
78  StringRef SymbolName; // from the "linking" section
79 };
80 
81 struct WasmInitExpr {
82  uint8_t Opcode;
83  union {
84  int32_t Int32;
85  int64_t Int64;
89  } Value;
90 };
91 
93  uint8_t Type;
94  bool Mutable;
95 };
96 
97 struct WasmGlobal {
101  StringRef SymbolName; // from the "linking" section
102 };
103 
104 struct WasmTagType {
105  // Kind of tag. Currently only WASM_TAG_ATTRIBUTE_EXCEPTION is possible.
106  uint8_t Attribute;
108 };
109 
110 struct WasmTag {
113  StringRef SymbolName; // from the "linking" section
114 };
115 
116 struct WasmImport {
119  uint8_t Kind;
120  union {
126  };
127 };
128 
130  uint8_t Type;
132 };
133 
134 struct WasmFunction {
136  std::vector<WasmLocalDecl> Locals;
140  uint32_t CodeOffset; // start of Locals and Body
141  Optional<StringRef> ExportName; // from the "export" section
142  StringRef SymbolName; // from the "linking" section
143  StringRef DebugName; // from the "name" section
144  uint32_t Comdat; // from the "comdat info" section
145 };
146 
149  // Present if InitFlags & WASM_DATA_SEGMENT_HAS_MEMINDEX.
151  // Present if InitFlags & WASM_DATA_SEGMENT_IS_PASSIVE == 0.
153 
155  StringRef Name; // from the "segment info" section
158  uint32_t Comdat; // from the "comdat info" section
159 };
160 
164  uint8_t ElemKind;
166  std::vector<uint32_t> Functions;
167 };
168 
169 // Represents the location of a Wasm data symbol within a WasmDataSegment, as
170 // the index of the segment, and the offset and size within the segment.
175 };
176 
178  uint8_t Type; // The type of the relocation.
179  uint32_t Index; // Index into either symbol or type index space.
180  uint64_t Offset; // Offset from the start of the section.
181  int64_t Addend; // A value to add to the symbol.
182 };
183 
184 struct WasmInitFunc {
187 };
188 
191  uint8_t Kind;
193  // For undefined symbols the module of the import
195  // For undefined symbols the name of the import
197  // For symbols to be exported from the final module
199  union {
200  // For function, table, or global symbols, the index in function, table, or
201  // global index space.
203  // For a data symbols, the address of the data relative to segment.
205  };
206 };
207 
208 enum class NameType {
209  FUNCTION,
210  GLOBAL,
211  DATA_SEGMENT,
212 };
213 
218 };
219 
222  std::vector<WasmInitFunc> InitFunctions;
223  std::vector<StringRef> Comdats;
224  std::vector<WasmSymbolInfo> SymbolTable;
225 };
226 
227 enum : unsigned {
228  WASM_SEC_CUSTOM = 0, // Custom / User-defined section
229  WASM_SEC_TYPE = 1, // Function signature declarations
230  WASM_SEC_IMPORT = 2, // Import declarations
231  WASM_SEC_FUNCTION = 3, // Function declarations
232  WASM_SEC_TABLE = 4, // Indirect function table and other tables
233  WASM_SEC_MEMORY = 5, // Memory attributes
234  WASM_SEC_GLOBAL = 6, // Global declarations
235  WASM_SEC_EXPORT = 7, // Exports
236  WASM_SEC_START = 8, // Start function declaration
237  WASM_SEC_ELEM = 9, // Elements section
238  WASM_SEC_CODE = 10, // Function bodies (code)
239  WASM_SEC_DATA = 11, // Data segments
240  WASM_SEC_DATACOUNT = 12, // Data segment count
241  WASM_SEC_TAG = 13 // Tag declarations
242 };
243 
244 // Type immediate encodings used in various contexts.
245 enum : unsigned {
254  WASM_TYPE_NORESULT = 0x40, // for blocks with no result values
255 };
256 
257 // Kinds of externals (for imports and exports).
258 enum : unsigned {
264 };
265 
266 // Opcodes used in initializer expressions.
267 enum : unsigned {
283 };
284 
285 // Opcodes used in synthetic functions.
286 enum : unsigned {
298 };
299 
300 enum : unsigned {
305 };
306 
307 enum : unsigned {
310 };
311 
312 enum : unsigned {
316 };
318 
319 // Feature policy prefixes used in the custom "target_features" section
320 enum : uint8_t {
324 };
325 
326 // Kind codes used in the custom "name" section
327 enum : unsigned {
332 };
333 
334 // Kind codes used in the custom "linking" section
335 enum : unsigned {
340 };
341 
342 // Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO
343 enum : unsigned {
346  // GLOBAL, TAG, and TABLE are in here but LLVM doesn't use them yet.
348 };
349 
350 // Kind codes used in the custom "linking" section in the WASM_SYMBOL_TABLE
351 enum WasmSymbolType : unsigned {
358 };
359 
360 enum WasmSegmentFlag : unsigned {
363 };
364 
365 // Kinds of tag attributes.
366 enum WasmTagAttribute : uint8_t {
368 };
369 
370 const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
371 const unsigned WASM_SYMBOL_VISIBILITY_MASK = 0xc;
372 
373 const unsigned WASM_SYMBOL_BINDING_GLOBAL = 0x0;
374 const unsigned WASM_SYMBOL_BINDING_WEAK = 0x1;
375 const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2;
376 const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
377 const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
378 const unsigned WASM_SYMBOL_UNDEFINED = 0x10;
379 const unsigned WASM_SYMBOL_EXPORTED = 0x20;
380 const unsigned WASM_SYMBOL_EXPLICIT_NAME = 0x40;
381 const unsigned WASM_SYMBOL_NO_STRIP = 0x80;
382 
383 #define WASM_RELOC(name, value) name = value,
384 
385 enum : unsigned {
386 #include "WasmRelocs.def"
387 };
388 
389 #undef WASM_RELOC
390 
391 // Subset of types that a value can have
392 enum class ValType {
393  I32 = WASM_TYPE_I32,
394  I64 = WASM_TYPE_I64,
395  F32 = WASM_TYPE_F32,
396  F64 = WASM_TYPE_F64,
400 };
401 
405  // Support empty and tombstone instances, needed by DenseMap.
407 
409  SmallVector<ValType, 4> &&InParams)
410  : Returns(InReturns), Params(InParams) {}
411  WasmSignature() = default;
412 };
413 
414 // Useful comparison operators
415 inline bool operator==(const WasmSignature &LHS, const WasmSignature &RHS) {
416  return LHS.State == RHS.State && LHS.Returns == RHS.Returns &&
417  LHS.Params == RHS.Params;
418 }
419 
420 inline bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS) {
421  return !(LHS == RHS);
422 }
423 
424 inline bool operator==(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
425  return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable;
426 }
427 
428 inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
429  return !(LHS == RHS);
430 }
431 
432 inline bool operator==(const WasmLimits &LHS, const WasmLimits &RHS) {
433  return LHS.Flags == RHS.Flags && LHS.Minimum == RHS.Minimum &&
434  (LHS.Flags & WASM_LIMITS_FLAG_HAS_MAX ? LHS.Maximum == RHS.Maximum
435  : true);
436 }
437 
438 inline bool operator==(const WasmTableType &LHS, const WasmTableType &RHS) {
439  return LHS.ElemType == RHS.ElemType && LHS.Limits == RHS.Limits;
440 }
441 
442 std::string toString(WasmSymbolType type);
443 std::string relocTypetoString(uint32_t type);
445 
446 } // end namespace wasm
447 } // end namespace llvm
448 
449 #endif
llvm::wasm::WasmImport::Memory
WasmLimits Memory
Definition: Wasm.h:124
llvm::wasm::WASM_SYMBOL_TYPE_SECTION
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:355
llvm::wasm::WASM_SYMBOL_EXPORTED
const unsigned WASM_SYMBOL_EXPORTED
Definition: Wasm.h:379
llvm::wasm::WASM_TYPE_V128
@ WASM_TYPE_V128
Definition: Wasm.h:250
llvm::wasm::WasmTag
Definition: Wasm.h:110
llvm::wasm::WASM_NAMES_GLOBAL
@ WASM_NAMES_GLOBAL
Definition: Wasm.h:330
llvm::wasm::WASM_OPCODE_F64_CONST
@ WASM_OPCODE_F64_CONST
Definition: Wasm.h:279
llvm::wasm::WasmDataSegment::Offset
WasmInitExpr Offset
Definition: Wasm.h:152
llvm::wasm::WasmDataSegment::Content
ArrayRef< uint8_t > Content
Definition: Wasm.h:154
llvm::wasm::WasmSegmentFlag
WasmSegmentFlag
Definition: Wasm.h:360
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::wasm::WasmDataSegment::Comdat
uint32_t Comdat
Definition: Wasm.h:158
llvm::wasm::ValType::I32
@ I32
llvm::wasm::WasmElemSegment::Offset
WasmInitExpr Offset
Definition: Wasm.h:165
llvm::wasm::WasmFunction::SymbolName
StringRef SymbolName
Definition: Wasm.h:142
Optional.h
llvm::wasm::WASM_LIMITS_FLAG_NONE
@ WASM_LIMITS_FLAG_NONE
Definition: Wasm.h:301
llvm::wasm::WasmFunction::CodeOffset
uint32_t CodeOffset
Definition: Wasm.h:140
llvm::wasm::WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
const unsigned WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
Definition: Wasm.h:317
llvm::wasm::WasmFunction::Body
ArrayRef< uint8_t > Body
Definition: Wasm.h:137
llvm::wasm::WasmLimits::Minimum
uint64_t Minimum
Definition: Wasm.h:66
llvm::wasm::WasmSignature::Plain
@ Plain
Definition: Wasm.h:406
StringRef.h
llvm::wasm::WasmDebugName::Index
uint32_t Index
Definition: Wasm.h:216
llvm::wasm::WASM_OPCODE_MISC_PREFIX
@ WASM_OPCODE_MISC_PREFIX
Definition: Wasm.h:290
llvm::wasm::WasmVersion
const uint32_t WasmVersion
Definition: Wasm.h:28
llvm::wasm::WASM_OPCODE_DATA_DROP
@ WASM_OPCODE_DATA_DROP
Definition: Wasm.h:292
llvm::wasm::WasmFeatureEntry
Definition: Wasm.h:53
llvm::SmallVector< ValType, 1 >
llvm::wasm::WASM_OPCODE_I32_ATOMIC_STORE
@ WASM_OPCODE_I32_ATOMIC_STORE
Definition: Wasm.h:296
llvm::wasm::WasmObjectHeader::Version
uint32_t Version
Definition: Wasm.h:36
llvm::wasm::WASM_OPCODE_I32_STORE
@ WASM_OPCODE_I32_STORE
Definition: Wasm.h:274
llvm::wasm::WasmLinkingData::SymbolTable
std::vector< WasmSymbolInfo > SymbolTable
Definition: Wasm.h:224
llvm::wasm::WASM_SYMBOL_NO_STRIP
const unsigned WASM_SYMBOL_NO_STRIP
Definition: Wasm.h:381
llvm::wasm::WasmDataSegment::InitFlags
uint32_t InitFlags
Definition: Wasm.h:148
llvm::wasm::WasmFunction::Comdat
uint32_t Comdat
Definition: Wasm.h:144
llvm::wasm::WASM_SYMBOL_BINDING_LOCAL
const unsigned WASM_SYMBOL_BINDING_LOCAL
Definition: Wasm.h:375
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:357
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:354
llvm::wasm::WasmRelocation
Definition: Wasm.h:177
llvm::wasm::WASM_SEC_TABLE
@ WASM_SEC_TABLE
Definition: Wasm.h:232
llvm::wasm::WasmImport::Table
WasmTableType Table
Definition: Wasm.h:123
llvm::wasm::WASM_LIMITS_FLAG_IS_64
@ WASM_LIMITS_FLAG_IS_64
Definition: Wasm.h:304
llvm::wasm::WASM_OPCODE_I32_ATOMIC_WAIT
@ WASM_OPCODE_I32_ATOMIC_WAIT
Definition: Wasm.h:295
llvm::wasm::WasmImport::SigIndex
uint32_t SigIndex
Definition: Wasm.h:121
llvm::wasm::WASM_OPCODE_GLOBAL_GET
@ WASM_OPCODE_GLOBAL_GET
Definition: Wasm.h:272
llvm::wasm::WASM_SEC_CUSTOM
@ WASM_SEC_CUSTOM
Definition: Wasm.h:228
llvm::wasm::WASM_COMDAT_FUNCTION
@ WASM_COMDAT_FUNCTION
Definition: Wasm.h:345
llvm::wasm::WASM_OPCODE_I64_STORE
@ WASM_OPCODE_I64_STORE
Definition: Wasm.h:275
llvm::wasm::WasmElemSegment::ElemKind
uint8_t ElemKind
Definition: Wasm.h:164
llvm::Optional
Definition: APInt.h:33
llvm::wasm::WASM_SYMBOL_UNDEFINED
const unsigned WASM_SYMBOL_UNDEFINED
Definition: Wasm.h:378
llvm::wasm::WasmFunction::Locals
std::vector< WasmLocalDecl > Locals
Definition: Wasm.h:136
llvm::wasm::WasmSymbolInfo::Kind
uint8_t Kind
Definition: Wasm.h:191
llvm::wasm::WasmDebugName::Name
StringRef Name
Definition: Wasm.h:217
llvm::wasm::WasmFunction
Definition: Wasm.h:134
llvm::wasm::WasmSignature::WasmSignature
WasmSignature(SmallVector< ValType, 1 > &&InReturns, SmallVector< ValType, 4 > &&InParams)
Definition: Wasm.h:408
llvm::wasm::WasmExport::Kind
uint8_t Kind
Definition: Wasm.h:60
llvm::wasm::WASM_NAMES_FUNCTION
@ WASM_NAMES_FUNCTION
Definition: Wasm.h:328
llvm::wasm::WasmDataReference::Offset
uint64_t Offset
Definition: Wasm.h:173
llvm::wasm::WASM_SEC_CODE
@ WASM_SEC_CODE
Definition: Wasm.h:238
llvm::wasm::WASM_OPCODE_CALL
@ WASM_OPCODE_CALL
Definition: Wasm.h:269
llvm::wasm::WASM_SEC_TYPE
@ WASM_SEC_TYPE
Definition: Wasm.h:229
llvm::wasm::WasmDataReference
Definition: Wasm.h:171
llvm::wasm::WasmGlobal::Type
WasmGlobalType Type
Definition: Wasm.h:99
llvm::wasm::WasmExport::Index
uint32_t Index
Definition: Wasm.h:61
llvm::wasm::WasmProducerInfo
Definition: Wasm.h:47
llvm::wasm::WasmRelocation::Offset
uint64_t Offset
Definition: Wasm.h:180
llvm::wasm::WasmSignature::Tombstone
@ Tombstone
Definition: Wasm.h:406
llvm::wasm::WasmTagType::SigIndex
uint32_t SigIndex
Definition: Wasm.h:107
llvm::wasm::WASM_EXTERNAL_TAG
@ WASM_EXTERNAL_TAG
Definition: Wasm.h:263
llvm::wasm::WasmElemSegment::TableNumber
uint32_t TableNumber
Definition: Wasm.h:163
llvm::wasm::WASM_SYMBOL_BINDING_WEAK
const unsigned WASM_SYMBOL_BINDING_WEAK
Definition: Wasm.h:374
llvm::wasm::WasmInitFunc::Priority
uint32_t Priority
Definition: Wasm.h:185
llvm::wasm::WasmFunction::DebugName
StringRef DebugName
Definition: Wasm.h:143
llvm::wasm::WasmInitExpr::Global
uint32_t Global
Definition: Wasm.h:88
llvm::wasm::WasmSymbolInfo::ExportName
Optional< StringRef > ExportName
Definition: Wasm.h:198
llvm::wasm::ValType::F64
@ F64
llvm::wasm::WasmGlobalType::Mutable
bool Mutable
Definition: Wasm.h:94
llvm::wasm::WasmLimits
Definition: Wasm.h:64
llvm::wasm::WasmSignature::Empty
@ Empty
Definition: Wasm.h:406
llvm::wasm::WASM_OPCODE_I32_ADD
@ WASM_OPCODE_I32_ADD
Definition: Wasm.h:280
llvm::wasm::WasmRelocation::Addend
int64_t Addend
Definition: Wasm.h:181
llvm::wasm::WasmSignature::State
enum llvm::wasm::WasmSignature::@166 State
llvm::wasm::WasmInitExpr::Float64
uint64_t Float64
Definition: Wasm.h:87
llvm::wasm::WASM_SYMBOL_VISIBILITY_MASK
const unsigned WASM_SYMBOL_VISIBILITY_MASK
Definition: Wasm.h:371
llvm::wasm::WasmTableType::ElemType
uint8_t ElemType
Definition: Wasm.h:71
llvm::wasm::WASM_SYMBOL_VISIBILITY_HIDDEN
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN
Definition: Wasm.h:377
llvm::wasm::WasmFeatureEntry::Prefix
uint8_t Prefix
Definition: Wasm.h:54
llvm::wasm::WASM_ELEM_SEGMENT_IS_PASSIVE
@ WASM_ELEM_SEGMENT_IS_PASSIVE
Definition: Wasm.h:313
llvm::wasm::WASM_OPCODE_ATOMICS_PREFIX
@ WASM_OPCODE_ATOMICS_PREFIX
Definition: Wasm.h:293
llvm::wasm::WasmInitExpr::Int64
int64_t Int64
Definition: Wasm.h:85
llvm::wasm::ValType::F32
@ F32
llvm::wasm::WASM_EXTERNAL_MEMORY
@ WASM_EXTERNAL_MEMORY
Definition: Wasm.h:261
llvm::wasm::WasmGlobalType
Definition: Wasm.h:92
llvm::wasm::WasmTagType::Attribute
uint8_t Attribute
Definition: Wasm.h:106
llvm::wasm::WasmFunction::CodeSectionOffset
uint32_t CodeSectionOffset
Definition: Wasm.h:138
llvm::wasm::WASM_DATA_SEGMENT_IS_PASSIVE
@ WASM_DATA_SEGMENT_IS_PASSIVE
Definition: Wasm.h:308
llvm::wasm::WasmSignature::WasmSignature
WasmSignature()=default
llvm::wasm::WASM_TYPE_EXTERNREF
@ WASM_TYPE_EXTERNREF
Definition: Wasm.h:252
llvm::wasm::WasmProducerInfo::Languages
std::vector< std::pair< std::string, std::string > > Languages
Definition: Wasm.h:48
llvm::wasm::WasmGlobal::SymbolName
StringRef SymbolName
Definition: Wasm.h:101
llvm::wasm::WasmTable::SymbolName
StringRef SymbolName
Definition: Wasm.h:78
llvm::wasm::WasmTag::Type
WasmTagType Type
Definition: Wasm.h:112
llvm::wasm::WasmDylinkInfo::MemoryAlignment
uint32_t MemoryAlignment
Definition: Wasm.h:41
llvm::wasm::WasmDataReference::Size
uint64_t Size
Definition: Wasm.h:174
llvm::wasm::WasmInitFunc::Symbol
uint32_t Symbol
Definition: Wasm.h:186
llvm::wasm::WasmTagAttribute
WasmTagAttribute
Definition: Wasm.h:366
llvm::wasm::WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
@ WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
Definition: Wasm.h:314
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:352
llvm::wasm::WasmMetadataVersion
const uint32_t WasmMetadataVersion
Definition: Wasm.h:30
llvm::wasm::NameType::FUNCTION
@ FUNCTION
llvm::wasm::ValType
ValType
Definition: Wasm.h:392
NameType
Definition: ItaniumDemangle.h:388
llvm::wasm::WasmLocalDecl::Type
uint8_t Type
Definition: Wasm.h:130
llvm::wasm::WasmTable::Index
uint32_t Index
Definition: Wasm.h:76
llvm::wasm::WASM_COMDAT_SECTION
@ WASM_COMDAT_SECTION
Definition: Wasm.h:347
llvm::wasm::WASM_OPCODE_GLOBAL_SET
@ WASM_OPCODE_GLOBAL_SET
Definition: Wasm.h:273
llvm::wasm::WASM_OPCODE_ELSE
@ WASM_OPCODE_ELSE
Definition: Wasm.h:288
llvm::wasm::WASM_FEATURE_PREFIX_DISALLOWED
@ WASM_FEATURE_PREFIX_DISALLOWED
Definition: Wasm.h:323
llvm::wasm::WasmTable::Type
WasmTableType Type
Definition: Wasm.h:77
llvm::wasm::WASM_LIMITS_FLAG_HAS_MAX
@ WASM_LIMITS_FLAG_HAS_MAX
Definition: Wasm.h:302
llvm::wasm::WasmSymbolInfo::Name
StringRef Name
Definition: Wasm.h:190
llvm::wasm::WasmImport::Field
StringRef Field
Definition: Wasm.h:118
llvm::wasm::WasmSymbolInfo::ElementIndex
uint32_t ElementIndex
Definition: Wasm.h:202
llvm::wasm::WasmInitExpr::Float32
uint32_t Float32
Definition: Wasm.h:86
llvm::wasm::WasmObjectHeader::Magic
StringRef Magic
Definition: Wasm.h:35
llvm::wasm::WASM_SEG_FLAG_TLS
@ WASM_SEG_FLAG_TLS
Definition: Wasm.h:362
llvm::wasm::WasmSymbolInfo::ImportModule
Optional< StringRef > ImportModule
Definition: Wasm.h:194
llvm::wasm::NameType::GLOBAL
@ GLOBAL
llvm::wasm::WasmDylinkInfo
Definition: Wasm.h:39
llvm::wasm::operator!=
bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS)
Definition: Wasm.h:420
llvm::wasm::WasmLinkingData::Comdats
std::vector< StringRef > Comdats
Definition: Wasm.h:223
llvm::wasm::WasmLimits::Flags
uint8_t Flags
Definition: Wasm.h:65
llvm::wasm::WASM_OPCODE_F32_CONST
@ WASM_OPCODE_F32_CONST
Definition: Wasm.h:278
llvm::wasm::WASM_TAG_ATTRIBUTE_EXCEPTION
@ WASM_TAG_ATTRIBUTE_EXCEPTION
Definition: Wasm.h:367
llvm::wasm::WasmRelocation::Type
uint8_t Type
Definition: Wasm.h:178
llvm::wasm::WASM_OPCODE_LOCAL_SET
@ WASM_OPCODE_LOCAL_SET
Definition: Wasm.h:271
llvm::wasm::WASM_SYMBOL_VISIBILITY_DEFAULT
const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT
Definition: Wasm.h:376
llvm::wasm::WasmDataSegment::LinkingFlags
uint32_t LinkingFlags
Definition: Wasm.h:157
llvm::wasm::WasmFunction::Size
uint32_t Size
Definition: Wasm.h:139
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
llvm::wasm::WASM_SEC_IMPORT
@ WASM_SEC_IMPORT
Definition: Wasm.h:230
uint64_t
llvm::wasm::WASM_SEGMENT_INFO
@ WASM_SEGMENT_INFO
Definition: Wasm.h:336
llvm::wasm::WasmElemSegment::Functions
std::vector< uint32_t > Functions
Definition: Wasm.h:166
llvm::wasm::ValType::EXTERNREF
@ EXTERNREF
llvm::wasm::WASM_INIT_FUNCS
@ WASM_INIT_FUNCS
Definition: Wasm.h:337
llvm::wasm::WasmExport::Name
StringRef Name
Definition: Wasm.h:59
llvm::wasm::WASM_SYMBOL_EXPLICIT_NAME
const unsigned WASM_SYMBOL_EXPLICIT_NAME
Definition: Wasm.h:380
llvm::wasm::WASM_DATA_SEGMENT_HAS_MEMINDEX
@ WASM_DATA_SEGMENT_HAS_MEMINDEX
Definition: Wasm.h:309
llvm::wasm::WASM_TYPE_F32
@ WASM_TYPE_F32
Definition: Wasm.h:248
llvm::wasm::ValType::I64
@ I64
llvm::wasm::WasmLocalDecl
Definition: Wasm.h:129
llvm::wasm::ValType::FUNCREF
@ FUNCREF
llvm::wasm::WasmProducerInfo::Tools
std::vector< std::pair< std::string, std::string > > Tools
Definition: Wasm.h:49
llvm::wasm::WasmGlobal::InitExpr
WasmInitExpr InitExpr
Definition: Wasm.h:100
llvm::wasm::WasmGlobal::Index
uint32_t Index
Definition: Wasm.h:98
llvm::wasm::WasmDebugName::Type
NameType Type
Definition: Wasm.h:215
llvm::wasm::WasmSignature::Returns
SmallVector< ValType, 1 > Returns
Definition: Wasm.h:403
llvm::wasm::WasmDylinkInfo::TableSize
uint32_t TableSize
Definition: Wasm.h:42
llvm::wasm::WASM_EXTERNAL_GLOBAL
@ WASM_EXTERNAL_GLOBAL
Definition: Wasm.h:262
llvm::wasm::WasmImport
Definition: Wasm.h:116
ArrayRef.h
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:356
llvm::wasm::WASM_SEC_GLOBAL
@ WASM_SEC_GLOBAL
Definition: Wasm.h:234
llvm::wasm::relocTypetoString
std::string relocTypetoString(uint32_t type)
Definition: Wasm.cpp:29
llvm::wasm::WasmFunction::Index
uint32_t Index
Definition: Wasm.h:135
llvm::wasm::WasmDebugName
Definition: Wasm.h:214
llvm::wasm::WasmImport::Tag
WasmTagType Tag
Definition: Wasm.h:125
llvm::wasm::WasmTagType
Definition: Wasm.h:104
llvm::wasm::WASM_OPCODE_IF
@ WASM_OPCODE_IF
Definition: Wasm.h:287
llvm::wasm::relocTypeHasAddend
bool relocTypeHasAddend(uint32_t type)
Definition: Wasm.cpp:41
llvm::wasm::WASM_FEATURE_PREFIX_REQUIRED
@ WASM_FEATURE_PREFIX_REQUIRED
Definition: Wasm.h:322
llvm::wasm::WASM_EXTERNAL_FUNCTION
@ WASM_EXTERNAL_FUNCTION
Definition: Wasm.h:259
llvm::wasm::WASM_OPCODE_MEMORY_INIT
@ WASM_OPCODE_MEMORY_INIT
Definition: Wasm.h:291
llvm::wasm::WasmElemSegment::Flags
uint32_t Flags
Definition: Wasm.h:162
llvm::wasm::WasmInitExpr::Int32
int32_t Int32
Definition: Wasm.h:84
llvm::ArrayRef< uint8_t >
llvm::wasm::WASM_OPCODE_DROP
@ WASM_OPCODE_DROP
Definition: Wasm.h:289
llvm::wasm::toString
std::string toString(WasmSymbolType type)
Definition: Wasm.cpp:11
llvm::wasm::WASM_COMDAT_INFO
@ WASM_COMDAT_INFO
Definition: Wasm.h:338
llvm::wasm::WASM_NAMES_LOCAL
@ WASM_NAMES_LOCAL
Definition: Wasm.h:329
llvm::wasm::WASM_TYPE_I32
@ WASM_TYPE_I32
Definition: Wasm.h:246
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::wasm::WASM_TYPE_FUNCREF
@ WASM_TYPE_FUNCREF
Definition: Wasm.h:251
llvm::wasm::WASM_SEC_TAG
@ WASM_SEC_TAG
Definition: Wasm.h:241
llvm::wasm::WasmLimits::Maximum
uint64_t Maximum
Definition: Wasm.h:67
llvm::wasm::WasmObjectHeader
Definition: Wasm.h:34
llvm::wasm::WasmGlobal
Definition: Wasm.h:97
uint32_t
llvm::wasm::WASM_SYMBOL_BINDING_MASK
const unsigned WASM_SYMBOL_BINDING_MASK
Definition: Wasm.h:370
llvm::wasm::WasmSymbolType
WasmSymbolType
Definition: Wasm.h:351
llvm::wasm::WASM_SEC_ELEM
@ WASM_SEC_ELEM
Definition: Wasm.h:237
llvm::wasm::WASM_SEC_MEMORY
@ WASM_SEC_MEMORY
Definition: Wasm.h:233
llvm::wasm::WasmTableType::Limits
WasmLimits Limits
Definition: Wasm.h:72
llvm::wasm::WASM_SEC_EXPORT
@ WASM_SEC_EXPORT
Definition: Wasm.h:235
llvm::wasm::WasmSymbolInfo
Definition: Wasm.h:189
llvm::wasm::WasmDylinkInfo::Needed
std::vector< StringRef > Needed
Definition: Wasm.h:44
llvm::wasm::WasmImport::Global
WasmGlobalType Global
Definition: Wasm.h:122
llvm::wasm::WasmGlobalType::Type
uint8_t Type
Definition: Wasm.h:93
llvm::wasm::WasmSymbolInfo::DataRef
WasmDataReference DataRef
Definition: Wasm.h:204
llvm::wasm::WASM_EXTERNAL_TABLE
@ WASM_EXTERNAL_TABLE
Definition: Wasm.h:260
llvm::wasm::operator==
bool operator==(const WasmSignature &LHS, const WasmSignature &RHS)
Definition: Wasm.h:415
llvm::wasm::WASM_SEC_START
@ WASM_SEC_START
Definition: Wasm.h:236
llvm::wasm::WasmProducerInfo::SDKs
std::vector< std::pair< std::string, std::string > > SDKs
Definition: Wasm.h:50
llvm::wasm::WASM_OPCODE_END
@ WASM_OPCODE_END
Definition: Wasm.h:268
llvm::wasm::WasmDataReference::Segment
uint32_t Segment
Definition: Wasm.h:172
llvm::wasm::WasmDataSegment::MemoryIndex
uint32_t MemoryIndex
Definition: Wasm.h:150
llvm::wasm::WasmMagic
const char WasmMagic[]
Definition: Wasm.h:26
llvm::wasm::WasmLinkingData::InitFunctions
std::vector< WasmInitFunc > InitFunctions
Definition: Wasm.h:222
llvm::wasm::WASM_TYPE_I64
@ WASM_TYPE_I64
Definition: Wasm.h:247
llvm::wasm::WASM_SYMBOL_BINDING_GLOBAL
const unsigned WASM_SYMBOL_BINDING_GLOBAL
Definition: Wasm.h:373
llvm::wasm::WASM_OPCODE_I32_RMW_CMPXCHG
@ WASM_OPCODE_I32_RMW_CMPXCHG
Definition: Wasm.h:297
llvm::wasm::WasmDylinkInfo::MemorySize
uint32_t MemorySize
Definition: Wasm.h:40
llvm::wasm::WASM_OPCODE_I32_CONST
@ WASM_OPCODE_I32_CONST
Definition: Wasm.h:276
llvm::wasm::WasmInitFunc
Definition: Wasm.h:184
llvm::wasm::WasmSymbolInfo::Flags
uint32_t Flags
Definition: Wasm.h:192
llvm::wasm::WasmLocalDecl::Count
uint32_t Count
Definition: Wasm.h:131
llvm::wasm::WASM_TYPE_NORESULT
@ WASM_TYPE_NORESULT
Definition: Wasm.h:254
llvm::wasm::WasmSymbolInfo::ImportName
Optional< StringRef > ImportName
Definition: Wasm.h:196
llvm::wasm::WasmDataSegment
Definition: Wasm.h:147
llvm::wasm::WasmInitExpr
Definition: Wasm.h:81
llvm::wasm::WasmFunction::ExportName
Optional< StringRef > ExportName
Definition: Wasm.h:141
llvm::wasm::WasmLinkingData::Version
uint32_t Version
Definition: Wasm.h:221
llvm::wasm::WASM_COMDAT_DATA
@ WASM_COMDAT_DATA
Definition: Wasm.h:344
llvm::wasm::WasmTable
Definition: Wasm.h:75
llvm::wasm::NameType::DATA_SEGMENT
@ DATA_SEGMENT
llvm::wasm::WASM_SEC_FUNCTION
@ WASM_SEC_FUNCTION
Definition: Wasm.h:231
llvm::wasm::ValType::V128
@ V128
llvm::wasm::WASM_OPCODE_ATOMIC_NOTIFY
@ WASM_OPCODE_ATOMIC_NOTIFY
Definition: Wasm.h:294
llvm::wasm::WASM_NAMES_DATA_SEGMENT
@ WASM_NAMES_DATA_SEGMENT
Definition: Wasm.h:331
llvm::wasm::WasmRelocation::Index
uint32_t Index
Definition: Wasm.h:179
llvm::wasm::WasmImport::Module
StringRef Module
Definition: Wasm.h:117
SmallVector.h
llvm::wasm::WasmElemSegment
Definition: Wasm.h:161
llvm::wasm::WASM_OPCODE_I64_ADD
@ WASM_OPCODE_I64_ADD
Definition: Wasm.h:281
llvm::wasm::WasmInitExpr::Value
union llvm::wasm::WasmInitExpr::@161 Value
llvm::wasm::WASM_OPCODE_REF_NULL
@ WASM_OPCODE_REF_NULL
Definition: Wasm.h:282
llvm::wasm::WASM_FEATURE_PREFIX_USED
@ WASM_FEATURE_PREFIX_USED
Definition: Wasm.h:321
llvm::wasm::WasmFeatureEntry::Name
std::string Name
Definition: Wasm.h:55
llvm::wasm::WasmInitExpr::Opcode
uint8_t Opcode
Definition: Wasm.h:82
llvm::wasm::WASM_SYMBOL_TABLE
@ WASM_SYMBOL_TABLE
Definition: Wasm.h:339
llvm::wasm::WasmLinkingData
Definition: Wasm.h:220
llvm::wasm::WasmTag::SymbolName
StringRef SymbolName
Definition: Wasm.h:113
llvm::wasm::WasmImport::Kind
uint8_t Kind
Definition: Wasm.h:119
llvm::wasm::WASM_ELEM_SEGMENT_HAS_INIT_EXPRS
@ WASM_ELEM_SEGMENT_HAS_INIT_EXPRS
Definition: Wasm.h:315
llvm::wasm::WASM_LIMITS_FLAG_IS_SHARED
@ WASM_LIMITS_FLAG_IS_SHARED
Definition: Wasm.h:303
llvm::wasm::WASM_TYPE_F64
@ WASM_TYPE_F64
Definition: Wasm.h:249
llvm::wasm::WASM_SEC_DATACOUNT
@ WASM_SEC_DATACOUNT
Definition: Wasm.h:240
llvm::wasm::WasmTableType
Definition: Wasm.h:70
llvm::wasm::WASM_OPCODE_I64_CONST
@ WASM_OPCODE_I64_CONST
Definition: Wasm.h:277
llvm::wasm::WasmDylinkInfo::TableAlignment
uint32_t TableAlignment
Definition: Wasm.h:43
llvm::wasm::WASM_SEG_FLAG_STRINGS
@ WASM_SEG_FLAG_STRINGS
Definition: Wasm.h:361
llvm::wasm::WasmSignature::Params
SmallVector< ValType, 4 > Params
Definition: Wasm.h:404
llvm::wasm::WasmExport
Definition: Wasm.h:58
llvm::wasm::WASM_OPCODE_LOCAL_GET
@ WASM_OPCODE_LOCAL_GET
Definition: Wasm.h:270
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:353
llvm::wasm::WasmSignature
Definition: Wasm.h:402
llvm::wasm::WasmDataSegment::Alignment
uint32_t Alignment
Definition: Wasm.h:156
llvm::wasm::WasmTag::Index
uint32_t Index
Definition: Wasm.h:111
llvm::wasm::WASM_SEC_DATA
@ WASM_SEC_DATA
Definition: Wasm.h:239
llvm::wasm::WasmDataSegment::Name
StringRef Name
Definition: Wasm.h:155
llvm::wasm::WASM_TYPE_FUNC
@ WASM_TYPE_FUNC
Definition: Wasm.h:253
llvm::wasm::WasmPageSize
const uint32_t WasmPageSize
Definition: Wasm.h:32