xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td (revision 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)
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*0eae32dcSDimitry Andricmulticlass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> {
15*0eae32dcSDimitry Andric  defm REF_NULL_#rc : I<(outs rc:$dst), (ins),
16*0eae32dcSDimitry Andric                        (outs), (ins),
17*0eae32dcSDimitry Andric                        [(set rc:$dst, (!cast<Intrinsic>("int_wasm_ref_null_" # ht)))],
18*0eae32dcSDimitry Andric                        "ref.null_" # ht # "$dst",
19*0eae32dcSDimitry Andric                        "ref.null_" # ht,
20*0eae32dcSDimitry Andric                        !cond(!eq(ht, "func")   : 0xd070,
21*0eae32dcSDimitry Andric                              !eq(ht, "extern") : 0xd06f)>,
22e8d8bef9SDimitry Andric                      Requires<[HasReferenceTypes]>;
23fe6060f1SDimitry Andric  defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond),
240b57cec5SDimitry Andric                     (outs), (ins),
25fe6060f1SDimitry Andric                     [(set rc:$dst,
26fe6060f1SDimitry Andric                       (select I32:$cond, rc:$lhs, rc:$rhs))],
27e8d8bef9SDimitry Andric                     vt#".select\t$dst, $lhs, $rhs, $cond",
28e8d8bef9SDimitry Andric                     vt#".select", 0x1b>,
29e8d8bef9SDimitry Andric                   Requires<[HasReferenceTypes]>;
30e8d8bef9SDimitry Andric}
310b57cec5SDimitry Andric
32*0eae32dcSDimitry Andricdefm "" : REF_I<FUNCREF, funcref, "func">;
33*0eae32dcSDimitry Andricdefm "" : REF_I<EXTERNREF, externref, "extern">;
34e8d8bef9SDimitry Andric
35fe6060f1SDimitry Andricforeach rc = [FUNCREF, EXTERNREF] in {
36fe6060f1SDimitry Andricdef : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs),
37fe6060f1SDimitry Andric          (!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>;
38fe6060f1SDimitry Andricdef : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs),
39fe6060f1SDimitry Andric          (!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>;
40e8d8bef9SDimitry Andric}
41