Skip to content

Commit cbbf969

Browse files
DmitryBushevigcbot
authored andcommitted
Add support for LLVM 13
Added spirv patches for LLVM 13 and enabled build option
1 parent f2d3fa8 commit cbbf969

7 files changed

+667
-0
lines changed

IGC/VectorCompiler/cmake/spirv.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ else()
159159
set(SPIRV_REV_PATCH 67d3e271a28287b2c92ecef2f5e98c49134e5946)
160160
set(SPRIV_PATCHES ${CMAKE_CURRENT_SOURCE_DIR}/spirv-patches-12/)
161161
set(SPRIV_BRANCH_PATCH spirvdll_120)
162+
elseif(${LLVM_VERSION_MAJOR} EQUAL 13)
163+
message(STATUS "[VC] Found LLVM version 13")
164+
set(SPIRV_REV_PATCH 7d3a83f6e81be9e13254e73edd4272fa96ed0d44)
165+
set(SPRIV_PATCHES ${CMAKE_CURRENT_SOURCE_DIR}/spirv-patches-13/)
166+
set(SPRIV_BRANCH_PATCH spirvdll_130)
162167
else()
163168
message(FATAL_ERROR "[VC] Found unsupported version of LLVM (LLVM_VERSION_MAJOR is set to ${LLVM_VERSION_MAJOR})")
164169
endif()
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: nrudenko <[email protected]>
3+
Date: Thu, 4 Jun 2020 16:34:15 +0300
4+
Subject: [PATCH 1/6] Add DecorationFuncParamKindINTEL and
5+
DecorationFuncParamDescINTEL
6+
7+
---
8+
lib/SPIRV/SPIRVReader.cpp | 12 ++++++++++++
9+
lib/SPIRV/SPIRVWriter.cpp | 13 +++++++++++++
10+
lib/SPIRV/VectorComputeUtil.h | 2 ++
11+
lib/SPIRV/libSPIRV/SPIRVDecorate.cpp | 12 ++++++++++++
12+
lib/SPIRV/libSPIRV/SPIRVDecorate.h | 9 +++++++++
13+
lib/SPIRV/libSPIRV/SPIRVEnum.h | 2 ++
14+
lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h | 2 ++
15+
lib/SPIRV/libSPIRV/spirv_internal.hpp | 8 +++++++-
16+
8 files changed, 59 insertions(+), 1 deletion(-)
17+
18+
diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp
19+
index 00000000..00000000 100644
20+
--- a/lib/SPIRV/SPIRVReader.cpp
21+
+++ b/lib/SPIRV/SPIRVReader.cpp
22+
@@ -3869,6 +3869,18 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
23+
}
24+
if (BA->hasDecorate(DecorationSingleElementVectorINTEL))
25+
F->addAttribute(ArgNo + 1, SEVAttr);
26+
+ if (BA->hasDecorate(internal::DecorationFuncParamKindINTEL, 0, &Kind)) {
27+
+ Attribute Attr = Attribute::get(*Context, kVCMetadata::VCArgumentKind,
28+
+ std::to_string(Kind));
29+
+ F->addAttribute(ArgNo + 1, Attr);
30+
+ }
31+
+ if (BA->hasDecorate(internal::DecorationFuncParamDescINTEL)) {
32+
+ auto Desc =
33+
+ BA->getDecorationStringLiteral(internal::DecorationFuncParamDescINTEL).front();
34+
+ Attribute Attr =
35+
+ Attribute::get(*Context, kVCMetadata::VCArgumentDesc, Desc);
36+
+ F->addAttribute(ArgNo + 1, Attr);
37+
+ }
38+
}
39+
40+
// Do not add float control if there is no any
41+
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
42+
index 00000000..00000000 100644
43+
--- a/lib/SPIRV/SPIRVWriter.cpp
44+
+++ b/lib/SPIRV/SPIRVWriter.cpp
45+
@@ -738,6 +738,19 @@ void LLVMToSPIRVBase::transVectorComputeMetadata(Function *F) {
46+
"This decoration is valid only for Scalar or Pointer types");
47+
BA->addDecorate(DecorationSingleElementVectorINTEL);
48+
}
49+
+ if (Attrs.hasAttribute(ArgNo + 1, kVCMetadata::VCArgumentKind)) {
50+
+ SPIRVWord Kind;
51+
+ Attrs.getAttribute(ArgNo + 1, kVCMetadata::VCArgumentKind)
52+
+ .getValueAsString()
53+
+ .getAsInteger(0, Kind);
54+
+ BA->addDecorate(internal::DecorationFuncParamKindINTEL, Kind);
55+
+ }
56+
+ if (Attrs.hasAttribute(ArgNo + 1, kVCMetadata::VCArgumentDesc)) {
57+
+ StringRef Desc =
58+
+ Attrs.getAttribute(ArgNo + 1, kVCMetadata::VCArgumentDesc)
59+
+ .getValueAsString();
60+
+ BA->addDecorate(new SPIRVDecorateFuncParamDescAttr(BA, Desc.str()));
61+
+ }
62+
}
63+
if (!isKernel(F) &&
64+
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_float_controls2) &&
65+
diff --git a/lib/SPIRV/VectorComputeUtil.h b/lib/SPIRV/VectorComputeUtil.h
66+
index 00000000..00000000 100755
67+
--- a/lib/SPIRV/VectorComputeUtil.h
68+
+++ b/lib/SPIRV/VectorComputeUtil.h
69+
@@ -111,6 +111,8 @@ const static char VCSIMTCall[] = "VCSIMTCall";
70+
const static char VCCallable[] = "VCCallable";
71+
const static char VCSingleElementVector[] = "VCSingleElementVector";
72+
const static char VCFCEntry[] = "VCFCEntry";
73+
+const static char VCArgumentKind[] = "VCArgumentKind";
74+
+const static char VCArgumentDesc[] = "VCArgumentDesc";
75+
} // namespace kVCMetadata
76+
77+
namespace kVCType {
78+
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
79+
index 00000000..00000000 100644
80+
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
81+
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
82+
@@ -114,6 +114,9 @@ void SPIRVDecorate::encode(spv_ostream &O) const {
83+
case DecorationUserSemantic:
84+
SPIRVDecorateUserSemanticAttr::encodeLiterals(Encoder, Literals);
85+
break;
86+
+ case internal::DecorationFuncParamDescINTEL:
87+
+ SPIRVDecorateFuncParamDescAttr::encodeLiterals(Encoder, Literals);
88+
+ break;
89+
default:
90+
Encoder << Literals;
91+
}
92+
@@ -140,6 +143,9 @@ void SPIRVDecorate::decode(std::istream &I) {
93+
case DecorationUserSemantic:
94+
SPIRVDecorateUserSemanticAttr::decodeLiterals(Decoder, Literals);
95+
break;
96+
+ case internal::DecorationFuncParamDescINTEL:
97+
+ SPIRVDecorateFuncParamDescAttr::decodeLiterals(Decoder, Literals);
98+
+ break;
99+
default:
100+
Decoder >> Literals;
101+
}
102+
@@ -175,6 +181,9 @@ void SPIRVMemberDecorate::encode(spv_ostream &O) const {
103+
case DecorationUserSemantic:
104+
SPIRVDecorateUserSemanticAttr::encodeLiterals(Encoder, Literals);
105+
break;
106+
+ case internal::DecorationFuncParamDescINTEL:
107+
+ SPIRVDecorateFuncParamDescAttr::encodeLiterals(Encoder, Literals);
108+
+ break;
109+
default:
110+
Encoder << Literals;
111+
}
112+
@@ -198,6 +207,9 @@ void SPIRVMemberDecorate::decode(std::istream &I) {
113+
case DecorationUserSemantic:
114+
SPIRVDecorateUserSemanticAttr::decodeLiterals(Decoder, Literals);
115+
break;
116+
+ case internal::DecorationFuncParamDescINTEL:
117+
+ SPIRVDecorateFuncParamDescAttr::decodeLiterals(Decoder, Literals);
118+
+ break;
119+
default:
120+
Decoder >> Literals;
121+
}
122+
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.h b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
123+
index 00000000..00000000 100644
124+
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.h
125+
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
126+
@@ -499,6 +499,15 @@ public:
127+
: SPIRVDecorateStrAttrBase(TheTarget, AnnotateString) {}
128+
};
129+
130+
+class SPIRVDecorateFuncParamDescAttr
131+
+ : public SPIRVDecorateStrAttrBase<internal::DecorationFuncParamDescINTEL> {
132+
+public:
133+
+ // Complete constructor for UserSemantic decoration
134+
+ SPIRVDecorateFuncParamDescAttr(SPIRVEntry *TheTarget,
135+
+ const std::string &AnnotateString)
136+
+ : SPIRVDecorateStrAttrBase(TheTarget, AnnotateString) {}
137+
+};
138+
+
139+
class SPIRVDecorateMergeINTELAttr : public SPIRVDecorate {
140+
public:
141+
// Complete constructor for MergeINTEL decoration
142+
diff --git a/lib/SPIRV/libSPIRV/SPIRVEnum.h b/lib/SPIRV/libSPIRV/SPIRVEnum.h
143+
index 00000000..00000000 100644
144+
--- a/lib/SPIRV/libSPIRV/SPIRVEnum.h
145+
+++ b/lib/SPIRV/libSPIRV/SPIRVEnum.h
146+
@@ -440,6 +440,8 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
147+
{internal::CapabilityFPGAInvocationPipeliningAttributesINTEL});
148+
ADD_VEC_INIT(internal::DecorationRuntimeAlignedINTEL,
149+
{internal::CapabilityRuntimeAlignedAttributeINTEL});
150+
+ ADD_VEC_INIT(internal::DecorationFuncParamKindINTEL, {CapabilityVectorComputeINTEL});
151+
+ ADD_VEC_INIT(internal::DecorationFuncParamDescINTEL, {CapabilityVectorComputeINTEL});
152+
}
153+
154+
template <> inline void SPIRVMap<BuiltIn, SPIRVCapVec>::init() {
155+
diff --git a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
156+
index 00000000..00000000 100644
157+
--- a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
158+
+++ b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
159+
@@ -179,6 +179,8 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
160+
add(internal::DecorationMaxConcurrencyINTEL, "MaxConcurrencyINTEL");
161+
add(internal::DecorationPipelineEnableINTEL, "PipelineEnableINTEL");
162+
add(internal::DecorationRuntimeAlignedINTEL, "RuntimeAlignedINTEL");
163+
+ add(internal::DecorationFuncParamKindINTEL, "FuncParamKindINTEL");
164+
+ add(internal::DecorationFuncParamDescINTEL, "FuncParamDescINTEL");
165+
166+
add(DecorationMax, "Max");
167+
}
168+
diff --git a/lib/SPIRV/libSPIRV/spirv_internal.hpp b/lib/SPIRV/libSPIRV/spirv_internal.hpp
169+
index 00000000..00000000 100644
170+
--- a/lib/SPIRV/libSPIRV/spirv_internal.hpp
171+
+++ b/lib/SPIRV/libSPIRV/spirv_internal.hpp
172+
@@ -54,7 +54,9 @@ enum InternalDecoration {
173+
IDecMaxConcurrencyINTEL = 5918,
174+
IDecPipelineEnableINTEL = 5919,
175+
IDecRuntimeAlignedINTEL = 5940,
176+
- IDecCallableFunctionINTEL = 6087
177+
+ IDecCallableFunctionINTEL = 6087,
178+
+ IDecorationFuncParamKindINTEL = 9624,
179+
+ IDecorationFuncParamDescINTEL = 9625,
180+
};
181+
182+
enum InternalCapability {
183+
@@ -107,6 +109,10 @@ constexpr Decoration DecorationCallableFunctionINTEL =
184+
static_cast<Decoration>(IDecCallableFunctionINTEL);
185+
constexpr Decoration DecorationRuntimeAlignedINTEL =
186+
static_cast<Decoration>(IDecRuntimeAlignedINTEL);
187+
+constexpr Decoration DecorationFuncParamKindINTEL =
188+
+ static_cast<Decoration>(IDecorationFuncParamKindINTEL);
189+
+constexpr Decoration DecorationFuncParamDescINTEL =
190+
+ static_cast<Decoration>(IDecorationFuncParamDescINTEL);
191+
192+
constexpr Capability CapabilityFastCompositeINTEL =
193+
static_cast<Capability>(ICapFastCompositeINTEL);
194+
--
195+
2.29.2
196+

0 commit comments

Comments
 (0)