1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature
2 // RUN: %clang_cc1 -triple wasm32 -target-feature +reference-types -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s
3 // REQUIRES: webassembly-registered-target
5 static __externref_t table
[0];
7 // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_get
8 // CHECK-SAME: (i32 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] {
10 // CHECK-NEXT: [[TMP0:%.*]] = call ptr addrspace(10) @llvm.wasm.table.get.externref(ptr addrspace(1) @table, i32 [[INDEX]])
11 // CHECK-NEXT: ret ptr addrspace(10) [[TMP0]]
13 __externref_t
test_builtin_wasm_table_get(int index
) {
14 return __builtin_wasm_table_get(table
, index
);
17 // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_set
18 // CHECK-SAME: (i32 noundef [[INDEX:%.*]], ptr addrspace(10) [[REF:%.*]]) #[[ATTR0]] {
20 // CHECK-NEXT: call void @llvm.wasm.table.set.externref(ptr addrspace(1) @table, i32 [[INDEX]], ptr addrspace(10) [[REF]])
21 // CHECK-NEXT: ret void
23 void test_builtin_wasm_table_set(int index
, __externref_t ref
) {
24 return __builtin_wasm_table_set(table
, index
, ref
);
27 // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_size
28 // CHECK-SAME: () #[[ATTR0]] {
30 // CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.wasm.table.size(ptr addrspace(1) @table)
31 // CHECK-NEXT: ret i32 [[TMP0]]
33 int test_builtin_wasm_table_size() {
34 return __builtin_wasm_table_size(table
);
37 // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_grow
38 // CHECK-SAME: (ptr addrspace(10) [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] {
40 // CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.wasm.table.grow.externref(ptr addrspace(1) @table, ptr addrspace(10) [[REF]], i32 [[NELEM]])
41 // CHECK-NEXT: ret i32 [[TMP0]]
43 int test_builtin_wasm_table_grow(__externref_t ref
, int nelem
) {
44 return __builtin_wasm_table_grow(table
, ref
, nelem
);
47 // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_fill
48 // CHECK-SAME: (i32 noundef [[INDEX:%.*]], ptr addrspace(10) [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] {
50 // CHECK-NEXT: call void @llvm.wasm.table.fill.externref(ptr addrspace(1) @table, i32 [[INDEX]], ptr addrspace(10) [[REF]], i32 [[NELEM]])
51 // CHECK-NEXT: ret void
53 void test_builtin_wasm_table_fill(int index
, __externref_t ref
, int nelem
) {
54 __builtin_wasm_table_fill(table
, index
, ref
, nelem
);
57 static __externref_t other_table
[0];
59 // CHECK-LABEL: define {{[^@]+}}@test_table_copy
60 // CHECK-SAME: (i32 noundef [[DST_IDX:%.*]], i32 noundef [[SRC_IDX:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] {
62 // CHECK-NEXT: call void @llvm.wasm.table.copy(ptr addrspace(1) @table, ptr addrspace(1) @other_table, i32 [[SRC_IDX]], i32 [[DST_IDX]], i32 [[NELEM]])
63 // CHECK-NEXT: ret void
65 void test_table_copy(int dst_idx
, int src_idx
, int nelem
) {
66 __builtin_wasm_table_copy(table
, other_table
, dst_idx
, src_idx
, nelem
);