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-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// WebAssembly Table operand code-gen constructs.
11/// Instructions that handle tables
12//===----------------------------------------------------------------------===//
13
14
15multiclass TABLE<WebAssemblyRegClass rt> {
16  defm TABLE_GET_#rt : I<(outs rt:$res), (ins table32_op:$table),
17                         (outs), (ins table32_op:$table),
18                         [],
19                         "table.get\t$res, $table",
20                         "table.get\t$table",
21                         0x25>;
22
23  defm TABLE_SET_#rt : I<(outs), (ins table32_op:$table, rt:$val, I32:$i),
24                         (outs), (ins table32_op:$table),
25                         [],
26                         "table.set\t$table, $val, $i",
27                         "table.set\t$table",
28                         0x26>;
29
30  defm TABLE_GROW_#rt : I<(outs I32:$sz), (ins table32_op:$table, I32:$n, rt:$val),
31                          (outs), (ins table32_op:$table),
32                          [],
33                          "table.grow\t$sz, $table, $n, $val",
34                          "table.grow\t$table",
35                          0xfc0f>;
36
37  defm TABLE_FILL_#rt : I<(outs), (ins table32_op:$table, I32:$n, rt:$val, I32:$i),
38                          (outs), (ins table32_op:$table),
39                          [],
40                          "table.fill\t$table, $n, $val, $i",
41                          "table.fill\t$table",
42                          0xfc11>;
43
44}
45
46defm "" : TABLE<FUNCREF>, Requires<[HasReferenceTypes]>;
47defm "" : TABLE<EXTERNREF>, Requires<[HasReferenceTypes]>;
48
49defm TABLE_SIZE : I<(outs I32:$sz), (ins table32_op:$table),
50                    (outs), (ins table32_op:$table),
51                    [],
52                    "table.size\t$sz, $table",
53                    "table.size\t$table",
54                    0xfc10>,
55                    Requires<[HasReferenceTypes]>;
56
57
58defm TABLE_COPY : I<(outs), (ins table32_op:$table1, table32_op:$table2, I32:$n, I32:$s, I32:$d),
59                    (outs), (ins table32_op:$table1, table32_op:$table2),
60                    [],
61                    "table.copy\t$table1, $table2, $n, $s, $d",
62                    "table.copy\t$table1, $table2",
63                    0xfc0e>,
64                    Requires<[HasReferenceTypes]>;
65