1// WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*- 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8/// 9/// \file 10/// WebAssembly reference type operand codegen constructs. 11/// 12//===----------------------------------------------------------------------===// 13 14multiclass REF_I<WebAssemblyRegClass reg, ValueType vt> { 15 defm REF_NULL_#reg : I<(outs reg:$res), (ins HeapType:$heaptype), 16 (outs), (ins HeapType:$heaptype), 17 [], 18 "ref.null\t$res, $heaptype", 19 "ref.null\t$heaptype", 20 0xd0>, 21 Requires<[HasReferenceTypes]>; 22 defm SELECT_#reg: I<(outs reg:$dst), (ins reg:$lhs, reg:$rhs, I32:$cond), 23 (outs), (ins), 24 [(set reg:$dst, 25 (select I32:$cond, reg:$lhs, reg:$rhs))], 26 vt#".select\t$dst, $lhs, $rhs, $cond", 27 vt#".select", 0x1b>, 28 Requires<[HasReferenceTypes]>; 29} 30 31defm "" : REF_I<FUNCREF, funcref>; 32defm "" : REF_I<EXTERNREF, externref>; 33 34foreach reg = [FUNCREF, EXTERNREF] in { 35def : Pat<(select (i32 (setne I32:$cond, 0)), reg:$lhs, reg:$rhs), 36 (!cast<Instruction>("SELECT_"#reg) reg:$lhs, reg:$rhs, I32:$cond)>; 37def : Pat<(select (i32 (seteq I32:$cond, 0)), reg:$lhs, reg:$rhs), 38 (!cast<Instruction>("SELECT_"#reg) reg:$rhs, reg:$lhs, I32:$cond)>; 39} 40