Skip to content

Commit 116f7a2

Browse files
authored
[SPIRV] Test basic float and int types (#66282)
Add Int16, Int64 and Float64 capabilities as always available for Vulkan (since 1.0), and add tests covering most of the basic types from clang/test/CodeGenHLSL/basic_types.hlsl except for half floats. Depends on D156049
1 parent cf8e189 commit 116f7a2

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ void RequirementHandler::initAvailableCapabilitiesForOpenCL(
587587
void RequirementHandler::initAvailableCapabilitiesForVulkan(
588588
const SPIRVSubtarget &ST) {
589589
addAvailableCaps({Capability::Shader, Capability::Linkage});
590+
591+
// Provided by Vulkan version 1.0.
592+
addAvailableCaps({Capability::Int16, Capability::Int64, Capability::Float64});
590593
}
591594

592595
} // namespace SPIRV
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
4+
5+
define void @main() {
6+
entry:
7+
; CHECK-DAG: %[[#float:]] = OpTypeFloat 32
8+
; CHECK-DAG: %[[#double:]] = OpTypeFloat 64
9+
10+
; CHECK-DAG: %[[#v2float:]] = OpTypeVector %[[#float]] 2
11+
; CHECK-DAG: %[[#v3float:]] = OpTypeVector %[[#float]] 3
12+
; CHECK-DAG: %[[#v4float:]] = OpTypeVector %[[#float]] 4
13+
14+
; CHECK-DAG: %[[#v2double:]] = OpTypeVector %[[#double]] 2
15+
; CHECK-DAG: %[[#v3double:]] = OpTypeVector %[[#double]] 3
16+
; CHECK-DAG: %[[#v4double:]] = OpTypeVector %[[#double]] 4
17+
18+
; CHECK-DAG: %[[#ptr_Function_float:]] = OpTypePointer Function %[[#float]]
19+
; CHECK-DAG: %[[#ptr_Function_double:]] = OpTypePointer Function %[[#double]]
20+
; CHECK-DAG: %[[#ptr_Function_v2float:]] = OpTypePointer Function %[[#v2float]]
21+
; CHECK-DAG: %[[#ptr_Function_v3float:]] = OpTypePointer Function %[[#v3float]]
22+
; CHECK-DAG: %[[#ptr_Function_v4float:]] = OpTypePointer Function %[[#v4float]]
23+
; CHECK-DAG: %[[#ptr_Function_v2double:]] = OpTypePointer Function %[[#v2double]]
24+
; CHECK-DAG: %[[#ptr_Function_v3double:]] = OpTypePointer Function %[[#v3double]]
25+
; CHECK-DAG: %[[#ptr_Function_v4double:]] = OpTypePointer Function %[[#v4double]]
26+
27+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_float]] Function
28+
%float_Val = alloca float, align 4
29+
30+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_double]] Function
31+
%double_Val = alloca double, align 8
32+
33+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v2float]] Function
34+
%float2_Val = alloca <2 x float>, align 8
35+
36+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v3float]] Function
37+
%float3_Val = alloca <3 x float>, align 16
38+
39+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v4float]] Function
40+
%float4_Val = alloca <4 x float>, align 16
41+
42+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v2double]] Function
43+
%double2_Val = alloca <2 x double>, align 16
44+
45+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v3double]] Function
46+
%double3_Val = alloca <3 x double>, align 32
47+
48+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v4double]] Function
49+
%double4_Val = alloca <4 x double>, align 32
50+
ret void
51+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
; RUN: llc -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
4+
5+
define void @main() {
6+
entry:
7+
; CHECK-DAG: %[[#short:]] = OpTypeInt 16 0
8+
; CHECK-DAG: %[[#int:]] = OpTypeInt 32 0
9+
; CHECK-DAG: %[[#long:]] = OpTypeInt 64 0
10+
11+
; CHECK-DAG: %[[#v2short:]] = OpTypeVector %[[#short]] 2
12+
; CHECK-DAG: %[[#v3short:]] = OpTypeVector %[[#short]] 3
13+
; CHECK-DAG: %[[#v4short:]] = OpTypeVector %[[#short]] 4
14+
15+
; CHECK-DAG: %[[#v2int:]] = OpTypeVector %[[#int]] 2
16+
; CHECK-DAG: %[[#v3int:]] = OpTypeVector %[[#int]] 3
17+
; CHECK-DAG: %[[#v4int:]] = OpTypeVector %[[#int]] 4
18+
19+
; CHECK-DAG: %[[#v2long:]] = OpTypeVector %[[#long]] 2
20+
; CHECK-DAG: %[[#v3long:]] = OpTypeVector %[[#long]] 3
21+
; CHECK-DAG: %[[#v4long:]] = OpTypeVector %[[#long]] 4
22+
23+
; CHECK-DAG: %[[#ptr_Function_short:]] = OpTypePointer Function %[[#short]]
24+
; CHECK-DAG: %[[#ptr_Function_int:]] = OpTypePointer Function %[[#int]]
25+
; CHECK-DAG: %[[#ptr_Function_long:]] = OpTypePointer Function %[[#long]]
26+
; CHECK-DAG: %[[#ptr_Function_v2short:]] = OpTypePointer Function %[[#v2short]]
27+
; CHECK-DAG: %[[#ptr_Function_v3short:]] = OpTypePointer Function %[[#v3short]]
28+
; CHECK-DAG: %[[#ptr_Function_v4short:]] = OpTypePointer Function %[[#v4short]]
29+
; CHECK-DAG: %[[#ptr_Function_v2int:]] = OpTypePointer Function %[[#v2int]]
30+
; CHECK-DAG: %[[#ptr_Function_v3int:]] = OpTypePointer Function %[[#v3int]]
31+
; CHECK-DAG: %[[#ptr_Function_v4int:]] = OpTypePointer Function %[[#v4int]]
32+
; CHECK-DAG: %[[#ptr_Function_v2long:]] = OpTypePointer Function %[[#v2long]]
33+
; CHECK-DAG: %[[#ptr_Function_v3long:]] = OpTypePointer Function %[[#v3long]]
34+
; CHECK-DAG: %[[#ptr_Function_v4long:]] = OpTypePointer Function %[[#v4long]]
35+
36+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_short]] Function
37+
%int16_t_Val = alloca i16, align 2
38+
39+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_int]] Function
40+
%int_Val = alloca i32, align 4
41+
42+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_long]] Function
43+
%int64_t_Val = alloca i64, align 8
44+
45+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v2short]] Function
46+
%int16_t2_Val = alloca <2 x i16>, align 4
47+
48+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v3short]] Function
49+
%int16_t3_Val = alloca <3 x i16>, align 8
50+
51+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v4short]] Function
52+
%int16_t4_Val = alloca <4 x i16>, align 8
53+
54+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v2int]] Function
55+
%int2_Val = alloca <2 x i32>, align 8
56+
57+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v3int]] Function
58+
%int3_Val = alloca <3 x i32>, align 16
59+
60+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v4int]] Function
61+
%int4_Val = alloca <4 x i32>, align 16
62+
63+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v2long]] Function
64+
%int64_t2_Val = alloca <2 x i64>, align 16
65+
66+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v3long]] Function
67+
%int64_t3_Val = alloca <3 x i64>, align 32
68+
69+
; CHECK: %[[#]] = OpVariable %[[#ptr_Function_v4long]] Function
70+
%int64_t4_Val = alloca <4 x i64>, align 32
71+
72+
ret void
73+
}

0 commit comments

Comments
 (0)