clover/llvm: handle Fixed vs Scalable vectors explicitly starting with llvm-11

This fixes compilation with llvm-13.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4200
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9973>
This commit is contained in:
Karol Herbst
2021-04-01 12:47:05 +02:00
committed by Marge Bot
parent 917049e7d6
commit f945cca983
2 changed files with 35 additions and 2 deletions
@@ -42,6 +42,7 @@
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Type.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/IPO.h>
@@ -103,6 +104,36 @@ namespace clover {
#endif
d);
}
static inline bool
is_scalable_vector(const ::llvm::Type *type)
{
#if LLVM_VERSION_MAJOR >= 11
return ::llvm::isa<::llvm::ScalableVectorType>(type);
#else
return false;
#endif
}
static inline bool
is_fixed_vector(const ::llvm::Type *type)
{
#if LLVM_VERSION_MAJOR >= 11
return ::llvm::isa<::llvm::FixedVectorType>(type);
#else
return type->isVectorTy();
#endif
}
static inline unsigned
get_fixed_vector_elements(const ::llvm::Type *type)
{
#if LLVM_VERSION_MAJOR >= 11
return ::llvm::cast<::llvm::FixedVectorType>(type)->getNumElements();
#else
return ((::llvm::VectorType*)type)->getNumElements();
#endif
}
}
}
}
@@ -128,8 +128,10 @@ namespace clover {
data += "long";
break;
}
if (type->isVectorTy())
data += std::to_string(((::llvm::VectorType*)type)->getNumElements());
if (compat::is_scalable_vector(type))
throw build_error("hit unexpected scalable vector");
if (compat::is_fixed_vector(type))
data += std::to_string(compat::get_fixed_vector_elements(type));
} else {
::llvm::raw_string_ostream os { data };