Skip to content

Commit aa2fd7a

Browse files
committed
Add new tests to check enabled capabilities.
1 parent 936cea7 commit aa2fd7a

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s --spirv-ext=+SPV_KHR_bit_instructions -o - | FileCheck %s --check-prefix=CHECK-EXTENSION
2+
; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-NO-EXTENSION
3+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s --spirv-ext=+SPV_KHR_bit_instructions -o - -filetype=obj | spirv-val %}
4+
;
5+
; if OpenCL builtin calls present in LLVM IR input and SPV_KHR_bit_instructions is enabled, no error and BitInstructions capability generated.
6+
; CHECK-EXTENSION: Capability BitInstructions
7+
; CHECK-EXTENSION: Extension "SPV_KHR_bit_instructions"
8+
; if OpenCL builtin calls present in LLVM IR input and SPV_KHR_bit_instructions is NOT enabled, error.
9+
; CHECK-NO-EXTENSION: LLVM ERROR: bitfield_insert: the builtin requires the following SPIR-V extension: SPV_KHR_bit_instructions
10+
;
11+
; CHECK-EXTENSION: %[[#]] = OpFunction %[[#]] None %[[#]]
12+
; CHECK-EXTENSION: %[[#insertbase_long:]] = OpFunctionParameter %[[#]]
13+
; CHECK-EXTENSION: %[[#insertinsert_long:]] = OpFunctionParameter %[[#]]
14+
; CHECK-EXTENSION: %[[#]] = OpBitFieldInsert %[[#]] %[[#insertbase_long]] %[[#insertinsert_long]]
15+
;
16+
; OpenCL equivalent.
17+
; kernel void testInsert_long(long b, long i, global long *res) {
18+
; *res = bitfield_insert(b, i, 4, 2);
19+
; }
20+
define dso_local spir_kernel void @testInsert_long(i64 noundef %b, i64 noundef %i, ptr addrspace(1) nocapture noundef writeonly align 8 initializes((0, 8)) %res) {
21+
entry:
22+
%call = tail call spir_func i64 @_Z15bitfield_insertlljj(i64 noundef %b, i64 noundef %i, i32 noundef 4, i32 noundef 2) #2
23+
store i64 %call, ptr addrspace(1) %res, align 8, !tbaa !7
24+
ret void
25+
}
26+
27+
declare spir_func i64 @_Z15bitfield_insertlljj(i64 noundef, i64 noundef, i32 noundef, i32 noundef)
28+
29+
attributes #2 = { convergent nounwind willreturn memory(none) }
30+
31+
!llvm.module.flags = !{!0}
32+
!opencl.ocl.version = !{!1}
33+
!opencl.spir.version = !{!1}
34+
!llvm.ident = !{!2}
35+
36+
!0 = !{i32 1, !"wchar_size", i32 4}
37+
!1 = !{i32 2, i32 0}
38+
!2 = !{!"clang version 20.0.0git (https://github.com/llvm/llvm-project.git cc61409d353a40f62d3a137f3c7436aa00df779d)"}
39+
!7 = !{!8, !8, i64 0}
40+
!8 = !{!"long", !9, i64 0}
41+
!9 = !{!"omnipotent char", !10, i64 0}
42+
!10 = !{!"Simple C/C++ TBAA"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s --spirv-ext=+SPV_KHR_bit_instructions -o - | FileCheck %s --check-prefix=CHECK-EXTENSION
2+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-NO-EXTENSION
3+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s --spirv-ext=+SPV_KHR_bit_instructions -o - -filetype=obj | spirv-val %}
4+
;
5+
; CHECK-EXTENSION: Capability BitInstructions
6+
; CHECK-EXTENSION: Extension "SPV_KHR_bit_instructions"
7+
; CHECK-NO-EXTENSION-NOT: Capability BitInstructions
8+
; CHECK-NO-EXTENSION-NOT: Extension "SPV_KHR_bit_instructions"
9+
; CHECK-NO-EXTENSION: Capability Shader
10+
;
11+
; CHECK-EXTENSION: %[[#]] = OpFunction %[[#]] None %[[#]]
12+
; CHECK-EXTENSION: %[[#reversebase:]] = OpFunctionParameter %[[#]]
13+
; CHECK-EXTENSION: %[[#]] = OpBitReverse %[[#]] %[[#reversebase]]
14+
; OpenCL equivalent.
15+
; kernel void testBitReverse_SPIRVFriendly(long4 b, global long4 *res) {
16+
; *res = bit_reverse(b);
17+
; }
18+
define spir_kernel void @testBitReverse_SPIRVFriendly(<4 x i64> %b, ptr addrspace(1) nocapture align 32 %res) #3 {
19+
entry:
20+
%call = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %b)
21+
store <4 x i64> %call, ptr addrspace(1) %res, align 32
22+
ret void
23+
}
24+
25+
declare <4 x i64> @llvm.bitreverse.v4i64(<4 x i64>) #4
26+
27+
28+
attributes #3 = { nounwind }
29+
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
30+
31+
!llvm.module.flags = !{!0}
32+
!opencl.ocl.version = !{!1}
33+
!opencl.spir.version = !{!1}
34+
!llvm.ident = !{!2}
35+
36+
!0 = !{i32 1, !"wchar_size", i32 4}
37+
!1 = !{i32 2, i32 0}
38+
!2 = !{!"clang version 20.0.0git (https://github.com/llvm/llvm-project.git cc61409d353a40f62d3a137f3c7436aa00df779d)"}

0 commit comments

Comments
 (0)