Skip to content

Commit d493496

Browse files
vmaksimosys-ce-bb
authored andcommitted
Incorporate SPV_KHR_integer_dot_product into SPIR-V 1.6 (#2584)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@3e649321c5af21c
1 parent 4ea28ff commit d493496

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVInstruction.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,9 @@ class SPIRVDotKHRBase : public SPIRVInstTemplateBase {
29942994
}
29952995

29962996
std::optional<ExtensionID> getRequiredExtension() const override {
2997-
return ExtensionID::SPV_KHR_integer_dot_product;
2997+
if (!Module->isAllowedToUseVersion(VersionNumber::SPIRV_1_6))
2998+
return ExtensionID::SPV_KHR_integer_dot_product;
2999+
return {};
29983000
}
29993001

30003002
void validate() const override {
@@ -3054,6 +3056,12 @@ class SPIRVDotKHRBase : public SPIRVInstTemplateBase {
30543056

30553057
llvm_unreachable("No mapping for argument type to capability.");
30563058
}
3059+
3060+
VersionNumber getRequiredSPIRVVersion() const override {
3061+
if (Module->isAllowedToUseVersion(VersionNumber::SPIRV_1_6))
3062+
return VersionNumber::SPIRV_1_6;
3063+
return VersionNumber::SPIRV_1_0;
3064+
}
30573065
};
30583066

30593067
#define _SPIRV_OP(x, ...) \

llvm-spirv/test/extensions/KHR/SPV_KHR_integer_dot_product/SPV_KHR_integer_dot_product-nonsat.ll

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: not llvm-spirv %t.bc -spirv-text -o %t.txt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
2+
; RUN: not llvm-spirv %t.bc -spirv-text --spirv-max-version=1.5 -o %t.txt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3+
; RUN: llvm-spirv %t.bc -spirv-text --spirv-max-version=1.5 --spirv-ext=+SPV_KHR_integer_dot_product -o %t.txt
4+
; RUN: FileCheck < %t.txt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT
5+
; RUN: llvm-spirv --spirv-max-version=1.5 --spirv-ext=+SPV_KHR_integer_dot_product %t.bc -o %t.spv
6+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
8+
39
; RUN: llvm-spirv %t.bc -spirv-text --spirv-ext=+SPV_KHR_integer_dot_product -o %t.txt
4-
; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
10+
; RUN: FileCheck < %t.txt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT
511
; RUN: llvm-spirv --spirv-ext=+SPV_KHR_integer_dot_product %t.bc -o %t.spv
612
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
713
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
@@ -12,11 +18,17 @@
1218
; CHECK-ERROR: Feature requires the following SPIR-V extension:
1319
; CHECK-ERROR-NEXT: SPV_KHR_integer_dot_product
1420

15-
; CHECK-SPIRV: Capability DotProductInputAllKHR
16-
; CHECK-SPIRV: Capability DotProductInput4x8BitKHR
17-
; CHECK-SPIRV: Capability DotProductInput4x8BitPackedKHR
18-
; CHECK-SPIRV: Capability DotProductKHR
19-
; CHECK-SPIRV: Extension "SPV_KHR_integer_dot_product"
21+
; Check SPIR-V versions in a format magic number + version
22+
; CHECK-SPIRV-EXT: 119734787 65536
23+
; CHECK-SPIRV-NOEXT: 119734787 67072
24+
25+
; CHECK-SPIRV: Int8
26+
; CHECK-SPIRV-DAG: Capability DotProductInput4x8BitKHR
27+
; CHECK-SPIRV-DAG: Capability DotProductInputAllKHR
28+
; CHECK-SPIRV-DAG: Capability DotProductInput4x8BitPackedKHR
29+
; CHECK-SPIRV-DAG: Capability DotProductKHR
30+
; CHECK-SPIRV-EXT: Extension "SPV_KHR_integer_dot_product"
31+
; CHECK-SPIRV-NOEXT-NOT: Extension "SPV_KHR_integer_dot_product"
2032

2133
; CHECK-SPIRV-DAG: TypeInt [[#I8:]] 8
2234
; CHECK-SPIRV-DAG: TypeInt [[#I16:]] 16

llvm-spirv/test/extensions/KHR/SPV_KHR_integer_dot_product/SPV_KHR_integer_dot_product-sat.ll

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: not llvm-spirv %t.bc -spirv-text -o %t.txt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
2+
; RUN: not llvm-spirv %t.bc -spirv-text --spirv-max-version=1.5 -o %t.txt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3+
; RUN: llvm-spirv %t.bc -spirv-text --spirv-max-version=1.5 --spirv-ext=+SPV_KHR_integer_dot_product -o %t.txt
4+
; RUN: FileCheck < %t.txt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT
5+
; RUN: llvm-spirv --spirv-max-version=1.5 --spirv-ext=+SPV_KHR_integer_dot_product %t.bc -o %t.spv
6+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
8+
39
; RUN: llvm-spirv %t.bc -spirv-text --spirv-ext=+SPV_KHR_integer_dot_product -o %t.txt
4-
; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
10+
; RUN: FileCheck < %t.txt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT
511
; RUN: llvm-spirv --spirv-ext=+SPV_KHR_integer_dot_product %t.bc -o %t.spv
612
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
713
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
@@ -12,11 +18,17 @@
1218
; CHECK-ERROR: Feature requires the following SPIR-V extension:
1319
; CHECK-ERROR-NEXT: SPV_KHR_integer_dot_product
1420

15-
; CHECK-SPIRV: Capability DotProductInputAllKHR
16-
; CHECK-SPIRV: Capability DotProductInput4x8BitKHR
17-
; CHECK-SPIRV: Capability DotProductInput4x8BitPackedKHR
18-
; CHECK-SPIRV: Capability DotProductKHR
19-
; CHECK-SPIRV: Extension "SPV_KHR_integer_dot_product"
21+
; Check SPIR-V versions in a format magic number + version
22+
; CHECK-SPIRV-EXT: 119734787 65536
23+
; CHECK-SPIRV-NOEXT: 119734787 67072
24+
25+
; CHECK-SPIRV: Int8
26+
; CHECK-SPIRV-DAG: Capability DotProductInputAllKHR
27+
; CHECK-SPIRV-DAG: Capability DotProductInput4x8BitKHR
28+
; CHECK-SPIRV-DAG: Capability DotProductInput4x8BitPackedKHR
29+
; CHECK-SPIRV-DAG: Capability DotProductKHR
30+
; CHECK-SPIRV-EXT: Extension "SPV_KHR_integer_dot_product"
31+
; CHECK-SPIRV-NOEXT-NOT: Extension "SPV_KHR_integer_dot_product"
2032

2133
; CHECK-SPIRV-DAG: TypeInt [[#I8:]] 8
2234
; CHECK-SPIRV-DAG: TypeInt [[#I16:]] 16

0 commit comments

Comments
 (0)