xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td (revision fe6060f10f634930ff71b7c50291ddc610da2475)
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*fe6060f1SDimitry Andricmulticlass REF_I<WebAssemblyRegClass rc, ValueType vt> {
15*fe6060f1SDimitry Andric  defm REF_NULL_#rc : I<(outs rc:$res), (ins HeapType:$heaptype),
16e8d8bef9SDimitry Andric                        (outs), (ins HeapType:$heaptype),
17e8d8bef9SDimitry Andric                        [],
18e8d8bef9SDimitry Andric                        "ref.null\t$res, $heaptype",
19e8d8bef9SDimitry Andric                        "ref.null\t$heaptype",
20e8d8bef9SDimitry Andric                        0xd0>,
21e8d8bef9SDimitry Andric                      Requires<[HasReferenceTypes]>;
22*fe6060f1SDimitry Andric  defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond),
230b57cec5SDimitry Andric                     (outs), (ins),
24*fe6060f1SDimitry Andric                     [(set rc:$dst,
25*fe6060f1SDimitry Andric                       (select I32:$cond, rc:$lhs, rc:$rhs))],
26e8d8bef9SDimitry Andric                     vt#".select\t$dst, $lhs, $rhs, $cond",
27e8d8bef9SDimitry Andric                     vt#".select", 0x1b>,
28e8d8bef9SDimitry Andric                   Requires<[HasReferenceTypes]>;
29e8d8bef9SDimitry Andric}
300b57cec5SDimitry Andric
31e8d8bef9SDimitry Andricdefm "" : REF_I<FUNCREF, funcref>;
32e8d8bef9SDimitry Andricdefm "" : REF_I<EXTERNREF, externref>;
33e8d8bef9SDimitry Andric
34*fe6060f1SDimitry Andricforeach rc = [FUNCREF, EXTERNREF] in {
35*fe6060f1SDimitry Andricdef : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs),
36*fe6060f1SDimitry Andric          (!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>;
37*fe6060f1SDimitry Andricdef : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs),
38*fe6060f1SDimitry Andric          (!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>;
39e8d8bef9SDimitry Andric}
40