LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
include
llvm
Support
Support/Wasm.h
Go to the documentation of this file.
1
//===- Wasm.h - Wasm object file format -------------------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file defines manifest constants for the wasm object file format.
11
// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_SUPPORT_WASM_H
16
#define LLVM_SUPPORT_WASM_H
17
18
#include "
llvm/ADT/ArrayRef.h
"
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
= 0xd;
27
28
struct
WasmObjectHeader
{
29
StringRef
Magic
;
30
uint32_t
Version
;
31
};
32
33
struct
WasmSection
{
34
uint32_t
Type
;
// Section type (See below)
35
uint32_t
Offset
;
// Offset with in the file
36
StringRef
Name
;
// Section name (User-defined sections only)
37
ArrayRef<uint8_t>
Content
;
// Section content
38
};
39
40
enum
:
unsigned
{
41
WASM_SEC_USER
= 0,
// User-defined section
42
WASM_SEC_TYPE
= 1,
// Function signature declarations
43
WASM_SEC_IMPORT
= 2,
// Import declarations
44
WASM_SEC_FUNCTION
= 3,
// Function declarations
45
WASM_SEC_TABLE
= 4,
// Indirect function table and other tables
46
WASM_SEC_MEMORY
= 5,
// Memory attributes
47
WASM_SEC_GLOBAL
= 6,
// Global declarations
48
WASM_SEC_EXPORT
= 7,
// Exports
49
WASM_SEC_START
= 8,
// Start function declaration
50
WASM_SEC_ELEM
= 9,
// Elements section
51
WASM_SEC_CODE
= 10,
// Function bodies (code)
52
WASM_SEC_DATA
= 11
// Data segments
53
};
54
55
// Type immediate encodings used in various contexts.
56
enum
:
unsigned
{
57
WASM_TYPE_I32
= 0x7f,
58
WASM_TYPE_I64
= 0x7e,
59
WASM_TYPE_F32
= 0x7d,
60
WASM_TYPE_F64
= 0x7c,
61
WASM_TYPE_ANYFUNC
= 0x70,
62
WASM_TYPE_FUNC
= 0x60,
63
WASM_TYPE_NORESULT
= 0x40,
// for blocks with no result values
64
};
65
66
// Kinds of externals (for imports and exports).
67
enum
:
unsigned
{
68
WASM_EXTERNAL_FUNCTION
= 0x0,
69
WASM_EXTERNAL_TABLE
= 0x1,
70
WASM_EXTERNAL_MEMORY
= 0x2,
71
WASM_EXTERNAL_GLOBAL
= 0x3,
72
};
73
74
// Opcodes used in initializer expressions.
75
enum
:
unsigned
{
76
WASM_OPCODE_END
= 0x0b,
77
WASM_OPCODE_GET_GLOBAL
= 0x23,
78
WASM_OPCODE_I32_CONST
= 0x41,
79
WASM_OPCODE_I64_CONST
= 0x42,
80
WASM_OPCODE_F32_CONST
= 0x43,
81
WASM_OPCODE_F64_CONST
= 0x44,
82
};
83
84
}
// end namespace wasm
85
}
// end namespace llvm
86
87
#endif
llvm::wasm::WasmSection::Content
ArrayRef< uint8_t > Content
Definition:
Support/Wasm.h:37
llvm::wasm::WASM_SEC_START
Definition:
Support/Wasm.h:49
llvm::wasm::WasmObjectHeader::Magic
StringRef Magic
Definition:
Support/Wasm.h:29
llvm::wasm::WASM_OPCODE_END
Definition:
Support/Wasm.h:76
llvm::wasm::WASM_EXTERNAL_GLOBAL
Definition:
Support/Wasm.h:71
llvm::wasm::WASM_SEC_CODE
Definition:
Support/Wasm.h:51
llvm::wasm::WASM_OPCODE_I32_CONST
Definition:
Support/Wasm.h:78
llvm::wasm::WASM_EXTERNAL_TABLE
Definition:
Support/Wasm.h:69
llvm::wasm::WasmVersion
const uint32_t WasmVersion
Definition:
Support/Wasm.h:26
llvm::wasm::WASM_TYPE_ANYFUNC
Definition:
Support/Wasm.h:61
llvm::ArrayRef< uint8_t >
llvm::wasm::WASM_TYPE_F64
Definition:
Support/Wasm.h:60
llvm::wasm::WASM_SEC_EXPORT
Definition:
Support/Wasm.h:48
llvm::wasm::WASM_OPCODE_GET_GLOBAL
Definition:
Support/Wasm.h:77
llvm::wasm::WasmSection
Definition:
Support/Wasm.h:33
llvm::wasm::WASM_SEC_TABLE
Definition:
Support/Wasm.h:45
llvm::wasm::WASM_EXTERNAL_FUNCTION
Definition:
Support/Wasm.h:68
llvm::wasm::WASM_OPCODE_F64_CONST
Definition:
Support/Wasm.h:81
llvm::wasm::WasmObjectHeader
Definition:
Support/Wasm.h:28
llvm::wasm::WASM_TYPE_I64
Definition:
Support/Wasm.h:58
llvm::wasm::WasmSection::Type
uint32_t Type
Definition:
Support/Wasm.h:34
ArrayRef.h
llvm::wasm::WasmSection::Offset
uint32_t Offset
Definition:
Support/Wasm.h:35
llvm::wasm::WASM_OPCODE_F32_CONST
Definition:
Support/Wasm.h:80
llvm::wasm::WASM_SEC_MEMORY
Definition:
Support/Wasm.h:46
llvm::wasm::WasmMagic
const char WasmMagic[]
Definition:
Support/Wasm.h:24
uint32_t
llvm::wasm::WASM_OPCODE_I64_CONST
Definition:
Support/Wasm.h:79
llvm::wasm::WASM_SEC_GLOBAL
Definition:
Support/Wasm.h:47
llvm::wasm::WASM_TYPE_NORESULT
Definition:
Support/Wasm.h:63
llvm::wasm::WASM_TYPE_FUNC
Definition:
Support/Wasm.h:62
llvm::wasm::WASM_SEC_USER
Definition:
Support/Wasm.h:41
llvm::wasm::WASM_SEC_ELEM
Definition:
Support/Wasm.h:50
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:47
llvm::wasm::WASM_SEC_DATA
Definition:
Support/Wasm.h:52
llvm::wasm::WASM_SEC_TYPE
Definition:
Support/Wasm.h:42
llvm::wasm::WASM_SEC_FUNCTION
Definition:
Support/Wasm.h:44
llvm::wasm::WASM_SEC_IMPORT
Definition:
Support/Wasm.h:43
llvm::wasm::WasmSection::Name
StringRef Name
Definition:
Support/Wasm.h:36
llvm::wasm::WASM_TYPE_I32
Definition:
Support/Wasm.h:57
llvm::wasm::WASM_TYPE_F32
Definition:
Support/Wasm.h:59
llvm::wasm::WasmObjectHeader::Version
uint32_t Version
Definition:
Support/Wasm.h:30
llvm::wasm::WASM_EXTERNAL_MEMORY
Definition:
Support/Wasm.h:70
Generated on Wed Mar 8 2017 17:30:41 for LLVM by
1.8.6