LLVM: include/llvm/BinaryFormat/Wasm.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_BINARYFORMAT_WASM_H

15#define LLVM_BINARYFORMAT_WASM_H

16

21#include

22

23namespace llvm {

25

26

27const char WasmMagic[] = {'\0', 'a', 's', 'm'};

28

30

32

33

35

36enum : unsigned {

41 WASM_SEC_TABLE = 4,

52};

53

54

55enum : unsigned {

82};

83

84

85enum : unsigned {

91};

92

93

94enum : unsigned {

117};

118

119

120enum : unsigned {

127

128

129};

130

131

132enum : unsigned {

147};

148

149

150enum : unsigned {

155};

156

157enum : unsigned {

163};

164

165enum : unsigned {

168};

169

170enum : unsigned {

175};

177

178

182};

183

184

185enum : unsigned {

191};

192

193

194enum : unsigned {

199};

200

201

202enum : unsigned {

208};

209

210

211enum : unsigned {

214

216};

217

218

227

233

234

238

241

253

254#define WASM_RELOC(name, value) name = value,

255

257#include "WasmRelocs.def"

258};

259

260#undef WASM_RELOC

261

266

267

281

287

292

303

305 std::vector<std::pair<std::string, std::string>> Languages;

306 std::vector<std::pair<std::string, std::string>> Tools;

307 std::vector<std::pair<std::string, std::string>> SDKs;

308};

309

314

320

327

332

338

349

350

351

358

363

372

378

390

395

409

423

424

425

427

428

429

430

431

432

433

441

442

443

449

458

463

468

470

472

474 union {

475

476

478

480 };

481};

482

488

494

495

505

509

510

511

513

515

520};

521

522

524 return LHS.State == RHS.State && LHS.Returns == RHS.Returns &&

525 LHS.Params == RHS.Params;

526}

527

529 return !(LHS == RHS);

530}

531

533 return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable;

534}

535

537 return !(LHS == RHS);

538}

539

541 return LHS.Flags == RHS.Flags && LHS.Minimum == RHS.Minimum &&

543 : true) &&

545 ? LHS.PageSize == RHS.PageSize

546 : true);

547}

548

550 return LHS.ElemType == RHS.ElemType && LHS.Limits == RHS.Limits;

551}

552

557

558}

559}

560

561#endif

This file defines the SmallVector class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

LLVM Value Representation.

const unsigned WASM_SYMBOL_UNDEFINED

Definition Wasm.h:247

@ WASM_INIT_FUNCS

Definition Wasm.h:196

@ WASM_COMDAT_INFO

Definition Wasm.h:197

@ WASM_SEGMENT_INFO

Definition Wasm.h:195

@ WASM_SYMBOL_TABLE

Definition Wasm.h:198

const unsigned WASM_SYMBOL_NO_STRIP

Definition Wasm.h:250

ValType

Definition Wasm.h:268

@ F64

Definition Wasm.h:272

@ OTHERREF

Definition Wasm.h:279

@ EXNREF

Definition Wasm.h:276

@ F32

Definition Wasm.h:271

@ EXTERNREF

Definition Wasm.h:275

@ FUNCREF

Definition Wasm.h:274

@ V128

Definition Wasm.h:273

@ I32

Definition Wasm.h:269

@ I64

Definition Wasm.h:270

@ WASM_TYPE_NULLFUNCREF

Definition Wasm.h:61

@ WASM_TYPE_ARRAY

Definition Wasm.h:76

@ WASM_TYPE_NULLREF

Definition Wasm.h:64

@ WASM_TYPE_NULLABLE

Definition Wasm.h:74

@ WASM_TYPE_I64

Definition Wasm.h:57

@ WASM_TYPE_F64

Definition Wasm.h:59

@ WASM_TYPE_FUNCREF

Definition Wasm.h:65

@ WASM_TYPE_STRUCTREF

Definition Wasm.h:71

@ WASM_TYPE_ARRAYREF

Definition Wasm.h:72

@ WASM_TYPE_ANYREF

Definition Wasm.h:68

@ WASM_TYPE_EQREF

Definition Wasm.h:69

@ WASM_TYPE_REC

Definition Wasm.h:80

@ WASM_TYPE_NULLEXTERNREF

Definition Wasm.h:62

@ WASM_TYPE_EXTERNREF

Definition Wasm.h:66

@ WASM_TYPE_SUB

Definition Wasm.h:78

@ WASM_TYPE_FUNC

Definition Wasm.h:75

@ WASM_TYPE_I31REF

Definition Wasm.h:70

@ WASM_TYPE_STRUCT

Definition Wasm.h:77

