Skip to content

Commit a5d2ed5

Browse files
EbinJose2002michalpaszkowski
authored andcommitted
[SPIRV] Porting tests to transcoding directory from translator (llvm#151661)
Checks for built-in variables, saturating conversion, half precision fract, and workgroup variable initialization --------- Co-authored-by: Michal Paszkowski <[email protected]>
1 parent 7ac0927 commit a5d2ed5

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; CHECK-SPIRV: [[#PtrT:]] = OpTypePointer Workgroup %[[#]]
5+
; CHECK-SPIRV: %[[#]] = OpVariable %[[#PtrT]] Workgroup
6+
7+
@test_atomic_fn.L = internal addrspace(3) global [64 x i32] zeroinitializer, align 4
8+
9+
define spir_kernel void @test_atomic_fn() {
10+
ret void
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
5+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6+
7+
; CHECK: OpDecorate %[[#Id:]] BuiltIn GlobalInvocationId
8+
; CHECK: %[[#Id]] = OpVariable %[[#]] CrossWorkgroup
9+
10+
@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32
11+
12+
define spir_kernel void @f() {
13+
entry:
14+
%0 = load i64, ptr addrspace(1) @__spirv_BuiltInGlobalInvocationId, align 32
15+
ret void
16+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; Check saturation conversion is translated when there is forward declaration
5+
; of SPIRV entry.
6+
7+
; CHECK: OpDecorate %[[#SAT:]] SaturatedConversion
8+
; CHECK: %[[#SAT]] = OpConvertFToU %[[#]] %[[#]]
9+
10+
declare spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float)
11+
12+
define spir_func void @forward(float %val, i8 %initval, ptr addrspace(1) %dst) {
13+
entry:
14+
br label %for.cond
15+
16+
for.cond: ; preds = %for.body, %entry
17+
%new_val.0 = phi i8 [ %initval, %entry ], [ %call1, %for.body ]
18+
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
19+
%cmp = icmp ult i32 %i.0, 1
20+
br i1 %cmp, label %for.body, label %for.end
21+
22+
for.body: ; preds = %for.cond
23+
%call1 = call spir_func zeroext i8 @_Z30__spirv_ConvertFToU_Ruchar_satf(float noundef %val)
24+
%inc = add i32 %i.0, 1
25+
br label %for.cond
26+
27+
for.end: ; preds = %for.cond
28+
store i8 %new_val.0, ptr addrspace(1) %dst, align 1
29+
ret void
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; CHECK-SPIRV: %[[#HALF:]] = OpTypeFloat 16
5+
; CHECK-SPIRV: %[[#HALFPTR:]] = OpTypePointer Function %[[#HALF]]
6+
; CHECK-SPIRV: %[[#HALFV2:]] = OpTypeVector %[[#HALF]] 2
7+
; CHECK-SPIRV: %[[#HALFV2PTR:]] = OpTypePointer Function %[[#HALFV2]]
8+
; CHECK-SPIRV: %[[#CONST:]] = OpConstant %[[#HALF]] 14788
9+
; CHECK-SPIRV: %[[#ADDR:]] = OpVariable %[[#HALFPTR]] Function
10+
; CHECK-SPIRV: %[[#ADDR2:]] = OpVariable %[[#HALFV2PTR]] Function
11+
; CHECK-SPIRV: %[[#]] = OpExtInst %[[#HALF]] %[[#]] fract %[[#CONST]] %[[#ADDR]]
12+
; CHECK-SPIRV: %[[#]] = OpExtInst %[[#HALFV2]] %[[#]] fract %[[#]] %[[#ADDR2]]
13+
14+
define spir_kernel void @test() {
15+
entry:
16+
%addr = alloca half
17+
%addr2 = alloca <2 x half>
18+
%res = call spir_func noundef half @_Z17__spirv_ocl_fractDF16_PU3AS0DF16_(half noundef 0xH39C4, ptr noundef %addr)
19+
%res2 = call spir_func noundef <2 x half> @_Z17__spirv_ocl_fractDv2_DF16_PU3AS0S_(<2 x half> noundef <half 0xH39C4, half 0xH0000>, ptr noundef %addr2)
20+
ret void
21+
}
22+
23+
declare spir_func noundef half @_Z17__spirv_ocl_fractDF16_PU3AS0DF16_(half noundef, ptr noundef) local_unnamed_addr
24+
25+
declare spir_func noundef <2 x half> @_Z17__spirv_ocl_fractDv2_DF16_PU3AS0S_(<2 x half> noundef, ptr noundef) local_unnamed_addr

0 commit comments

Comments
 (0)