Skip to content

Commit 0485266

Browse files
amielczaigcbot
authored andcommitted
Expand Type.h LLVM wrapper
Expand Type.h LLVM wrapper
1 parent bd5abd7 commit 0485266

File tree

23 files changed

+66
-51
lines changed

23 files changed

+66
-51
lines changed

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ SPDX-License-Identifier: MIT
2121

2222
#include "llvm/IR/Attributes.h"
2323
#include <llvmWrapper/IR/Function.h>
24+
#include <llvmWrapper/IR/Type.h>
25+
2426
#include "llvmWrapper/IR/InstrTypes.h"
2527
#include "llvmWrapper/IR/Instructions.h"
2628

@@ -276,7 +278,7 @@ static void getBuiltinType(Type *T, SmallPtrSetImpl<Type *> &BuiltinTypes) {
276278
getBuiltinType(*I, BuiltinTypes);
277279
}
278280
}
279-
} else if (T->isPointerTy() && !T->isOpaquePointerTy()) {
281+
} else if (T->isPointerTy() && !IGCLLVM::isPointerTy(T)) {
280282
return getBuiltinType(IGCLLVM::getNonOpaquePtrEltTy(cast<PointerType>(T)), BuiltinTypes);
281283
}
282284
#if LLVM_VERSION_MAJOR >= 16

