[Mesa-dev] [PATCH] clover: Fix build after llvm 1dfede3122eec
Jan Vesely
jan.vesely at rutgers.edu
Fri Nov 15 07:01:50 UTC 2019
CodeGenFileType enum was moved to Support/CodeGen.h
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
Tested by building and running CLOVER_DEBUG=llvm,native clinfo using
both llvm-git (10) and llvm-9
.../state_trackers/clover/llvm/codegen/native.cpp | 10 ++++------
src/gallium/state_trackers/clover/llvm/compat.hpp | 12 ++++++++++++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
index b8ed01c7289..a9809549927 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp
@@ -105,7 +105,7 @@ namespace {
std::vector<char>
emit_code(::llvm::Module &mod, const target &target,
- TargetMachine::CodeGenFileType ft,
+ compat::CodeGenFileType ft,
std::string &r_log) {
std::string err;
auto t = ::llvm::TargetRegistry::lookupTarget(target.triple, err);
@@ -128,7 +128,7 @@ namespace {
mod.setDataLayout(tm->createDataLayout());
tm->Options.MCOptions.AsmVerbose =
- (ft == TargetMachine::CGFT_AssemblyFile);
+ (ft == compat::CGFT_AssemblyFile);
if (compat::add_passes_to_emit_file(*tm, pm, os, ft))
fail(r_log, build_error(), "TargetMachine can't emit this file");
@@ -144,8 +144,7 @@ module
clover::llvm::build_module_native(::llvm::Module &mod, const target &target,
const clang::CompilerInstance &c,
std::string &r_log) {
- const auto code = emit_code(mod, target,
- TargetMachine::CGFT_ObjectFile, r_log);
+ const auto code = emit_code(mod, target, compat::CGFT_ObjectFile, r_log);
return build_module_common(mod, code, get_symbol_offsets(code, r_log), c);
}
@@ -155,8 +154,7 @@ clover::llvm::print_module_native(const ::llvm::Module &mod,
std::string log;
try {
std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) };
- return as_string(emit_code(*cmod, target,
- TargetMachine::CGFT_AssemblyFile, log));
+ return as_string(emit_code(*cmod, target, compat::CGFT_AssemblyFile, log));
} catch (...) {
return "Couldn't output native disassembly: " + log;
}
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp b/src/gallium/state_trackers/clover/llvm/compat.hpp
index 2015fccaf8c..4b3ac860bf1 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -70,6 +70,18 @@
namespace clover {
namespace llvm {
namespace compat {
+#if LLVM_VERSION_MAJOR >= 10
+ using CodeGenFileType = ::llvm::CodeGenFileType;
+ const CodeGenFileType CGFT_AssemblyFile = CGFT_AssemblyFile;
+ const CodeGenFileType CGFT_ObjectFile = CGFT_ObjectFile;
+#else
+ using CodeGenFileType = ::llvm::TargetMachine::CodeGenFileType;
+ const CodeGenFileType CGFT_AssemblyFile =
+ ::llvm::TargetMachine::CGFT_AssemblyFile;
+ const CodeGenFileType CGFT_ObjectFile =
+ ::llvm::TargetMachine::CGFT_ObjectFile;
+#endif
+
template<typename T, typename AS>
unsigned target_address_space(const T &target, const AS lang_as) {
const auto &map = target.getAddressSpaceMap();
--
2.23.0
More information about the mesa-dev
mailing list