Skip to content

Commit 9d06835

Browse files
jcranmer-inteldbudanov-cmplr
authored andcommitted
Use TypedPointerType in lieu of PointerIndirectPair in mangleBuiltin. (#1568)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@42cf770
1 parent cb6e1e3 commit 9d06835

File tree

7 files changed

+134
-206
lines changed

7 files changed

+134
-206
lines changed

llvm-spirv/include/LLVMSPIRVLib.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ std::unique_ptr<SPIRVModule> readSpirvModule(std::istream &IS,
106106
const SPIRV::TranslatorOpts &Opts,
107107
std::string &ErrMsg);
108108

109-
/// This contains a pair of the pointer element type and an indirection
110-
/// parameter (to capture cases where an array of OpenCL types is used).
111-
typedef llvm::PointerIntPair<llvm::Type *, 1, bool> PointerIndirectPair;
112-
113109
} // End namespace SPIRV
114110

115111
namespace llvm {
@@ -160,13 +156,11 @@ bool regularizeLlvmForSpirv(Module *M, std::string &ErrMsg,
160156
const SPIRV::TranslatorOpts &Opts);
161157

162158
/// \brief Mangle OpenCL builtin function function name.
163-
/// If any type in ArgTypes is a pointer type, the corresponding entry in
164-
/// ArgPointerTypes should contain the type should point to. If there are no
165-
/// pointer-typed arguments in ArgTypes, then ArgPointerTypes may be empty.
159+
/// If any type in ArgTypes is a pointer type, it should be represented as a
160+
/// TypedPointerType instead, to faithfully represent the pointer element types
161+
/// for name mangling.
166162
void mangleOpenClBuiltin(const std::string &UnmangledName,
167-
ArrayRef<Type *> ArgTypes,
168-
ArrayRef<SPIRV::PointerIndirectPair> ArgPointerTypes,
169-
std::string &MangledName);
163+
ArrayRef<Type *> ArgTypes, std::string &MangledName);
170164

171165
/// Create a pass for translating LLVM to SPIR-V.
172166
ModulePass *createLLVMToSPIRVLegacy(SPIRV::SPIRVModule *);

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,9 +1596,7 @@ Value *SPIRV::transSPIRVMemorySemanticsIntoOCLMemFenceFlags(
15961596

15971597
void llvm::mangleOpenClBuiltin(const std::string &UniqName,
15981598
ArrayRef<Type *> ArgTypes,
1599-
ArrayRef<PointerIndirectPair> PointerElementTys,
16001599
std::string &MangledName) {
16011600
OCLUtil::OCLBuiltinFuncMangleInfo BtnInfo(ArgTypes);
1602-
BtnInfo.fillPointerElementTypes(PointerElementTys);
16031601
MangledName = SPIRV::mangleBuiltin(UniqName, ArgTypes, &BtnInfo);
16041602
}

llvm-spirv/lib/SPIRV/SPIRVInternal.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,11 @@ struct BuiltinArgTypeMangleInfo {
456456
bool IsLocalArgBlock;
457457
SPIR::TypePrimitiveEnum Enum;
458458
unsigned Attr;
459-
PointerIndirectPair PointerElementType;
459+
Type *PointerTy;
460460
BuiltinArgTypeMangleInfo()
461461
: IsSigned(true), IsVoidPtr(false), IsEnum(false), IsSampler(false),
462462
IsAtomic(false), IsLocalArgBlock(false), Enum(SPIR::PRIMITIVE_NONE),
463-
Attr(0), PointerElementType(nullptr, false) {}
463+
Attr(0), PointerTy(nullptr) {}
464464
};
465465

466466
/// Information for mangling builtin function.
@@ -518,8 +518,6 @@ class BuiltinFuncMangleInfo {
518518
UnmangledName = UniqUnmangledName.str();
519519
}
520520

521-
void fillPointerElementTypes(ArrayRef<PointerIndirectPair>);
522-
523521
protected:
524522
std::string UnmangledName;
525523
std::vector<BuiltinArgTypeMangleInfo> ArgInfo;
@@ -986,7 +984,6 @@ inline void getParameterTypes(CallInst *CI,
986984
/// manner
987985
std::string getSPIRVFriendlyIRFunctionName(OCLExtOpKind ExtOpId,
988986
ArrayRef<Type *> ArgTys,
989-
ArrayRef<PointerIndirectPair> PETs,
990987
Type *RetTy = nullptr);
991988

992989
/// Mangle a function in SPIR-V friendly IR manner
@@ -998,8 +995,7 @@ std::string getSPIRVFriendlyIRFunctionName(OCLExtOpKind ExtOpId,
998995
/// \param Types of arguments of SPIR-V built-in function
999996
/// \return IA64 mangled name.
1000997
std::string getSPIRVFriendlyIRFunctionName(const std::string &UniqName,
1001-
spv::Op OC, ArrayRef<Type *> ArgTys,
1002-
ArrayRef<PointerIndirectPair> PETs);
998+
spv::Op OC, ArrayRef<Type *> ArgTys);
1003999

10041000
/// Cast a function to a void(void) funtion pointer.
10051001
Constant *castToVoidFuncPtr(Function *F);

0 commit comments

Comments
 (0)