IGC/AdaptorOCL/dllInterfaceCompute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ void RebuildGlobalAnnotations(IGC::OpenCLProgramContext &oclContext, Module *pKe
887887
// On typed pointers it was: struct -> bitcast -> functionPointer
888888
// On opaque pointer the bitcast is just "ptr", so it is: struct -> functionPointer
889889
// Non-opaque pointers path should be removed after transition to opaque pointers.
890-
if (IGCLLVM::isOpaquePointerTy(operand0->getType())) {
890+
if (IGCLLVM::isPointerTy(operand0->getType())) {
891891
annotated_function = cast<Function>(operand0);
892892
} else {
893893
annotated_function = cast<Function>(operand0->getOperand(0));

IGC/AdaptorOCL/preprocess_spvir/ConvertUserSemanticDecoratorOnFunctions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
1212
#include "common/LLVMWarningsPush.hpp"
1313
#include "llvmWrapper/IR/DerivedTypes.h"
1414
#include "llvmWrapper/IR/Instructions.h"
15+
#include "llvmWrapper/IR/Type.h"
1516
#include <llvm/IR/Module.h>
1617
#include <llvm/IR/Function.h>
1718
#include <llvm/IR/Instructions.h>
@@ -86,7 +87,7 @@ bool ConvertUserSemanticDecoratorOnFunctions::runOnModule(Module &M) {
8687

8788
// For opaque pointers we can call only single getOperand() on annotation_struct,
8889
// beacause we don't need to use e.g. bitcast instruction like for typed pointers
89-
if (annotation_struct->getOperand(0)->getType()->isOpaquePointerTy()) {
90+
if (IGCLLVM::isPointerTy(annotation_struct->getOperand(0)->getType())) {
9091
annotated_function = cast<Function>(annotation_struct->getOperand(0));
9192
annotation_gv = cast<GlobalVariable>(annotation_struct->getOperand(1));
9293
} else {

IGC/AdaptorOCL/preprocess_spvir/HandleSPIRVDecorations/HandleSpirvDecorationMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void HandleSpirvDecorationMetadata::handleCacheControlINTELForPrefetch(llvm::Cal
373373
// is needed to implement this prefetch correctly on opaque pointers.
374374
// It will of course result in performance penalty and needs to be changed once
375375
// "OpUntypedPrefetch" is ready.
376-
if (IGCLLVM::isOpaquePointerTy(PTy))
376+
if (IGCLLVM::isPointerTy(PTy))
377377
return;
378378

379379
args.push_back(ConstantInt::get(Type::getInt32Ty(I.getContext()),

IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,9 @@ bool PromoteSubByte::typeNeedsPromotion(Type *type, DenseSet<Type *> visitedType
284284
} else if (auto vectorType = dyn_cast<VectorType>(type)) {
285285
return typeNeedsPromotion(vectorType->getElementType(), visitedTypes);
286286
} else if (auto pointerType = dyn_cast<PointerType>(type)) {
287-
return IGCLLVM::isOpaquePointerTy(pointerType)
288-
? false
289-
: typeNeedsPromotion(IGCLLVM::getNonOpaquePtrEltTy(type),
290-
visitedTypes); // Legacy code: getNonOpaquePtrEltTy
287+
return IGCLLVM::isPointerTy(pointerType) ? false
288+
: typeNeedsPromotion(IGCLLVM::getNonOpaquePtrEltTy(type),
289+
visitedTypes); // Legacy code: getNonOpaquePtrEltTy
291290
} else if (auto arrayType = dyn_cast<ArrayType>(type)) {
292291
return typeNeedsPromotion(arrayType->getElementType(), visitedTypes);
293292
} else if (auto structType = dyn_cast<StructType>(type)) {
@@ -327,7 +326,7 @@ Type *PromoteSubByte::getOrCreatePromotedType(Type *type) {
327326
Type *promotedElemType = getOrCreatePromotedType(fixedVectorType->getElementType());
328327
newType = IGCLLVM::FixedVectorType::get(promotedElemType, numElts);
329328
} else if (auto pointerType = dyn_cast<PointerType>(type)) {
330-
newType = IGCLLVM::isOpaquePointerTy(pointerType)
329+
newType = IGCLLVM::isPointerTy(pointerType)
331330
? pointerType
332331
: PointerType::get(getOrCreatePromotedType(
333332
IGCLLVM::getNonOpaquePtrEltTy(type)), // Legacy code: getNonOpaquePtrEltTy
@@ -632,7 +631,7 @@ Constant *PromoteSubByte::promoteConstant(Constant *constant) {
632631

633632
return ConstantInt::get(Type::getInt8Ty(constant->getContext()), constantInteger->getZExtValue());
634633
} else if (auto constantPointerNull = dyn_cast<ConstantPointerNull>(constant)) {
635-
if (IGCLLVM::isOpaquePointerTy(constantPointerNull->getType())) {
634+
if (IGCLLVM::isPointerTy(constantPointerNull->getType())) {
636635
return constant;
637636
}
638637
if (!typeNeedsPromotion(

IGC/Compiler/FixResourcePtr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void FixResourcePtr::RemoveGetBufferPtr(GenIntrinsicInst *bufPtr, Value *bufIdx)
100100
PointerType *const instType = dyn_cast<PointerType>(inst->getType());
101101
IGC_ASSERT(nullptr != instType);
102102
PointerType *ptrType = nullptr;
103-
if (IGCLLVM::isOpaquePointerTy(instType)) {
103+
if (IGCLLVM::isPointerTy(instType)) {
104104
ptrType = PointerType::get(bufPtr->getContext(), outAS);
105105
} else {
106106
Type *eltType = IGCLLVM::getNonOpaquePtrEltTy(instType); // Legacy code: getNonOpaquePtrEltTy

IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Align AlignmentAnalysis::getAlignValue(Value *V) const {
216216
}
217217

218218
Type *pointedTo = IGCLLVM::getArgAttrEltTy(arg);
219-
if (pointedTo == nullptr && !IGCLLVM::isOpaquePointerTy(arg->getType()))
219+
if (pointedTo == nullptr && !IGCLLVM::isPointerTy(arg->getType()))
220220
pointedTo = IGCLLVM::getNonOpaquePtrEltTy(arg->getType());
221221

222222
// Pointer arguments are guaranteed to be aligned on the ABI alignment

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASPropagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool GASPropagator::visitBitCastInst(BitCastInst &I) {
120120
BuilderType::InsertPointGuard Guard(IRB);
121121
IRB.SetInsertPoint(I.getNextNode());
122122
Value *Src = TheVal;
123-
if (!IGCLLVM::isOpaquePointerTy(SrcPtrTy)) {
123+
if (!IGCLLVM::isPointerTy(SrcPtrTy)) {
124124
// Push `addrspacecast` forward by replacing this `bitcast` on GAS with the
125125
// one on non-GAS followed by a new `addrspacecast` to GAS.
126126
Type *DstTy = IGCLLVM::getNonOpaquePtrEltTy(DstPtrTy); // Legacy code: getNonOpaquePtrEltTy

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASResolving.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool GASResolving::canonicalizeAddrSpaceCasts(Function &F) const {
7575
std::vector<AddrSpaceCastInst *> GASAddrSpaceCasts;
7676
for (auto &I : make_range(inst_begin(F), inst_end(F)))
7777
if (AddrSpaceCastInst *ASCI = dyn_cast<AddrSpaceCastInst>(&I)) {
78-
if (IGCLLVM::isOpaquePointerTy(ASCI->getType()))
78+
if (IGCLLVM::isPointerTy(ASCI->getType()))
7979
return false;
8080
if (ASCI->getDestAddressSpace() == GAS)
8181
GASAddrSpaceCasts.push_back(ASCI);
@@ -259,7 +259,7 @@ bool GASResolving::checkGenericArguments(Function &F) const {
259259
if (Ty->getAddressSpace() != ADDRESS_SPACE_GLOBAL)
260260
continue;
261261
auto PteeTy = IGCLLVM::getArgAttrEltTy(F.getArg(p));
262-
if (PteeTy == nullptr && !IGCLLVM::isOpaquePointerTy(Ty))
262+
if (PteeTy == nullptr && !IGCLLVM::isPointerTy(Ty))
263263
PteeTy = IGCLLVM::getNonOpaquePtrEltTy(Ty); // Legacy code: getNonOpaquePtrEltTy
264264
if (PteeTy == nullptr)
265265
// go to slow path

IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ JointMatrixFuncsResolutionPass::JointMatrixFuncsResolutionPass() : ModulePass(ID
9292

9393
// Static helper functions for type traversal
9494
static bool isMatrixType(const Type *type) {
95-
// isOpaquePointerTy check here and below in other places will skip resolving of matrix types,
95+
// isPointerTy check here and below in other places will skip resolving of matrix types,
9696
// when opaque pointers are enabled, but target extension types are not.
9797
StringRef name = "";
9898

9999
if (IGCLLVM::isTargetExtTy(type)) {
100100
name = IGCLLVM::getTargetExtName(type);
101101
} else {
102-
if (!type->isPointerTy() || IGCLLVM::isOpaquePointerTy(type))
102+
if (!type->isPointerTy() || IGCLLVM::isPointerTy(type))
103103
return false;
104104

105105
Type *eltType = IGCLLVM::getNonOpaquePtrEltTy(type);
@@ -137,7 +137,7 @@ static void PreOrderTypeTraversal(Type *t, std::unordered_set<Type *> &set) {
137137

138138
if (PointerType *PT = dyn_cast<PointerType>(t)) {
139139
set.insert(t);
140-
if (IGCLLVM::isOpaquePointerTy(PT))
140+
if (IGCLLVM::isPointerTy(PT))
141141
return;
142142
return PreOrderTypeTraversal(IGCLLVM::getNonOpaquePtrEltTy(PT), set);
143143
}
@@ -1339,7 +1339,7 @@ Type *JointMatrixFuncsResolutionPass::TryFindTypeOfOpaquePtr(Value *V) {
13391339
} else if (auto *gep = dyn_cast<GetElementPtrInst>(use)) {
13401340
return gep->getResultElementType();
13411341
} else if (auto *bitcast = dyn_cast<BitCastInst>(use)) {
1342-
if (!IGCLLVM::isOpaquePointerTy(bitcast->getSrcTy()))
1342+
if (!IGCLLVM::isPointerTy(bitcast->getSrcTy()))
13431343
return bitcast->getSrcTy();
13441344

13451345
return TryFindTypeOfOpaquePtr(bitcast->getOperand(0));
@@ -1355,7 +1355,7 @@ Type *JointMatrixFuncsResolutionPass::ResolveType(Type *inputType, JointMatrixTy
13551355
"Unexpected type in matrix function resolution.");
13561356

13571357
#if LLVM_VERSION_MAJOR >= 16
1358-
IGC_ASSERT_EXIT_MESSAGE(!IGCLLVM::isOpaquePointerTy(inputType),
1358+
IGC_ASSERT_EXIT_MESSAGE(!IGCLLVM::isPointerTy(inputType),
13591359
"Unexpected opaque pointer. Expected TargetExtensionType instead.");
13601360
#endif
13611361

@@ -1457,7 +1457,7 @@ Instruction *JointMatrixFuncsResolutionPass::ResolvePrefetch(CallInst *CI) {
14571457
Type *ptrElemType = nullptr;
14581458

14591459
#if LLVM_VERSION_MAJOR >= 16
1460-
if (IGCLLVM::isOpaquePointerTy(ptrVal->getType()))
1460+
if (IGCLLVM::isPointerTy(ptrVal->getType()))
14611461
ptrElemType = TryFindTypeOfOpaquePtr(ptrVal);
14621462
else
14631463
#endif
@@ -2276,7 +2276,7 @@ bool JointMatrixFuncsResolutionPass::preprocessAccessChain(Function *F) {
22762276
}
22772277

22782278
#if LLVM_VERSION_MAJOR < 16
2279-
if (IGCLLVM::isOpaquePointerTy(CI->getArgOperand(0)->getType()))
2279+
if (IGCLLVM::isPointerTy(CI->getArgOperand(0)->getType()))
22802280
continue;
22812281
#endif
22822282

@@ -2286,7 +2286,7 @@ bool JointMatrixFuncsResolutionPass::preprocessAccessChain(Function *F) {
22862286
auto operand0 = CI->getArgOperand(0);
22872287

22882288
#if LLVM_VERSION_MAJOR >= 16
2289-
if (IGCLLVM::isOpaquePointerTy(operand0->getType())) {
2289+
if (IGCLLVM::isPointerTy(operand0->getType())) {
22902290
chainBaseTy = TryFindTargetExtensionTypeOfOpaquePtr(operand0);
22912291

22922292
if (!chainBaseTy) {
@@ -2618,7 +2618,7 @@ Type *JointMatrixFuncsResolutionPass::ResolvePointerType(Type *oldType) {
26182618
return ResolvedTypes[oldType];
26192619

26202620
PointerType *ptrType = dyn_cast<PointerType>(oldType);
2621-
if (IGCLLVM::isOpaquePointerTy(ptrType))
2621+
if (IGCLLVM::isPointerTy(ptrType))
26222622
return oldType;
26232623

26242624
Type *elemType = IGCLLVM::getNonOpaquePtrEltTy(ptrType);
@@ -2741,7 +2741,7 @@ void JointMatrixFuncsResolutionPass::visitCallInst(CallInst &CI) {
27412741
StringRef funcName = func->getName();
27422742

27432743
#if LLVM_VERSION_MAJOR < 16
2744-
if (IGCLLVM::isOpaquePointerTy(CI.getType()) || isAnyOperand(CI, IGCLLVM::isOpaquePointerTy))
2744+
if (IGCLLVM::isPointerTy(CI.getType()) || isAnyOperand(CI, IGCLLVM::isPointerTy))
27452745
return;
27462746
#endif
27472747

@@ -3066,7 +3066,7 @@ void JointMatrixFuncsResolutionPass::visitBitCastInst(BitCastInst &I) {
30663066
// it returns in visitStoreInst and then remove it.
30673067
PointerType *srcPtr = dyn_cast<PointerType>(I.getSrcTy());
30683068
PointerType *dstPtr = dyn_cast<PointerType>(I.getDestTy());
3069-
if (srcPtr && dstPtr && !IGCLLVM::isOpaquePointerTy(srcPtr) && !IGCLLVM::isOpaquePointerTy(dstPtr)) {
3069+
if (srcPtr && dstPtr && !IGCLLVM::isPointerTy(srcPtr) && !IGCLLVM::isPointerTy(dstPtr)) {
30703070
Type *srcPtrType = IGCLLVM::getNonOpaquePtrEltTy(srcPtr);
30713071
Type *dstPtrType = IGCLLVM::getNonOpaquePtrEltTy(dstPtr);
30723072

0 commit comments

Comments
 (0)