|
| 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"} |
0 commit comments