2016-11-30 17:49:11 +01:00
|
|
|
//===- Wasm.h - Wasm object file format -------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-11-30 17:49:11 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines manifest constants for the wasm object file format.
|
|
|
|
// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-07 05:48:56 +02:00
|
|
|
#ifndef LLVM_BINARYFORMAT_WASM_H
|
|
|
|
#define LLVM_BINARYFORMAT_WASM_H
|
2016-11-30 17:49:11 +01:00
|
|
|
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2018-10-04 00:22:48 +02:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2016-11-30 17:49:11 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace wasm {
|
|
|
|
|
|
|
|
// Object file magic string.
|
|
|
|
const char WasmMagic[] = {'\0', 'a', 's', 'm'};
|
|
|
|
// Wasm binary format version
|
2017-02-22 19:50:20 +01:00
|
|
|
const uint32_t WasmVersion = 0x1;
|
2018-04-26 20:15:32 +02:00
|
|
|
// Wasm linking metadata version
|
2019-01-16 02:34:48 +01:00
|
|
|
const uint32_t WasmMetadataVersion = 0x2;
|
2017-04-28 23:12:09 +02:00
|
|
|
// Wasm uses a 64k page size
|
|
|
|
const uint32_t WasmPageSize = 65536;
|
2016-11-30 17:49:11 +01:00
|
|
|
|
|
|
|
struct WasmObjectHeader {
|
|
|
|
StringRef Magic;
|
|
|
|
uint32_t Version;
|
|
|
|
};
|
|
|
|
|
2018-11-14 19:36:24 +01:00
|
|
|
struct WasmDylinkInfo {
|
|
|
|
uint32_t MemorySize; // Memory size in bytes
|
|
|
|
uint32_t MemoryAlignment; // P2 alignment of memory
|
|
|
|
uint32_t TableSize; // Table size in elements
|
|
|
|
uint32_t TableAlignment; // P2 alignment of table
|
2018-12-13 00:40:58 +01:00
|
|
|
std::vector<StringRef> Needed; // Shared library depenedencies
|
2018-11-14 19:36:24 +01:00
|
|
|
};
|
|
|
|
|
2019-01-17 03:29:55 +01:00
|
|
|
struct WasmProducerInfo {
|
|
|
|
std::vector<std::pair<std::string, std::string>> Languages;
|
|
|
|
std::vector<std::pair<std::string, std::string>> Tools;
|
|
|
|
std::vector<std::pair<std::string, std::string>> SDKs;
|
|
|
|
};
|
|
|
|
|
[WebAssembly] Target features section
Summary:
Implements a new target features section in assembly and object files
that records what features are used, required, and disallowed in
WebAssembly objects. The linker uses this information to ensure that
all objects participating in a link are feature-compatible and records
the set of used features in the output binary for use by optimizers
and other tools later in the toolchain.
The "atomics" feature is always required or disallowed to prevent
linking code with stripped atomics into multithreaded binaries. Other
features are marked used if they are enabled globally or on any
function in a module.
Future CLs will add linker flags for ignoring feature compatibility
checks and for specifying the set of allowed features, implement using
the presence of the "atomics" feature to control the type of memory
and segments in the linked binary, and add front-end flags for
relaxing the linkage policy for atomics.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59173
llvm-svn: 356610
2019-03-20 21:26:45 +01:00
|
|
|
struct WasmFeatureEntry {
|
|
|
|
uint8_t Prefix;
|
|
|
|
std::string Name;
|
|
|
|
};
|
|
|
|
|
2017-03-30 21:44:09 +02:00
|
|
|
struct WasmExport {
|
|
|
|
StringRef Name;
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Kind;
|
2017-03-30 21:44:09 +02:00
|
|
|
uint32_t Index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmLimits {
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Flags;
|
2017-03-30 21:44:09 +02:00
|
|
|
uint32_t Initial;
|
|
|
|
uint32_t Maximum;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmTable {
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t ElemType;
|
2017-03-30 21:44:09 +02:00
|
|
|
WasmLimits Limits;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmInitExpr {
|
|
|
|
uint8_t Opcode;
|
|
|
|
union {
|
|
|
|
int32_t Int32;
|
|
|
|
int64_t Int64;
|
|
|
|
int32_t Float32;
|
|
|
|
int64_t Float64;
|
|
|
|
uint32_t Global;
|
|
|
|
} Value;
|
|
|
|
};
|
|
|
|
|
2018-01-31 20:50:14 +01:00
|
|
|
struct WasmGlobalType {
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Type;
|
2017-03-30 21:44:09 +02:00
|
|
|
bool Mutable;
|
2018-01-31 20:50:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmGlobal {
|
|
|
|
uint32_t Index;
|
|
|
|
WasmGlobalType Type;
|
2017-03-30 21:44:09 +02:00
|
|
|
WasmInitExpr InitExpr;
|
2018-04-20 19:07:24 +02:00
|
|
|
StringRef SymbolName; // from the "linking" section
|
2017-03-30 21:44:09 +02:00
|
|
|
};
|
|
|
|
|
2018-11-14 03:46:21 +01:00
|
|
|
struct WasmEventType {
|
|
|
|
// Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible.
|
|
|
|
uint32_t Attribute;
|
|
|
|
uint32_t SigIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmEvent {
|
|
|
|
uint32_t Index;
|
|
|
|
WasmEventType Type;
|
|
|
|
StringRef SymbolName; // from the "linking" section
|
|
|
|
};
|
|
|
|
|
2017-05-10 01:48:41 +02:00
|
|
|
struct WasmImport {
|
|
|
|
StringRef Module;
|
|
|
|
StringRef Field;
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Kind;
|
2017-05-10 01:48:41 +02:00
|
|
|
union {
|
|
|
|
uint32_t SigIndex;
|
2018-01-31 20:50:14 +01:00
|
|
|
WasmGlobalType Global;
|
2017-05-10 01:48:41 +02:00
|
|
|
WasmTable Table;
|
|
|
|
WasmLimits Memory;
|
2018-11-14 03:46:21 +01:00
|
|
|
WasmEventType Event;
|
2017-05-10 01:48:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-03-30 21:44:09 +02:00
|
|
|
struct WasmLocalDecl {
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Type;
|
2017-03-30 21:44:09 +02:00
|
|
|
uint32_t Count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmFunction {
|
2018-01-09 22:38:53 +01:00
|
|
|
uint32_t Index;
|
2017-03-30 21:44:09 +02:00
|
|
|
std::vector<WasmLocalDecl> Locals;
|
|
|
|
ArrayRef<uint8_t> Body;
|
2017-12-17 18:50:07 +01:00
|
|
|
uint32_t CodeSectionOffset;
|
|
|
|
uint32_t Size;
|
2018-05-15 23:49:58 +02:00
|
|
|
uint32_t CodeOffset; // start of Locals and Body
|
2018-04-20 19:07:24 +02:00
|
|
|
StringRef SymbolName; // from the "linking" section
|
2018-09-05 03:27:38 +02:00
|
|
|
StringRef DebugName; // from the "name" section
|
|
|
|
uint32_t Comdat; // from the "comdat info" section
|
2017-03-30 21:44:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmDataSegment {
|
2019-02-19 23:56:19 +01:00
|
|
|
uint32_t InitFlags;
|
|
|
|
uint32_t MemoryIndex; // present if InitFlags & WASM_SEGMENT_HAS_MEMINDEX
|
|
|
|
WasmInitExpr Offset; // present if InitFlags & WASM_SEGMENT_IS_PASSIVE == 0
|
2017-03-30 21:44:09 +02:00
|
|
|
ArrayRef<uint8_t> Content;
|
2018-04-20 19:07:24 +02:00
|
|
|
StringRef Name; // from the "segment info" section
|
2017-09-29 18:50:08 +02:00
|
|
|
uint32_t Alignment;
|
2019-02-19 23:56:19 +01:00
|
|
|
uint32_t LinkerFlags;
|
2018-03-14 16:44:45 +01:00
|
|
|
uint32_t Comdat; // from the "comdat info" section
|
2017-03-30 21:44:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmElemSegment {
|
|
|
|
uint32_t TableIndex;
|
|
|
|
WasmInitExpr Offset;
|
|
|
|
std::vector<uint32_t> Functions;
|
|
|
|
};
|
|
|
|
|
2018-02-23 06:08:34 +01:00
|
|
|
// Represents the location of a Wasm data symbol within a WasmDataSegment, as
|
|
|
|
// the index of the segment, and the offset and size within the segment.
|
|
|
|
struct WasmDataReference {
|
|
|
|
uint32_t Segment;
|
|
|
|
uint32_t Offset;
|
|
|
|
uint32_t Size;
|
|
|
|
};
|
|
|
|
|
2017-03-30 21:44:09 +02:00
|
|
|
struct WasmRelocation {
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Type; // The type of the relocation.
|
2018-02-23 06:08:34 +01:00
|
|
|
uint32_t Index; // Index into either symbol or type index space.
|
2017-06-07 05:48:56 +02:00
|
|
|
uint64_t Offset; // Offset from the start of the section.
|
|
|
|
int64_t Addend; // A value to add to the symbol.
|
2016-11-30 17:49:11 +01:00
|
|
|
};
|
|
|
|
|
2017-12-14 22:10:03 +01:00
|
|
|
struct WasmInitFunc {
|
|
|
|
uint32_t Priority;
|
2018-02-23 06:08:34 +01:00
|
|
|
uint32_t Symbol;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmSymbolInfo {
|
|
|
|
StringRef Name;
|
2018-03-01 19:06:21 +01:00
|
|
|
uint8_t Kind;
|
2018-02-23 06:08:34 +01:00
|
|
|
uint32_t Flags;
|
2019-02-07 23:03:32 +01:00
|
|
|
StringRef ImportModule; // For undefined symbols the module of the import
|
|
|
|
StringRef ImportName; // For undefined symbols the name of the import
|
2018-02-23 06:08:34 +01:00
|
|
|
union {
|
2018-04-20 19:07:24 +02:00
|
|
|
// For function or global symbols, the index in function or global index
|
2018-02-23 06:08:34 +01:00
|
|
|
// space.
|
|
|
|
uint32_t ElementIndex;
|
|
|
|
// For a data symbols, the address of the data relative to segment.
|
|
|
|
WasmDataReference DataRef;
|
|
|
|
};
|
2017-12-14 22:10:03 +01:00
|
|
|
};
|
|
|
|
|
2018-01-17 20:28:43 +01:00
|
|
|
struct WasmFunctionName {
|
|
|
|
uint32_t Index;
|
|
|
|
StringRef Name;
|
|
|
|
};
|
|
|
|
|
2017-06-27 22:27:59 +02:00
|
|
|
struct WasmLinkingData {
|
2018-04-26 20:15:32 +02:00
|
|
|
uint32_t Version;
|
2017-12-14 22:10:03 +01:00
|
|
|
std::vector<WasmInitFunc> InitFunctions;
|
2018-03-14 16:44:45 +01:00
|
|
|
std::vector<StringRef> Comdats;
|
2018-02-23 06:08:34 +01:00
|
|
|
std::vector<WasmSymbolInfo> SymbolTable;
|
2017-06-27 22:27:59 +02:00
|
|
|
};
|
|
|
|
|
2016-11-30 17:49:11 +01:00
|
|
|
enum : unsigned {
|
2018-12-15 01:58:12 +01:00
|
|
|
WASM_SEC_CUSTOM = 0, // Custom / User-defined section
|
|
|
|
WASM_SEC_TYPE = 1, // Function signature declarations
|
|
|
|
WASM_SEC_IMPORT = 2, // Import declarations
|
|
|
|
WASM_SEC_FUNCTION = 3, // Function declarations
|
|
|
|
WASM_SEC_TABLE = 4, // Indirect function table and other tables
|
|
|
|
WASM_SEC_MEMORY = 5, // Memory attributes
|
|
|
|
WASM_SEC_GLOBAL = 6, // Global declarations
|
|
|
|
WASM_SEC_EXPORT = 7, // Exports
|
|
|
|
WASM_SEC_START = 8, // Start function declaration
|
|
|
|
WASM_SEC_ELEM = 9, // Elements section
|
|
|
|
WASM_SEC_CODE = 10, // Function bodies (code)
|
|
|
|
WASM_SEC_DATA = 11, // Data segments
|
|
|
|
WASM_SEC_DATACOUNT = 12, // Data segment count
|
|
|
|
WASM_SEC_EVENT = 13 // Event declarations
|
2016-11-30 17:49:11 +01:00
|
|
|
};
|
|
|
|
|
2016-12-01 21:02:12 +01:00
|
|
|
// Type immediate encodings used in various contexts.
|
2018-03-01 19:48:08 +01:00
|
|
|
enum : unsigned {
|
2018-03-01 19:06:21 +01:00
|
|
|
WASM_TYPE_I32 = 0x7F,
|
|
|
|
WASM_TYPE_I64 = 0x7E,
|
|
|
|
WASM_TYPE_F32 = 0x7D,
|
|
|
|
WASM_TYPE_F64 = 0x7C,
|
2018-09-21 00:04:44 +02:00
|
|
|
WASM_TYPE_V128 = 0x7B,
|
2019-01-08 07:25:55 +01:00
|
|
|
WASM_TYPE_FUNCREF = 0x70,
|
2018-03-08 05:05:37 +01:00
|
|
|
WASM_TYPE_EXCEPT_REF = 0x68,
|
2018-03-01 19:06:21 +01:00
|
|
|
WASM_TYPE_FUNC = 0x60,
|
|
|
|
WASM_TYPE_NORESULT = 0x40, // for blocks with no result values
|
2016-12-01 21:02:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Kinds of externals (for imports and exports).
|
2018-03-01 19:48:08 +01:00
|
|
|
enum : unsigned {
|
2016-12-01 21:02:12 +01:00
|
|
|
WASM_EXTERNAL_FUNCTION = 0x0,
|
2017-06-07 05:48:56 +02:00
|
|
|
WASM_EXTERNAL_TABLE = 0x1,
|
|
|
|
WASM_EXTERNAL_MEMORY = 0x2,
|
|
|
|
WASM_EXTERNAL_GLOBAL = 0x3,
|
2018-11-14 03:46:21 +01:00
|
|
|
WASM_EXTERNAL_EVENT = 0x4,
|
2016-12-01 21:02:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Opcodes used in initializer expressions.
|
|
|
|
enum : unsigned {
|
2017-06-07 05:48:56 +02:00
|
|
|
WASM_OPCODE_END = 0x0b,
|
2019-01-08 07:25:55 +01:00
|
|
|
WASM_OPCODE_GLOBAL_GET = 0x23,
|
2017-06-07 05:48:56 +02:00
|
|
|
WASM_OPCODE_I32_CONST = 0x41,
|
|
|
|
WASM_OPCODE_I64_CONST = 0x42,
|
|
|
|
WASM_OPCODE_F32_CONST = 0x43,
|
|
|
|
WASM_OPCODE_F64_CONST = 0x44,
|
2016-12-01 21:02:12 +01:00
|
|
|
};
|
|
|
|
|
2017-03-30 21:44:09 +02:00
|
|
|
enum : unsigned {
|
|
|
|
WASM_LIMITS_FLAG_HAS_MAX = 0x1,
|
2018-11-06 18:27:25 +01:00
|
|
|
WASM_LIMITS_FLAG_IS_SHARED = 0x2,
|
2017-03-30 21:44:09 +02:00
|
|
|
};
|
|
|
|
|
2019-02-19 23:56:19 +01:00
|
|
|
enum : unsigned {
|
|
|
|
WASM_SEGMENT_IS_PASSIVE = 0x01,
|
|
|
|
WASM_SEGMENT_HAS_MEMINDEX = 0x02,
|
|
|
|
};
|
|
|
|
|
[WebAssembly] Target features section
Summary:
Implements a new target features section in assembly and object files
that records what features are used, required, and disallowed in
WebAssembly objects. The linker uses this information to ensure that
all objects participating in a link are feature-compatible and records
the set of used features in the output binary for use by optimizers
and other tools later in the toolchain.
The "atomics" feature is always required or disallowed to prevent
linking code with stripped atomics into multithreaded binaries. Other
features are marked used if they are enabled globally or on any
function in a module.
Future CLs will add linker flags for ignoring feature compatibility
checks and for specifying the set of allowed features, implement using
the presence of the "atomics" feature to control the type of memory
and segments in the linked binary, and add front-end flags for
relaxing the linkage policy for atomics.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59173
llvm-svn: 356610
2019-03-20 21:26:45 +01:00
|
|
|
// Feature policy prefixes used in the custom "target_features" section
|
|
|
|
enum : uint8_t {
|
|
|
|
WASM_FEATURE_PREFIX_USED = '+',
|
|
|
|
WASM_FEATURE_PREFIX_REQUIRED = '=',
|
|
|
|
WASM_FEATURE_PREFIX_DISALLOWED = '-',
|
|
|
|
};
|
|
|
|
|
2018-01-10 00:43:14 +01:00
|
|
|
// Kind codes used in the custom "name" section
|
|
|
|
enum : unsigned {
|
|
|
|
WASM_NAMES_FUNCTION = 0x1,
|
2018-09-05 03:27:38 +02:00
|
|
|
WASM_NAMES_LOCAL = 0x2,
|
2018-01-10 00:43:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Kind codes used in the custom "linking" section
|
2017-03-31 01:58:19 +02:00
|
|
|
enum : unsigned {
|
2018-09-05 03:27:38 +02:00
|
|
|
WASM_SEGMENT_INFO = 0x5,
|
|
|
|
WASM_INIT_FUNCS = 0x6,
|
|
|
|
WASM_COMDAT_INFO = 0x7,
|
|
|
|
WASM_SYMBOL_TABLE = 0x8,
|
2018-01-10 00:43:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO
|
|
|
|
enum : unsigned {
|
2018-09-05 03:27:38 +02:00
|
|
|
WASM_COMDAT_DATA = 0x0,
|
|
|
|
WASM_COMDAT_FUNCTION = 0x1,
|
2017-06-20 06:04:59 +02:00
|
|
|
};
|
|
|
|
|
2018-02-23 06:08:34 +01:00
|
|
|
// Kind codes used in the custom "linking" section in the WASM_SYMBOL_TABLE
|
2018-03-01 19:48:08 +01:00
|
|
|
enum WasmSymbolType : unsigned {
|
2018-02-23 06:08:34 +01:00
|
|
|
WASM_SYMBOL_TYPE_FUNCTION = 0x0,
|
2018-04-26 21:27:28 +02:00
|
|
|
WASM_SYMBOL_TYPE_DATA = 0x1,
|
|
|
|
WASM_SYMBOL_TYPE_GLOBAL = 0x2,
|
|
|
|
WASM_SYMBOL_TYPE_SECTION = 0x3,
|
2018-11-14 03:46:21 +01:00
|
|
|
WASM_SYMBOL_TYPE_EVENT = 0x4,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Kinds of event attributes.
|
|
|
|
enum WasmEventAttribute : unsigned {
|
|
|
|
WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0,
|
2018-02-23 06:08:34 +01:00
|
|
|
};
|
|
|
|
|
2018-09-05 03:27:38 +02:00
|
|
|
const unsigned WASM_SYMBOL_BINDING_MASK = 0x3;
|
|
|
|
const unsigned WASM_SYMBOL_VISIBILITY_MASK = 0xc;
|
2017-12-03 02:19:23 +01:00
|
|
|
|
2018-09-05 03:27:38 +02:00
|
|
|
const unsigned WASM_SYMBOL_BINDING_GLOBAL = 0x0;
|
|
|
|
const unsigned WASM_SYMBOL_BINDING_WEAK = 0x1;
|
|
|
|
const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2;
|
2017-12-03 02:19:23 +01:00
|
|
|
const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0;
|
2018-09-05 03:27:38 +02:00
|
|
|
const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4;
|
|
|
|
const unsigned WASM_SYMBOL_UNDEFINED = 0x10;
|
2019-02-07 02:24:44 +01:00
|
|
|
const unsigned WASM_SYMBOL_EXPORTED = 0x20;
|
2019-02-07 23:03:32 +01:00
|
|
|
const unsigned WASM_SYMBOL_EXPLICIT_NAME = 0x40;
|
2017-03-31 01:58:19 +02:00
|
|
|
|
2017-02-24 22:21:44 +01:00
|
|
|
#define WASM_RELOC(name, value) name = value,
|
|
|
|
|
2018-03-01 19:48:08 +01:00
|
|
|
enum : unsigned {
|
2017-12-21 04:16:34 +01:00
|
|
|
#include "WasmRelocs.def"
|
2017-02-24 22:21:44 +01:00
|
|
|
};
|
|
|
|
|
2017-03-30 21:44:09 +02:00
|
|
|
#undef WASM_RELOC
|
|
|
|
|
2018-10-04 00:22:48 +02:00
|
|
|
// Subset of types that a value can have
|
|
|
|
enum class ValType {
|
|
|
|
I32 = WASM_TYPE_I32,
|
|
|
|
I64 = WASM_TYPE_I64,
|
|
|
|
F32 = WASM_TYPE_F32,
|
|
|
|
F64 = WASM_TYPE_F64,
|
|
|
|
V128 = WASM_TYPE_V128,
|
|
|
|
EXCEPT_REF = WASM_TYPE_EXCEPT_REF,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WasmSignature {
|
2019-02-04 18:26:22 +01:00
|
|
|
SmallVector<ValType, 1> Returns;
|
|
|
|
SmallVector<ValType, 4> Params;
|
2018-10-04 00:22:48 +02:00
|
|
|
// Support empty and tombstone instances, needed by DenseMap.
|
|
|
|
enum { Plain, Empty, Tombstone } State = Plain;
|
|
|
|
|
2019-02-04 18:26:22 +01:00
|
|
|
WasmSignature(SmallVector<ValType, 1> &&InReturns,
|
|
|
|
SmallVector<ValType, 4> &&InParams)
|
2018-10-04 00:22:48 +02:00
|
|
|
: Returns(InReturns), Params(InParams) {}
|
|
|
|
WasmSignature() = default;
|
|
|
|
};
|
|
|
|
|
2018-03-14 16:58:03 +01:00
|
|
|
// Useful comparison operators
|
|
|
|
inline bool operator==(const WasmSignature &LHS, const WasmSignature &RHS) {
|
2018-10-04 00:22:48 +02:00
|
|
|
return LHS.State == RHS.State && LHS.Returns == RHS.Returns &&
|
|
|
|
LHS.Params == RHS.Params;
|
2018-03-14 16:58:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS) {
|
|
|
|
return !(LHS == RHS);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
|
|
|
|
return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
|
|
|
|
return !(LHS == RHS);
|
|
|
|
}
|
|
|
|
|
2019-02-04 18:26:22 +01:00
|
|
|
std::string toString(WasmSymbolType type);
|
2018-05-15 00:42:07 +02:00
|
|
|
std::string relocTypetoString(uint32_t type);
|
|
|
|
|
2016-11-30 17:49:11 +01:00
|
|
|
} // end namespace wasm
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|