LLVM: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H

15#define LLVM_LIB_TARGET_WEBASSEMBLY_MCTARGETDESC_WEBASSEMBLYMCTARGETDESC_H

16

22#include

23

24namespace llvm {

25

31

34

36

37std::unique_ptr

39

41

43

45

47

49

51

53

55

57

59

61

63

65

67

69

71

73

75

77

79

81

83

85};

86}

87

89

90

93

94

95

96

97

99

100

102

103

104

105

107

108

109

110

112

113

114

115

117

118

119

121};

122

123}

124

125}

126

127

128

129

130#define GET_REGINFO_ENUM

131#include "WebAssemblyGenRegisterInfo.inc"

132

133

134

135#define GET_INSTRINFO_ENUM

136#define GET_INSTRINFO_MC_HELPER_DECLS

137#include "WebAssemblyGenInstrInfo.inc"

138

139namespace llvm {

140namespace WebAssembly {

141

142

143static const unsigned Nop = 0x01;

144static const unsigned End = 0x0b;

145

146

148 switch (Opc) {

149#define WASM_LOAD_STORE(NAME) \

150 case WebAssembly::NAME##_A32: \

151 case WebAssembly::NAME##_A64: \

152 case WebAssembly::NAME##_A32_S: \

153 case WebAssembly::NAME##_A64_S:

181 return 0;

211 return 1;

243 return 2;

268 return 3;

271 return 4;

272 default:

273 return -1;

274 }

275#undef WASM_LOAD_STORE

276}

277

285

287 switch (Opc) {

288 case WebAssembly::CONST_I32:

289 case WebAssembly::CONST_I32_S:

290 case WebAssembly::CONST_I64:

291 case WebAssembly::CONST_I64_S:

292 case WebAssembly::CONST_F32:

293 case WebAssembly::CONST_F32_S:

294 case WebAssembly::CONST_F64:

295 case WebAssembly::CONST_F64_S:

296 case WebAssembly::CONST_V128_I8x16:

297 case WebAssembly::CONST_V128_I8x16_S:

298 case WebAssembly::CONST_V128_I16x8:

299 case WebAssembly::CONST_V128_I16x8_S:

300 case WebAssembly::CONST_V128_I32x4:

301 case WebAssembly::CONST_V128_I32x4_S:

302 case WebAssembly::CONST_V128_I64x2:

303 case WebAssembly::CONST_V128_I64x2_S:

304 case WebAssembly::CONST_V128_F32x4:

305 case WebAssembly::CONST_V128_F32x4_S:

306 case WebAssembly::CONST_V128_F64x2:

307 case WebAssembly::CONST_V128_F64x2_S:

308 return true;

309 default:

310 return false;

311 }

312}

313

315 switch (Opc) {

316 case WebAssembly::CONST_I32:

317 case WebAssembly::CONST_I32_S:

318 case WebAssembly::CONST_I64:

319 case WebAssembly::CONST_I64_S:

320 case WebAssembly::CONST_F32:

321 case WebAssembly::CONST_F32_S:

322 case WebAssembly::CONST_F64:

323 case WebAssembly::CONST_F64_S:

324 return true;

325 default:

326 return false;

327 }

328}

329