@ WASM_TYPE_NULLEXNREF

Definition Wasm.h:63

@ WASM_TYPE_NONNULLABLE

Definition Wasm.h:73

@ WASM_TYPE_I32

Definition Wasm.h:56

@ WASM_TYPE_NORESULT

Definition Wasm.h:81

@ WASM_TYPE_F32

Definition Wasm.h:58

@ WASM_TYPE_V128

Definition Wasm.h:60

@ WASM_TYPE_SUB_FINAL

Definition Wasm.h:79

@ WASM_TYPE_EXNREF

Definition Wasm.h:67

const char WasmMagic[]

Definition Wasm.h:27

@ WASM_OPCODE_CATCH_ALL_REF

Definition Wasm.h:154

@ WASM_OPCODE_CATCH

Definition Wasm.h:151

@ WASM_OPCODE_CATCH_ALL

Definition Wasm.h:153

@ WASM_OPCODE_CATCH_REF

Definition Wasm.h:152

const unsigned WASM_SYMBOL_BINDING_GLOBAL

Definition Wasm.h:242

WasmTagAttribute

Definition Wasm.h:235

@ WASM_TAG_ATTRIBUTE_EXCEPTION

Definition Wasm.h:236

const unsigned WASM_SYMBOL_TLS

Definition Wasm.h:251

const uint32_t WasmMetadataVersion

Definition Wasm.h:31

const unsigned WASM_SYMBOL_BINDING_WEAK

Definition Wasm.h:243

@ WASM_SEC_CODE

Definition Wasm.h:47

@ WASM_SEC_MEMORY

Definition Wasm.h:42

@ WASM_SEC_IMPORT

Definition Wasm.h:39

@ WASM_SEC_EXPORT

Definition Wasm.h:44

@ WASM_SEC_DATACOUNT

Definition Wasm.h:49

@ WASM_SEC_LAST_KNOWN

Definition Wasm.h:51

@ WASM_SEC_CUSTOM

Definition Wasm.h:37

@ WASM_SEC_FUNCTION

Definition Wasm.h:40

@ WASM_SEC_ELEM

Definition Wasm.h:46

@ WASM_SEC_START

Definition Wasm.h:45

@ WASM_SEC_TABLE

Definition Wasm.h:41

@ WASM_SEC_TYPE

Definition Wasm.h:38

@ WASM_SEC_TAG

Definition Wasm.h:50

@ WASM_SEC_GLOBAL

Definition Wasm.h:43

@ WASM_SEC_DATA

Definition Wasm.h:48

const unsigned WASM_SYMBOL_BINDING_LOCAL

Definition Wasm.h:244

@ WASM_LIMITS_FLAG_HAS_MAX

Definition Wasm.h:159

@ WASM_LIMITS_FLAG_IS_SHARED

Definition Wasm.h:160

@ WASM_LIMITS_FLAG_IS_64

Definition Wasm.h:161

@ WASM_LIMITS_FLAG_NONE

Definition Wasm.h:158

@ WASM_LIMITS_FLAG_HAS_PAGE_SIZE

Definition Wasm.h:162

@ WASM_DATA_SEGMENT_IS_PASSIVE

Definition Wasm.h:166

@ WASM_DATA_SEGMENT_HAS_MEMINDEX

Definition Wasm.h:167

LLVM_ABI llvm::StringRef toString(WasmSymbolType type)

@ WASM_FEATURE_PREFIX_USED

Definition Wasm.h:180

@ WASM_FEATURE_PREFIX_DISALLOWED

Definition Wasm.h:181

WasmSymbolType

Definition Wasm.h:219

@ WASM_SYMBOL_TYPE_GLOBAL

Definition Wasm.h:222

@ WASM_SYMBOL_TYPE_DATA

Definition Wasm.h:221

@ WASM_SYMBOL_TYPE_TAG

Definition Wasm.h:224

@ WASM_SYMBOL_TYPE_TABLE

Definition Wasm.h:225

@ WASM_SYMBOL_TYPE_SECTION

Definition Wasm.h:223

@ WASM_SYMBOL_TYPE_FUNCTION

Definition Wasm.h:220

const uint32_t WasmVersion

Definition Wasm.h:29

ElemSegmentMode

Definition Wasm.h:426

@ Active

Definition Wasm.h:426

@ Declarative

Definition Wasm.h:426

@ Passive

Definition Wasm.h:426

const unsigned WASM_SYMBOL_EXPORTED

Definition Wasm.h:248

const unsigned WASM_SYMBOL_BINDING_MASK

Definition Wasm.h:239

@ WASM_COMDAT_SECTION

