Mesa (master): clover/llvm: handle Fixed vs Scalable vectors explicitly starting with llvm-11
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 15 11:49:22 UTC 2021
Module: Mesa
Branch: master
Commit: f945cca9837815fe1fb2c7eba543ee33630fc9ca
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f945cca9837815fe1fb2c7eba543ee33630fc9ca
Author: Karol Herbst <kherbst at redhat.com>
Date: Thu Apr 1 12:47:05 2021 +0200
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 at redhat.com>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9973>
---
src/gallium/frontends/clover/llvm/compat.hpp | 31 ++++++++++++++++++++++++++
src/gallium/frontends/clover/llvm/metadata.hpp | 6 +++--
2 files changed, 35 insertions(+), 2 deletions(-)
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 <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
+ }
}
}
}
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 };
More information about the mesa-commit
mailing list