331 switch (Opc) {

332 case WebAssembly::ARGUMENT_i32:

333 case WebAssembly::ARGUMENT_i32_S:

334 case WebAssembly::ARGUMENT_i64:

335 case WebAssembly::ARGUMENT_i64_S:

336 case WebAssembly::ARGUMENT_f32:

337 case WebAssembly::ARGUMENT_f32_S:

338 case WebAssembly::ARGUMENT_f64:

339 case WebAssembly::ARGUMENT_f64_S:

340 case WebAssembly::ARGUMENT_v16i8:

341 case WebAssembly::ARGUMENT_v16i8_S:

342 case WebAssembly::ARGUMENT_v8i16:

343 case WebAssembly::ARGUMENT_v8i16_S:

344 case WebAssembly::ARGUMENT_v4i32:

345 case WebAssembly::ARGUMENT_v4i32_S:

346 case WebAssembly::ARGUMENT_v2i64:

347 case WebAssembly::ARGUMENT_v2i64_S:

348 case WebAssembly::ARGUMENT_v8f16:

349 case WebAssembly::ARGUMENT_v8f16_S:

350 case WebAssembly::ARGUMENT_v4f32:

351 case WebAssembly::ARGUMENT_v4f32_S:

352 case WebAssembly::ARGUMENT_v2f64:

353 case WebAssembly::ARGUMENT_v2f64_S:

354 case WebAssembly::ARGUMENT_funcref:

355 case WebAssembly::ARGUMENT_funcref_S:

356 case WebAssembly::ARGUMENT_externref:

357 case WebAssembly::ARGUMENT_externref_S:

358 case WebAssembly::ARGUMENT_exnref:

359 case WebAssembly::ARGUMENT_exnref_S:

360 return true;

361 default:

362 return false;

363 }

364}

365

367 switch (Opc) {

368 case WebAssembly::COPY_I32:

369 case WebAssembly::COPY_I32_S:

370 case WebAssembly::COPY_I64:

371 case WebAssembly::COPY_I64_S:

372 case WebAssembly::COPY_F32:

373 case WebAssembly::COPY_F32_S:

374 case WebAssembly::COPY_F64:

375 case WebAssembly::COPY_F64_S:

376 case WebAssembly::COPY_V128:

377 case WebAssembly::COPY_V128_S:

378 case WebAssembly::COPY_FUNCREF:

379 case WebAssembly::COPY_FUNCREF_S:

380 case WebAssembly::COPY_EXTERNREF:

381 case WebAssembly::COPY_EXTERNREF_S:

382 case WebAssembly::COPY_EXNREF:

383 case WebAssembly::COPY_EXNREF_S:

384 return true;

385 default:

386 return false;

387 }

388}

389

391 switch (Opc) {

392 case WebAssembly::TEE_I32:

393 case WebAssembly::TEE_I32_S:

394 case WebAssembly::TEE_I64:

395 case WebAssembly::TEE_I64_S:

396 case WebAssembly::TEE_F32:

397 case WebAssembly::TEE_F32_S:

398 case WebAssembly::TEE_F64:

399 case WebAssembly::TEE_F64_S:

400 case WebAssembly::TEE_V128:

401 case WebAssembly::TEE_V128_S:

402 case WebAssembly::TEE_FUNCREF:

403 case WebAssembly::TEE_FUNCREF_S:

404 case WebAssembly::TEE_EXTERNREF:

405 case WebAssembly::TEE_EXTERNREF_S:

406 case WebAssembly::TEE_EXNREF:

407 case WebAssembly::TEE_EXNREF_S:

408 return true;

409 default:

410 return false;

411 }

412}

413

415 switch (Opc) {

416 case WebAssembly::CALL:

417 case WebAssembly::CALL_S:

418 case WebAssembly::RET_CALL:

419 case WebAssembly::RET_CALL_S:

420 return true;

421 default:

422 return false;

423 }

424}

425

427 switch (Opc) {

428 case WebAssembly::CALL_INDIRECT:

429 case WebAssembly::CALL_INDIRECT_S:

430 case WebAssembly::RET_CALL_INDIRECT:

431 case WebAssembly::RET_CALL_INDIRECT_S:

432 return true;

433 default:

434 return false;

435 }

436}

437

439 switch (Opc) {

440 case WebAssembly::BR_TABLE_I32:

441 case WebAssembly::BR_TABLE_I32_S:

442 case WebAssembly::BR_TABLE_I64:

443 case WebAssembly::BR_TABLE_I64_S:

444 return true;

445 default:

446 return false;

447 }

448}

449

