1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/spirv-llvm-translator/hotfix-intel-composites.patch.disabled
3 # Copyright (C) 2024 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 diff --git a/include/LLVMSPIRVExtensions.inc b/include/LLVMSPIRVExtensions.inc
15 index eb98c7f..4e2eb0b 100644
16 --- a/include/LLVMSPIRVExtensions.inc
17 +++ b/include/LLVMSPIRVExtensions.inc
18 @@ -41,7 +41,7 @@ EXT(SPV_INTEL_variable_length_array)
19 EXT(SPV_INTEL_fp_fast_math_mode)
20 EXT(SPV_INTEL_fpga_cluster_attributes)
21 EXT(SPV_INTEL_loop_fuse)
22 -EXT(SPV_INTEL_long_constant_composite)
23 +EXT(SPV_INTEL_long_composites)
24 EXT(SPV_INTEL_optnone)
25 EXT(SPV_INTEL_fpga_dsp_control)
26 EXT(SPV_INTEL_memory_access_aliasing)
27 diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
28 index 807aa0c..0946dbe 100644
29 --- a/lib/SPIRV/SPIRVWriter.cpp
30 +++ b/lib/SPIRV/SPIRVWriter.cpp
31 @@ -409,11 +409,10 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
32 const size_t NumElements = ST->getNumElements();
33 size_t SPIRVStructNumElements = NumElements;
34 // In case number of elements is greater than maximum WordCount and
35 - // SPV_INTEL_long_constant_composite is not enabled, the error will be
36 + // SPV_INTEL_long_composites is not enabled, the error will be
37 // emitted by validate functionality of SPIRVTypeStruct class.
38 if (NumElements > MaxNumElements &&
39 - BM->isAllowedToUseExtension(
40 - ExtensionID::SPV_INTEL_long_constant_composite)) {
41 + BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites)) {
42 SPIRVStructNumElements = MaxNumElements;
45 @@ -421,8 +420,7 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
48 if (NumElements > MaxNumElements &&
49 - BM->isAllowedToUseExtension(
50 - ExtensionID::SPV_INTEL_long_constant_composite)) {
51 + BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites)) {
52 uint64_t NumOfContinuedInstructions = NumElements / MaxNumElements - 1;
53 for (uint64_t J = 0; J < NumOfContinuedInstructions; J++) {
54 auto *Continued = BM->addTypeStructContinuedINTEL(MaxNumElements);
55 @@ -1832,8 +1830,7 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
58 } else if (Init && !isa<UndefValue>(Init)) {
59 - if (!BM->isAllowedToUseExtension(
60 - ExtensionID::SPV_INTEL_long_constant_composite)) {
61 + if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites)) {
62 if (auto ArrTy = dyn_cast_or_null<ArrayType>(Init->getType())) {
63 // First 3 words of OpConstantComposite encode: 1) word count &
64 // opcode, 2) Result Type and 3) Result Id. Max length of SPIRV
65 diff --git a/lib/SPIRV/libSPIRV/SPIRVEntry.h b/lib/SPIRV/libSPIRV/SPIRVEntry.h
66 index a3c9441..e188099 100644
67 --- a/lib/SPIRV/libSPIRV/SPIRVEntry.h
68 +++ b/lib/SPIRV/libSPIRV/SPIRVEntry.h
69 @@ -908,11 +908,11 @@ public:
72 SPIRVCapVec getRequiredCapability() const override {
73 - return getVec(CapabilityLongConstantCompositeINTEL);
74 + return getVec(CapabilityLongCompositesINTEL);
77 std::optional<ExtensionID> getRequiredExtension() const override {
78 - return ExtensionID::SPV_INTEL_long_constant_composite;
79 + return ExtensionID::SPV_INTEL_long_composites;
82 SPIRVWord getNumElements() const { return Elements.size(); }
83 diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
84 index 5ac7275..d8d06f6 100644
85 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
86 +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
87 @@ -1175,10 +1175,10 @@ SPIRVValue *SPIRVModuleImpl::addCompositeConstant(
88 const int NumElements = Elements.size();
90 // In case number of elements is greater than maximum WordCount and
91 - // SPV_INTEL_long_constant_composite is not enabled, the error will be emitted
92 + // SPV_INTEL_long_composites is not enabled, the error will be emitted
93 // by validate functionality of SPIRVCompositeConstant class.
94 if (NumElements <= MaxNumElements ||
95 - !isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_constant_composite))
96 + !isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites))
97 return addConstant(new SPIRVConstantComposite(this, Ty, getId(), Elements));
99 auto Start = Elements.begin();
100 @@ -1213,7 +1213,7 @@ SPIRVValue *SPIRVModuleImpl::addSpecConstantComposite(
101 // SPV_INTEL_long_constant_composite is not enabled, the error will be emitted
102 // by validate functionality of SPIRVSpecConstantComposite class.
103 if (NumElements <= MaxNumElements ||
104 - !isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_constant_composite))
105 + !isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites))
107 new SPIRVSpecConstantComposite(this, Ty, getId(), Elements));
109 diff --git a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
110 index d450a43..a2a0ddb 100644
111 --- a/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
112 +++ b/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
113 @@ -610,7 +610,7 @@ template <> inline void SPIRVMap<Capability, std::string>::init() {
114 add(CapabilityGroupNonUniformRotateKHR, "GroupNonUniformRotateKHR");
115 add(CapabilityAtomicFloat32AddEXT, "AtomicFloat32AddEXT");
116 add(CapabilityAtomicFloat64AddEXT, "AtomicFloat64AddEXT");
117 - add(CapabilityLongConstantCompositeINTEL, "LongConstantCompositeINTEL");
118 + add(CapabilityLongCompositesINTEL, "LongCompositesINTEL");
119 add(CapabilityOptNoneINTEL, "OptNoneINTEL");
120 add(CapabilityAtomicFloat16AddEXT, "AtomicFloat16AddEXT");
121 add(CapabilityDebugInfoModuleINTEL, "DebugInfoModuleINTEL");
122 diff --git a/test/SpecConstants/long-spec-const-composite.ll b/test/SpecConstants/long-spec-const-composite.ll
123 index a45c895..e943296 100644
124 --- a/test/SpecConstants/long-spec-const-composite.ll
125 +++ b/test/SpecConstants/long-spec-const-composite.ll
127 ; RUN: llvm-as %s -o %t.bc
128 -; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
129 +; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
130 ; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
131 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
132 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
134 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
135 target triple = "spir64-unknown-unknown"
137 -; CHECK-SPIRV: Capability LongConstantCompositeINTEL
138 -; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
139 +; CHECK-SPIRV: Capability LongCompositesINTEL
140 +; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
141 ; CHECK-SPIRV-DAG: Decorate [[First:[0-9]+]] SpecId 0
142 ; CHECK-SPIRV-DAG: Decorate [[Last:[0-9]+]] SpecId 65548
143 ; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
144 diff --git a/test/long-constant-array.ll b/test/long-constant-array.ll
145 index 415a723..cfef59d 100644
146 --- a/test/long-constant-array.ll
147 +++ b/test/long-constant-array.ll
149 ; RUN: llvm-as %s -o %t.bc
150 ; RUN: not llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
152 -; Check that everything is fine if SPV_INTEL_long_constant_composite is enabled
153 -; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
154 +; Check that everything is fine if SPV_INTEL_long_composites is enabled
155 +; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
156 ; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
157 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
158 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
159 ; TODO: run validator once it supports the extension
160 ; RUNx: spirv-val %t.spv
162 -; CHECK-SPIRV: Capability LongConstantCompositeINTEL
163 -; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
164 +; CHECK-SPIRV: Capability LongCompositesINTEL
165 +; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
166 ; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
167 ; CHECK-SPIRV: Constant {{[0-9]+}} [[ArrSize:[0-9]+]] 78000
168 ; CHECK-SPIRV: TypeArray [[TArr:[0-9]+]] [[TInt]] [[ArrSize]]
169 diff --git a/test/long-type-struct.ll b/test/long-type-struct.ll
170 index 9b83f62..de6352a 100644
171 --- a/test/long-type-struct.ll
172 +++ b/test/long-type-struct.ll
174 ; RUN: llvm-as %s -o %t.bc
175 -; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
176 +; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
177 ; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
178 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
179 -; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite -spirv-text %t.rev.bc -o %t2.spt
180 +; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites -spirv-text %t.rev.bc -o %t2.spt
181 ; RUN: FileCheck --input-file=%t2.spt %s --check-prefix=CHECK-SPIRV
182 ; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
183 ; TODO: run validator once it supports the extension
186 ; RUN: not llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
188 -; CHECK-SPIRV: Capability LongConstantCompositeINTEL
189 -; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
190 +; CHECK-SPIRV: Capability LongCompositesINTEL
191 +; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
192 ; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
193 ; CHECK-SPIRV: TypePointer [[TIntPtr:[0-9]+]] 8 [[TInt]]
194 ; CHECK-SPIRV: TypeArray [[TArr:[0-9]+]]