Skip to content

Commit ff8b37b

Browse files
committed
[SPIRV] Test basic float and int types
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 9120e85 commit ff8b37b

File tree

3 files changed

+123
-0
lines changed

3 files changed

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

0 commit comments

Comments
 (0)