1*d99af237SThomas Lively// WebAssemblyInstrBulkMemory.td - bulk memory codegen support --*- tablegen -*-
2*d99af237SThomas Lively//
3*d99af237SThomas Lively// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*d99af237SThomas Lively// See https://llvm.org/LICENSE.txt for license information.
5*d99af237SThomas Lively// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*d99af237SThomas Lively//
7*d99af237SThomas Lively//===----------------------------------------------------------------------===//
8*d99af237SThomas Lively///
9*d99af237SThomas Lively/// \file
10*d99af237SThomas Lively/// WebAssembly bulk memory codegen constructs.
11*d99af237SThomas Lively///
12*d99af237SThomas Lively//===----------------------------------------------------------------------===//
13*d99af237SThomas Lively
14*d99af237SThomas Lively// Instruction requiring HasBulkMemory and the bulk memory prefix byte
15*d99af237SThomas Livelymulticlass BULK_I<dag oops_r, dag iops_r, dag oops_s, dag iops_s,
16*d99af237SThomas Lively                  list<dag> pattern_r, string asmstr_r = "",
17*d99af237SThomas Lively                  string asmstr_s = "", bits<32> simdop = -1> {
18*d99af237SThomas Lively  defm "" : I<oops_r, iops_r, oops_s, iops_s, pattern_r, asmstr_r, asmstr_s,
19*d99af237SThomas Lively              !or(0xfc00, !and(0xff, simdop))>,
20*d99af237SThomas Lively            Requires<[HasBulkMemory]>;
21*d99af237SThomas Lively}
22*d99af237SThomas Lively
23*d99af237SThomas Lively// Bespoke types and nodes for bulk memory ops
24*d99af237SThomas Livelydef wasm_memcpy_t : SDTypeProfile<0, 3,
25*d99af237SThomas Lively  [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisInt<2>]
26*d99af237SThomas Lively>;
27*d99af237SThomas Livelydef wasm_memcpy : SDNode<"WebAssemblyISD::MEMORY_COPY", wasm_memcpy_t,
28*d99af237SThomas Lively                         [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
29*d99af237SThomas Lively
30*d99af237SThomas Lively//===----------------------------------------------------------------------===//
31*d99af237SThomas Lively// memory.copy
32*d99af237SThomas Lively//===----------------------------------------------------------------------===//
33*d99af237SThomas Lively
34*d99af237SThomas Livelylet mayLoad = 1, mayStore = 1 in
35*d99af237SThomas Livelydefm MEMORY_COPY : BULK_I<(outs), (ins I32:$dst, I32:$src, I32:$len),
36*d99af237SThomas Lively                          (outs), (ins),
37*d99af237SThomas Lively                          [(wasm_memcpy I32:$dst, I32:$src, I32:$len)],
38*d99af237SThomas Lively                          "memory.copy\t$dst, $src, $len",
39*d99af237SThomas Lively                          "memory.copy", 0x0a>;
40