451 switch (Opc) {

452 case WebAssembly::BLOCK:

453 case WebAssembly::BLOCK_S:

454 case WebAssembly::END_BLOCK:

455 case WebAssembly::END_BLOCK_S:

456 case WebAssembly::LOOP:

457 case WebAssembly::LOOP_S:

458 case WebAssembly::END_LOOP:

459 case WebAssembly::END_LOOP_S:

460 case WebAssembly::TRY:

461 case WebAssembly::TRY_S:

462 case WebAssembly::END_TRY:

463 case WebAssembly::END_TRY_S:

464 case WebAssembly::TRY_TABLE:

465 case WebAssembly::TRY_TABLE_S:

466 case WebAssembly::END_TRY_TABLE:

467 case WebAssembly::END_TRY_TABLE_S:

468 return true;

469 default:

470 return false;

471 }

472}

473

475 switch (Opc) {

476 case WebAssembly::END_BLOCK:

477 case WebAssembly::END_BLOCK_S:

478 case WebAssembly::END_LOOP:

479 case WebAssembly::END_LOOP_S:

480 case WebAssembly::END_TRY:

481 case WebAssembly::END_TRY_S:

482 case WebAssembly::END_TRY_TABLE:

483 case WebAssembly::END_TRY_TABLE_S:

484 return true;

485 default:

486 return false;

487 }

488}

489

491 switch (Opc) {

492 case WebAssembly::TRY:

493 case WebAssembly::TRY_S:

494 case WebAssembly::TRY_TABLE:

495 case WebAssembly::TRY_TABLE_S:

496 return true;

497 default:

498 return false;

499 }

500}

501

503 switch (Opc) {

504 case WebAssembly::CATCH_LEGACY:

505 case WebAssembly::CATCH_LEGACY_S:

506 case WebAssembly::CATCH_ALL_LEGACY:

507 case WebAssembly::CATCH_ALL_LEGACY_S:

508 case WebAssembly::CATCH:

509 case WebAssembly::CATCH_S:

510 case WebAssembly::CATCH_REF:

511 case WebAssembly::CATCH_REF_S:

512 case WebAssembly::CATCH_ALL:

513 case WebAssembly::CATCH_ALL_S:

514 case WebAssembly::CATCH_ALL_REF:

515 case WebAssembly::CATCH_ALL_REF_S:

516 return true;

517 default:

518 return false;

519 }

520}

521

523 switch (Opc) {

524 case WebAssembly::CATCH_ALL_LEGACY:

525 case WebAssembly::CATCH_ALL_LEGACY_S:

526 case WebAssembly::CATCH_ALL:

527 case WebAssembly::CATCH_ALL_S:

528 case WebAssembly::CATCH_ALL_REF:

529 case WebAssembly::CATCH_ALL_REF_S:

530 return true;

531 default:

532 return false;

533 }

534}

535

537 switch (Opc) {

538 case WebAssembly::LOCAL_GET_I32:

539 case WebAssembly::LOCAL_GET_I32_S:

540 case WebAssembly::LOCAL_GET_I64:

541 case WebAssembly::LOCAL_GET_I64_S:

542 case WebAssembly::LOCAL_GET_F32:

543 case WebAssembly::LOCAL_GET_F32_S:

544 case WebAssembly::LOCAL_GET_F64:

545 case WebAssembly::LOCAL_GET_F64_S:

546 case WebAssembly::LOCAL_GET_V128:

547 case WebAssembly::LOCAL_GET_V128_S:

548 case WebAssembly::LOCAL_GET_FUNCREF:

549 case WebAssembly::LOCAL_GET_FUNCREF_S:

550 case WebAssembly::LOCAL_GET_EXTERNREF:

551 case WebAssembly::LOCAL_GET_EXTERNREF_S:

552 case WebAssembly::LOCAL_GET_EXNREF:

553 case WebAssembly::LOCAL_GET_EXNREF_S:

554 return true;

555 default:

556 return false;

557 }

558}

559

