Files
TheRock/compiler/amd-llvm/llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

81 lines
3.7 KiB
TableGen

// WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*-
//
// 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
//
//===----------------------------------------------------------------------===//
///
/// \file
/// WebAssembly reference type operand codegen constructs.
///
//===----------------------------------------------------------------------===//
multiclass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> {
defm REF_NULL_#rc : I<(outs rc:$dst), (ins),
(outs), (ins),
[(set rc:$dst, (!cast<Intrinsic>("int_wasm_ref_null_" # ht)))],
"ref.null_" # ht # "$dst",
"ref.null_" # ht,
!cond(!eq(ht, "func") : 0xd070,
!eq(ht, "extern") : 0xd06f,
!eq(ht, "exn") : 0xd069)>,
Requires<[HasReferenceTypes]>;
defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond),
(outs), (ins),
[(set rc:$dst,
(select I32:$cond, rc:$lhs, rc:$rhs))],
vt#".select\t$dst, $lhs, $rhs, $cond",
vt#".select", 0x1b>,
Requires<[HasReferenceTypes]>;
defm REF_IS_NULL_#rc
: I<(outs I32:$dst), (ins rc:$ref), (outs), (ins),
[(set I32:$dst, (!cast<Intrinsic>("int_wasm_ref_is_null_" # ht) rc:$ref))],
"ref.is_null\t$ref",
"ref.is_null", 0xd1>,
Requires<[HasReferenceTypes]>;
}
defm REF_TEST_FUNCREF : I<(outs I32:$res), (ins TypeIndex:$type, FUNCREF:$ref),
(outs), (ins TypeIndex:$type), [],
"ref.test\t$type, $ref", "ref.test $type", 0xfb14>,
Requires<[HasGC]>;
defm REF_CAST_FUNCREF : I<(outs FUNCREF:$res), (ins TypeIndex:$type, FUNCREF:$ref),
(outs), (ins TypeIndex:$type), [],
"ref.cast\t$type, $ref", "ref.cast $type", 0xfb16>,
Requires<[HasGC]>;
defm REF_FUNC : I<(outs FUNCREF:$res), (ins function32_op:$func),
(outs), (ins function32_op:$func), [],
"ref.func\t$func", "ref.func $func", 0xd2>,
Requires<[HasReferenceTypes]>;
// A vector of value types used by the typed select instruction (select t*).
def TypeListAsmOperand : AsmOperandClass { let Name = "TypeList"; }
let OperandNamespace = "WebAssembly", OperandType = "OPERAND_VALTYPE_LIST" in
def typelist : Operand<i32> {
let ParserMatchClass = TypeListAsmOperand;
let PrintMethod = "printTypeList";
}
// Typed select: pops an i32 condition and two values of each declared type,
// then pushes the declared types back. ISel continues to use the numeric
// SELECT_<type> instructions at 0x1b; SELECT_T exists purely at the MC layer
// so the assembler and disassembler understand the typed form. It has no
// register operands distinct from its stack form, hence NRI.
defm SELECT_T : NRI<(outs), (ins typelist:$list), [],
"select\t$list", 0x1c>,
Requires<[HasReferenceTypes]>;
defm "" : REF_I<FUNCREF, funcref, "func">;
defm "" : REF_I<EXTERNREF, externref, "extern">;
defm "" : REF_I<EXNREF, exnref, "exn">;
foreach rc = [FUNCREF, EXTERNREF, EXNREF] in {
def : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs),
(!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>;
def : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs),
(!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>;
}