1 // WebAssemblyInstrRef.td - WebAssembly reference type codegen --*- tablegen -*-
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
7 //===----------------------------------------------------------------------===//
10 /// WebAssembly reference type operand codegen constructs.
12 //===----------------------------------------------------------------------===//
14 multiclass REF_I<WebAssemblyRegClass rc, ValueType vt> {
15 defm REF_NULL_#rc : I<(outs rc:$res), (ins HeapType:$heaptype),
16 (outs), (ins HeapType:$heaptype),
18 "ref.null\t$res, $heaptype",
19 "ref.null\t$heaptype",
21 Requires<[HasReferenceTypes]>;
22 defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond),
25 (select I32:$cond, rc:$lhs, rc:$rhs))],
26 vt#".select\t$dst, $lhs, $rhs, $cond",
28 Requires<[HasReferenceTypes]>;
31 defm "" : REF_I<FUNCREF, funcref>;
32 defm "" : REF_I<EXTERNREF, externref>;
34 foreach rc = [FUNCREF, EXTERNREF] in {
35 def : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs),
36 (!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>;
37 def : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs),
38 (!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>;