Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- Wasm.h - Wasm object file format -------------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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" |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallVector.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | namespace wasm { |
| 22 | |
| 23 | // Object file magic string. |
| 24 | const char WasmMagic[] = {'\0', 'a', 's', 'm'}; |
| 25 | // Wasm binary format version |
| 26 | const uint32_t WasmVersion = 0x1; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 27 | // Wasm linking metadata version |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 28 | const uint32_t WasmMetadataVersion = 0x2; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 29 | // Wasm uses a 64k page size |
| 30 | const uint32_t WasmPageSize = 65536; |
| 31 | |
| 32 | struct WasmObjectHeader { |
| 33 | StringRef Magic; |
| 34 | uint32_t Version; |
| 35 | }; |
| 36 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 37 | struct WasmDylinkInfo { |
| 38 | uint32_t MemorySize; // Memory size in bytes |
| 39 | uint32_t MemoryAlignment; // P2 alignment of memory |
| 40 | uint32_t TableSize; // Table size in elements |
| 41 | uint32_t TableAlignment; // P2 alignment of table |
| 42 | std::vector<StringRef> Needed; // Shared library depenedencies |
| 43 | }; |
| 44 | |
| 45 | struct WasmProducerInfo { |
| 46 | std::vector<std::pair<std::string, std::string>> Languages; |
| 47 | std::vector<std::pair<std::string, std::string>> Tools; |
| 48 | std::vector<std::pair<std::string, std::string>> SDKs; |
| 49 | }; |
| 50 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 51 | struct WasmFeatureEntry { |
| 52 | uint8_t Prefix; |
| 53 | std::string Name; |
| 54 | }; |
| 55 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 56 | struct WasmExport { |
| 57 | StringRef Name; |
| 58 | uint8_t Kind; |
| 59 | uint32_t Index; |
| 60 | }; |
| 61 | |
| 62 | struct WasmLimits { |
| 63 | uint8_t Flags; |
| 64 | uint32_t Initial; |
| 65 | uint32_t Maximum; |
| 66 | }; |
| 67 | |
| 68 | struct WasmTable { |
| 69 | uint8_t ElemType; |
| 70 | WasmLimits Limits; |
| 71 | }; |
| 72 | |
| 73 | struct WasmInitExpr { |
| 74 | uint8_t Opcode; |
| 75 | union { |
| 76 | int32_t Int32; |
| 77 | int64_t Int64; |
| 78 | int32_t Float32; |
| 79 | int64_t Float64; |
| 80 | uint32_t Global; |
| 81 | } Value; |
| 82 | }; |
| 83 | |
| 84 | struct WasmGlobalType { |
| 85 | uint8_t Type; |
| 86 | bool Mutable; |
| 87 | }; |
| 88 | |
| 89 | struct WasmGlobal { |
| 90 | uint32_t Index; |
| 91 | WasmGlobalType Type; |
| 92 | WasmInitExpr InitExpr; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 93 | StringRef SymbolName; // from the "linking" section |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 94 | }; |
| 95 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 96 | struct WasmEventType { |
| 97 | // Kind of event. Currently only WASM_EVENT_ATTRIBUTE_EXCEPTION is possible. |
| 98 | uint32_t Attribute; |
| 99 | uint32_t SigIndex; |
| 100 | }; |
| 101 | |
| 102 | struct WasmEvent { |
| 103 | uint32_t Index; |
| 104 | WasmEventType Type; |
| 105 | StringRef SymbolName; // from the "linking" section |
| 106 | }; |
| 107 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 108 | struct WasmImport { |
| 109 | StringRef Module; |
| 110 | StringRef Field; |
| 111 | uint8_t Kind; |
| 112 | union { |
| 113 | uint32_t SigIndex; |
| 114 | WasmGlobalType Global; |
| 115 | WasmTable Table; |
| 116 | WasmLimits Memory; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 117 | WasmEventType Event; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 118 | }; |
| 119 | }; |
| 120 | |
| 121 | struct WasmLocalDecl { |
| 122 | uint8_t Type; |
| 123 | uint32_t Count; |
| 124 | }; |
| 125 | |
| 126 | struct WasmFunction { |
| 127 | uint32_t Index; |
| 128 | std::vector<WasmLocalDecl> Locals; |
| 129 | ArrayRef<uint8_t> Body; |
| 130 | uint32_t CodeSectionOffset; |
| 131 | uint32_t Size; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 132 | uint32_t CodeOffset; // start of Locals and Body |
| 133 | StringRef SymbolName; // from the "linking" section |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 134 | StringRef DebugName; // from the "name" section |
| 135 | uint32_t Comdat; // from the "comdat info" section |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | struct WasmDataSegment { |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 139 | uint32_t InitFlags; |
| 140 | uint32_t MemoryIndex; // present if InitFlags & WASM_SEGMENT_HAS_MEMINDEX |
| 141 | WasmInitExpr Offset; // present if InitFlags & WASM_SEGMENT_IS_PASSIVE == 0 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 142 | ArrayRef<uint8_t> Content; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 143 | StringRef Name; // from the "segment info" section |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 144 | uint32_t Alignment; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 145 | uint32_t LinkerFlags; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 146 | uint32_t Comdat; // from the "comdat info" section |
| 147 | }; |
| 148 | |
| 149 | struct WasmElemSegment { |
| 150 | uint32_t TableIndex; |
| 151 | WasmInitExpr Offset; |
| 152 | std::vector<uint32_t> Functions; |
| 153 | }; |
| 154 | |
| 155 | // Represents the location of a Wasm data symbol within a WasmDataSegment, as |
| 156 | // the index of the segment, and the offset and size within the segment. |
| 157 | struct WasmDataReference { |
| 158 | uint32_t Segment; |
| 159 | uint32_t Offset; |
| 160 | uint32_t Size; |
| 161 | }; |
| 162 | |
| 163 | struct WasmRelocation { |
| 164 | uint8_t Type; // The type of the relocation. |
| 165 | uint32_t Index; // Index into either symbol or type index space. |
| 166 | uint64_t Offset; // Offset from the start of the section. |
| 167 | int64_t Addend; // A value to add to the symbol. |
| 168 | }; |
| 169 | |
| 170 | struct WasmInitFunc { |
| 171 | uint32_t Priority; |
| 172 | uint32_t Symbol; |
| 173 | }; |
| 174 | |
| 175 | struct WasmSymbolInfo { |
| 176 | StringRef Name; |
| 177 | uint8_t Kind; |
| 178 | uint32_t Flags; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 179 | StringRef ImportModule; // For undefined symbols the module of the import |
| 180 | StringRef ImportName; // For undefined symbols the name of the import |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 181 | union { |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 182 | // For function or global symbols, the index in function or global index |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 183 | // space. |
| 184 | uint32_t ElementIndex; |
| 185 | // For a data symbols, the address of the data relative to segment. |
| 186 | WasmDataReference DataRef; |
| 187 | }; |
| 188 | }; |
| 189 | |
| 190 | struct WasmFunctionName { |
| 191 | uint32_t Index; |
| 192 | StringRef Name; |
| 193 | }; |
| 194 | |
| 195 | struct WasmLinkingData { |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 196 | uint32_t Version; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 197 | std::vector<WasmInitFunc> InitFunctions; |
| 198 | std::vector<StringRef> Comdats; |
| 199 | std::vector<WasmSymbolInfo> SymbolTable; |
| 200 | }; |
| 201 | |
| 202 | enum : unsigned { |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 203 | WASM_SEC_CUSTOM = 0, // Custom / User-defined section |
| 204 | WASM_SEC_TYPE = 1, // Function signature declarations |
| 205 | WASM_SEC_IMPORT = 2, // Import declarations |
| 206 | WASM_SEC_FUNCTION = 3, // Function declarations |
| 207 | WASM_SEC_TABLE = 4, // Indirect function table and other tables |
| 208 | WASM_SEC_MEMORY = 5, // Memory attributes |
| 209 | WASM_SEC_GLOBAL = 6, // Global declarations |
| 210 | WASM_SEC_EXPORT = 7, // Exports |
| 211 | WASM_SEC_START = 8, // Start function declaration |
| 212 | WASM_SEC_ELEM = 9, // Elements section |
| 213 | WASM_SEC_CODE = 10, // Function bodies (code) |
| 214 | WASM_SEC_DATA = 11, // Data segments |
| 215 | WASM_SEC_DATACOUNT = 12, // Data segment count |
| 216 | WASM_SEC_EVENT = 13 // Event declarations |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | // Type immediate encodings used in various contexts. |
| 220 | enum : unsigned { |
| 221 | WASM_TYPE_I32 = 0x7F, |
| 222 | WASM_TYPE_I64 = 0x7E, |
| 223 | WASM_TYPE_F32 = 0x7D, |
| 224 | WASM_TYPE_F64 = 0x7C, |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 225 | WASM_TYPE_V128 = 0x7B, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 226 | WASM_TYPE_FUNCREF = 0x70, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 227 | WASM_TYPE_EXCEPT_REF = 0x68, |
| 228 | WASM_TYPE_FUNC = 0x60, |
| 229 | WASM_TYPE_NORESULT = 0x40, // for blocks with no result values |
| 230 | }; |
| 231 | |
| 232 | // Kinds of externals (for imports and exports). |
| 233 | enum : unsigned { |
| 234 | WASM_EXTERNAL_FUNCTION = 0x0, |
| 235 | WASM_EXTERNAL_TABLE = 0x1, |
| 236 | WASM_EXTERNAL_MEMORY = 0x2, |
| 237 | WASM_EXTERNAL_GLOBAL = 0x3, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 238 | WASM_EXTERNAL_EVENT = 0x4, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | // Opcodes used in initializer expressions. |
| 242 | enum : unsigned { |
| 243 | WASM_OPCODE_END = 0x0b, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 244 | WASM_OPCODE_CALL = 0x10, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 245 | WASM_OPCODE_GLOBAL_GET = 0x23, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 246 | WASM_OPCODE_I32_STORE = 0x36, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 247 | WASM_OPCODE_I32_CONST = 0x41, |
| 248 | WASM_OPCODE_I64_CONST = 0x42, |
| 249 | WASM_OPCODE_F32_CONST = 0x43, |
| 250 | WASM_OPCODE_F64_CONST = 0x44, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 251 | WASM_OPCODE_I32_ADD = 0x6a, |
| 252 | WASM_OPCODE_MISC_PREFIX = 0xfc, |
| 253 | WASM_OPCODE_MEMORY_INIT = 0x08, |
| 254 | WASM_OPCODE_DATA_DROP = 0x09, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 255 | }; |
| 256 | |
| 257 | enum : unsigned { |
| 258 | WASM_LIMITS_FLAG_HAS_MAX = 0x1, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 259 | WASM_LIMITS_FLAG_IS_SHARED = 0x2, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 260 | }; |
| 261 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 262 | enum : unsigned { |
| 263 | WASM_SEGMENT_IS_PASSIVE = 0x01, |
| 264 | WASM_SEGMENT_HAS_MEMINDEX = 0x02, |
| 265 | }; |
| 266 | |
| 267 | // Feature policy prefixes used in the custom "target_features" section |
| 268 | enum : uint8_t { |
| 269 | WASM_FEATURE_PREFIX_USED = '+', |
| 270 | WASM_FEATURE_PREFIX_REQUIRED = '=', |
| 271 | WASM_FEATURE_PREFIX_DISALLOWED = '-', |
| 272 | }; |
| 273 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 274 | // Kind codes used in the custom "name" section |
| 275 | enum : unsigned { |
| 276 | WASM_NAMES_FUNCTION = 0x1, |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 277 | WASM_NAMES_LOCAL = 0x2, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 278 | }; |
| 279 | |
| 280 | // Kind codes used in the custom "linking" section |
| 281 | enum : unsigned { |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 282 | WASM_SEGMENT_INFO = 0x5, |
| 283 | WASM_INIT_FUNCS = 0x6, |
| 284 | WASM_COMDAT_INFO = 0x7, |
| 285 | WASM_SYMBOL_TABLE = 0x8, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | // Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO |
| 289 | enum : unsigned { |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 290 | WASM_COMDAT_DATA = 0x0, |
| 291 | WASM_COMDAT_FUNCTION = 0x1, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 292 | }; |
| 293 | |
| 294 | // Kind codes used in the custom "linking" section in the WASM_SYMBOL_TABLE |
| 295 | enum WasmSymbolType : unsigned { |
| 296 | WASM_SYMBOL_TYPE_FUNCTION = 0x0, |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 297 | WASM_SYMBOL_TYPE_DATA = 0x1, |
| 298 | WASM_SYMBOL_TYPE_GLOBAL = 0x2, |
| 299 | WASM_SYMBOL_TYPE_SECTION = 0x3, |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 300 | WASM_SYMBOL_TYPE_EVENT = 0x4, |
| 301 | }; |
| 302 | |
| 303 | // Kinds of event attributes. |
| 304 | enum WasmEventAttribute : unsigned { |
| 305 | WASM_EVENT_ATTRIBUTE_EXCEPTION = 0x0, |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 306 | }; |
| 307 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 308 | const unsigned WASM_SYMBOL_BINDING_MASK = 0x3; |
| 309 | const unsigned WASM_SYMBOL_VISIBILITY_MASK = 0xc; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 310 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 311 | const unsigned WASM_SYMBOL_BINDING_GLOBAL = 0x0; |
| 312 | const unsigned WASM_SYMBOL_BINDING_WEAK = 0x1; |
| 313 | const unsigned WASM_SYMBOL_BINDING_LOCAL = 0x2; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 314 | const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT = 0x0; |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 315 | const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN = 0x4; |
| 316 | const unsigned WASM_SYMBOL_UNDEFINED = 0x10; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 317 | const unsigned WASM_SYMBOL_EXPORTED = 0x20; |
| 318 | const unsigned WASM_SYMBOL_EXPLICIT_NAME = 0x40; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 319 | |
| 320 | #define WASM_RELOC(name, value) name = value, |
| 321 | |
| 322 | enum : unsigned { |
| 323 | #include "WasmRelocs.def" |
| 324 | }; |
| 325 | |
| 326 | #undef WASM_RELOC |
| 327 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 328 | // Subset of types that a value can have |
| 329 | enum class ValType { |
| 330 | I32 = WASM_TYPE_I32, |
| 331 | I64 = WASM_TYPE_I64, |
| 332 | F32 = WASM_TYPE_F32, |
| 333 | F64 = WASM_TYPE_F64, |
| 334 | V128 = WASM_TYPE_V128, |
| 335 | EXCEPT_REF = WASM_TYPE_EXCEPT_REF, |
| 336 | }; |
| 337 | |
| 338 | struct WasmSignature { |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 339 | SmallVector<ValType, 1> Returns; |
| 340 | SmallVector<ValType, 4> Params; |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 341 | // Support empty and tombstone instances, needed by DenseMap. |
| 342 | enum { Plain, Empty, Tombstone } State = Plain; |
| 343 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 344 | WasmSignature(SmallVector<ValType, 1> &&InReturns, |
| 345 | SmallVector<ValType, 4> &&InParams) |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 346 | : Returns(InReturns), Params(InParams) {} |
| 347 | WasmSignature() = default; |
| 348 | }; |
| 349 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 350 | // Useful comparison operators |
| 351 | inline bool operator==(const WasmSignature &LHS, const WasmSignature &RHS) { |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 352 | return LHS.State == RHS.State && LHS.Returns == RHS.Returns && |
| 353 | LHS.Params == RHS.Params; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | inline bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS) { |
| 357 | return !(LHS == RHS); |
| 358 | } |
| 359 | |
| 360 | inline bool operator==(const WasmGlobalType &LHS, const WasmGlobalType &RHS) { |
| 361 | return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable; |
| 362 | } |
| 363 | |
| 364 | inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) { |
| 365 | return !(LHS == RHS); |
| 366 | } |
| 367 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 368 | std::string toString(WasmSymbolType type); |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 369 | std::string relocTypetoString(uint32_t type); |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 370 | bool relocTypeHasAddend(uint32_t type); |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 371 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 372 | } // end namespace wasm |
| 373 | } // end namespace llvm |
| 374 | |
| 375 | #endif |