brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 02f0ab8 Raw
92 lines · plain
1// WebAssemblyInstrTable.td - WebAssembly Table codegen support -*- 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 Table operand code-gen constructs.11/// Instructions that handle tables12//===----------------------------------------------------------------------===//13 14def WebAssemblyTableSet_t : SDTypeProfile<0, 3, [SDTCisPtrTy<1>]>;15def WebAssemblyTableSet : SDNode<"WebAssemblyISD::TABLE_SET", WebAssemblyTableSet_t,16                                 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;17 18def WebAssemblyTableGet_t : SDTypeProfile<1, 2, [SDTCisPtrTy<1>]>;19def WebAssemblyTableGet : SDNode<"WebAssemblyISD::TABLE_GET", WebAssemblyTableGet_t,20                                 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;21 22 23multiclass TABLE<WebAssemblyRegClass rc, string suffix> {24  let mayLoad = 1 in25  defm TABLE_GET_#rc : I<(outs rc:$res), (ins table32_op:$table, I32:$i),26                         (outs), (ins table32_op:$table),27                         [(set rc:$res, (!cast<Intrinsic>("int_wasm_table_get_" # suffix) (WebAssemblyWrapper tglobaladdr:$table), I32:$i))],28                         "table.get\t$res, $table, $i",29                         "table.get\t$table",30                         0x25>;31 32  let mayStore = 1 in33  defm TABLE_SET_#rc : I<(outs), (ins table32_op:$table, I32:$i, rc:$val),34                         (outs), (ins table32_op:$table),35                         [(!cast<Intrinsic>("int_wasm_table_set_" # suffix) (WebAssemblyWrapper tglobaladdr:$table), I32:$i, rc:$val)],36                         "table.set\t$table, $i, $val",37                         "table.set\t$table",38                         0x26>;39 40  defm TABLE_GROW_#rc : I<(outs I32:$sz), (ins table32_op:$table, rc:$val, I32:$n),41                          (outs), (ins table32_op:$table),42                          [(set I32:$sz, (!cast<Intrinsic>("int_wasm_table_grow_" # suffix) (WebAssemblyWrapper tglobaladdr:$table), rc:$val, I32:$n))],43                          "table.grow\t$sz, $table, $val, $n",44                          "table.grow\t$table",45                          0xfc0f>;46 47  defm TABLE_FILL_#rc : I<(outs), (ins table32_op:$table, I32:$i, rc:$val, I32:$n),48                          (outs), (ins table32_op:$table),49                          [(!cast<Intrinsic>("int_wasm_table_fill_" # suffix) (WebAssemblyWrapper tglobaladdr:$table), I32:$i, rc:$val, I32:$n)],50                          "table.fill\t$table, $i, $val, $n",51                          "table.fill\t$table",52                          0xfc11>;53 54  foreach vt = rc.RegTypes in {55    def : Pat<(vt (WebAssemblyTableGet (WebAssemblyWrapper tglobaladdr:$table), i32:$idx)),56              (!cast<NI>("TABLE_GET_" # rc) tglobaladdr:$table, i32:$idx)>;57    def : Pat<(WebAssemblyTableSet58               (WebAssemblyWrapper tglobaladdr:$table),59               i32:$idx,60               vt:$src),61              (!cast<NI>("TABLE_SET_" # rc) tglobaladdr:$table, i32:$idx, vt:$src)>;62  }63}64 65defm "" : TABLE<FUNCREF, "funcref">, Requires<[HasReferenceTypes]>;66defm "" : TABLE<EXTERNREF, "externref">, Requires<[HasReferenceTypes]>;67defm "" : TABLE<EXNREF, "exnref">,68          Requires<[HasReferenceTypes, HasExceptionHandling]>;69 70def : Pat<(WebAssemblyTableSet mcsym:$table, i32:$idx, funcref:$r),71          (TABLE_SET_FUNCREF mcsym:$table, i32:$idx, funcref:$r)>,72          Requires<[HasReferenceTypes]>;73 74defm TABLE_SIZE : I<(outs I32:$sz), (ins table32_op:$table),75                    (outs), (ins table32_op:$table),76                    [(set I32:$sz, (int_wasm_table_size (WebAssemblyWrapper tglobaladdr:$table)))],77                    "table.size\t$sz, $table",78                    "table.size\t$table",79                    0xfc10>,80                    Requires<[HasReferenceTypes]>;81 82 83defm TABLE_COPY : I<(outs), (ins table32_op:$table1, table32_op:$table2, I32:$d, I32:$s, I32:$n),84                    (outs), (ins table32_op:$table1, table32_op:$table2),85                    [(int_wasm_table_copy (WebAssemblyWrapper tglobaladdr:$table1),86                                          (WebAssemblyWrapper tglobaladdr:$table2),87                                          I32:$d, I32:$s, I32:$n)],88                    "table.copy\t$table1, $table2, $d, $s, $n",89                    "table.copy\t$table1, $table2",90                    0xfc0e>,91                    Requires<[HasReferenceTypes]>;92