brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 304c4f3 Raw
59 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// WebAssembly reference type operand codegen constructs.11///12//===----------------------------------------------------------------------===//13 14multiclass REF_I<WebAssemblyRegClass rc, ValueType vt, string ht> {15  defm REF_NULL_#rc : I<(outs rc:$dst), (ins),16                        (outs), (ins),17                        [(set rc:$dst, (!cast<Intrinsic>("int_wasm_ref_null_" # ht)))],18                        "ref.null_" # ht # "$dst",19                        "ref.null_" # ht,20                        !cond(!eq(ht, "func")   : 0xd070,21                              !eq(ht, "extern") : 0xd06f,22                              !eq(ht, "exn")    : 0xd069)>,23                      Requires<[HasReferenceTypes]>;24  defm SELECT_#rc: I<(outs rc:$dst), (ins rc:$lhs, rc:$rhs, I32:$cond),25                     (outs), (ins),26                     [(set rc:$dst,27                       (select I32:$cond, rc:$lhs, rc:$rhs))],28                     vt#".select\t$dst, $lhs, $rhs, $cond",29                     vt#".select", 0x1b>,30                   Requires<[HasReferenceTypes]>;31  defm REF_IS_NULL_#rc32      : I<(outs I32:$dst), (ins rc:$ref), (outs), (ins),33          [(set I32:$dst, (!cast<Intrinsic>("int_wasm_ref_is_null_" # ht) rc:$ref))],34          "ref.is_null\t$ref",35          "ref.is_null", 0xd1>,36        Requires<[HasReferenceTypes]>;37}38 39defm REF_TEST_FUNCREF : I<(outs I32:$res), (ins TypeIndex:$type, FUNCREF:$ref),40                          (outs), (ins TypeIndex:$type), [],41                          "ref.test\t$type, $ref", "ref.test $type", 0xfb14>,42                        Requires<[HasGC]>;43 44defm REF_FUNC : I<(outs FUNCREF:$res), (ins function32_op:$func),45                    (outs), (ins function32_op:$func), [],46                    "ref.func\t$func", "ref.func $func", 0xd2>,47                Requires<[HasReferenceTypes]>;48 49defm "" : REF_I<FUNCREF, funcref, "func">;50defm "" : REF_I<EXTERNREF, externref, "extern">;51defm "" : REF_I<EXNREF, exnref, "exn">;52 53foreach rc = [FUNCREF, EXTERNREF, EXNREF] in {54def : Pat<(select (i32 (setne I32:$cond, 0)), rc:$lhs, rc:$rhs),55          (!cast<Instruction>("SELECT_"#rc) rc:$lhs, rc:$rhs, I32:$cond)>;56def : Pat<(select (i32 (seteq I32:$cond, 0)), rc:$lhs, rc:$rhs),57          (!cast<Instruction>("SELECT_"#rc) rc:$rhs, rc:$lhs, I32:$cond)>;58}59