From: jzielins Date: Thu, 10 Dec 2020 16:55:35 +0000 (+0100) Subject: swr: Fix building with LLVM12 X-Git-Tag: upstream/21.0.0~1353 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87d7568d69199d1fa16858b45521764d31815aa9;p=platform%2Fupstream%2Fmesa.git swr: Fix building with LLVM12 Updates SWR code to match recent changes in StructType and VectorType APIs Fixes: #3917 Reviewed-by: Krzysztof Raszkowski Part-of: --- diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp index d785887..da1ca87 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_builder.hpp @@ -46,7 +46,9 @@ ${func['decl']} %for arg in func['args']: argTypes.push_back(${arg}->getType()); %endfor -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + #define VEC_GET_NUM_ELEMS cast(a->getType())->getNumElements() +#elif LLVM_VERSION_MAJOR >= 11 #define VEC_GET_NUM_ELEMS cast(a->getType())->getNumElements() #else #define VEC_GET_NUM_ELEMS a->getType()->getVectorNumElements() diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp index df2934f..99a3f30 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp +++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_llvm.hpp @@ -32,6 +32,8 @@ ******************************************************************************/ // clang-format off +#include + #pragma once namespace SwrJit @@ -45,7 +47,11 @@ namespace SwrJit LLVMContext& ctx = pJitMgr->mContext; %endif +#if LLVM_VERSION_MAJOR >= 12 + StructType* pRetType = StructType::getTypeByName(pJitMgr->mContext, "${type['name']}"); +#else StructType* pRetType = pJitMgr->mpCurrentModule->getTypeByName("${type['name']}"); +#endif if (pRetType == nullptr) { std::vector members =<% (max_type_len, max_name_len) = calc_max_len(type['members']) %> diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp index 7b86899..4448293 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp @@ -381,7 +381,13 @@ DIType* JitManager::GetDebugIntegerType(Type* pTy) DIType* JitManager::GetDebugVectorType(Type* pTy) { DIBuilder builder(*mpCurrentModule); +#if LLVM_VERSION_MAJOR >= 12 + FixedVectorType* pVecTy = cast(pTy); +#elif LLVM_VERSION_MAJOR >= 11 VectorType* pVecTy = cast(pTy); +#else + auto pVecTy = pTy; +#endif DataLayout DL = DataLayout(mpCurrentModule); uint32_t size = DL.getTypeAllocSizeInBits(pVecTy); uint32_t alignment = DL.getABITypeAlignment(pVecTy); diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp index fc5d782..f30db9a 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp @@ -392,7 +392,9 @@ namespace SwrJit if (pType->isVectorTy()) { Type* pContainedType = pType->getContainedType(0); -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + FixedVectorType* pVectorType = cast(pType); +#elif LLVM_VERSION_MAJOR >= 11 VectorType* pVectorType = cast(pType); #endif if (toupper(tempStr[pos + 1]) == 'X') @@ -575,7 +577,11 @@ namespace SwrJit Value* Builder::VMOVMSK(Value* mask) { #if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + FixedVectorType* pVectorType = cast(mask->getType()); +#else VectorType* pVectorType = cast(mask->getType()); +#endif SWR_ASSERT(pVectorType->getElementType() == mInt1Ty); uint32_t numLanes = pVectorType->getNumElements(); #else @@ -620,7 +626,11 @@ namespace SwrJit Constant* cB = dyn_cast(b); assert(cB != nullptr); // number of 8 bit elements in b +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElms = cast(cB->getType())->getNumElements(); +#else uint32_t numElms = cast(cB->getType())->getNumElements(); +#endif // output vector Value* vShuf = UndefValue::get(getVectorType(mInt8Ty, numElms)); @@ -687,7 +697,9 @@ namespace SwrJit Value* Builder::CVTPH2PS(Value* a, const llvm::Twine& name) { // Bitcast Nxint16 to Nxhalf -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElems = cast(a->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t numElems = cast(a->getType())->getNumElements(); #else uint32_t numElems = a->getType()->getVectorNumElements(); diff --git a/src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp b/src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp index 7ee2289..e5fb08b 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp @@ -173,7 +173,9 @@ namespace SwrJit static uint32_t getBitWidth(VectorType *pVTy) { -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + return cast(pVTy)->getNumElements() * pVTy->getElementType()->getPrimitiveSizeInBits(); +#elif LLVM_VERSION_MAJOR >= 11 return pVTy->getNumElements() * pVTy->getElementType()->getPrimitiveSizeInBits(); #else return pVTy->getBitWidth(); @@ -320,7 +322,9 @@ namespace SwrJit // Convert mask to x86 mask Value* VectorMask(Value* vi1Mask) { -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElem = cast(vi1Mask->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t numElem = cast(vi1Mask->getType())->getNumElements(); #else uint32_t numElem = vi1Mask->getType()->getVectorNumElements(); @@ -509,7 +513,9 @@ namespace SwrJit else { v32Result = UndefValue::get(v32A->getType()); -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElem = cast(v32A->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t numElem = cast(v32A->getType())->getNumElements(); #else uint32_t numElem = v32A->getType()->getVectorNumElements(); @@ -536,7 +542,11 @@ namespace SwrJit pBase = B->POINTER_CAST(pBase, PointerType::get(B->mInt8Ty, 0)); #if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + FixedVectorType* pVectorType = cast(vSrc->getType()); +#else VectorType* pVectorType = cast(vSrc->getType()); +#endif uint32_t numElem = pVectorType->getNumElements(); auto srcTy = pVectorType->getElementType(); #else @@ -609,14 +619,18 @@ namespace SwrJit else if (width == W512) { // Double pump 4-wide for 64bit elements -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + if (cast(vSrc->getType())->getElementType() == B->mDoubleTy) +#elif LLVM_VERSION_MAJOR >= 11 if (cast(vSrc->getType())->getElementType() == B->mDoubleTy) #else if (vSrc->getType()->getVectorElementType() == B->mDoubleTy) #endif { auto v64Mask = pThis->VectorMask(vi1Mask); -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElem = cast(v64Mask->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t numElem = cast(v64Mask->getType())->getNumElements(); #else uint32_t numElem = v64Mask->getType()->getVectorNumElements(); @@ -633,7 +647,12 @@ namespace SwrJit Value* mask0 = B->VSHUFFLE(v64Mask, v64Mask, B->C({0, 1, 2, 3})); Value* mask1 = B->VSHUFFLE(v64Mask, v64Mask, B->C({4, 5, 6, 7})); -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t numElemSrc0 = cast(src0->getType())->getNumElements(); + uint32_t numElemMask0 = cast(mask0->getType())->getNumElements(); + uint32_t numElemSrc1 = cast(src1->getType())->getNumElements(); + uint32_t numElemMask1 = cast(mask1->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t numElemSrc0 = cast(src0->getType())->getNumElements(); uint32_t numElemMask0 = cast(mask0->getType())->getNumElements(); uint32_t numElemSrc1 = cast(src1->getType())->getNumElements(); @@ -891,7 +910,10 @@ namespace SwrJit auto argType = arg.get()->getType(); if (argType->isVectorTy()) { -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + uint32_t vecWidth = cast(argType)->getNumElements(); + auto elemTy = cast(argType)->getElementType(); +#elif LLVM_VERSION_MAJOR >= 11 uint32_t vecWidth = cast(argType)->getNumElements(); auto elemTy = cast(argType)->getElementType(); #else @@ -913,7 +935,10 @@ namespace SwrJit if (result[0]->getType()->isVectorTy()) { assert(result[1]->getType()->isVectorTy()); -#if LLVM_VERSION_MAJOR >= 11 +#if LLVM_VERSION_MAJOR >= 12 + vecWidth = cast(result[0]->getType())->getNumElements() + + cast(result[1]->getType())->getNumElements(); +#elif LLVM_VERSION_MAJOR >= 11 vecWidth = cast(result[0]->getType())->getNumElements() + cast(result[1]->getType())->getNumElements(); #else