From dd72efa3b4aafdbbf599e6f3c6f8c55450e348de Mon Sep 17 00:00:00 2001 From: "Gorban, Igor" Date: Wed, 21 Dec 2022 23:00:51 +0000 Subject: [PATCH] Fix build against llvm tot . --- .../llvm/GenXIntrinsics/GenXIntrinsics.h | 21 ++++++------------- .../include/llvmVCWrapper/IR/Instructions.h | 10 --------- .../GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp | 11 ++++++---- .../GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp | 10 ++++++--- .../GenXSingleElementVectorUtil.cpp | 7 +++++-- 5 files changed, 25 insertions(+), 34 deletions(-) diff --git a/GenXIntrinsics/include/llvm/GenXIntrinsics/GenXIntrinsics.h b/GenXIntrinsics/include/llvm/GenXIntrinsics/GenXIntrinsics.h index 320fa9a4..b3981621 100644 --- a/GenXIntrinsics/include/llvm/GenXIntrinsics/GenXIntrinsics.h +++ b/GenXIntrinsics/include/llvm/GenXIntrinsics/GenXIntrinsics.h @@ -25,15 +25,6 @@ SPDX-License-Identifier: MIT #include "llvm/IR/Instructions.h" #include "llvm/GenXIntrinsics/GenXVersion.h" - -namespace VCINTR { -#if VC_INTR_LLVM_VERSION_MAJOR < 16 -const llvm::NoneType None = llvm::None; -#else -inline constexpr std::nullopt_t None = std::nullopt; -#endif -} // namespace VCINTR - namespace llvm { namespace GenXIntrinsic { @@ -182,7 +173,7 @@ inline bool isGenXNonTrivialIntrinsic(const Value *V) { /// GenXIntrinsic::getGenXName(ID) - Return the LLVM name for a GenX intrinsic, /// such as "llvm.genx.lane.id". -std::string getGenXName(ID id, ArrayRef Tys = VCINTR::None); +std::string getGenXName(ID id, ArrayRef Tys = {}); ID lookupGenXIntrinsicID(StringRef Name); @@ -190,7 +181,7 @@ AttributeList getAttributes(LLVMContext &C, ID id); /// GenXIntrinsic::getGenXType(ID) - Return the function type for an intrinsic. FunctionType *getGenXType(LLVMContext &Context, GenXIntrinsic::ID id, - ArrayRef Tys = VCINTR::None); + ArrayRef Tys = {}); /// GenXIntrinsic::getGenXDeclaration(M, ID) - Create or insert a GenX LLVM /// Function declaration for an intrinsic, and return it. @@ -199,7 +190,7 @@ FunctionType *getGenXType(LLVMContext &Context, GenXIntrinsic::ID id, /// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded /// intrinsic, Tys must provide exactly one type for each overloaded type in /// the intrinsic. -Function *getGenXDeclaration(Module *M, ID id, ArrayRef Tys = VCINTR::None); +Function *getGenXDeclaration(Module *M, ID id, ArrayRef Tys = {}); void getIntrinsicInfoTableEntries( GenXIntrinsic::ID id, @@ -271,11 +262,11 @@ inline bool isAnyNonTrivialIntrinsic(const Value *V) { /// GenXIntrinsic::getAnyName(ID) - Return the LLVM name for LLVM or GenX /// intrinsic, such as "llvm.genx.lane.id". -std::string getAnyName(unsigned id, ArrayRef Tys = VCINTR::None); +std::string getAnyName(unsigned id, ArrayRef Tys = {}); /// GenXIntrinsic::getAnyType(ID) - Return the function type for an intrinsic. inline FunctionType *getAnyType(LLVMContext &Context, unsigned id, - ArrayRef Tys = VCINTR::None) { + ArrayRef Tys = {}) { assert(isAnyNonTrivialIntrinsic(id)); if (isGenXIntrinsic(id)) return getGenXType(Context, (ID)id, Tys); @@ -303,7 +294,7 @@ bool isOverloadedRet(unsigned IntrinID); /// intrinsic, Tys must provide exactly one type for each overloaded type in /// the intrinsic. inline Function *getAnyDeclaration(Module *M, unsigned id, - ArrayRef Tys = VCINTR::None) { + ArrayRef Tys = {}) { assert(isAnyNonTrivialIntrinsic(id)); if (isGenXIntrinsic(id)) { return getGenXDeclaration(M, (ID)id, Tys); diff --git a/GenXIntrinsics/include/llvmVCWrapper/IR/Instructions.h b/GenXIntrinsics/include/llvmVCWrapper/IR/Instructions.h index 2952b7e3..9510f5f5 100644 --- a/GenXIntrinsics/include/llvmVCWrapper/IR/Instructions.h +++ b/GenXIntrinsics/include/llvmVCWrapper/IR/Instructions.h @@ -61,16 +61,6 @@ inline const ArgKind &getValue(const llvm::Optional &opt) { #endif } -#if VC_INTR_LLVM_VERSION_MAJOR > 15 -template inline ArgKind &getValue(std::optional &opt) { - return opt.value(); -} - -template -inline const ArgKind &getValue(const std::optional &opt) { - return opt.value(); -} -#endif } // namespace VCINTR #endif // VCINTR_IR_INSTRUCTIONS_H diff --git a/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp b/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp index fe81cb66..9f820990 100644 --- a/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp +++ b/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVReaderAdaptor.cpp @@ -203,7 +203,7 @@ static SPIRVArgDesc parseSPIRVIRImageType(StringRef TyName) { static Optional parseIntelType(StringRef TyName) { if (!TyName.consume_front(IntelTypes::TypePrefix)) - return None; + return {}; SPIRVType MainType; std::tie(MainType, TyName) = parseIntelMainType(TyName); @@ -215,7 +215,7 @@ static Optional parseIntelType(StringRef TyName) { static Optional parseOCLType(StringRef TyName) { if (!TyName.consume_front(OCLTypes::TypePrefix)) - return None; + return {}; // Sampler type. if (TyName.consume_front(OCLTypes::Sampler)) { @@ -229,7 +229,7 @@ static Optional parseOCLType(StringRef TyName) { static Optional parseSPIRVIRType(StringRef TyName) { if (!TyName.consume_front(SPIRVIRTypes::TypePrefix)) - return None; + return {}; if (TyName.consume_front(SPIRVIRTypes::Sampler)) return {SPIRVType::Sampler}; @@ -491,8 +491,11 @@ static void rewriteKernelArguments(Function &F) { Function *NewF = transformKernelSignature(F, ArgDescs); F.getParent()->getFunctionList().insert(F.getIterator(), NewF); +#if VC_INTR_LLVM_VERSION_MAJOR > 15 + NewF->splice(NewF->begin(), &F); +#else NewF->getBasicBlockList().splice(NewF->begin(), F.getBasicBlockList()); - +#endif // Rewrite uses and delete conversion intrinsics. for (int i = 0, e = ArgDescs.size(); i != e; ++i) { Argument &OldArg = *std::next(F.arg_begin(), i); diff --git a/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp b/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp index 417f763a..b8044f51 100644 --- a/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp +++ b/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp @@ -273,7 +273,7 @@ static SPIRVArgDesc parseArgDesc(StringRef Desc) { .Case(ArgDesc::Image3d, SPIRVType::Image3d) .Case(ArgDesc::SVM, SPIRVType::Pointer) .Case(ArgDesc::Sampler, SPIRVType::Sampler) - .Default(None); + .Default({}); } if (!AccTy) { @@ -281,7 +281,7 @@ static SPIRVArgDesc parseArgDesc(StringRef Desc) { .Case(ArgDesc::ReadOnly, AccessType::ReadOnly) .Case(ArgDesc::WriteOnly, AccessType::WriteOnly) .Case(ArgDesc::ReadWrite, AccessType::ReadWrite) - .Default(None); + .Default({}); } if (Ty && AccTy) @@ -372,7 +372,7 @@ static Optional extractArgumentKind(const Argument &Arg) { const Function *F = Arg.getParent(); const AttributeList Attrs = F->getAttributes(); if (!Attrs.hasParamAttr(Arg.getArgNo(), VCFunctionMD::VCArgumentKind)) - return None; + return {}; const Attribute Attr = Attrs.getParamAttr(Arg.getArgNo(), VCFunctionMD::VCArgumentKind); @@ -434,7 +434,11 @@ static void rewriteKernelArguments(Function &F) { Function *NewF = transformKernelSignature(F, ArgDescs); F.getParent()->getFunctionList().insert(F.getIterator(), NewF); +#if VC_INTR_LLVM_VERSION_MAJOR > 15 + NewF->splice(NewF->begin(), &F); +#else NewF->getBasicBlockList().splice(NewF->begin(), F.getBasicBlockList()); +#endif Instruction *InsPt = &NewF->getEntryBlock().front(); for (auto ArgPair : llvm::zip(F.args(), NewF->args())) { diff --git a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp index acf26931..faa61819 100644 --- a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp +++ b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp @@ -567,11 +567,14 @@ static void rewriteSingleElementVectorSignature(Function &F, NewF.copyMetadata(&F, 0); NewF.recalculateIntrinsicID(); F.getParent()->getFunctionList().insert(F.getIterator(), &NewF); +#if VC_INTR_LLVM_VERSION_MAJOR > 15 + NewF.splice(NewF.begin(), &F); +#else NewF.getBasicBlockList().splice(NewF.begin(), F.getBasicBlockList()); - +#endif manageSingleElementVectorAttributes(F, NewF); - if (NewF.getBasicBlockList().size() > 0) { + if (NewF.size() > 0) { for (auto ArgPair : llvm::zip(F.args(), NewF.args())) replaceAllUsesWith(std::get<0>(ArgPair), std::get<1>(ArgPair), NewF); if (NewF.getReturnType() != F.getReturnType())