Skip to content

Commit

Permalink
馃敟
Browse files Browse the repository at this point in the history
  • Loading branch information
karolherbst committed Nov 14, 2023
1 parent 8ea71a0 commit 08ff0a1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,10 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,

SPIRVStorageClassKind StorageClass;
auto AddressSpace = static_cast<SPIRAddressSpace>(GV->getAddressSpace());
// force constant address space for constant global varaibles as emitting
// would be invalid.
if (AddressSpace == SPIRAS_Private && !BB && GV->isConstant())
AddressSpace = SPIRAS_Constant;
bool IsVectorCompute =
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute) &&
GV->hasAttribute(kVCMetadata::VCGlobalVariable);
Expand All @@ -1872,7 +1876,7 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
StorageClass = SPIRSPIRVAddrSpaceMap::map(AddressSpace);
}

SPIRVType *TranslatedTy = transPointerType(Ty, GV->getAddressSpace());
SPIRVType *TranslatedTy = transPointerType(Ty, static_cast<unsigned int>(AddressSpace));
auto BVar = static_cast<SPIRVVariable *>(
BM->addVariable(TranslatedTy, GV->isConstant(), transLinkageType(GV),
BVarInit, GV->getName().str(), StorageClass, nullptr));
Expand Down Expand Up @@ -2230,8 +2234,16 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
TransPointerOperand, BB);
}
} else {
unsigned int AddressSpace;
if (TransPointerOperand->getOpCode() == OpVariable) {
auto SpirvVar = static_cast<SPIRVVariable*>(TransPointerOperand);
AddressSpace = SPIRSPIRVAddrSpaceMap::rmap(SpirvVar->getStorageClass());
} else {
AddressSpace = GEP->getType()->getPointerAddressSpace();
}

TranslatedTy = transPointerType(GEP->getResultElementType(),
GEP->getType()->getPointerAddressSpace());
AddressSpace);
}
return mapValue(V,
BM->addPtrAccessChainInst(TranslatedTy, TransPointerOperand,
Expand Down

0 comments on commit 08ff0a1

Please sign in to comment.