Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LongConstantCompositeINTEL to LongCompositesINTEL capability after Headers change #2258

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/LLVMSPIRVExtensions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EXT(SPV_INTEL_variable_length_array)
EXT(SPV_INTEL_fp_fast_math_mode)
EXT(SPV_INTEL_fpga_cluster_attributes)
EXT(SPV_INTEL_loop_fuse)
EXT(SPV_INTEL_long_constant_composite)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the renaming is a breaking change
please first change SPIRVReader in release branches to accept both SPV_INTEL_long_constant_composite and SPV_INTEL_long_composites, then wait for a graceful period and only then proceed with the renaming in ToT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks!

EXT(SPV_INTEL_long_composites)
EXT(SPV_INTEL_optnone)
EXT(SPV_INTEL_fpga_dsp_control)
EXT(SPV_INTEL_memory_access_aliasing)
Expand Down
10 changes: 4 additions & 6 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,18 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
const size_t NumElements = ST->getNumElements();
size_t SPIRVStructNumElements = NumElements;
// In case number of elements is greater than maximum WordCount and
// SPV_INTEL_long_constant_composite is not enabled, the error will be
// SPV_INTEL_long_composites is not enabled, the error will be
// emitted by validate functionality of SPIRVTypeStruct class.
if (NumElements > MaxNumElements &&
BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_long_constant_composite)) {
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites)) {
SPIRVStructNumElements = MaxNumElements;
}

auto *Struct = BM->openStructType(SPIRVStructNumElements, Name.str());
mapType(T, Struct);

if (NumElements > MaxNumElements &&
BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_long_constant_composite)) {
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites)) {
uint64_t NumOfContinuedInstructions = NumElements / MaxNumElements - 1;
for (uint64_t J = 0; J < NumOfContinuedInstructions; J++) {
auto *Continued = BM->addTypeStructContinuedINTEL(MaxNumElements);
Expand Down Expand Up @@ -1869,7 +1867,7 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
BVarInit = I->second;
} else if (Init && !isa<UndefValue>(Init)) {
if (!BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_long_constant_composite)) {
ExtensionID::SPV_INTEL_long_composites)) {
if (auto *ArrTy = dyn_cast_or_null<ArrayType>(Init->getType())) {
// First 3 words of OpConstantComposite encode: 1) word count &
// opcode, 2) Result Type and 3) Result Id. Max length of SPIRV
Expand Down
4 changes: 2 additions & 2 deletions lib/SPIRV/libSPIRV/SPIRVEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,11 @@ class SPIRVContinuedInstINTELBase : public SPIRVEntryNoId<OC> {
}

SPIRVCapVec getRequiredCapability() const override {
return getVec(CapabilityLongConstantCompositeINTEL);
return getVec(CapabilityLongCompositesINTEL);
}

std::optional<ExtensionID> getRequiredExtension() const override {
return ExtensionID::SPV_INTEL_long_constant_composite;
return ExtensionID::SPV_INTEL_long_composites;
}

SPIRVWord getNumElements() const { return Elements.size(); }
Expand Down
8 changes: 4 additions & 4 deletions lib/SPIRV/libSPIRV/SPIRVModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,10 +1204,10 @@ SPIRVValue *SPIRVModuleImpl::addCompositeConstant(
const int NumElements = Elements.size();

// In case number of elements is greater than maximum WordCount and
// SPV_INTEL_long_constant_composite is not enabled, the error will be emitted
// SPV_INTEL_long_composites is not enabled, the error will be emitted
// by validate functionality of SPIRVCompositeConstant class.
if (NumElements <= MaxNumElements ||
!isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_constant_composite))
!isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites))
return addConstant(new SPIRVConstantComposite(this, Ty, getId(), Elements));

