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