#include "util/algorithm.hpp"
-#if HAVE_LLVM < 0x0400
+#include <llvm/Config/llvm-config.h>
+#if LLVM_VERSION_MAJOR < 4
#include <llvm/Bitcode/ReaderWriter.h>
#else
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Target/TargetMachine.h>
-#if HAVE_LLVM >= 0x0400
+#if LLVM_VERSION_MAJOR >= 4
#include <llvm/Support/Error.h>
#else
#include <llvm/Support/ErrorOr.h>
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
-#if HAVE_LLVM >= 0x0800
+#if LLVM_VERSION_MAJOR >= 8
#include <clang/Basic/CodeGenOptions.h>
#else
#include <clang/Frontend/CodeGenOptions.h>
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
+#if LLVM_VERSION_MAJOR >= 5
return map[static_cast<unsigned>(lang_as)];
#else
return map[lang_as - clang::LangAS::Offset];
#endif
}
-#if HAVE_LLVM >= 0x1000
+#if LLVM_VERSION_MAJOR >= 10
const clang::InputKind ik_opencl = clang::Language::OpenCL;
-#elif HAVE_LLVM >= 0x0500
+#elif LLVM_VERSION_MAJOR >= 5
const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
#else
const clang::InputKind ik_opencl = clang::IK_OpenCL;
#endif
-#if HAVE_LLVM >= 0x0500
+#if LLVM_VERSION_MAJOR >= 5
const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl10;
#else
const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl;
inline void
add_link_bitcode_file(clang::CodeGenOptions &opts,
const std::string &path) {
-#if HAVE_LLVM >= 0x0500
+#if LLVM_VERSION_MAJOR >= 5
clang::CodeGenOptions::BitcodeFileToLink F;
F.Filename = path;
#endif
}
-#if HAVE_LLVM >= 0x0600
+#if LLVM_VERSION_MAJOR >= 6
const auto default_code_model = ::llvm::None;
#else
const auto default_code_model = ::llvm::CodeModel::Default;
template<typename M, typename F> void
handle_module_error(M &mod, const F &f) {
-#if HAVE_LLVM >= 0x0400
+#if LLVM_VERSION_MAJOR >= 4
if (::llvm::Error err = mod.takeError())
::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
f(eib.message());
template<typename T> void
set_diagnostic_handler(::llvm::LLVMContext &ctx,
T *diagnostic_handler, void *data) {
-#if HAVE_LLVM >= 0x0600
+#if LLVM_VERSION_MAJOR >= 6
ctx.setDiagnosticHandlerCallBack(diagnostic_handler, data);
#else
ctx.setDiagnosticHandler(diagnostic_handler, data);
inline std::unique_ptr< ::llvm::Module>
clone_module(const ::llvm::Module &mod)
{
-#if HAVE_LLVM >= 0x0700
+#if LLVM_VERSION_MAJOR >= 7
return ::llvm::CloneModule(mod);
#else
return ::llvm::CloneModule(&mod);
template<typename T> void
write_bitcode_to_file(const ::llvm::Module &mod, T &os)
{
-#if HAVE_LLVM >= 0x0700
+#if LLVM_VERSION_MAJOR >= 7
::llvm::WriteBitcodeToFile(mod, os);
#else
::llvm::WriteBitcodeToFile(&mod, os);
template<typename TM, typename PM, typename OS, typename FT>
bool add_passes_to_emit_file(TM &tm, PM &pm, OS &os, FT &ft)
{
-#if HAVE_LLVM >= 0x0700
+#if LLVM_VERSION_MAJOR >= 7
return tm.addPassesToEmitFile(pm, os, nullptr, ft);
#else
return tm.addPassesToEmitFile(pm, os, ft);
T copts,
clang::DiagnosticsEngine &diag)
{
-#if HAVE_LLVM >= 0x1000
+#if LLVM_VERSION_MAJOR >= 10
return clang::CompilerInvocation::CreateFromArgs(
cinv, copts, diag);
#else
template<typename T, typename M>
T get_abi_type(const T &arg_type, const M &mod) {
-#if HAVE_LLVM >= 0x0700
+#if LLVM_VERSION_MAJOR >= 7
return arg_type;
#else
::llvm::DataLayout dl(&mod);