auto Start = Elements.begin();
Expand Down Expand Up @@ -1239,10 +1239,10 @@ SPIRVValue *SPIRVModuleImpl::addSpecConstantComposite(
const int NumElements = Elements.size();

// In case number of elements is greater than maximum WordCount and
// SPV_INTEL_long_constant_composite is not enabled, the error will be emitted
// SPV_INTEL_long_composites is not enabled, the error will be emitted
// by validate functionality of SPIRVSpecConstantComposite class.
if (NumElements <= MaxNumElements ||
!isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_constant_composite))
!isAllowedToUseExtension(ExtensionID::SPV_INTEL_long_composites))
return addConstant(
new SPIRVSpecConstantComposite(this, Ty, getId(), Elements));

Expand Down
2 changes: 1 addition & 1 deletion lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ template <> inline void SPIRVMap<Capability, std::string>::init() {
add(CapabilityGroupNonUniformRotateKHR, "GroupNonUniformRotateKHR");
add(CapabilityAtomicFloat32AddEXT, "AtomicFloat32AddEXT");
add(CapabilityAtomicFloat64AddEXT, "AtomicFloat64AddEXT");
add(CapabilityLongConstantCompositeINTEL, "LongConstantCompositeINTEL");
add(CapabilityLongCompositesINTEL, "LongCompositesINTEL");
add(CapabilityOptNoneINTEL, "OptNoneINTEL");
add(CapabilityAtomicFloat16AddEXT, "AtomicFloat16AddEXT");
add(CapabilityDebugInfoModuleINTEL, "DebugInfoModuleINTEL");
Expand Down
2 changes: 1 addition & 1 deletion spirv-headers-tag.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cca08c63cefa129d082abca0302adcb81610b465
1c6bb2743599e6eb6f37b2969acc0aef812e32e3
6 changes: 3 additions & 3 deletions test/SpecConstants/long-spec-const-composite.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
Expand All @@ -11,8 +11,8 @@
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"
target triple = "spir64-unknown-unknown"

; CHECK-SPIRV: Capability LongConstantCompositeINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
; CHECK-SPIRV: Capability LongCompositesINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
; CHECK-SPIRV-DAG: Decorate [[First:[0-9]+]] SpecId 0
; CHECK-SPIRV-DAG: Decorate [[Last:[0-9]+]] SpecId 65548
; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
Expand Down
8 changes: 4 additions & 4 deletions test/long-constant-array.ll
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
; RUN: llvm-as %s -o %t.bc
; RUN: not llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR

; Check that everything is fine if SPV_INTEL_long_constant_composite is enabled
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
; Check that everything is fine if SPV_INTEL_long_composites is enabled
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
; TODO: run validator once it supports the extension
; RUNx: spirv-val %t.spv

; CHECK-SPIRV: Capability LongConstantCompositeINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
; CHECK-SPIRV: Capability LongCompositesINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
; CHECK-SPIRV: Constant {{[0-9]+}} [[ArrSize:[0-9]+]] 78000
; CHECK-SPIRV: TypeArray [[TArr:[0-9]+]] [[TInt]] [[ArrSize]]
Expand Down
8 changes: 4 additions & 4 deletions test/long-type-struct.ll
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite %t.bc -o %t.spv
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites %t.bc -o %t.spv
; RUN: llvm-spirv %t.spv --to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_constant_composite -spirv-text %t.rev.bc -o %t2.spt
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_long_composites -spirv-text %t.rev.bc -o %t2.spt
; RUN: FileCheck --input-file=%t2.spt %s --check-prefix=CHECK-SPIRV
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
; TODO: run validator once it supports the extension
; RUNx: spirv-val %t.spv

; RUN: not llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR

; CHECK-SPIRV: Capability LongConstantCompositeINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_constant_composite"
; CHECK-SPIRV: Capability LongCompositesINTEL
; CHECK-SPIRV: Extension "SPV_INTEL_long_composites"
; CHECK-SPIRV: TypeInt [[TInt:[0-9]+]] 8
; CHECK-SPIRV: TypePointer [[TIntPtr:[0-9]+]] 8 [[TInt]]
; CHECK-SPIRV: TypeArray [[TArr:[0-9]+]]
Expand Down
Loading