561 switch (Opc) {

562 case WebAssembly::LOCAL_SET_I32:

563 case WebAssembly::LOCAL_SET_I32_S:

564 case WebAssembly::LOCAL_SET_I64:

565 case WebAssembly::LOCAL_SET_I64_S:

566 case WebAssembly::LOCAL_SET_F32:

567 case WebAssembly::LOCAL_SET_F32_S:

568 case WebAssembly::LOCAL_SET_F64:

569 case WebAssembly::LOCAL_SET_F64_S:

570 case WebAssembly::LOCAL_SET_V128:

571 case WebAssembly::LOCAL_SET_V128_S:

572 case WebAssembly::LOCAL_SET_FUNCREF:

573 case WebAssembly::LOCAL_SET_FUNCREF_S:

574 case WebAssembly::LOCAL_SET_EXTERNREF:

575 case WebAssembly::LOCAL_SET_EXTERNREF_S:

576 case WebAssembly::LOCAL_SET_EXNREF:

577 case WebAssembly::LOCAL_SET_EXNREF_S:

578 return true;

579 default:

580 return false;

581 }

582}

583

585 switch (Opc) {

586 case WebAssembly::LOCAL_TEE_I32:

587 case WebAssembly::LOCAL_TEE_I32_S:

588 case WebAssembly::LOCAL_TEE_I64:

589 case WebAssembly::LOCAL_TEE_I64_S:

590 case WebAssembly::LOCAL_TEE_F32:

591 case WebAssembly::LOCAL_TEE_F32_S:

592 case WebAssembly::LOCAL_TEE_F64:

593 case WebAssembly::LOCAL_TEE_F64_S:

594 case WebAssembly::LOCAL_TEE_V128:

595 case WebAssembly::LOCAL_TEE_V128_S:

596 case WebAssembly::LOCAL_TEE_FUNCREF:

597 case WebAssembly::LOCAL_TEE_FUNCREF_S:

598 case WebAssembly::LOCAL_TEE_EXTERNREF:

599 case WebAssembly::LOCAL_TEE_EXTERNREF_S:

600 case WebAssembly::LOCAL_TEE_EXNREF:

601 case WebAssembly::LOCAL_TEE_EXNREF_S:

602 return true;

603 default:

604 return false;

605 }

606}

607

609

610

613 return Reg.id() & INT32_MAX;

614}

615

616}

617}

618

619#define GET_SUBTARGETINFO_ENUM

620#include "WebAssemblyGenSubtargetInfo.inc"

621

622#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define WASM_LOAD_STORE(NAME)

Generic interface to target specific assembler backends.

MCCodeEmitter - Generic instruction encoding interface.

Context object for machine code objects.

Interface to description of machine instruction set.

Base class for classes that define behaviour that is specific to both the target and the object forma...

Wrapper class representing physical registers. Should be passed by value.

Triple - Helper class for working with autoconf configuration names.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

TOF

Target Operand Flag enum.

Definition WebAssemblyMCTargetDesc.h:91

@ MO_NO_FLAG

Definition WebAssemblyMCTargetDesc.h:92

@ MO_TABLE_BASE_REL

Definition WebAssemblyMCTargetDesc.h:116

@ MO_MEMORY_BASE_REL

Definition WebAssemblyMCTargetDesc.h:106

@ MO_CATCH_BLOCK_SIG

Definition WebAssemblyMCTargetDesc.h:120

@ MO_TLS_BASE_REL

Definition WebAssemblyMCTargetDesc.h:111

@ MO_GOT

Definition WebAssemblyMCTargetDesc.h:98

@ MO_GOT_TLS

Definition WebAssemblyMCTargetDesc.h:101

