From 3b3494174daffabfdf90306652622e6fbba0c94e Mon Sep 17 00:00:00 2001 From: Aaron Watry Date: Thu, 14 Nov 2019 22:44:02 -0600 Subject: clover/llvm: fix build after llvm 10 commit 1dfede3122ee CodeGenFileType moved from ::llvm::TargetMachine in llvm/Target/TargetMachine.h to ::llvm:: in llvm/Support/CodeGen.h Signed-off-by: Aaron Watry Reviewed-by: Jan Vesely Reviewed-by: Francisco Jerez --- .../state_trackers/clover/llvm/codegen/native.cpp | 8 ++++---- src/gallium/state_trackers/clover/llvm/compat.hpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp index b8ed01c7289..52346131200 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 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"); @@ -145,7 +145,7 @@ 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); + compat::CGFT_ObjectFile, r_log); return build_module_common(mod, code, get_symbol_offsets(code, r_log), c); } @@ -156,7 +156,7 @@ clover::llvm::print_module_native(const ::llvm::Module &mod, try { std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) }; return as_string(emit_code(*cmod, target, - TargetMachine::CGFT_AssemblyFile, log)); + 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..51902739acc 100644 --- a/src/gallium/state_trackers/clover/llvm/compat.hpp +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp @@ -67,9 +67,25 @@ #include #endif +#if LLVM_VERSION_MAJOR >= 10 +#include +#endif + namespace clover { namespace llvm { namespace compat { + +#if LLVM_VERSION_MAJOR >= 10 + const auto CGFT_ObjectFile = ::llvm::CGFT_ObjectFile; + const auto CGFT_AssemblyFile = ::llvm::CGFT_AssemblyFile; + typedef ::llvm::CodeGenFileType CodeGenFileType; +#else + const auto CGFT_ObjectFile = ::llvm::TargetMachine::CGFT_ObjectFile; + const auto CGFT_AssemblyFile = + ::llvm::TargetMachine::CGFT_AssemblyFile; + typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType; +#endif + template unsigned target_address_space(const T &target, const AS lang_as) { const auto &map = target.getAddressSpaceMap(); -- cgit v1.2.3