1 ; RUN: llc --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types < %s | FileCheck %s
3 %externref = type ptr addrspace(10) ;; addrspace 10 is nonintegral
5 @externref_table1 = local_unnamed_addr addrspace(1) global [0 x %externref] undef
6 @externref_table2 = local_unnamed_addr addrspace(1) global [0 x %externref] undef
8 declare void @llvm.wasm.table.copy(ptr addrspace(1), ptr addrspace(1), i32, i32, i32) nounwind readonly
10 define void @table_copy(i32 %dst, i32 %src, i32 %len) {
11 ; CHECK-LABEL: table_copy:
12 ; CHECK-NEXT: .functype table_copy (i32, i32, i32) -> ()
13 ; CHECK-NEXT: local.get 0
14 ; CHECK-NEXT: local.get 1
15 ; CHECK-NEXT: local.get 2
16 ; CHECK-NEXT: table.copy externref_table1, externref_table2
17 ; CHECK-NEXT: end_function
18 call void @llvm.wasm.table.copy(ptr addrspace(1) @externref_table1, ptr addrspace(1) @externref_table2, i32 %dst, i32 %src, i32 %len)
22 ; Testing copying from a table to itself at different offsets
23 ; Copies len items from table1 at src to table1 at src+off
24 define void @self_table_copy(i32 %src, i32 %off, i32 %len) {
25 ; CHECK-LABEL: self_table_copy:
26 ; CHECK-NEXT: .functype self_table_copy (i32, i32, i32) -> ()
27 ; CHECK-NEXT: local.get 0
28 ; CHECK-NEXT: local.get 1
30 ; CHECK-NEXT: local.get 0
31 ; CHECK-NEXT: local.get 2
32 ; CHECK-NEXT: table.copy externref_table1, externref_table1
33 ; CHECK-NEXT: end_function
34 %dst = add nsw i32 %src, %off
35 call void @llvm.wasm.table.copy(ptr addrspace(1) @externref_table1, ptr addrspace(1) @externref_table1, i32 %dst, i32 %src, i32 %len)