[Mesa-dev] [PATCH 12/12] clover: remove pre LLVM 5.0 codepaths
Emil Velikov
emil.l.velikov at gmail.com
Wed Oct 31 13:30:04 UTC 2018
From: Emil Velikov <emil.velikov at collabora.com>
LLVM versions earlier than 5.0.1 are no longer supported.
Cc: Jan Vesely <jan.vesely at rutgers.edu>
Cc: Francisco Jerez <currojerez at riseup.net>
Cc: Aaron Watry <awatry at gmail.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
I guess some of compat.hpp can be cleaned-up, but I'd suggest sticking
with that as a follow-up.
---
.../clover/llvm/codegen/bitcode.cpp | 4 ---
.../state_trackers/clover/llvm/compat.hpp | 26 ----------------
.../state_trackers/clover/llvm/metadata.hpp | 30 -------------------
3 files changed, 60 deletions(-)
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
index 40bb426218d..b67afb34542 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
@@ -38,12 +38,8 @@
#include "util/algorithm.hpp"
#include <map>
-#if HAVE_LLVM < 0x0400
-#include <llvm/Bitcode/ReaderWriter.h>
-#else
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Bitcode/BitcodeWriter.h>
-#endif
#include <llvm/Support/raw_ostream.h>
using namespace clover;
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp b/src/gallium/state_trackers/clover/llvm/compat.hpp
index 975012cbda4..5f526ec155d 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -36,23 +36,15 @@
#include "util/algorithm.hpp"
-#if HAVE_LLVM < 0x0400
-#include <llvm/Bitcode/ReaderWriter.h>
-#else
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Bitcode/BitcodeWriter.h>
-#endif
#include <llvm/IR/LLVMContext.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Target/TargetMachine.h>
-#if HAVE_LLVM >= 0x0400
#include <llvm/Support/Error.h>
-#else
-#include <llvm/Support/ErrorOr.h>
-#endif
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
@@ -67,34 +59,21 @@ namespace clover {
template<typename T, typename AS>
unsigned target_address_space(const T &target, const AS lang_as) {
const auto &map = target.getAddressSpaceMap();
-#if HAVE_LLVM >= 0x0500
return map[static_cast<unsigned>(lang_as)];
-#else
- return map[lang_as - clang::LangAS::Offset];
-#endif
}
-#if HAVE_LLVM >= 0x0500
const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl10;
-#else
- const clang::InputKind ik_opencl = clang::IK_OpenCL;
- const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl;
-#endif
inline void
add_link_bitcode_file(clang::CodeGenOptions &opts,
const std::string &path) {
-#if HAVE_LLVM >= 0x0500
clang::CodeGenOptions::BitcodeFileToLink F;
F.Filename = path;
F.PropagateAttrs = true;
F.LinkFlags = ::llvm::Linker::Flags::None;
opts.LinkBitcodeFiles.emplace_back(F);
-#else
- opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
-#endif
}
#if HAVE_LLVM >= 0x0600
@@ -105,15 +84,10 @@ namespace clover {
template<typename M, typename F> void
handle_module_error(M &mod, const F &f) {
-#if HAVE_LLVM >= 0x0400
if (::llvm::Error err = mod.takeError())
::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
f(eib.message());
});
-#else
- if (!mod)
- f(mod.getError().message());
-#endif
}
template<typename T> void
diff --git a/src/gallium/state_trackers/clover/llvm/metadata.hpp b/src/gallium/state_trackers/clover/llvm/metadata.hpp
index 825008d4974..f020e85e915 100644
--- a/src/gallium/state_trackers/clover/llvm/metadata.hpp
+++ b/src/gallium/state_trackers/clover/llvm/metadata.hpp
@@ -57,44 +57,14 @@ namespace clover {
inline bool
is_kernel(const ::llvm::Function &f) {
-#if HAVE_LLVM >= 0x0309
return f.getMetadata("kernel_arg_type");
-#else
- return clover::any_of(is_kernel_node_for(f),
- get_kernel_nodes(*f.getParent()));
-#endif
}
inline iterator_range< ::llvm::MDNode::op_iterator>
get_kernel_metadata_operands(const ::llvm::Function &f,
const std::string &name) {
-#if HAVE_LLVM >= 0x0309
- // On LLVM v3.9+ kernel argument attributes are stored as
- // function metadata.
const auto data_node = f.getMetadata(name);
return range(data_node->op_begin(), data_node->op_end());
-#else
- using ::llvm::cast;
- using ::llvm::dyn_cast;
- const auto kernel_node = find(is_kernel_node_for(f),
- get_kernel_nodes(*f.getParent()));
-
- const auto data_node = cast< ::llvm::MDNode>(
- find([&](const ::llvm::MDOperand &op) {
- if (auto m = dyn_cast< ::llvm::MDNode>(op))
- if (m->getNumOperands())
- if (auto m_name = dyn_cast< ::llvm::MDString>(
- m->getOperand(0).get()))
- return m_name->getString() == name;
-
- return false;
- },
- kernel_node->operands()));
-
- // Skip the first operand node which is just the metadata
- // attribute name.
- return range(data_node->op_begin() + 1, data_node->op_end());
-#endif
}
}
--
2.19.1
More information about the mesa-dev
mailing list