10b57cec5SDimitry Andric// WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*- 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric/// 90b57cec5SDimitry Andric/// \file 105ffd83dbSDimitry Andric/// WebAssembly reference type operand codegen constructs. 110b57cec5SDimitry Andric/// 120b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 14*e8d8bef9SDimitry Andricmulticlass REF_I<WebAssemblyRegClass reg, ValueType vt> { 15*e8d8bef9SDimitry Andric defm REF_NULL_#reg : I<(outs reg:$res), (ins HeapType:$heaptype), 16*e8d8bef9SDimitry Andric (outs), (ins HeapType:$heaptype), 17*e8d8bef9SDimitry Andric [], 18*e8d8bef9SDimitry Andric "ref.null\t$res, $heaptype", 19*e8d8bef9SDimitry Andric "ref.null\t$heaptype", 20*e8d8bef9SDimitry Andric 0xd0>, 21*e8d8bef9SDimitry Andric Requires<[HasReferenceTypes]>; 22*e8d8bef9SDimitry Andric defm SELECT_#reg: I<(outs reg:$dst), (ins reg:$lhs, reg:$rhs, I32:$cond), 230b57cec5SDimitry Andric (outs), (ins), 24*e8d8bef9SDimitry Andric [(set reg:$dst, 25*e8d8bef9SDimitry Andric (select I32:$cond, reg:$lhs, reg:$rhs))], 26*e8d8bef9SDimitry Andric vt#".select\t$dst, $lhs, $rhs, $cond", 27*e8d8bef9SDimitry Andric vt#".select", 0x1b>, 28*e8d8bef9SDimitry Andric Requires<[HasReferenceTypes]>; 29*e8d8bef9SDimitry Andric} 300b57cec5SDimitry Andric 31*e8d8bef9SDimitry Andricdefm "" : REF_I<FUNCREF, funcref>; 32*e8d8bef9SDimitry Andricdefm "" : REF_I<EXTERNREF, externref>; 33*e8d8bef9SDimitry Andric 34*e8d8bef9SDimitry Andricforeach reg = [FUNCREF, EXTERNREF] in { 35*e8d8bef9SDimitry Andricdef : Pat<(select (i32 (setne I32:$cond, 0)), reg:$lhs, reg:$rhs), 36*e8d8bef9SDimitry Andric (!cast<Instruction>("SELECT_"#reg) reg:$lhs, reg:$rhs, I32:$cond)>; 37*e8d8bef9SDimitry Andricdef : Pat<(select (i32 (seteq I32:$cond, 0)), reg:$lhs, reg:$rhs), 38*e8d8bef9SDimitry Andric (!cast<Instruction>("SELECT_"#reg) reg:$rhs, reg:$lhs, I32:$cond)>; 39*e8d8bef9SDimitry Andric} 40