Definition Wasm.h:215

@ WASM_COMDAT_FUNCTION

Definition Wasm.h:213

@ WASM_COMDAT_DATA

Definition Wasm.h:212

@ WASM_ELEM_SEGMENT_HAS_INIT_EXPRS

Definition Wasm.h:174

@ WASM_ELEM_SEGMENT_IS_DECLARATIVE

Definition Wasm.h:172

@ WASM_ELEM_SEGMENT_HAS_TABLE_NUMBER

Definition Wasm.h:173

@ WASM_ELEM_SEGMENT_IS_PASSIVE

Definition Wasm.h:171

LLVM_ABI bool relocTypeHasAddend(uint32_t type)

@ WASM_OPCODE_LOCAL_SET

Definition Wasm.h:98

@ WASM_OPCODE_CALL

Definition Wasm.h:96

@ WASM_OPCODE_LOCAL_GET

Definition Wasm.h:97

@ WASM_OPCODE_I64_ADD

Definition Wasm.h:111

@ WASM_OPCODE_I32_SUB

Definition Wasm.h:109

@ WASM_OPCODE_F64_CONST

Definition Wasm.h:107

@ WASM_OPCODE_END

Definition Wasm.h:95

@ WASM_OPCODE_I64_MUL

Definition Wasm.h:113

@ WASM_OPCODE_GLOBAL_SET

Definition Wasm.h:101

@ WASM_OPCODE_REF_NULL

Definition Wasm.h:114

@ WASM_OPCODE_GC_PREFIX

Definition Wasm.h:116

@ WASM_OPCODE_REF_FUNC

Definition Wasm.h:115

@ WASM_OPCODE_F32_CONST

Definition Wasm.h:106

@ WASM_OPCODE_GLOBAL_GET

Definition Wasm.h:100

@ WASM_OPCODE_I64_SUB

Definition Wasm.h:112

@ WASM_OPCODE_I32_MUL

Definition Wasm.h:110

@ WASM_OPCODE_I32_ADD

Definition Wasm.h:108

@ WASM_OPCODE_LOCAL_TEE

Definition Wasm.h:99

@ WASM_OPCODE_I32_STORE

Definition Wasm.h:102

@ WASM_OPCODE_I64_CONST

Definition Wasm.h:105

@ WASM_OPCODE_I64_STORE

Definition Wasm.h:103

@ WASM_OPCODE_I32_CONST

Definition Wasm.h:104

@ WASM_EXTERNAL_TABLE

Definition Wasm.h:87

@ WASM_EXTERNAL_FUNCTION

Definition Wasm.h:86

@ WASM_EXTERNAL_TAG

Definition Wasm.h:90

@ WASM_EXTERNAL_MEMORY

Definition Wasm.h:88

@ WASM_EXTERNAL_GLOBAL

Definition Wasm.h:89

NameType

Definition Wasm.h:483

@ DATA_SEGMENT

Definition Wasm.h:486

@ FUNCTION

Definition Wasm.h:484

@ GLOBAL

Definition Wasm.h:485

@ WASM_DYLINK_RUNTIME_PATH

Definition Wasm.h:207

@ WASM_DYLINK_NEEDED

Definition Wasm.h:204

@ WASM_DYLINK_MEM_INFO

Definition Wasm.h:203

@ WASM_DYLINK_EXPORT_INFO

Definition Wasm.h:205

@ WASM_DYLINK_IMPORT_INFO

Definition Wasm.h:206

@ WASM_OPCODE_ARRAY_NEW_FIXED

Definition Wasm.h:125

@ WASM_OPCODE_REF_I31

Definition Wasm.h:126

@ WASM_OPCODE_ARRAY_NEW_DEFAULT

Definition Wasm.h:124

@ WASM_OPCODE_STRUCT_NEW

Definition Wasm.h:121

@ WASM_OPCODE_STRUCT_NEW_DEFAULT

Definition Wasm.h:122

@ WASM_OPCODE_ARRAY_NEW

Definition Wasm.h:123

WasmSegmentFlag

Definition Wasm.h:228

@ WASM_SEG_FLAG_RETAIN

Definition Wasm.h:231

@ WASM_SEG_FLAG_TLS

Definition Wasm.h:230

@ WASM_SEG_FLAG_STRINGS

Definition Wasm.h:229

@ WASM_NAMES_LOCAL

Definition Wasm.h:188

@ WASM_NAMES_DATA_SEGMENT

Definition Wasm.h:190

@ WASM_NAMES_GLOBAL

Definition Wasm.h:189

@ WASM_NAMES_FUNCTION

Definition Wasm.h:187

