1e8d8bef9SDimitry Andric// WebAssemblyInstrTable.td - WebAssembly Table codegen support -*- tablegen -*- 2e8d8bef9SDimitry Andric// 3e8d8bef9SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e8d8bef9SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5e8d8bef9SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e8d8bef9SDimitry Andric// 7e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 8e8d8bef9SDimitry Andric/// 9e8d8bef9SDimitry Andric/// \file 10e8d8bef9SDimitry Andric/// WebAssembly Table operand code-gen constructs. 11e8d8bef9SDimitry Andric/// Instructions that handle tables 12e8d8bef9SDimitry Andric//===----------------------------------------------------------------------===// 13e8d8bef9SDimitry Andric 14e8d8bef9SDimitry Andricmulticlass TABLE<WebAssemblyRegClass rt> { 15*fe6060f1SDimitry Andric let mayLoad = 1 in 16*fe6060f1SDimitry Andric defm TABLE_GET_#rt : I<(outs rt:$res), (ins table32_op:$table, I32:$i), 17e8d8bef9SDimitry Andric (outs), (ins table32_op:$table), 18e8d8bef9SDimitry Andric [], 19*fe6060f1SDimitry Andric "table.get\t$res, $table, $i", 20e8d8bef9SDimitry Andric "table.get\t$table", 21e8d8bef9SDimitry Andric 0x25>; 22e8d8bef9SDimitry Andric 23*fe6060f1SDimitry Andric let mayStore = 1 in 24*fe6060f1SDimitry Andric defm TABLE_SET_#rt : I<(outs), (ins table32_op:$table, I32:$i, rt:$val), 25e8d8bef9SDimitry Andric (outs), (ins table32_op:$table), 26e8d8bef9SDimitry Andric [], 27*fe6060f1SDimitry Andric "table.set\t$table, $i, $val", 28e8d8bef9SDimitry Andric "table.set\t$table", 29e8d8bef9SDimitry Andric 0x26>; 30e8d8bef9SDimitry Andric 31*fe6060f1SDimitry Andric defm TABLE_GROW_#rt : I<(outs I32:$sz), (ins table32_op:$table, rt:$val, I32:$n), 32e8d8bef9SDimitry Andric (outs), (ins table32_op:$table), 33e8d8bef9SDimitry Andric [], 34*fe6060f1SDimitry Andric "table.grow\t$sz, $table, $val, $n", 35e8d8bef9SDimitry Andric "table.grow\t$table", 36e8d8bef9SDimitry Andric 0xfc0f>; 37e8d8bef9SDimitry Andric 38*fe6060f1SDimitry Andric defm TABLE_FILL_#rt : I<(outs), (ins table32_op:$table, I32:$i, rt:$val, I32:$n), 39e8d8bef9SDimitry Andric (outs), (ins table32_op:$table), 40e8d8bef9SDimitry Andric [], 41*fe6060f1SDimitry Andric "table.fill\t$table, $i, $val, $n", 42e8d8bef9SDimitry Andric "table.fill\t$table", 43e8d8bef9SDimitry Andric 0xfc11>; 44e8d8bef9SDimitry Andric 45e8d8bef9SDimitry Andric} 46e8d8bef9SDimitry Andric 47e8d8bef9SDimitry Andricdefm "" : TABLE<FUNCREF>, Requires<[HasReferenceTypes]>; 48e8d8bef9SDimitry Andricdefm "" : TABLE<EXTERNREF>, Requires<[HasReferenceTypes]>; 49e8d8bef9SDimitry Andric 50*fe6060f1SDimitry Andricdef wasm_table_set_t : SDTypeProfile<0, 3, []>; 51*fe6060f1SDimitry Andricdef wasm_table_set : SDNode<"WebAssemblyISD::TABLE_SET", wasm_table_set_t, 52*fe6060f1SDimitry Andric [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>; 53*fe6060f1SDimitry Andric 54*fe6060f1SDimitry Andricdef : Pat<(wasm_table_set i32:$table, i32:$idx, funcref:$r), 55*fe6060f1SDimitry Andric (TABLE_SET_FUNCREF i32:$table, i32:$idx, funcref:$r)>, 56*fe6060f1SDimitry Andric Requires<[HasReferenceTypes]>; 57*fe6060f1SDimitry Andricdef : Pat<(wasm_table_set i32:$table, i32:$idx, externref:$r), 58*fe6060f1SDimitry Andric (TABLE_SET_EXTERNREF i32:$table, i32:$idx, externref:$r)>, 59*fe6060f1SDimitry Andric Requires<[HasReferenceTypes]>; 60*fe6060f1SDimitry Andric 61e8d8bef9SDimitry Andricdefm TABLE_SIZE : I<(outs I32:$sz), (ins table32_op:$table), 62e8d8bef9SDimitry Andric (outs), (ins table32_op:$table), 63e8d8bef9SDimitry Andric [], 64e8d8bef9SDimitry Andric "table.size\t$sz, $table", 65e8d8bef9SDimitry Andric "table.size\t$table", 66e8d8bef9SDimitry Andric 0xfc10>, 67e8d8bef9SDimitry Andric Requires<[HasReferenceTypes]>; 68e8d8bef9SDimitry Andric 69e8d8bef9SDimitry Andric 70*fe6060f1SDimitry Andricdefm TABLE_COPY : I<(outs), (ins table32_op:$table1, table32_op:$table2, I32:$d, I32:$s, I32:$n), 71e8d8bef9SDimitry Andric (outs), (ins table32_op:$table1, table32_op:$table2), 72e8d8bef9SDimitry Andric [], 73*fe6060f1SDimitry Andric "table.copy\t$table1, $table2, $d, $s, $n", 74e8d8bef9SDimitry Andric "table.copy\t$table1, $table2", 75e8d8bef9SDimitry Andric 0xfc0e>, 76e8d8bef9SDimitry Andric Requires<[HasReferenceTypes]>; 77