Skip to content

Commit b3d3a80

Browse files
committed
tests: add dis/scalars.rs test for iN/uN/fN types.
1 parent c0fda94 commit b3d3a80

File tree

6 files changed

+182
-10
lines changed

6 files changed

+182
-10
lines changed

tests/compiletests/ui/dis/asm_op_decorate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// normalize-stderr-test "ui/dis/" -> "$$DIR/"
1313

1414
// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output
15-
// and the pre-`vulkan1.2` output, but per-revisions `{only,ignore}-*` directives
15+
// and the pre-`vulkan1.2` output, but per-revision `{only,ignore}-*` directives
1616
// are not supported in `compiletest-rs`.
1717
// ignore-vulkan1.2
1818
// ignore-vulkan1.3

tests/compiletests/ui/dis/non-writable-storage_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// normalize-stderr-test "ui/dis/" -> "$$DIR/"
1414

1515
// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output
16-
// and the pre-`vulkan1.2` output, but per-revisions `{only,ignore}-*` directives
16+
// and the pre-`vulkan1.2` output, but per-revision `{only,ignore}-*` directives
1717
// are not supported in `compiletest-rs`.
1818
// ignore-vulkan1.2
1919
// ignore-vulkan1.3
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: `u128` unsupported in SPIR-V
2+
3+
error: `i128` unsupported in SPIR-V
4+
5+
error: missing required capabilities for types
6+
|
7+
= note: `u8` type used without `OpCapability Int8`
8+
= note: `u16` type used without `OpCapability Int16`
9+
= note: `u64` type used without `OpCapability Int64`
10+
= note: `i8` type used without `OpCapability Int8`
11+
= note: `i16` type used without `OpCapability Int16`
12+
= note: `i64` type used without `OpCapability Int64`
13+
= note: `f64` type used without `OpCapability Float64`
14+
15+
error: aborting due to 3 previous errors
16+

