Skip to content

Commit 118d136

Browse files
ViacheslavRbigcbot
authored andcommitted
Reduce usage of pointer element types (29).
This change replaces calls to getNonOpaquePtrEltTy with element type information got through other means. This change is part of the effort to support opaque pointers in newer LLVM versions.
1 parent fb5c2ec commit 118d136

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

IGC/Compiler/CISACodeGen/PayloadMapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ uint PayloadMapping::GetNonAdjustedNumPayloadElements_Sample(const SampleIntrins
497497
EOPCODE opCode = GetOpCode(inst);
498498
llvm::Type* cubeTextureType = GetResourceDimensionType(*inst->getModule(), RESOURCE_DIMENSION_TYPE::DIM_CUBE_TYPE);
499499
llvm::Type* cubeArrayTextureType = GetResourceDimensionType(*inst->getModule(), RESOURCE_DIMENSION_TYPE::DIM_CUBE_ARRAY_TYPE);
500-
llvm::Type* textureType = IGCLLVM::getNonOpaquePtrEltTy(inst->getTextureValue()->getType());
500+
llvm::Type* textureType = inst->getTexturePtrEltTy();
501501
bool isCube = (textureType == cubeTextureType || textureType == cubeArrayTextureType);
502502
ValidateNumberofSources(opCode, isCube, numSources);
503503

IGC/Compiler/DynamicTextureFolding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void DynamicTextureFolding::FoldSingleTextureValue(CallInst& I)
4444
if (SamplerLoadIntrinsic * lInst = dyn_cast<SamplerLoadIntrinsic>(&I))
4545
{
4646
addrSpace = lInst->getTextureValue()->getType()->getPointerAddressSpace();
47-
Type* textureType = IGCLLVM::getNonOpaquePtrEltTy(lInst->getTextureValue()->getType());
47+
Type* textureType = lInst->getTexturePtrEltTy();
4848
if (textureType == type1DArray || textureType == type2DArray || textureType == typeCubeArray)
4949
{
5050
skipBoundaryCheck = 0;

IGC/Compiler/FixSampleDInputs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ IGC_INITIALIZE_PASS_END(FixSampleDInputsPass, PASS_FLAG, PASS_DESCRIPTION, PASS_
6161
for (Instruction& inst : BB)
6262
{
6363
SampleIntrinsic* sampleInst = dyn_cast<SampleIntrinsic>(&inst);
64-
Type* textureType = sampleInst ? IGCLLVM::getNonOpaquePtrEltTy(sampleInst->getTextureValue()->getType()) : nullptr;
64+
Type* textureType = sampleInst ? sampleInst->getTexturePtrEltTy() : nullptr;
6565
// 3D/Cube/CubeArray access is emulated in CodeGen, see EmitPass::emulateSampleD()
6666
if (sampleInst &&
6767
(textureType != volumeTextureType && textureType != cubeTextureType && textureType != cubeArrayTextureType))
@@ -97,7 +97,7 @@ IGC_INITIALIZE_PASS_END(FixSampleDInputsPass, PASS_FLAG, PASS_DESCRIPTION, PASS_
9797
uint mlodParamIndex = 11;
9898
Value* mlod_r = sampleInst->getArgOperand(mlodParamIndex); // MLOD
9999
Type* type2DArray = GetResourceDimensionType(*M, RESOURCE_DIMENSION_TYPE::DIM_2D_ARRAY_TYPE);
100-
Type* typeTex = IGCLLVM::getNonOpaquePtrEltTy(sampleInst->getTextureValue()->getType());
100+
Type* typeTex = sampleInst->getTexturePtrEltTy();
101101
if (typeTex == type2DArray)
102102
{
103103
// combine MLOD and R

IGC/Compiler/TranslateToProgrammableOffsetsPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ inline bool needsSampleDEmulation(const SampleIntrinsic* inst)
450450
Type* volumeTextureType = GetResourceDimensionType(M, RESOURCE_DIMENSION_TYPE::DIM_3D_TYPE);
451451
Type* cubeTextureType = GetResourceDimensionType(M, RESOURCE_DIMENSION_TYPE::DIM_CUBE_TYPE);
452452
Type* cubeArrayTextureType = GetResourceDimensionType(M, RESOURCE_DIMENSION_TYPE::DIM_CUBE_ARRAY_TYPE);
453-
Type* textureType = IGCLLVM::getNonOpaquePtrEltTy(inst->getTextureValue()->getType());
453+
Type* textureType = inst->getTexturePtrEltTy();
454454
if (textureType == cubeTextureType ||
455455
textureType == cubeArrayTextureType ||
456456
textureType == volumeTextureType)

IGC/GenISAIntrinsics/GenIntrinsicInst.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ See LICENSE.TXT for details.
4646

4747
#include "llvmWrapper/IR/Instructions.h"
4848
#include "llvmWrapper/Support/Alignment.h"
49+
#include "llvmWrapper/IR/Type.h"
4950
#include "usc_gen7_types.h"
5051

5152
namespace llvm {
@@ -499,6 +500,11 @@ class SamplerLoadIntrinsic : public GenIntrinsicInst {
499500
return false;
500501
}
501502
}
503+
504+
Type* getTexturePtrEltTy() const {
505+
Value* textureVal = this->getTextureValue();
506+
return textureVal ? IGCLLVM::getNonOpaquePtrEltTy(textureVal->getType()) : nullptr;
507+
}
502508
};
503509

504510
class LdMSIntrinsic : public SamplerLoadIntrinsic {
@@ -851,6 +857,11 @@ class SampleIntrinsic : public GenIntrinsicInst {
851857
}
852858
return false;
853859
}
860+
861+
Type* getTexturePtrEltTy() const {
862+
Value* textureVal = this->getTextureValue();
863+
return textureVal ? IGCLLVM::getNonOpaquePtrEltTy(textureVal->getType()) : nullptr;
864+
}
854865
};
855866

856867
class LdRawIntrinsic : public GenIntrinsicInst {

0 commit comments

Comments
 (0)