Skip to content

Commit fa9dd79

Browse files
svenvhsys-ce-bb
authored andcommitted
Add SPIR-V 1.5 enum value (#2374)
Recognize SPIR-V 1.5 modules and allow specifying the `--spirv-max-version=1.5` option. This does not implement any SPIR-V 1.5 functionality yet, so mark 1.5 as "experimental". Original commit: KhronosGroup/SPIRV-LLVM-Translator@747ef0f0ec03a25
1 parent 417d637 commit fa9dd79

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

llvm-spirv/include/LLVMSPIRVOpts.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class IntrinsicInst;
5454

5555
namespace SPIRV {
5656

57+
/// SPIR-V versions known to translator.
5758
enum class VersionNumber : uint32_t {
5859
// See section 2.3 of SPIR-V spec: Physical Layout of a SPIR_V Module and
5960
// Instruction
@@ -62,10 +63,9 @@ enum class VersionNumber : uint32_t {
6263
SPIRV_1_2 = 0x00010200,
6364
SPIRV_1_3 = 0x00010300,
6465
SPIRV_1_4 = 0x00010400,
65-
// TODO: populate this enum with the latest versions (up to 1.5) once
66-
// translator get support of corresponding features
66+
SPIRV_1_5 = 0x00010500,
6767
MinimumVersion = SPIRV_1_0,
68-
MaximumVersion = SPIRV_1_4
68+
MaximumVersion = SPIRV_1_5
6969
};
7070

7171
inline constexpr std::string_view formatVersionNumber(uint32_t Version) {
@@ -80,6 +80,8 @@ inline constexpr std::string_view formatVersionNumber(uint32_t Version) {
8080
return "1.3";
8181
case static_cast<uint32_t>(VersionNumber::SPIRV_1_4):
8282
return "1.4";
83+
case static_cast<uint32_t>(VersionNumber::SPIRV_1_5):
84+
return "1.5";
8385
}
8486
return "unknown";
8587
}

llvm-spirv/test/negative/spirv-version-controls-1.spt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
119734787 66816 393230 12 0
1+
119734787 67072 393230 12 0
22
2 Capability Addresses
33
2 Capability Kernel
44
5 ExtInstImport 1 "OpenCL.std"
@@ -29,5 +29,4 @@
2929

3030
; RUN: not llvm-spirv %s -to-binary -o - 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3131
;
32-
; CHECK-ERROR: Invalid SPIR-V module: unsupported SPIR-V version number 'unknown (66816)'. Range of supported/known SPIR-V versions is 1.0 (65536) - 1.4 (66560)
33-
32+
; CHECK-ERROR: Invalid SPIR-V module: unsupported SPIR-V version number 'unknown (67072)'. Range of supported/known SPIR-V versions is 1.0 (65536) - 1.5 (66816)

llvm-spirv/test/negative/spirv-version-controls-2.spt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@
2929

3030
; RUN: not llvm-spirv %s -to-binary -o - 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3131
;
32-
; CHECK-ERROR: Invalid SPIR-V module: unsupported SPIR-V version number 'unknown (1024)'. Range of supported/known SPIR-V versions is 1.0 (65536) - 1.4 (66560)
33-
34-
32+
; CHECK-ERROR: Invalid SPIR-V module: unsupported SPIR-V version number 'unknown (1024)'. Range of supported/known SPIR-V versions is 1.0 (65536) - 1.5 (66816)

llvm-spirv/tools/llvm-spirv/llvm-spirv.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ static cl::opt<VersionNumber> MaxSPIRVVersion(
111111
clEnumValN(VersionNumber::SPIRV_1_1, "1.1", "SPIR-V 1.1"),
112112
clEnumValN(VersionNumber::SPIRV_1_2, "1.2", "SPIR-V 1.2"),
113113
clEnumValN(VersionNumber::SPIRV_1_3, "1.3", "SPIR-V 1.3"),
114-
clEnumValN(VersionNumber::SPIRV_1_4, "1.4", "SPIR-V 1.4")),
114+
clEnumValN(VersionNumber::SPIRV_1_4, "1.4", "SPIR-V 1.4"),
115+
clEnumValN(VersionNumber::SPIRV_1_5, "1.5",
116+
"SPIR-V 1.5 (experimental)")),
115117
cl::init(VersionNumber::MaximumVersion));
116118

117119
static cl::list<std::string>

0 commit comments

Comments
 (0)