tests/compiletests/ui/dis/scalars.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#![crate_name = "scalars"]
2+
3+
// Tests all the (supported) Rust integer/floating-point scalar types.
4+
5+
// revisions: supported nocaps
6+
//[supported] build-pass
7+
//[supported] compile-flags: -C target-feature=+Int8,+Int16,+Int64,+Float64
8+
//[nocaps] build-fail
9+
10+
// compile-flags: -C llvm-args=--disassemble-globals
11+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
12+
// normalize-stderr-test "OpSource .*\n" -> ""
13+
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
14+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
15+
16+
// HACK(eddyb) `compiletest` handles `ui\dis\`, but not `ui\\dis\\`, on Windows.
17+
// normalize-stderr-test "ui/dis/" -> "$$DIR/"
18+
19+
use spirv_std::spirv;
20+
21+
#[spirv(fragment)]
22+
pub fn main(
23+
out: &mut u32,
24+
25+
#[spirv(flat)] in_u8: u8,
26+
#[spirv(flat)] in_u16: u16,
27+
#[spirv(flat)] in_u32: u32,
28+
#[spirv(flat)] in_u64: u64,
29+
// FIXME(eddyb) support `u128` somehow!
30+
#[cfg(not(supported))]
31+
#[spirv(flat)]
32+
in_u128: u128,
33+
34+
#[spirv(flat)] in_i8: i8,
35+
#[spirv(flat)] in_i16: i16,
36+
#[spirv(flat)] in_i32: i32,
37+
#[spirv(flat)] in_i64: i64,
38+
// FIXME(eddyb) support `i128` somehow!
39+
#[cfg(not(supported))]
40+
#[spirv(flat)]
41+
in_i128: i128,
42+
43+
in_f32: f32,
44+
#[spirv(flat)] in_f64: f64,
45+
) {
46+
// HACK(eddyb) to make it more obvious in the disassembly, each type gets a
47+
// constant with its bit width, disambiguated for signed integers by negation.
48+
*out |= (in_u8 * 8) as u32;
49+
*out |= (in_u16 * 16) as u32;
50+
*out |= (in_u32 * 32) as u32;
51+
*out |= (in_u64 * 64) as u32;
52+
// FIXME(eddyb) support `u128` somehow!
53+
#[cfg(not(supported))]
54+
{
55+
// FIXME(eddyb) constants still emit zombies that get reported too early.
56+
// *out |= (in_u128 * 128) as u32;
57+
*out |= (in_u128 + in_u128) as u32;
58+
}
59+
60+
*out |= (in_i8 * -8) as u32;
61+
*out |= (in_i16 * -16) as u32;
62+
*out |= (in_i32 * -32) as u32;
63+
*out |= (in_i64 * -64) as u32;
64+
// FIXME(eddyb) support `i128` somehow!
65+
#[cfg(not(supported))]
66+
{
67+
// FIXME(eddyb) constants still emit zombies that get reported too early.
68+
// *out |= (in_i128 * -128) as u32;
69+
*out |= (in_i128 + in_i128) as u32;
70+
}
71+
72+
*out |= (in_f32 * 32.0) as u32;
73+
*out |= (in_f64 * 64.0) as u32;
74+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
OpCapability Shader
2+
OpCapability Float64
3+
OpCapability Int64
4+
OpCapability Int16
5+
OpCapability Int8
6+
OpMemoryModel Logical Simple
7+
OpEntryPoint Fragment %1 "main" %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12
8+
OpExecutionMode %1 OriginUpperLeft
9+
%13 = OpString "$DIR/scalars.rs"
10+
OpName %3 "in_u8"
11+
OpName %4 "in_u16"
12+
OpName %5 "in_u32"
13+
OpName %6 "in_u64"
14+
OpName %7 "in_i8"
15+
OpName %8 "in_i16"
16+
OpName %9 "in_i32"
17+
OpName %10 "in_i64"
18+
OpName %11 "in_f32"
19+
OpName %12 "in_f64"
20+
OpName %2 "out"
21+
OpDecorate %3 Flat
22+
OpDecorate %3 Location 0
23+
OpDecorate %4 Flat
24+
OpDecorate %4 Location 1
25+
OpDecorate %5 Flat
26+
OpDecorate %5 Location 2
27+
OpDecorate %6 Flat
28+
OpDecorate %6 Location 3
29+
OpDecorate %7 Flat
30+
OpDecorate %7 Location 4
31+
OpDecorate %8 Flat
32+
OpDecorate %8 Location 5
33+
OpDecorate %9 Flat
34+
OpDecorate %9 Location 6
35+
OpDecorate %10 Flat
36+
OpDecorate %10 Location 7
37+
OpDecorate %11 Location 8
38+
OpDecorate %12 Flat
39+
OpDecorate %12 Location 9
40+
OpDecorate %2 Location 0
41+
%14 = OpTypeInt 32 0
42+
%15 = OpTypePointer Output %14
43+
%16 = OpTypeInt 8 0
44+
%17 = OpTypePointer Input %16
45+
%18 = OpTypeInt 16 0
46+
%19 = OpTypePointer Input %18
47+
%20 = OpTypePointer Input %14
48+
%21 = OpTypeInt 64 0
49+
%22 = OpTypePointer Input %21
50+
%23 = OpTypeInt 8 1
51+
%24 = OpTypePointer Input %23
52+
%25 = OpTypeInt 16 1
53+
%26 = OpTypePointer Input %25
54+
%27 = OpTypeInt 32 1
55+
%28 = OpTypePointer Input %27
56+
%29 = OpTypeInt 64 1
57+
%30 = OpTypePointer Input %29
58+
%31 = OpTypeFloat 32
59+
%32 = OpTypePointer Input %31
60+
%33 = OpTypeFloat 64
61+
%34 = OpTypePointer Input %33
62+
%35 = OpTypeVoid
63+
%36 = OpTypeFunction %35
64+
%3 = OpVariable %17 Input
65+
%4 = OpVariable %19 Input
66+
%5 = OpVariable %20 Input
67+
%6 = OpVariable %22 Input
68+
%7 = OpVariable %24 Input
69+
%8 = OpVariable %26 Input
70+
%9 = OpVariable %28 Input
71+
%10 = OpVariable %30 Input
72+
%11 = OpVariable %32 Input
73+
%12 = OpVariable %34 Input
74+
%37 = OpConstant %16 8
75+
%2 = OpVariable %15 Output
76+
%38 = OpConstant %18 16
77+
%39 = OpConstant %14 32
78+
%40 = OpConstant %21 64
79+
%41 = OpConstant %23 4294967288
80+
%42 = OpConstant %25 4294967280
81+
%43 = OpConstant %27 4294967264
82+
%44 = OpConstant %29 18446744073709551552
83+
%45 = OpConstant %31 1107296256
84+
%46 = OpConstant %14 0
85+
%47 = OpConstant %14 1333788671
86+
%48 = OpTypeBool
87+
%49 = OpConstant %14 4294967295
88+
%50 = OpConstant %33 4634204016564240384
89+
%51 = OpConstant %21 0
90+
%52 = OpConstant %21 4751297606873776128

tests/compiletests/ui/dis/target_features.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)