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