Skip to content

Commit e2e20fe

Browse files
troelsigcbot
authored andcommitted
Compile PreprocessSpvir.cpp when compiling UnifyIROCL.cpp
When IGC_SCALAR_USE_KHRONOS_SPIRV_TRANSLATOR is set UnifyIROCL.cpp depends on PreprocessSPVIR.
1 parent 24ff60a commit e2e20fe

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

IGC/AdaptorOCL/PreprocessSPVIR.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PreprocessSPVIR::PreprocessSPVIR() : ModulePass(ID)
4242

4343
uint64_t PreprocessSPVIR::parseSampledImageTy(StructType* sampledImageTy)
4444
{
45-
std::string Name = sampledImageTy->getName();
45+
std::string Name = sampledImageTy->getName().str();
4646
std::smatch match;
4747
std::regex reg("spirv.SampledImage._void_([0-6])_([0-2])_([0-1])_([0-1])_([0-2])_([0-9]+)_([0-2])");
4848

@@ -77,18 +77,18 @@ Value* PreprocessSPVIR::getWidenImageCoordsArg(Value* Coords)
7777
{
7878
Type* coordsType = Coords->getType();
7979
Value* newCoords = nullptr;
80-
if (!isa<VectorType>(coordsType))
80+
if (!isa<IGCLLVM::FixedVectorType>(coordsType))
8181
{
82-
Value* undef = UndefValue::get(VectorType::get(coordsType, 4));
82+
Value* undef = UndefValue::get(IGCLLVM::FixedVectorType::get(coordsType, 4));
8383
newCoords = m_Builder->CreateInsertElement(undef, Coords, ConstantInt::get(m_Builder->getInt32Ty(), 0));
8484
}
85-
else if (cast<VectorType>(coordsType)->getNumElements() < 4)
85+
else if (cast<IGCLLVM::FixedVectorType>(coordsType)->getNumElements() < 4)
8686
{
8787
SmallVector<Constant*, 4> shuffleIdx;
88-
for (uint64_t i = 0; i < cast<VectorType>(coordsType)->getNumElements(); i++)
88+
for (uint64_t i = 0; i < cast<IGCLLVM::FixedVectorType>(coordsType)->getNumElements(); i++)
8989
shuffleIdx.push_back(ConstantInt::get(m_Builder->getInt32Ty(), i));
9090

91-
for (uint64_t i = cast<VectorType>(coordsType)->getNumElements(); i < 4; i++)
91+
for (uint64_t i = cast<IGCLLVM::FixedVectorType>(coordsType)->getNumElements(); i < 4; i++)
9292
shuffleIdx.push_back(ConstantInt::get(m_Builder->getInt32Ty(), 0));
9393

9494
newCoords = m_Builder->CreateShuffleVector(Coords, UndefValue::get(coordsType), ConstantVector::get(shuffleIdx));
@@ -156,7 +156,7 @@ void PreprocessSPVIR::visitImageSampleExplicitLod(CallInst& CI)
156156
// -image,
157157
// -image type which comes from parsing opaque type
158158
// -sampler.
159-
Value* unifiedSampledImage = UndefValue::get(VectorType::get(m_Builder->getInt64Ty(), 3));
159+
Value* unifiedSampledImage = UndefValue::get(IGCLLVM::FixedVectorType::get(m_Builder->getInt64Ty(), 3));
160160

161161
Value* imageAsInt = m_Builder->CreatePtrToInt(callSampledImage->getArgOperand(0), m_Builder->getInt64Ty());
162162
Value* samplerAsInt = m_Builder->CreatePtrToInt(callSampledImage->getArgOperand(1), m_Builder->getInt64Ty());
@@ -205,9 +205,9 @@ void PreprocessSPVIR::visitImageSampleExplicitLod(CallInst& CI)
205205
else
206206
IGC_ASSERT_MESSAGE(0, "Unsupported dx/dy types of ImageSampleExplicitLod builtin.");
207207

208-
if (isa<VectorType>(dxType))
208+
if (auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(dxType))
209209
{
210-
unifiedImageSampleName += std::to_string(dxType->getVectorNumElements());
210+
unifiedImageSampleName += std::to_string(VT->getNumElements());
211211
}
212212
}
213213
break;
@@ -216,9 +216,10 @@ void PreprocessSPVIR::visitImageSampleExplicitLod(CallInst& CI)
216216
break;
217217
}
218218

219-
Type* retType = CI.getType();
220-
if (retType->isVectorTy() && retType->getVectorNumElements() == 4)
221-
{
219+
Type* retType = CI.getType();
220+
auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(retType);
221+
if (VT && VT->getNumElements() == 4)
222+
{
222223
Type* retScalarType = retType->getScalarType();
223224
if (retScalarType->isIntegerTy())
224225
unifiedImageSampleName += "_Ruint4";

IGC/DriverInterface/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set(IGC_BUILD__SRC__DriverInterface
2727
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/OCL/sp/sp_debug.cpp"
2828
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/OCL/util/BinaryStream.cpp"
2929
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/UnifyIROCL.cpp"
30+
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/PreprocessSPVIR.cpp"
3031
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/MoveStaticAllocas.cpp"
3132
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/OCL/sp/zebin_builder.cpp"
3233
)

0 commit comments

Comments
 (0)