@ WASM_NAMES_MODULE

Definition Wasm.h:186

WasmRelocType

Definition Wasm.h:256

bool operator!=(const WasmSignature &LHS, const WasmSignature &RHS)

Definition Wasm.h:528

LLVM_ABI llvm::StringRef sectionTypeToString(uint32_t type)

const uint32_t WasmDefaultPageSize

Definition Wasm.h:34

const unsigned WASM_SYMBOL_EXPLICIT_NAME

Definition Wasm.h:249

const unsigned WASM_SYMBOL_ABSOLUTE

Definition Wasm.h:252

bool operator==(const WasmSignature &LHS, const WasmSignature &RHS)

Definition Wasm.h:523

const unsigned WASM_SYMBOL_VISIBILITY_MASK

Definition Wasm.h:240

const unsigned WASM_SYMBOL_VISIBILITY_HIDDEN

Definition Wasm.h:246

const unsigned WASM_ELEM_SEGMENT_MASK_HAS_ELEM_DESC

Definition Wasm.h:176

LLVM_ABI llvm::StringRef relocTypetoString(uint32_t type)

const unsigned WASM_SYMBOL_VISIBILITY_DEFAULT

Definition Wasm.h:245

@ WASM_OPCODE_BR

Definition Wasm.h:134

@ WASM_OPCODE_I32_ATOMIC_STORE

Definition Wasm.h:145

@ WASM_OPCODE_MEMORY_FILL

Definition Wasm.h:140

@ WASM_OPCODE_DATA_DROP

Definition Wasm.h:141

@ WASM_OPCODE_BR_TABLE

Definition Wasm.h:135

@ WASM_OPCODE_I32_ATOMIC_WAIT

Definition Wasm.h:144

@ WASM_OPCODE_MISC_PREFIX

Definition Wasm.h:138

@ WASM_OPCODE_BLOCK

Definition Wasm.h:133

@ WASM_OPCODE_ATOMIC_NOTIFY

Definition Wasm.h:143

@ WASM_OPCODE_RETURN

Definition Wasm.h:136

@ WASM_OPCODE_I32_RMW_CMPXCHG

Definition Wasm.h:146

@ WASM_OPCODE_MEMORY_INIT

Definition Wasm.h:139

@ WASM_OPCODE_DROP

Definition Wasm.h:137

@ WASM_OPCODE_ATOMICS_PREFIX

Definition Wasm.h:142

This is an optimization pass for GlobalISel generic memory operations.

uint64_t Size

Definition Wasm.h:447

uint32_t Segment

Definition Wasm.h:445

uint64_t Offset

Definition Wasm.h:446

uint32_t MemoryIndex

Definition Wasm.h:413

StringRef Name

Definition Wasm.h:418

uint32_t LinkingFlags

Definition Wasm.h:420

ArrayRef< uint8_t > Content

Definition Wasm.h:417

uint32_t Alignment

Definition Wasm.h:419

uint32_t InitFlags

Definition Wasm.h:411

uint32_t Comdat

Definition Wasm.h:421

WasmInitExpr Offset

Definition Wasm.h:415

uint32_t Index

Definition Wasm.h:491

StringRef Name

Definition Wasm.h:492

NameType Type

Definition Wasm.h:490

StringRef Name

Definition Wasm.h:289

uint32_t Flags

Definition Wasm.h:290

uint32_t Flags

Definition Wasm.h:285

StringRef Field

Definition Wasm.h:284

StringRef Module

Definition Wasm.h:283

uint32_t MemoryAlignment

Definition Wasm.h:295

std::vector< StringRef > Needed

Definition Wasm.h:298

uint32_t TableSize

Definition Wasm.h:296

std::vector< StringRef > RuntimePath

Definition Wasm.h:301

std::vector< WasmDylinkExportInfo > ExportInfo

Definition Wasm.h:300

std::vector< WasmDylinkImportInfo > ImportInfo

Definition Wasm.h:299

uint32_t TableAlignment

Definition Wasm.h:297

uint32_t MemorySize

Definition Wasm.h:294

WasmInitExpr Offset

Definition Wasm.h:438

std::vector< uint32_t > Functions

Definition Wasm.h:439

uint32_t Flags

Definition Wasm.h:435

uint32_t TableNumber

Definition Wasm.h:436

ValType ElemKind

Definition Wasm.h:437

StringRef Name

Definition Wasm.h:316

uint8_t Kind

Definition Wasm.h:317

uint32_t Index

Definition Wasm.h:318

uint8_t Prefix

Definition Wasm.h:311

std::string Name

Definition Wasm.h:312

