Skip to content

Commit d8e73ba

Browse files
NikitaRudenkoIntelsys_zuul
authored andcommitted
Update patches for SPIRV-LLVM-Translator based on LLVM10
Change-Id: I2e0c7e765851e6200fd1a55ecf8c1de942644a5b
1 parent 3c06273 commit d8e73ba

File tree

3 files changed

+521
-0
lines changed

3 files changed

+521
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
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/3] Add DecorationFuncParamKindINTEL and
5+
DecorationFuncParamDescINTEL
6+
7+
Change-Id: Ic90237386532736588c558c7479370e48af7ce87
8+
---
9+
lib/SPIRV/SPIRVReader.cpp | 12 ++++++++++++
10+
lib/SPIRV/SPIRVWriter.cpp | 13 +++++++++++++
11+
lib/SPIRV/VectorComputeUtil.h | 2 ++
12+
lib/SPIRV/libSPIRV/SPIRVDecorate.cpp | 12 ++++++++++++
13+
lib/SPIRV/libSPIRV/SPIRVDecorate.h | 9 +++++++++
14+
lib/SPIRV/libSPIRV/SPIRVEnum.h | 2 ++
15+
lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h | 2 ++
16+
lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h | 2 ++
17+
lib/SPIRV/libSPIRV/spirv.hpp | 2 ++
18+
9 files changed, 56 insertions(+)
19+
20+
diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp
21+
index 2574c1d..e985e7d 100644
22+
--- a/lib/SPIRV/SPIRVReader.cpp
23+
+++ b/lib/SPIRV/SPIRVReader.cpp
24+
@@ -3367,6 +3367,18 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
25+
std::to_string(Kind));
26+
F->addAttribute(ArgNo + 1, Attr);
27+
}
28+
+ if (BA->hasDecorate(DecorationFuncParamKindINTEL, 0, &Kind)) {
29+
+ Attribute Attr = Attribute::get(*Context, kVCMetadata::VCArgumentKind,
30+
+ std::to_string(Kind));
31+
+ F->addAttribute(ArgNo + 1, Attr);
32+
+ }
33+
+ if (BA->hasDecorate(DecorationFuncParamDescINTEL)) {
34+
+ auto Desc =
35+
+ BA->getDecorationStringLiteral(DecorationFuncParamDescINTEL).front();
36+
+ Attribute Attr =
37+
+ Attribute::get(*Context, kVCMetadata::VCArgumentDesc, Desc);
38+
+ F->addAttribute(ArgNo + 1, Attr);
39+
+ }
40+
}
41+
42+
// Do not add float control if there is no any
43+
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
44+
index 6ea8eb0..7c4c94f 100644
45+
--- a/lib/SPIRV/SPIRVWriter.cpp
46+
+++ b/lib/SPIRV/SPIRVWriter.cpp
47+
@@ -572,6 +572,19 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
48+
.getAsInteger(0, Kind);
49+
BA->addDecorate(DecorationFuncParamIOKind, Kind);
50+
}
51+
+ if (Attrs.hasAttribute(ArgNo + 1, kVCMetadata::VCArgumentKind)) {
52+
+ SPIRVWord Kind;
53+
+ Attrs.getAttribute(ArgNo + 1, kVCMetadata::VCArgumentKind)
54+
+ .getValueAsString()
55+
+ .getAsInteger(0, Kind);
56+
+ BA->addDecorate(DecorationFuncParamKindINTEL, Kind);
57+
+ }
58+
+ if (Attrs.hasAttribute(ArgNo + 1, kVCMetadata::VCArgumentDesc)) {
59+
+ StringRef Desc =
60+
+ Attrs.getAttribute(ArgNo + 1, kVCMetadata::VCArgumentDesc)
61+
+ .getValueAsString();
62+
+ BA->addDecorate(new SPIRVDecorateFuncParamDescAttr(BA, Desc.str()));
63+
+ }
64+
}
65+
if (!isKernel(F) &&
66+
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_float_controls2) &&
67+
diff --git a/lib/SPIRV/VectorComputeUtil.h b/lib/SPIRV/VectorComputeUtil.h
68+
index f550dca..d9e7d8a 100755
69+
--- a/lib/SPIRV/VectorComputeUtil.h
70+
+++ b/lib/SPIRV/VectorComputeUtil.h
71+
@@ -105,6 +105,8 @@ const static char VCGlobalVariable[] = "VCGlobalVariable";
72+
const static char VCVolatile[] = "VCVolatile";
73+
const static char VCByteOffset[] = "VCByteOffset";
74+
const static char VCSIMTCall[] = "VCSIMTCall";
75+
+const static char VCArgumentKind[] = "VCArgumentKind";
76+
+const static char VCArgumentDesc[] = "VCArgumentDesc";
77+
} // namespace kVCMetadata
78+
79+
///////////////////////////////////////////////////////////////////////////////
80+
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
81+
index 4da518a..3767b9b 100644
82+
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
83+
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
84+
@@ -113,6 +113,9 @@ void SPIRVDecorate::encode(spv_ostream &O) const {
85+
case DecorationUserSemantic:
86+
SPIRVDecorateUserSemanticAttr::encodeLiterals(Encoder, Literals);
87+
break;
88+
+ case DecorationFuncParamDescINTEL:
89+
+ SPIRVDecorateFuncParamDescAttr::encodeLiterals(Encoder, Literals);
90+
+ break;
91+
default:
92+
Encoder << Literals;
93+
}
94+
@@ -139,6 +142,9 @@ void SPIRVDecorate::decode(std::istream &I) {
95+
case DecorationUserSemantic:
96+
SPIRVDecorateUserSemanticAttr::decodeLiterals(Decoder, Literals);
97+
break;
98+
+ case DecorationFuncParamDescINTEL:
99+
+ SPIRVDecorateFuncParamDescAttr::decodeLiterals(Decoder, Literals);
100+
+ break;
101+
default:
102+
Decoder >> Literals;
103+
}
104+
@@ -158,6 +164,9 @@ void SPIRVMemberDecorate::encode(spv_ostream &O) const {
105+
case DecorationUserSemantic:
106+
SPIRVDecorateUserSemanticAttr::encodeLiterals(Encoder, Literals);
107+
break;
108+
+ case DecorationFuncParamDescINTEL:
109+
+ SPIRVDecorateFuncParamDescAttr::encodeLiterals(Encoder, Literals);
110+
+ break;
111+
default:
112+
Encoder << Literals;
113+
}
114+
@@ -181,6 +190,9 @@ void SPIRVMemberDecorate::decode(std::istream &I) {
115+
case DecorationUserSemantic:
116+
SPIRVDecorateUserSemanticAttr::decodeLiterals(Decoder, Literals);
117+
break;
118+
+ case DecorationFuncParamDescINTEL:
119+
+ SPIRVDecorateFuncParamDescAttr::decodeLiterals(Decoder, Literals);
120+
+ break;
121+
default:
122+
Decoder >> Literals;
123+
}
124+
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.h b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
125+
index 31736b3..c5ed314 100644
126+
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.h
127+
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
128+
@@ -418,6 +418,15 @@ public:
129+
: SPIRVDecorateStrAttrBase(TheTarget, AnnotateString) {}
130+
};
131+
132+
+class SPIRVDecorateFuncParamDescAttr
133+
+ : public SPIRVDecorateStrAttrBase<DecorationFuncParamDescINTEL> {
134+
+public:
135+
+ // Complete constructor for UserSemantic decoration
136+
+ SPIRVDecorateFuncParamDescAttr(SPIRVEntry *TheTarget,
137+
+ const std::string &AnnotateString)
138+
+ : SPIRVDecorateStrAttrBase(TheTarget, AnnotateString) {}
139+
+};
140+
+
141+
class SPIRVDecorateMergeINTELAttr : public SPIRVDecorate {
142+
public:
143+
// Complete constructor for MergeINTEL decoration
144+
diff --git a/lib/SPIRV/libSPIRV/SPIRVEnum.h b/lib/SPIRV/libSPIRV/SPIRVEnum.h
145+
index 05a9078..fce14ae 100644
146+
--- a/lib/SPIRV/libSPIRV/SPIRVEnum.h
147+
+++ b/lib/SPIRV/libSPIRV/SPIRVEnum.h
148+
@@ -401,6 +401,8 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
149+
{CapabilityFunctionFloatControlINTEL});
150+
ADD_VEC_INIT(DecorationFunctionFloatingPointModeINTEL,
151+
{CapabilityFunctionFloatControlINTEL});
152+
+ ADD_VEC_INIT(DecorationFuncParamKindINTEL, {CapabilityVectorComputeINTEL});
153+
+ ADD_VEC_INIT(DecorationFuncParamDescINTEL, {CapabilityVectorComputeINTEL});
154+
}
155+
156+
template <> inline void SPIRVMap<BuiltIn, SPIRVCapVec>::init() {
157+
diff --git a/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h b/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h
158+
index 67981b6..d740ee3 100644
159+
--- a/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h
160+
+++ b/lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h
161+
@@ -422,6 +422,8 @@ inline bool isValid(spv::Decoration V) {
162+
case DecorationReferencedIndirectlyINTEL:
163+
case DecorationVectorComputeFunctionINTEL:
164+
case DecorationStackCallINTEL:
165+
+ case DecorationFuncParamKindINTEL:
166+
+ case DecorationFuncParamDescINTEL:
167+
case DecorationVectorComputeVariableINTEL:
168+
case DecorationGlobalVariableOffsetINTEL:
169+
case DecorationFuncParamIOKind:
170+
diff --git a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
171+
index 3c06f11..4615e82 100644
172+
--- a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
173+
+++ b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
174+
@@ -361,6 +361,8 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
175+
add(DecorationReferencedIndirectlyINTEL, "ReferencedIndirectlyINTEL");
176+
add(DecorationVectorComputeFunctionINTEL, "VectorComputeFunctionINTEL");
177+
add(DecorationStackCallINTEL, "StackCallINTEL");
178+
+ add(DecorationFuncParamKindINTEL, "FuncParamKindINTEL");
179+
+ add(DecorationFuncParamDescINTEL, "FuncParamDescINTEL");
180+
add(DecorationVectorComputeVariableINTEL, "VectorComputeVariableINTEL");
181+
add(DecorationGlobalVariableOffsetINTEL, "GlobalVariableOffsetINTEL");
182+
add(DecorationFuncParamIOKind, "FuncParamIOKind");
183+
diff --git a/lib/SPIRV/libSPIRV/spirv.hpp b/lib/SPIRV/libSPIRV/spirv.hpp
184+
index 0ca7905..580899f 100644
185+
--- a/lib/SPIRV/libSPIRV/spirv.hpp
186+
+++ b/lib/SPIRV/libSPIRV/spirv.hpp
187+
@@ -486,6 +486,8 @@ enum Decoration {
188+
DecorationAliasedPointer = 5356,
189+
DecorationAliasedPointerEXT = 5356,
190+
DecorationSIMTCallINTEL = 5599,
191+
+ DecorationFuncParamKindINTEL = 9624,
192+
+ DecorationFuncParamDescINTEL = 9625,
193+
DecorationReferencedIndirectlyINTEL = 5602,
194+
DecorationSideEffectsINTEL = 5608,
195+
DecorationVectorComputeVariableINTEL = 5624,
196+
--
197+
2.17.1
198+

0 commit comments

Comments
 (0)