diff --git a/src/gallium/frontends/clover/llvm/compat.hpp b/src/gallium/frontends/clover/llvm/compat.hpp index 380d16a8346..89aa0dfbf5b 100644 --- a/src/gallium/frontends/clover/llvm/compat.hpp +++ b/src/gallium/frontends/clover/llvm/compat.hpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -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 + } } } } diff --git a/src/gallium/frontends/clover/llvm/metadata.hpp b/src/gallium/frontends/clover/llvm/metadata.hpp index e3e58a32ff9..578a50c0d21 100644 --- a/src/gallium/frontends/clover/llvm/metadata.hpp +++ b/src/gallium/frontends/clover/llvm/metadata.hpp @@ -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 };