| // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature | |
| // RUN: %clang_cc1 -triple wasm32 -target-feature +reference-types -disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s | |
| // REQUIRES: webassembly-registered-target | |
| static __externref_t table[0]; | |
| static const __externref_t const_table[0]; | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_get | |
| // CHECK-SAME: (i32 noundef [[INDEX:%.*]]) #[[ATTR0:[0-9]+]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: [[TMP0:%.*]] = call target("wasm.externref") @llvm.wasm.table.get.externref(ptr addrspace(1) @table, i32 [[INDEX]]) | |
| // CHECK-NEXT: ret target("wasm.externref") [[TMP0]] | |
| // | |
| __externref_t test_builtin_wasm_table_get(int index) { | |
| return __builtin_wasm_table_get(table, index); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_get_const | |
| // CHECK-SAME: (i32 noundef [[INDEX:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: [[TMP0:%.*]] = call target("wasm.externref") @llvm.wasm.table.get.externref(ptr addrspace(1) @table, i32 [[INDEX]]) | |
| // CHECK-NEXT: ret target("wasm.externref") [[TMP0]] | |
| // | |
| __externref_t test_builtin_wasm_table_get_const(const int index) { | |
| return __builtin_wasm_table_get(table, index); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_set | |
| // CHECK-SAME: (i32 noundef [[INDEX:%.*]], target("wasm.externref") [[REF:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: call void @llvm.wasm.table.set.externref(ptr addrspace(1) @const_table, i32 [[INDEX]], target("wasm.externref") [[REF]]) | |
| // CHECK-NEXT: call void @llvm.wasm.table.set.externref(ptr addrspace(1) @table, i32 [[INDEX]], target("wasm.externref") [[REF]]) | |
| // CHECK-NEXT: ret void | |
| // | |
| void test_builtin_wasm_table_set(const int index, __externref_t ref) { | |
| __builtin_wasm_table_set(const_table, index, ref); | |
| return __builtin_wasm_table_set(table, index, ref); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_set_const | |
| // CHECK-SAME: (i32 noundef [[INDEX:%.*]], target("wasm.externref") [[REF:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: call void @llvm.wasm.table.set.externref(ptr addrspace(1) @table, i32 [[INDEX]], target("wasm.externref") [[REF]]) | |
| // CHECK-NEXT: call void @llvm.wasm.table.set.externref(ptr addrspace(1) @const_table, i32 [[INDEX]], target("wasm.externref") [[REF]]) | |
| // CHECK-NEXT: ret void | |
| // | |
| void test_builtin_wasm_table_set_const(const int index, const __externref_t ref) { | |
| __builtin_wasm_table_set(table, index, ref); | |
| return __builtin_wasm_table_set(const_table, index, ref); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_size | |
| // CHECK-SAME: () #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.wasm.table.size(ptr addrspace(1) @table) | |
| // CHECK-NEXT: ret i32 [[TMP0]] | |
| // | |
| int test_builtin_wasm_table_size() { | |
| return __builtin_wasm_table_size(table); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_grow | |
| // CHECK-SAME: (target("wasm.externref") [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.wasm.table.grow.externref(ptr addrspace(1) @table, target("wasm.externref") [[REF]], i32 [[NELEM]]) | |
| // CHECK-NEXT: ret i32 [[TMP0]] | |
| // | |
| int test_builtin_wasm_table_grow(__externref_t ref, int nelem) { | |
| return __builtin_wasm_table_grow(table, ref, nelem); | |
| } | |
| // CHECK-LABEL: define {{[^@]+}}@test_builtin_wasm_table_fill | |
| // CHECK-SAME: (i32 noundef [[INDEX:%.*]], target("wasm.externref") [[REF:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // CHECK-NEXT: call void @llvm.wasm.table.fill.externref(ptr addrspace(1) @table, i32 [[INDEX]], target("wasm.externref") [[REF]], i32 [[NELEM]]) | |
| // CHECK-NEXT: ret void | |
| // | |
| void test_builtin_wasm_table_fill(int index, __externref_t ref, int nelem) { | |
| __builtin_wasm_table_fill(table, index, ref, nelem); | |
| } | |
| static __externref_t other_table[0]; | |
| // CHECK-LABEL: define {{[^@]+}}@test_table_copy | |
| // CHECK-SAME: (i32 noundef [[DST_IDX:%.*]], i32 noundef [[SRC_IDX:%.*]], i32 noundef [[NELEM:%.*]]) #[[ATTR0]] { | |
| // CHECK-NEXT: entry: | |
| // 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]]) | |
| // CHECK-NEXT: ret void | |
| // | |
| void test_table_copy(int dst_idx, int src_idx, int nelem) { | |
| __builtin_wasm_table_copy(table, other_table, dst_idx, src_idx, nelem); | |
| } |