uint32_t CodeOffset

Definition Wasm.h:403

ArrayRef< uint8_t > Body

Definition Wasm.h:400

std::optional< StringRef > ExportName

Definition Wasm.h:404

uint32_t Index

Definition Wasm.h:397

std::vector< WasmLocalDecl > Locals

Definition Wasm.h:399

uint32_t Comdat

Definition Wasm.h:407

StringRef SymbolName

Definition Wasm.h:405

uint32_t CodeSectionOffset

Definition Wasm.h:401

uint32_t Size

Definition Wasm.h:402

uint32_t SigIndex

Definition Wasm.h:398

StringRef DebugName

Definition Wasm.h:406

bool Mutable

Definition Wasm.h:361

uint8_t Type

Definition Wasm.h:360

uint32_t Offset

Definition Wasm.h:369

WasmInitExpr InitExpr

Definition Wasm.h:367

StringRef SymbolName

Definition Wasm.h:368

WasmGlobalType Type

Definition Wasm.h:366

uint32_t Index

Definition Wasm.h:365

uint32_t Size

Definition Wasm.h:370

WasmLimits Memory

Definition Wasm.h:387

uint8_t Kind

Definition Wasm.h:382

StringRef Field

Definition Wasm.h:381

WasmGlobalType Global

Definition Wasm.h:385

StringRef Module

Definition Wasm.h:380

uint32_t SigIndex

Definition Wasm.h:384

WasmTableType Table

Definition Wasm.h:386

int32_t Int32

Definition Wasm.h:342

uint8_t Opcode

Definition Wasm.h:340

uint32_t Float32

Definition Wasm.h:344

int64_t Int64

Definition Wasm.h:343

uint32_t Global

Definition Wasm.h:346

uint64_t Float64

Definition Wasm.h:345

uint8_t Extended

Definition Wasm.h:353

WasmInitExprMVP Inst

Definition Wasm.h:355

ArrayRef< uint8_t > Body

Definition Wasm.h:356

uint32_t Symbol

Definition Wasm.h:461

uint32_t Priority

Definition Wasm.h:460

uint8_t Flags

Definition Wasm.h:322

uint64_t Minimum

Definition Wasm.h:323

uint32_t PageSize

Definition Wasm.h:325

uint64_t Maximum

Definition Wasm.h:324

std::vector< WasmInitFunc > InitFunctions

Definition Wasm.h:498

uint32_t Version

Definition Wasm.h:497

std::vector< StringRef > Comdats

Definition Wasm.h:499

uint32_t Count

Definition Wasm.h:393

uint8_t Type

Definition Wasm.h:392

std::vector< std::pair< std::string, std::string > > SDKs

Definition Wasm.h:307

std::vector< std::pair< std::string, std::string > > Languages

Definition Wasm.h:305

std::vector< std::pair< std::string, std::string > > Tools

Definition Wasm.h:306

WasmRelocType getType() const

Definition Wasm.h:456

int64_t Addend

Definition Wasm.h:454

uint8_t Type

Definition Wasm.h:451

uint64_t Offset

Definition Wasm.h:453

uint32_t Index

Definition Wasm.h:452

WasmSignature(SmallVector< ValType, 1 > &&InReturns, SmallVector< ValType, 4 > &&InParams)

Definition Wasm.h:516

@ Tag

Definition Wasm.h:512

@ Function

Definition Wasm.h:512

@ Placeholder

Definition Wasm.h:512

SmallVector< ValType, 1 > Returns

Definition Wasm.h:507

@ Tombstone

Definition Wasm.h:514

@ Empty

Definition Wasm.h:514

@ Plain

Definition Wasm.h:514

SmallVector< ValType, 4 > Params

Definition Wasm.h:508

std::optional< StringRef > ExportName

Definition Wasm.h:473

uint32_t Flags

Definition Wasm.h:467

WasmDataReference DataRef

Definition Wasm.h:479

StringRef Name

Definition Wasm.h:465

uint8_t Kind

Definition Wasm.h:466

std::optional< StringRef > ImportModule

Definition Wasm.h:469

uint32_t ElementIndex

Definition Wasm.h:477

std::optional< StringRef > ImportName

Definition Wasm.h:471

ValType ElemType

Definition Wasm.h:329

WasmLimits Limits

Definition Wasm.h:330

WasmTableType Type

Definition Wasm.h:335

StringRef SymbolName

Definition Wasm.h:336

uint32_t Index

Definition Wasm.h:334

uint32_t Index

Definition Wasm.h:374

uint32_t SigIndex

Definition Wasm.h:375

StringRef SymbolName

Definition Wasm.h:376