bool isLocalTee(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:584

bool isArgument(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:330

bool isTry(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:490

bool isCallIndirect(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:426

unsigned GetDefaultP2Align(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:278

bool isCatchAll(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:522

bool isMarker(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:450

bool isBrTable(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:438

bool isEndMarker(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:474

bool isCatch(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:502

static const unsigned UnusedReg

Definition WebAssemblyMCTargetDesc.h:608

static const unsigned Nop

Instruction opcodes emitted via means other than CodeGen.

Definition WebAssemblyMCTargetDesc.h:143

bool isCopy(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:366

bool isTee(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:390

static const unsigned End

Definition WebAssemblyMCTargetDesc.h:144

bool isConst(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:286

OperandType

Definition WebAssemblyMCTargetDesc.h:42

@ OPERAND_GLOBAL

Global index.

Definition WebAssemblyMCTargetDesc.h:48

@ OPERAND_CATCH_LIST

A list of catch clauses for try_table.

Definition WebAssemblyMCTargetDesc.h:84

@ OPERAND_OFFSET64

64-bit unsigned memory offsets.

Definition WebAssemblyMCTargetDesc.h:70

@ OPERAND_I32IMM

32-bit integer immediates.

Definition WebAssemblyMCTargetDesc.h:50

@ OPERAND_P2ALIGN

p2align immediate for load and store address alignment.

Definition WebAssemblyMCTargetDesc.h:72

@ OPERAND_TABLE

32-bit unsigned table number.

Definition WebAssemblyMCTargetDesc.h:82

@ OPERAND_LOCAL

Local index.

Definition WebAssemblyMCTargetDesc.h:46

@ OPERAND_VEC_I64IMM

64-bit vector lane immediate

Definition WebAssemblyMCTargetDesc.h:64

@ OPERAND_VEC_I16IMM

16-bit vector lane immediate

Definition WebAssemblyMCTargetDesc.h:60

@ OPERAND_TYPEINDEX

type signature immediate for call_indirect.

Definition WebAssemblyMCTargetDesc.h:76

@ OPERAND_TAG

Tag index.

Definition WebAssemblyMCTargetDesc.h:78

@ OPERAND_FUNCTION32

32-bit unsigned function indices.

Definition WebAssemblyMCTargetDesc.h:66

@ OPERAND_F32IMM

32-bit floating-point immediates.

Definition WebAssemblyMCTargetDesc.h:54

@ OPERAND_BASIC_BLOCK

Basic block label in a branch construct.

Definition WebAssemblyMCTargetDesc.h:44

@ OPERAND_VEC_I32IMM

32-bit vector lane immediate

Definition WebAssemblyMCTargetDesc.h:62

@ OPERAND_BRLIST

A list of branch targets for br_list.

Definition WebAssemblyMCTargetDesc.h:80

@ OPERAND_F64IMM

64-bit floating-point immediates.

Definition WebAssemblyMCTargetDesc.h:56

@ OPERAND_VEC_I8IMM

8-bit vector lane immediate

Definition WebAssemblyMCTargetDesc.h:58

@ OPERAND_SIGNATURE

signature immediate for block/loop.

Definition WebAssemblyMCTargetDesc.h:74

@ OPERAND_I64IMM

64-bit integer immediates.

Definition WebAssemblyMCTargetDesc.h:52

@ OPERAND_OFFSET32

32-bit unsigned memory offsets.

Definition WebAssemblyMCTargetDesc.h:68

unsigned GetDefaultP2AlignAny(unsigned Opc)

Return the default p2align value for a load or store with the given opcode.

Definition WebAssemblyMCTargetDesc.h:147

unsigned getWARegStackId(MCRegister Reg)

Definition WebAssemblyMCTargetDesc.h:611

bool isCallDirect(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:414

bool isScalarConst(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:314

bool isLocalSet(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:560

bool isLocalGet(unsigned Opc)

Definition WebAssemblyMCTargetDesc.h:536

This is an optimization pass for GlobalISel generic memory operations.

MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)

MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)

std::unique_ptr< MCObjectTargetWriter > createWebAssemblyWasmObjectWriter(bool Is64Bit, bool IsEmscripten)

This struct is a compact representation of a valid (non-zero power of two) alignment.