| 1 |
; This test checks that the translator is capable to correctly translate |
| 2 |
; __spirv_ControlBarrier with runtime-known MemScope parameter |
| 3 |
; to SPIR-V and back to OpenCL 2.0 IR. |
| 4 |
; TODO: to remove this test once |
| 5 |
; https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/1805 |
| 6 |
; is fixed as barrier.cl and sub_group_barrier.cl will be enough to test this |
| 7 |
; case |
| 8 |
|
| 9 |
; RUN: llvm-as %s -o %t.bc |
| 10 |
; RUN: llvm-spirv %t.bc -spirv-text -o %t.spv.txt |
| 11 |
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV |
| 12 |
; RUN: llvm-spirv -to-binary %t.spv.txt -o %t.spv |
| 13 |
; RUN: spirv-val %t.spv |
| 14 |
; RUN: llvm-spirv --spirv-target-env=CL2.0 -r %t.spv -o %t.bc |
| 15 |
; RUN: llvm-dis %t.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM |
| 16 |
|
| 17 |
; CHECK-SPIRV: FunctionCall [[#]] [[#SCOPE:]] [[#]] |
| 18 |
; CHECK-SPIRV: ControlBarrier [[#]] [[#SCOPE]] [[#]] |
| 19 |
|
| 20 |
; CHECK-LLVM: %[[#SCOPE:]] = call spir_func i32 @_Z8getScopev() |
| 21 |
; CHECK-LLVM: [[CALL:%[a-z0-9]+]] = call spir_func i32 @__translate_spirv_memory_scope(i32 %[[#SCOPE]]) |
| 22 |
; CHECK-LLVM: call spir_func void @_Z17sub_group_barrierj12memory_scope(i32 3, i32 [[CALL]]) |
| 23 |
|
| 24 |
; CHECK-LLVM: define private spir_func i32 @__translate_spirv_memory_scope(i32 %key) { |
| 25 |
; CHECK-LLVM: entry: |
| 26 |
; CHECK-LLVM: switch i32 %key, label %default [ |
| 27 |
; CHECK-LLVM: i32 4, label %case.4 |
| 28 |
; CHECK-LLVM: i32 2, label %case.2 |
| 29 |
; CHECK-LLVM: i32 1, label %case.1 |
| 30 |
; CHECK-LLVM: i32 0, label %case.0 |
| 31 |
; CHECK-LLVM: i32 3, label %case.3 |
| 32 |
; CHECK-LLVM: ] |
| 33 |
; CHECK-LLVM: default: ; preds = %entry |
| 34 |
; CHECK-LLVM: unreachable |
| 35 |
; CHECK-LLVM: case.4: ; preds = %entry |
| 36 |
; CHECK-LLVM: ret i32 0 |
| 37 |
; CHECK-LLVM: case.2: ; preds = %entry |
| 38 |
; CHECK-LLVM: ret i32 1 |
| 39 |
; CHECK-LLVM: case.1: ; preds = %entry |
| 40 |
; CHECK-LLVM: ret i32 2 |
| 41 |
; CHECK-LLVM: case.0: ; preds = %entry |
| 42 |
; CHECK-LLVM: ret i32 3 |
| 43 |
; CHECK-LLVM: case.3: ; preds = %entry |
| 44 |
; CHECK-LLVM: ret i32 4 |
| 45 |
; CHECK-LLVM: } |
| 46 |
|
| 47 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" |
| 48 |
target triple = "spirv64-unknown-unknown" |
| 49 |
|
| 50 |
define spir_func void @_Z3foov() { |
| 51 |
%1 = call noundef i32 @_Z8getScopev() |
| 52 |
call void @_Z22__spirv_ControlBarrieriii(i32 noundef 3, i32 noundef %1, i32 noundef 912) |
| 53 |
ret void |
| 54 |
} |
| 55 |
|
| 56 |
declare spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef, i32 noundef, i32 noundef) |
| 57 |
|
| 58 |
declare spir_func i32 @_Z8getScopev() |