swr: Fix building with LLVM12
Updates SWR code to match recent changes in StructType and VectorType APIs Fixes: #3917 Reviewed-by: Krzysztof Raszkowski <krzysztof.raszkowski@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8041>
This commit is contained in:
parent
27097ca6b5
commit
87d7568d69
|
@ -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<FixedVectorType>(a->getType())->getNumElements()
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
#define VEC_GET_NUM_ELEMS cast<VectorType>(a->getType())->getNumElements()
|
||||
#else
|
||||
#define VEC_GET_NUM_ELEMS a->getType()->getVectorNumElements()
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
******************************************************************************/
|
||||
// clang-format off
|
||||
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
|
||||
#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<Type*> members =<% (max_type_len, max_name_len) = calc_max_len(type['members']) %>
|
||||
|
|
|
@ -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<FixedVectorType>(pTy);
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
VectorType* pVecTy = cast<VectorType>(pTy);
|
||||
#else
|
||||
auto pVecTy = pTy;
|
||||
#endif
|
||||
DataLayout DL = DataLayout(mpCurrentModule);
|
||||
uint32_t size = DL.getTypeAllocSizeInBits(pVecTy);
|
||||
uint32_t alignment = DL.getABITypeAlignment(pVecTy);
|
||||
|
|
|
@ -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<FixedVectorType>(pType);
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
VectorType* pVectorType = cast<VectorType>(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<FixedVectorType>(mask->getType());
|
||||
#else
|
||||
VectorType* pVectorType = cast<VectorType>(mask->getType());
|
||||
#endif
|
||||
SWR_ASSERT(pVectorType->getElementType() == mInt1Ty);
|
||||
uint32_t numLanes = pVectorType->getNumElements();
|
||||
#else
|
||||
|
@ -620,7 +626,11 @@ namespace SwrJit
|
|||
Constant* cB = dyn_cast<Constant>(b);
|
||||
assert(cB != nullptr);
|
||||
// number of 8 bit elements in b
|
||||
#if LLVM_VERSION_MAJOR >= 12
|
||||
uint32_t numElms = cast<FixedVectorType>(cB->getType())->getNumElements();
|
||||
#else
|
||||
uint32_t numElms = cast<VectorType>(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<FixedVectorType>(a->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t numElems = cast<VectorType>(a->getType())->getNumElements();
|
||||
#else
|
||||
uint32_t numElems = a->getType()->getVectorNumElements();
|
||||
|
|
|
@ -173,7 +173,9 @@ namespace SwrJit
|
|||
|
||||
static uint32_t getBitWidth(VectorType *pVTy)
|
||||
{
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
#if LLVM_VERSION_MAJOR >= 12
|
||||
return cast<FixedVectorType>(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 <N x i1> mask to <N x i32> x86 mask
|
||||
Value* VectorMask(Value* vi1Mask)
|
||||
{
|
||||
#if LLVM_VERSION_MAJOR >= 11
|
||||
#if LLVM_VERSION_MAJOR >= 12
|
||||
uint32_t numElem = cast<FixedVectorType>(vi1Mask->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t numElem = cast<VectorType>(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<FixedVectorType>(v32A->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t numElem = cast<VectorType>(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<FixedVectorType>(vSrc->getType());
|
||||
#else
|
||||
VectorType* pVectorType = cast<VectorType>(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<FixedVectorType>(vSrc->getType())->getElementType() == B->mDoubleTy)
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
if (cast<VectorType>(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<FixedVectorType>(v64Mask->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t numElem = cast<VectorType>(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<FixedVectorType>(src0->getType())->getNumElements();
|
||||
uint32_t numElemMask0 = cast<FixedVectorType>(mask0->getType())->getNumElements();
|
||||
uint32_t numElemSrc1 = cast<FixedVectorType>(src1->getType())->getNumElements();
|
||||
uint32_t numElemMask1 = cast<FixedVectorType>(mask1->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t numElemSrc0 = cast<VectorType>(src0->getType())->getNumElements();
|
||||
uint32_t numElemMask0 = cast<VectorType>(mask0->getType())->getNumElements();
|
||||
uint32_t numElemSrc1 = cast<VectorType>(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<FixedVectorType>(argType)->getNumElements();
|
||||
auto elemTy = cast<FixedVectorType>(argType)->getElementType();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
uint32_t vecWidth = cast<VectorType>(argType)->getNumElements();
|
||||
auto elemTy = cast<VectorType>(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<FixedVectorType>(result[0]->getType())->getNumElements() +
|
||||
cast<FixedVectorType>(result[1]->getType())->getNumElements();
|
||||
#elif LLVM_VERSION_MAJOR >= 11
|
||||
vecWidth = cast<VectorType>(result[0]->getType())->getNumElements() +
|
||||
cast<VectorType>(result[1]->getType())->getNumElements();
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue