19f96a58cSHeejin Ahn// WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*- 29f96a58cSHeejin Ahn// 39f96a58cSHeejin Ahn// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 49f96a58cSHeejin Ahn// See https://llvm.org/LICENSE.txt for license information. 59f96a58cSHeejin Ahn// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 69f96a58cSHeejin Ahn// 79f96a58cSHeejin Ahn//===----------------------------------------------------------------------===// 89f96a58cSHeejin Ahn/// 99f96a58cSHeejin Ahn/// \file 100312b9f5SKazuaki Ishizaki/// WebAssembly reference type operand codegen constructs. 119f96a58cSHeejin Ahn/// 129f96a58cSHeejin Ahn//===----------------------------------------------------------------------===// 139f96a58cSHeejin Ahn 14a96d8285SPaulo Matosmulticlass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> { 15a96d8285SPaulo Matos defm REF_NULL_#rc : I<(outs rc:$dst), (ins), 16a96d8285SPaulo Matos (outs), (ins), 17a96d8285SPaulo Matos [(set rc:$dst, (!cast<Intrinsic>("int_wasm_ref_null_" # ht)))], 18a96d8285SPaulo Matos "ref.null_" # ht # "$dst", 19a96d8285SPaulo Matos "ref.null_" # ht, 20a96d8285SPaulo Matos !cond(!eq(ht, "func") : 0xd070, 21a96d8285SPaulo Matos !eq(ht, "extern") : 0xd06f)>, 2260653e24SHeejin Ahn Requires<[HasReferenceTypes]>; 23d7086af2SPaulo Matos defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond), 2460653e24SHeejin Ahn (outs), (ins), 25d7086af2SPaulo Matos [(set rc:$dst, 26d7086af2SPaulo Matos (select I32:$cond, rc:$lhs, rc:$rhs))], 2760653e24SHeejin Ahn vt#".select\t$dst, $lhs, $rhs, $cond", 2860653e24SHeejin Ahn vt#".select", 0x1b>, 2960653e24SHeejin Ahn Requires<[HasReferenceTypes]>; 30*cb778e93SAlex Bradbury defm REF_IS_NULL_#rc 31*cb778e93SAlex Bradbury : I<(outs I32:$dst), (ins rc:$ref), (outs), (ins), 32*cb778e93SAlex Bradbury [(set I32:$dst, (!cast<Intrinsic>("int_wasm_ref_is_null_" # ht) rc:$ref))], 33*cb778e93SAlex Bradbury "ref.is_null\t$ref", 34*cb778e93SAlex Bradbury "ref.is_null", 0xd1>, 35*cb778e93SAlex Bradbury Requires<[HasReferenceTypes]>; 36107c3a12SAndy Wingo} 37107c3a12SAndy Wingo 38a96d8285SPaulo Matosdefm "" : REF_I<FUNCREF, funcref, "func">; 39a96d8285SPaulo Matosdefm "" : REF_I<EXTERNREF, externref, "extern">; 4060653e24SHeejin Ahn 41d7086af2SPaulo Matosforeach rc = [FUNCREF, EXTERNREF] in { 42d7086af2SPaulo Matosdef : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs), 43d7086af2SPaulo Matos (!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>; 44d7086af2SPaulo Matosdef : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs), 45d7086af2SPaulo Matos (!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>; 4660653e24SHeejin Ahn} 47