LLVM  15.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/main/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 
43 };
44 
48 };
49 
51  uint32_t MemorySize; // Memory size in bytes
52  uint32_t MemoryAlignment; // P2 alignment of memory
53  uint32_t TableSize; // Table size in elements
54  uint32_t TableAlignment; // P2 alignment of table
55  std::vector<StringRef> Needed; // Shared library dependencies
56  std::vector<WasmDylinkImportInfo> ImportInfo;
57  std::vector<WasmDylinkExportInfo> ExportInfo;
58 };
59 
61  std::vector<std::pair<std::string, std::string>> Languages;
62  std::vector<std::pair<std::string, std::string>> Tools;
63  std::vector<std::pair<std::string, std::string>> SDKs;
64 };
65 
67  uint8_t Prefix;
68  std::string Name;
69 };
70 
71 struct WasmExport {
73  uint8_t Kind;
75 };
76 
77 struct WasmLimits {
78  uint8_t Flags;
81 };
82 
83 struct WasmTableType {
84  uint8_t ElemType;
86 };
87 
88 struct WasmTable {
91  StringRef SymbolName; // from the "linking" section
92 };
93 
95  uint8_t Opcode;
96  union {
97  int32_t Int32;
98  int64_t Int64;
102  } Value;
103 };
104 
105 struct WasmInitExpr {
106  uint8_t Extended; // Set to non-zero if extended const is used (i.e. more than
107  // one instruction)
110 };
111 
113  uint8_t Type;
114  bool Mutable;
115 };
116 
117 struct WasmGlobal {
121  StringRef SymbolName; // from the "linking" section
122 };
123 
124 struct WasmTag {
127  StringRef SymbolName; // from the "linking" section
128 };
129 
130 struct WasmImport {
133  uint8_t Kind;
134  union {
139  };
140 };
141 
143  uint8_t Type;
145 };
146 
147 struct WasmFunction {
150  std::vector<WasmLocalDecl> Locals;
154  uint32_t CodeOffset; // start of Locals and Body
155  Optional<StringRef> ExportName; // from the "export" section
156  StringRef SymbolName; // from the "linking" section
157  StringRef DebugName; // from the "name" section
158  uint32_t Comdat; // from the "comdat info" section
159 };
160 
163  // Present if InitFlags & WASM_DATA_SEGMENT_HAS_MEMINDEX.
165  // Present if InitFlags & WASM_DATA_SEGMENT_IS_PASSIVE == 0.
167 
169  StringRef Name; // from the "segment info" section
172  uint32_t Comdat; // from the "comdat info" section
173 };
174 
178  uint8_t ElemKind;
180  std::vector<uint32_t> Functions;
181 };
182 
183 // Represents the location of a Wasm data symbol within a WasmDataSegment, as
184 // the index of the segment, and the offset and size within the segment.
189 };
190 
192  uint8_t Type; // The type of the relocation.
193  uint32_t Index; // Index into either symbol or type index space.
194  uint64_t Offset; // Offset from the start of the section.
195  int64_t Addend; // A value to add to the symbol.
196 };
197 
198 struct WasmInitFunc {
201 };
202 
205  uint8_t Kind;
207  // For undefined symbols the module of the import
209  // For undefined symbols the name of the import
211  // For symbols to be exported from the final module
213  union {
214  // For function, table, or global symbols, the index in function, table, or
215  // global index space.
217  // For a data symbols, the address of the data relative to segment.
219  };
220 };
221 
222 enum class NameType {
223  FUNCTION,
224  GLOBAL,
225  DATA_SEGMENT,
226 };
227 
232 };
233 
236  std::vector<WasmInitFunc> InitFunctions;
237  std::vector<StringRef> Comdats;
238  std::vector<WasmSymbolInfo> SymbolTable;
239 };
240 
241 enum : unsigned {
242  WASM_SEC_CUSTOM = 0, // Custom / User-defined section
243  WASM_SEC_TYPE = 1, // Function signature declarations
244  WASM_SEC_IMPORT = 2, // Import declarations
245  WASM_SEC_FUNCTION = 3, // Function declarations
246  WASM_SEC_TABLE = 4, // Indirect function table and other tables
247  WASM_SEC_MEMORY = 5, // Memory attributes
248  WASM_SEC_GLOBAL = 6, // Global declarations
249  WASM_SEC_EXPORT = 7, // Exports
250  WASM_SEC_START = 8, // Start function declaration
251  WASM_SEC_ELEM = 9, // Elements section
252  WASM_SEC_CODE = 10, // Function bodies (code)
253  WASM_SEC_DATA = 11, // Data segments
254  WASM_SEC_DATACOUNT = 12, // Data segment count
255  WASM_SEC_TAG = 13, // Tag declarations
257 };
258 
259 // Type immediate encodings used in various contexts.
260 enum : unsigned {
269  WASM_TYPE_NORESULT = 0x40, // for blocks with no result values
270 };
271 
272 // Kinds of externals (for imports and exports).
273 enum : unsigned {
279 };
280 
281 // Opcodes used in initializer expressions.
282 enum : unsigned {
303 };
304 
305 // Opcodes used in synthetic functions.
306 enum : unsigned {
321 };
322 
323 enum : unsigned {
328 };
329 
330 enum : unsigned {
333 };
334 
335 enum : unsigned {
339 };
341 
342 // Feature policy prefixes used in the custom "target_features" section
343 enum : uint8_t {
347 };
348 
349 // Kind codes used in the custom "name" section
350 enum : unsigned {
355 };
356 
357 // Kind codes used in the custom "linking" section
358 enum : unsigned {
363 };
364 
365 // Kind codes used in the custom "dylink" section
366 enum : unsigned {
371 };
372 
373 // Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO
374 enum : unsigned {
377  // GLOBAL, TAG, and TABLE are in here but LLVM doesn't use them yet.
379 };
380 
381 // Kind codes used in the custom "linking" section in the WASM_SYMBOL_TABLE
382 enum WasmSymbolType : unsigned {
389 };
390 
391 enum WasmSegmentFlag : unsigned {
394 };
395 
396 // Kinds of tag attributes.
397 enum WasmTagAttribute : uint8_t {
399 };
400 
401 const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
402 const unsigned WASM_SYMBOL_VISIBILITY_MASK = 0xc;
403 
404 const unsigned WASM_SYMBOL_BINDING_GLOBAL = 0x0;
405 const unsigned WASM_SYMBOL_BINDING_WEAK = 0x1;
406 const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2;
407 const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
408 const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
409 const unsigned WASM_SYMBOL_UNDEFINED = 0x10;
410 const unsigned WASM_SYMBOL_EXPORTED = 0x20;
411 const unsigned WASM_SYMBOL_EXPLICIT_NAME = 0x40;
412 const unsigned WASM_SYMBOL_NO_STRIP = 0x80;
413 const unsigned WASM_SYMBOL_TLS = 0x100;
414 
415 #define WASM_RELOC(name, value) name = value,
416 
417 enum : unsigned {
418 #include "WasmRelocs.def"
419 };
420 
421 #undef WASM_RELOC
422 
423 // Subset of types that a value can have
424 enum class ValType {
425  I32 = WASM_TYPE_I32,
426  I64 = WASM_TYPE_I64,
427  F32 = WASM_TYPE_F32,
428  F64 = WASM_TYPE_F64,
432 };
433 
437  // Support empty and tombstone instances, needed by DenseMap.
439 
441  SmallVector<ValType, 4> &&InParams)
442  : Returns(InReturns), Params(InParams) {}
443  WasmSignature() = default;
444 };
445 
446 // Useful comparison operators
447 inline bool operator==(const WasmSignature &LHS, const WasmSignature &RHS) {
448  return LHS.State == RHS.State && LHS.Returns == RHS.Returns &&
449  LHS.Params == RHS.Params;
450 }
451 
452 inline bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS) {
453  return !(LHS == RHS);
454 }
455 
456 inline bool operator==(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
457  return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable;
458 }
459 
460 inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
461  return !(LHS == RHS);
462 }
463 
464 inline bool operator==(const WasmLimits &LHS, const WasmLimits &RHS) {
465  return LHS.Flags == RHS.Flags && LHS.Minimum == RHS.Minimum &&
466  (LHS.Flags & WASM_LIMITS_FLAG_HAS_MAX ? LHS.Maximum == RHS.Maximum
467  : true);
468 }
469 
470 inline bool operator==(const WasmTableType &LHS, const WasmTableType &RHS) {
471  return LHS.ElemType == RHS.ElemType && LHS.Limits == RHS.Limits;
472 }
473 
478 
479 } // end namespace wasm
480 } // end namespace llvm
481 
482 #endif
llvm::wasm::WASM_EXTERNAL_GLOBAL
@ WASM_EXTERNAL_GLOBAL
Definition: Wasm.h:277
llvm::wasm::WasmImport::Memory
WasmLimits Memory
Definition: Wasm.h:138
llvm::wasm::WASM_SYMBOL_TYPE_SECTION
@ WASM_SYMBOL_TYPE_SECTION
Definition: Wasm.h:386
llvm::wasm::WasmInitExprMVP::Float64
uint64_t Float64
Definition: Wasm.h:100
llvm::wasm::WASM_SYMBOL_EXPORTED
const unsigned WASM_SYMBOL_EXPORTED
Definition: Wasm.h:410
llvm::wasm::WASM_FEATURE_PREFIX_DISALLOWED
@ WASM_FEATURE_PREFIX_DISALLOWED
Definition: Wasm.h:346
llvm::wasm::WASM_EXTERNAL_MEMORY
@ WASM_EXTERNAL_MEMORY
Definition: Wasm.h:276
llvm::wasm::WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
@ WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER
Definition: Wasm.h:337
llvm::wasm::WasmTag
Definition: Wasm.h:124
llvm::wasm::WASM_OPCODE_I64_MUL
@ WASM_OPCODE_I64_MUL
Definition: Wasm.h:301
llvm::wasm::WasmDylinkExportInfo::Flags
uint32_t Flags
Definition: Wasm.h:47
llvm::wasm::WasmDataSegment::Offset
WasmInitExpr Offset
Definition: Wasm.h:166
llvm::wasm::WASM_LIMITS_FLAG_IS_64
@ WASM_LIMITS_FLAG_IS_64
Definition: Wasm.h:327
llvm::wasm::WasmDataSegment::Content
ArrayRef< uint8_t > Content
Definition: Wasm.h:168
llvm::wasm::WASM_OPCODE_REF_NULL
@ WASM_OPCODE_REF_NULL
Definition: Wasm.h:302
llvm::wasm::WasmSegmentFlag
WasmSegmentFlag
Definition: Wasm.h:391
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::wasm::WasmDataSegment::Comdat
uint32_t Comdat
Definition: Wasm.h:172
llvm::wasm::ValType::I32
@ I32
llvm::wasm::WasmElemSegment::Offset
WasmInitExpr Offset
Definition: Wasm.h:179
llvm::wasm::WASM_SEC_GLOBAL
@ WASM_SEC_GLOBAL
Definition: Wasm.h:248
llvm::wasm::WasmFunction::SymbolName
StringRef SymbolName
Definition: Wasm.h:156
llvm::wasm::WASM_DATA_SEGMENT_IS_PASSIVE
@ WASM_DATA_SEGMENT_IS_PASSIVE
Definition: Wasm.h:331
Optional.h
llvm::wasm::WasmFunction::CodeOffset
uint32_t CodeOffset
Definition: Wasm.h:154
llvm::wasm::WASM_OPCODE_GLOBAL_GET
@ WASM_OPCODE_GLOBAL_GET
Definition: Wasm.h:288
llvm::wasm::WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
const unsigned WASM_ELEM_SEGMENT_MASK_HAS_ELEM_KIND
Definition: Wasm.h:340
llvm::wasm::WasmInitExpr::Inst
WasmInitExprMVP Inst
Definition: Wasm.h:108
llvm::wasm::WasmFunction::Body
ArrayRef< uint8_t > Body
Definition: Wasm.h:151
llvm::wasm::WASM_OPCODE_LOCAL_GET
@ WASM_OPCODE_LOCAL_GET
Definition: Wasm.h:285
llvm::wasm::WasmFunction::SigIndex
uint32_t SigIndex
Definition: Wasm.h:149
llvm::wasm::WasmLimits::Minimum
uint64_t Minimum
Definition: Wasm.h:79
llvm::wasm::WASM_DYLINK_IMPORT_INFO
@ WASM_DYLINK_IMPORT_INFO
Definition: Wasm.h:370
StringRef.h
llvm::wasm::WasmDebugName::Index
uint32_t Index
Definition: Wasm.h:230
llvm::wasm::WasmVersion
const uint32_t WasmVersion
Definition: Wasm.h:28
llvm::wasm::WASM_INIT_FUNCS
@ WASM_INIT_FUNCS
Definition: Wasm.h:360
llvm::wasm::WASM_OPCODE_ATOMICS_PREFIX
@ WASM_OPCODE_ATOMICS_PREFIX
Definition: Wasm.h:316
llvm::wasm::WasmFeatureEntry
Definition: Wasm.h:66
llvm::SmallVector< ValType, 1 >
llvm::wasm::WasmObjectHeader::Version
uint32_t Version
Definition: Wasm.h:36
llvm::wasm::WasmLinkingData::SymbolTable
std::vector< WasmSymbolInfo > SymbolTable
Definition: Wasm.h:238
llvm::wasm::WASM_SYMBOL_NO_STRIP
const unsigned WASM_SYMBOL_NO_STRIP
Definition: Wasm.h:412
llvm::wasm::WasmDataSegment::InitFlags
uint32_t InitFlags
Definition: Wasm.h:162
llvm::wasm::WasmFunction::Comdat
uint32_t Comdat
Definition: Wasm.h:158
llvm::wasm::WASM_OPCODE_I32_RMW_CMPXCHG
@ WASM_OPCODE_I32_RMW_CMPXCHG
Definition: Wasm.h:320
llvm::wasm::WASM_SYMBOL_BINDING_LOCAL
const unsigned WASM_SYMBOL_BINDING_LOCAL
Definition: Wasm.h:406
llvm::wasm::WASM_OPCODE_I64_CONST
@ WASM_OPCODE_I64_CONST
Definition: Wasm.h:293
llvm::wasm::WASM_SYMBOL_TYPE_TABLE
@ WASM_SYMBOL_TYPE_TABLE
Definition: Wasm.h:388
llvm::wasm::relocTypetoString
llvm::StringRef relocTypetoString(uint32_t type)
Definition: Wasm.cpp:29
llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:385
llvm::wasm::WasmRelocation
Definition: Wasm.h:191
llvm::wasm::WasmSignature::Empty
@ Empty
Definition: Wasm.h:438
llvm::wasm::WasmImport::Table
WasmTableType Table
Definition: Wasm.h:137
llvm::wasm::WASM_OPCODE_I32_SUB
@ WASM_OPCODE_I32_SUB
Definition: Wasm.h:297
llvm::wasm::WASM_SYMBOL_TABLE
@ WASM_SYMBOL_TABLE
Definition: Wasm.h:362
llvm::wasm::WASM_OPCODE_CALL
@ WASM_OPCODE_CALL
Definition: Wasm.h:284
llvm::wasm::WasmDylinkInfo::ImportInfo
std::vector< WasmDylinkImportInfo > ImportInfo
Definition: Wasm.h:56
llvm::wasm::WASM_ELEM_SEGMENT_IS_PASSIVE
@ WASM_ELEM_SEGMENT_IS_PASSIVE
Definition: Wasm.h:336
llvm::wasm::WasmImport::SigIndex
uint32_t SigIndex
Definition: Wasm.h:135
llvm::wasm::WASM_EXTERNAL_TAG
@ WASM_EXTERNAL_TAG
Definition: Wasm.h:278
llvm::wasm::WasmElemSegment::ElemKind
uint8_t ElemKind
Definition: Wasm.h:178
llvm::Optional
Definition: APInt.h:33
llvm::wasm::WASM_SYMBOL_UNDEFINED
const unsigned WASM_SYMBOL_UNDEFINED
Definition: Wasm.h:409
llvm::wasm::WASM_OPCODE_GLOBAL_SET
@ WASM_OPCODE_GLOBAL_SET
Definition: Wasm.h:289
llvm::wasm::WASM_FEATURE_PREFIX_REQUIRED
@ WASM_FEATURE_PREFIX_REQUIRED
Definition: Wasm.h:345
llvm::wasm::WasmFunction::Locals
std::vector< WasmLocalDecl > Locals
Definition: Wasm.h:150
llvm::wasm::WASM_TYPE_F32
@ WASM_TYPE_F32
Definition: Wasm.h:263
llvm::wasm::WasmSymbolInfo::Kind
uint8_t Kind
Definition: Wasm.h:205
llvm::wasm::WasmDebugName::Name
StringRef Name
Definition: Wasm.h:231
llvm::wasm::WasmFunction
Definition: Wasm.h:147
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::wasm::WasmSignature::WasmSignature
WasmSignature(SmallVector< ValType, 1 > &&InReturns, SmallVector< ValType, 4 > &&InParams)
Definition: Wasm.h:440
llvm::wasm::WasmExport::Kind
uint8_t Kind
Definition: Wasm.h:73
llvm::wasm::WasmDataReference::Offset
uint64_t Offset
Definition: Wasm.h:187
llvm::wasm::WASM_SEC_LAST_KNOWN
@ WASM_SEC_LAST_KNOWN
Definition: Wasm.h:256
llvm::wasm::toString
llvm::StringRef toString(WasmSymbolType type)
Definition: Wasm.cpp:11
llvm::wasm::WasmDataReference
Definition: Wasm.h:185
llvm::wasm::WasmGlobal::Type
WasmGlobalType Type
Definition: Wasm.h:119
llvm::wasm::WasmExport::Index
uint32_t Index
Definition: Wasm.h:74
llvm::wasm::WasmProducerInfo
Definition: Wasm.h:60
llvm::wasm::WASM_NAMES_LOCAL
@ WASM_NAMES_LOCAL
Definition: Wasm.h:352
llvm::wasm::WASM_NAMES_FUNCTION
@ WASM_NAMES_FUNCTION
Definition: Wasm.h:351
llvm::wasm::WASM_OPCODE_I32_MUL
@ WASM_OPCODE_I32_MUL
Definition: Wasm.h:298
llvm::wasm::WasmRelocation::Offset
uint64_t Offset
Definition: Wasm.h:194
llvm::wasm::WASM_SEC_CUSTOM
@ WASM_SEC_CUSTOM
Definition: Wasm.h:242
llvm::wasm::WASM_OPCODE_BR
@ WASM_OPCODE_BR
Definition: Wasm.h:308
llvm::wasm::WASM_OPCODE_I32_CONST
@ WASM_OPCODE_I32_CONST
Definition: Wasm.h:292
llvm::wasm::WASM_OPCODE_I32_STORE
@ WASM_OPCODE_I32_STORE
Definition: Wasm.h:290
llvm::wasm::WasmElemSegment::TableNumber
uint32_t TableNumber
Definition: Wasm.h:177
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::wasm::WASM_SEC_TAG
@ WASM_SEC_TAG
Definition: Wasm.h:255
llvm::wasm::WASM_SYMBOL_BINDING_WEAK
const unsigned WASM_SYMBOL_BINDING_WEAK
Definition: Wasm.h:405
llvm::wasm::WasmInitFunc::Priority
uint32_t Priority
Definition: Wasm.h:199
llvm::wasm::WasmFunction::DebugName
StringRef DebugName
Definition: Wasm.h:157
llvm::wasm::WASM_TYPE_F64
@ WASM_TYPE_F64
Definition: Wasm.h:264
llvm::wasm::WASM_TYPE_FUNCREF
@ WASM_TYPE_FUNCREF
Definition: Wasm.h:266
llvm::wasm::WasmSymbolInfo::ExportName
Optional< StringRef > ExportName
Definition: Wasm.h:212
llvm::wasm::ValType::F64
@ F64
llvm::wasm::WasmGlobalType::Mutable
bool Mutable
Definition: Wasm.h:114
llvm::wasm::WasmSignature::State
enum llvm::wasm::WasmSignature::@177 State
llvm::wasm::WasmLimits
Definition: Wasm.h:77
llvm::wasm::WasmRelocation::Addend
int64_t Addend
Definition: Wasm.h:195
llvm::wasm::WASM_SYMBOL_VISIBILITY_MASK
const unsigned WASM_SYMBOL_VISIBILITY_MASK
Definition: Wasm.h:402
llvm::wasm::WasmTableType::ElemType
uint8_t ElemType
Definition: Wasm.h:84
llvm::wasm::WASM_SYMBOL_VISIBILITY_HIDDEN
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN
Definition: Wasm.h:408
llvm::wasm::WASM_SEC_MEMORY
@ WASM_SEC_MEMORY
Definition: Wasm.h:247
llvm::wasm::WasmFeatureEntry::Prefix
uint8_t Prefix
Definition: Wasm.h:67
llvm::wasm::WASM_SEC_DATACOUNT
@ WASM_SEC_DATACOUNT
Definition: Wasm.h:254
llvm::wasm::WASM_SYMBOL_TLS
const unsigned WASM_SYMBOL_TLS
Definition: Wasm.h:413
llvm::wasm::ValType::F32
@ F32
llvm::wasm::WasmGlobalType
Definition: Wasm.h:112
llvm::wasm::WASM_SEC_TABLE
@ WASM_SEC_TABLE
Definition: Wasm.h:246
llvm::wasm::WasmFunction::CodeSectionOffset
uint32_t CodeSectionOffset
Definition: Wasm.h:152
llvm::wasm::WasmSignature::WasmSignature
WasmSignature()=default
llvm::wasm::WasmProducerInfo::Languages
std::vector< std::pair< std::string, std::string > > Languages
Definition: Wasm.h:61
llvm::wasm::WasmGlobal::SymbolName
StringRef SymbolName
Definition: Wasm.h:121
llvm::wasm::WasmTable::SymbolName
StringRef SymbolName
Definition: Wasm.h:91
llvm::wasm::WasmInitExprMVP::Int64
int64_t Int64
Definition: Wasm.h:98
llvm::wasm::WasmDylinkInfo::MemoryAlignment
uint32_t MemoryAlignment
Definition: Wasm.h:52
llvm::wasm::WasmDataReference::Size
uint64_t Size
Definition: Wasm.h:188
llvm::wasm::WasmInitFunc::Symbol
uint32_t Symbol
Definition: Wasm.h:200
llvm::wasm::WASM_DYLINK_MEM_INFO
@ WASM_DYLINK_MEM_INFO
Definition: Wasm.h:367
llvm::wasm::WASM_OPCODE_END
@ WASM_OPCODE_END
Definition: Wasm.h:283
llvm::wasm::WasmTagAttribute
WasmTagAttribute
Definition: Wasm.h:397
llvm::wasm::WASM_SEC_START
@ WASM_SEC_START
Definition: Wasm.h:250
llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION
@ WASM_SYMBOL_TYPE_FUNCTION
Definition: Wasm.h:383
llvm::wasm::WasmMetadataVersion
const uint32_t WasmMetadataVersion
Definition: Wasm.h:30
llvm::wasm::NameType::FUNCTION
@ FUNCTION
llvm::wasm::ValType
ValType
Definition: Wasm.h:424
NameType
Definition: ItaniumDemangle.h:471
llvm::wasm::WasmLocalDecl::Type
uint8_t Type
Definition: Wasm.h:143
llvm::wasm::WasmTable::Index
uint32_t Index
Definition: Wasm.h:89
llvm::wasm::WASM_TYPE_V128
@ WASM_TYPE_V128
Definition: Wasm.h:265
llvm::wasm::WASM_OPCODE_DROP
@ WASM_OPCODE_DROP
Definition: Wasm.h:311
llvm::wasm::WASM_SEC_FUNCTION
@ WASM_SEC_FUNCTION
Definition: Wasm.h:245
llvm::wasm::WASM_LIMITS_FLAG_NONE
@ WASM_LIMITS_FLAG_NONE
Definition: Wasm.h:324
llvm::wasm::WasmTable::Type
WasmTableType Type
Definition: Wasm.h:90
llvm::wasm::WASM_SEC_EXPORT
@ WASM_SEC_EXPORT
Definition: Wasm.h:249
llvm::wasm::WasmInitExpr::Body
ArrayRef< uint8_t > Body
Definition: Wasm.h:109
llvm::wasm::WasmSymbolInfo::Name
StringRef Name
Definition: Wasm.h:204
llvm::wasm::WasmImport::Field
StringRef Field
Definition: Wasm.h:132
llvm::wasm::WasmSymbolInfo::ElementIndex
uint32_t ElementIndex
Definition: Wasm.h:216
llvm::wasm::WasmObjectHeader::Magic
StringRef Magic
Definition: Wasm.h:35
llvm::wasm::WASM_SEG_FLAG_TLS
@ WASM_SEG_FLAG_TLS
Definition: Wasm.h:393
llvm::wasm::WasmSymbolInfo::ImportModule
Optional< StringRef > ImportModule
Definition: Wasm.h:208
llvm::wasm::NameType::GLOBAL
@ GLOBAL
llvm::wasm::WasmDylinkInfo
Definition: Wasm.h:50
llvm::wasm::WasmInitExprMVP::Value
union llvm::wasm::WasmInitExprMVP::@172 Value
llvm::wasm::operator!=
bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS)
Definition: Wasm.h:452
llvm::wasm::WasmLinkingData::Comdats
std::vector< StringRef > Comdats
Definition: Wasm.h:237
llvm::wasm::WasmLimits::Flags
uint8_t Flags
Definition: Wasm.h:78
llvm::wasm::WASM_TAG_ATTRIBUTE_EXCEPTION
@ WASM_TAG_ATTRIBUTE_EXCEPTION
Definition: Wasm.h:398
llvm::wasm::WasmRelocation::Type
uint8_t Type
Definition: Wasm.h:192
llvm::wasm::WASM_SEC_IMPORT
@ WASM_SEC_IMPORT
Definition: Wasm.h:244
llvm::wasm::WASM_SYMBOL_VISIBILITY_DEFAULT
const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT
Definition: Wasm.h:407
llvm::wasm::WasmDataSegment::LinkingFlags
uint32_t LinkingFlags
Definition: Wasm.h:171
llvm::wasm::WasmFunction::Size
uint32_t Size
Definition: Wasm.h:153
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
uint64_t
llvm::wasm::WASM_FEATURE_PREFIX_USED
@ WASM_FEATURE_PREFIX_USED
Definition: Wasm.h:344
llvm::wasm::WasmElemSegment::Functions
std::vector< uint32_t > Functions
Definition: Wasm.h:180
llvm::wasm::ValType::EXTERNREF
@ EXTERNREF
llvm::wasm::WasmExport::Name
StringRef Name
Definition: Wasm.h:72
llvm::wasm::WASM_SYMBOL_EXPLICIT_NAME
const unsigned WASM_SYMBOL_EXPLICIT_NAME
Definition: Wasm.h:411
llvm::wasm::WASM_OPCODE_I64_STORE
@ WASM_OPCODE_I64_STORE
Definition: Wasm.h:291
llvm::wasm::ValType::I64
@ I64
llvm::wasm::WASM_SEC_DATA
@ WASM_SEC_DATA
Definition: Wasm.h:253
llvm::wasm::WASM_ELEM_SEGMENT_HAS_INIT_EXPRS
@ WASM_ELEM_SEGMENT_HAS_INIT_EXPRS
Definition: Wasm.h:338
llvm::wasm::WasmLocalDecl
Definition: Wasm.h:142
llvm::wasm::ValType::FUNCREF
@ FUNCREF
llvm::wasm::WasmInitExprMVP
Definition: Wasm.h:94
llvm::wasm::WasmProducerInfo::Tools
std::vector< std::pair< std::string, std::string > > Tools
Definition: Wasm.h:62
llvm::wasm::WasmDylinkImportInfo::Field
StringRef Field
Definition: Wasm.h:41
llvm::wasm::WasmGlobal::InitExpr
WasmInitExpr InitExpr
Definition: Wasm.h:120
llvm::wasm::WasmGlobal::Index
uint32_t Index
Definition: Wasm.h:118
llvm::wasm::WasmDebugName::Type
NameType Type
Definition: Wasm.h:229
llvm::wasm::WasmSignature::Returns
SmallVector< ValType, 1 > Returns
Definition: Wasm.h:435
llvm::wasm::WasmDylinkInfo::TableSize
uint32_t TableSize
Definition: Wasm.h:53
llvm::wasm::WasmImport
Definition: Wasm.h:130
ArrayRef.h
llvm::wasm::WASM_SYMBOL_TYPE_TAG
@ WASM_SYMBOL_TYPE_TAG
Definition: Wasm.h:387
llvm::wasm::WASM_OPCODE_I32_ATOMIC_STORE
@ WASM_OPCODE_I32_ATOMIC_STORE
Definition: Wasm.h:319
llvm::wasm::WASM_OPCODE_BR_TABLE
@ WASM_OPCODE_BR_TABLE
Definition: Wasm.h:309
llvm::wasm::WASM_TYPE_FUNC
@ WASM_TYPE_FUNC
Definition: Wasm.h:268
llvm::wasm::WasmDylinkImportInfo::Module
StringRef Module
Definition: Wasm.h:40
llvm::wasm::WasmFunction::Index
uint32_t Index
Definition: Wasm.h:148
llvm::wasm::WasmDebugName
Definition: Wasm.h:228
llvm::wasm::WASM_OPCODE_F32_CONST
@ WASM_OPCODE_F32_CONST
Definition: Wasm.h:294
llvm::wasm::WASM_NAMES_DATA_SEGMENT
@ WASM_NAMES_DATA_SEGMENT
Definition: Wasm.h:354
llvm::wasm::relocTypeHasAddend
bool relocTypeHasAddend(uint32_t type)
Definition: Wasm.cpp:66
llvm::wasm::WASM_OPCODE_MEMORY_INIT
@ WASM_OPCODE_MEMORY_INIT
Definition: Wasm.h:313
llvm::wasm::WasmDylinkImportInfo::Flags
uint32_t Flags
Definition: Wasm.h:42
llvm::wasm::WasmInitExprMVP::Global
uint32_t Global
Definition: Wasm.h:101
llvm::wasm::WASM_OPCODE_MISC_PREFIX
@ WASM_OPCODE_MISC_PREFIX
Definition: Wasm.h:312
llvm::wasm::WasmSignature::Tombstone
@ Tombstone
Definition: Wasm.h:438
llvm::wasm::WASM_OPCODE_DATA_DROP
@ WASM_OPCODE_DATA_DROP
Definition: Wasm.h:315
llvm::wasm::WasmElemSegment::Flags
uint32_t Flags
Definition: Wasm.h:176
llvm::wasm::WASM_OPCODE_BLOCK
@ WASM_OPCODE_BLOCK
Definition: Wasm.h:307
llvm::wasm::WASM_NAMES_GLOBAL
@ WASM_NAMES_GLOBAL
Definition: Wasm.h:353
llvm::ArrayRef< uint8_t >
llvm::wasm::WASM_OPCODE_I32_ATOMIC_WAIT
@ WASM_OPCODE_I32_ATOMIC_WAIT
Definition: Wasm.h:318
llvm::wasm::WasmDylinkInfo::ExportInfo
std::vector< WasmDylinkExportInfo > ExportInfo
Definition: Wasm.h:57
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::wasm::WasmLimits::Maximum
uint64_t Maximum
Definition: Wasm.h:80
llvm::wasm::WasmObjectHeader
Definition: Wasm.h:34
llvm::wasm::WasmGlobal
Definition: Wasm.h:117
llvm::wasm::WasmInitExprMVP::Int32
int32_t Int32
Definition: Wasm.h:97
uint32_t
llvm::wasm::WASM_SEC_ELEM
@ WASM_SEC_ELEM
Definition: Wasm.h:251
llvm::wasm::WASM_SYMBOL_BINDING_MASK
const unsigned WASM_SYMBOL_BINDING_MASK
Definition: Wasm.h:401
llvm::wasm::WASM_SEGMENT_INFO
@ WASM_SEGMENT_INFO
Definition: Wasm.h:359
llvm::wasm::WasmSymbolType
WasmSymbolType
Definition: Wasm.h:382
llvm::wasm::WASM_OPCODE_I64_SUB
@ WASM_OPCODE_I64_SUB
Definition: Wasm.h:300
llvm::wasm::WASM_OPCODE_LOCAL_TEE
@ WASM_OPCODE_LOCAL_TEE
Definition: Wasm.h:287
llvm::wasm::WASM_EXTERNAL_TABLE
@ WASM_EXTERNAL_TABLE
Definition: Wasm.h:275
llvm::wasm::WasmTableType::Limits
WasmLimits Limits
Definition: Wasm.h:85
llvm::wasm::WasmSymbolInfo
Definition: Wasm.h:203
llvm::wasm::WasmDylinkExportInfo
Definition: Wasm.h:45
llvm::wasm::WasmDylinkInfo::Needed
std::vector< StringRef > Needed
Definition: Wasm.h:55
llvm::wasm::WasmImport::Global
WasmGlobalType Global
Definition: Wasm.h:136
llvm::wasm::WasmGlobalType::Type
uint8_t Type
Definition: Wasm.h:113
llvm::wasm::WASM_LIMITS_FLAG_HAS_MAX
@ WASM_LIMITS_FLAG_HAS_MAX
Definition: Wasm.h:325
llvm::wasm::WasmSymbolInfo::DataRef
WasmDataReference DataRef
Definition: Wasm.h:218
llvm::wasm::WasmDylinkImportInfo
Definition: Wasm.h:39
llvm::wasm::operator==
bool operator==(const WasmSignature &LHS, const WasmSignature &RHS)
Definition: Wasm.h:447
llvm::wasm::WasmProducerInfo::SDKs
std::vector< std::pair< std::string, std::string > > SDKs
Definition: Wasm.h:63
llvm::wasm::WasmDataReference::Segment
uint32_t Segment
Definition: Wasm.h:186
llvm::wasm::WASM_COMDAT_DATA
@ WASM_COMDAT_DATA
Definition: Wasm.h:375
llvm::wasm::WASM_OPCODE_ATOMIC_NOTIFY
@ WASM_OPCODE_ATOMIC_NOTIFY
Definition: Wasm.h:317
llvm::wasm::WASM_COMDAT_FUNCTION
@ WASM_COMDAT_FUNCTION
Definition: Wasm.h:376
llvm::wasm::WASM_DYLINK_EXPORT_INFO
@ WASM_DYLINK_EXPORT_INFO
Definition: Wasm.h:369
llvm::wasm::WasmDataSegment::MemoryIndex
uint32_t MemoryIndex
Definition: Wasm.h:164
llvm::wasm::WasmMagic
const char WasmMagic[]
Definition: Wasm.h:26
llvm::wasm::WasmLinkingData::InitFunctions
std::vector< WasmInitFunc > InitFunctions
Definition: Wasm.h:236
llvm::wasm::WASM_SEC_CODE
@ WASM_SEC_CODE
Definition: Wasm.h:252
llvm::wasm::WASM_SYMBOL_BINDING_GLOBAL
const unsigned WASM_SYMBOL_BINDING_GLOBAL
Definition: Wasm.h:404
llvm::wasm::WasmDylinkInfo::MemorySize
uint32_t MemorySize
Definition: Wasm.h:51
llvm::wasm::WasmInitFunc
Definition: Wasm.h:198
llvm::wasm::WasmSymbolInfo::Flags
uint32_t Flags
Definition: Wasm.h:206
llvm::wasm::WasmLocalDecl::Count
uint32_t Count
Definition: Wasm.h:144
llvm::wasm::WASM_EXTERNAL_FUNCTION
@ WASM_EXTERNAL_FUNCTION
Definition: Wasm.h:274
llvm::wasm::WasmSignature::Plain
@ Plain
Definition: Wasm.h:438
llvm::wasm::WasmSymbolInfo::ImportName
Optional< StringRef > ImportName
Definition: Wasm.h:210
llvm::wasm::WasmDataSegment
Definition: Wasm.h:161
llvm::wasm::WASM_OPCODE_RETURN
@ WASM_OPCODE_RETURN
Definition: Wasm.h:310
llvm::wasm::WasmInitExpr
Definition: Wasm.h:105
llvm::wasm::WasmFunction::ExportName
Optional< StringRef > ExportName
Definition: Wasm.h:155
llvm::wasm::WasmLinkingData::Version
uint32_t Version
Definition: Wasm.h:235
llvm::wasm::WasmTable
Definition: Wasm.h:88
llvm::wasm::NameType::DATA_SEGMENT
@ DATA_SEGMENT
llvm::wasm::WasmDylinkExportInfo::Name
StringRef Name
Definition: Wasm.h:46
llvm::wasm::ValType::V128
@ V128
llvm::wasm::WasmRelocation::Index
uint32_t Index
Definition: Wasm.h:193
llvm::wasm::WasmImport::Module
StringRef Module
Definition: Wasm.h:131
SmallVector.h
llvm::wasm::WASM_COMDAT_SECTION
@ WASM_COMDAT_SECTION
Definition: Wasm.h:378
llvm::wasm::sectionTypeToString
llvm::StringRef sectionTypeToString(uint32_t type)
Definition: Wasm.cpp:41
llvm::wasm::WASM_TYPE_I64
@ WASM_TYPE_I64
Definition: Wasm.h:262
llvm::wasm::WasmElemSegment
Definition: Wasm.h:175
llvm::wasm::WasmFeatureEntry::Name
std::string Name
Definition: Wasm.h:68
llvm::wasm::WASM_TYPE_EXTERNREF
@ WASM_TYPE_EXTERNREF
Definition: Wasm.h:267
llvm::wasm::WasmLinkingData
Definition: Wasm.h:234
llvm::wasm::WasmTag::SymbolName
StringRef SymbolName
Definition: Wasm.h:127
llvm::wasm::WasmImport::Kind
uint8_t Kind
Definition: Wasm.h:133
llvm::wasm::WasmInitExprMVP::Opcode
uint8_t Opcode
Definition: Wasm.h:95
llvm::wasm::WASM_SEC_TYPE
@ WASM_SEC_TYPE
Definition: Wasm.h:243
llvm::wasm::WASM_TYPE_I32
@ WASM_TYPE_I32
Definition: Wasm.h:261
llvm::wasm::WASM_OPCODE_MEMORY_FILL
@ WASM_OPCODE_MEMORY_FILL
Definition: Wasm.h:314
llvm::wasm::WASM_OPCODE_F64_CONST
@ WASM_OPCODE_F64_CONST
Definition: Wasm.h:295
llvm::wasm::WASM_LIMITS_FLAG_IS_SHARED
@ WASM_LIMITS_FLAG_IS_SHARED
Definition: Wasm.h:326
llvm::wasm::WasmTableType
Definition: Wasm.h:83
llvm::wasm::WasmInitExprMVP::Float32
uint32_t Float32
Definition: Wasm.h:99
llvm::wasm::WasmDylinkInfo::TableAlignment
uint32_t TableAlignment
Definition: Wasm.h:54
llvm::wasm::WASM_COMDAT_INFO
@ WASM_COMDAT_INFO
Definition: Wasm.h:361
llvm::wasm::WasmInitExpr::Extended
uint8_t Extended
Definition: Wasm.h:106
llvm::wasm::WASM_SEG_FLAG_STRINGS
@ WASM_SEG_FLAG_STRINGS
Definition: Wasm.h:392
llvm::wasm::WASM_DATA_SEGMENT_HAS_MEMINDEX
@ WASM_DATA_SEGMENT_HAS_MEMINDEX
Definition: Wasm.h:332
llvm::wasm::WasmSignature::Params
SmallVector< ValType, 4 > Params
Definition: Wasm.h:436
llvm::wasm::WasmExport
Definition: Wasm.h:71
llvm::wasm::WASM_OPCODE_I64_ADD
@ WASM_OPCODE_I64_ADD
Definition: Wasm.h:299
llvm::wasm::WASM_SYMBOL_TYPE_DATA
@ WASM_SYMBOL_TYPE_DATA
Definition: Wasm.h:384
llvm::wasm::WasmSignature
Definition: Wasm.h:434
llvm::wasm::WasmDataSegment::Alignment
uint32_t Alignment
Definition: Wasm.h:170
llvm::wasm::WASM_OPCODE_I32_ADD
@ WASM_OPCODE_I32_ADD
Definition: Wasm.h:296
llvm::wasm::WASM_OPCODE_LOCAL_SET
@ WASM_OPCODE_LOCAL_SET
Definition: Wasm.h:286
llvm::wasm::WasmTag::Index
uint32_t Index
Definition: Wasm.h:125
llvm::wasm::WasmDataSegment::Name
StringRef Name
Definition: Wasm.h:169
llvm::wasm::WasmTag::SigIndex
uint32_t SigIndex
Definition: Wasm.h:126
llvm::wasm::WASM_DYLINK_NEEDED
@ WASM_DYLINK_NEEDED
Definition: Wasm.h:368
llvm::wasm::WASM_TYPE_NORESULT
@ WASM_TYPE_NORESULT
Definition: Wasm.h:269
llvm::wasm::WasmPageSize
const uint32_t WasmPageSize
Definition: Wasm.h:32