| 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 |
| 4 |
|
| 5 |
static __externref_t table[0]; |
| 6 |
|
| 7 |
// CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_get |
| 8 |
// CHECK-SAME: (i32 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] { |
| 9 |
// CHECK-NEXT: entry: |
| 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]] |
| 12 |
// |
| 13 |
__externref_t test_builtin_wasm_table_get(int index) { |
| 14 |
return __builtin_wasm_table_get(table, index); |
| 15 |
} |
| 16 |
|
| 17 |
// CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_set |
| 18 |
// CHECK-SAME: (i32 noundef [[INDEX:%.*]], ptr addrspace(10) [[REF:%.*]]) #[[ATTR0]] { |
| 19 |
// CHECK-NEXT: entry: |
| 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 |
| 22 |
// |
| 23 |
void test_builtin_wasm_table_set(int index, __externref_t ref) { |
| 24 |
return __builtin_wasm_table_set(table, index, ref); |
| 25 |
} |
| 26 |
|
| 27 |
// CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_size |
| 28 |
// CHECK-SAME: () #[[ATTR0]] { |
| 29 |
// CHECK-NEXT: entry: |
| 30 |
// CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.wasm.table.size(ptr addrspace(1) @table) |
| 31 |
// CHECK-NEXT: ret i32 [[TMP0]] |
| 32 |
// |
| 33 |
int test_builtin_wasm_table_size() { |
| 34 |
return __builtin_wasm_table_size(table); |
| 35 |
} |
| 36 |
|
| 37 |
// CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_grow |
| 38 |
// CHECK-SAME: (ptr addrspace(10) [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { |
| 39 |
// CHECK-NEXT: entry: |
| 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]] |
| 42 |
// |
| 43 |
int test_builtin_wasm_table_grow(__externref_t ref, int nelem) { |
| 44 |
return __builtin_wasm_table_grow(table, ref, nelem); |
| 45 |
} |
| 46 |
|
| 47 |
// CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_fill |
| 48 |
// CHECK-SAME: (i32 noundef [[INDEX:%.*]], ptr addrspace(10) [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { |
| 49 |
// CHECK-NEXT: entry: |
| 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 |
| 52 |
// |
| 53 |
void test_builtin_wasm_table_fill(int index, __externref_t ref, int nelem) { |
| 54 |
__builtin_wasm_table_fill(table, index, ref, nelem); |
| 55 |
} |
| 56 |
|
| 57 |
static __externref_t other_table[0]; |
| 58 |
|
| 59 |
// CHECK-LABEL: define {{[^@]+}}@test_table_copy |
| 60 |
// CHECK-SAME: (i32 noundef [[DST_IDX:%.*]], i32 noundef [[SRC_IDX:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { |
| 61 |
// CHECK-NEXT: entry: |
| 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 |
| 64 |
// |
| 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); |
| 67 |
} |