#include "util/algorithm.hpp"
+#include <llvm/IR/LLVMContext.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Support/FormattedStream.h>
#endif
+#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CodeGenOptions.h>
#include <clang/Frontend/CompilerInstance.h>
typedef ::llvm::TargetLibraryInfo target_library_info;
#endif
+#if HAVE_LLVM >= 0x0500
+ const auto lang_as_offset = 0;
+ const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
+#else
+ const auto lang_as_offset = clang::LangAS::Offset;
+ const clang::InputKind ik_opencl = clang::IK_OpenCL;
+#endif
+
inline void
set_lang_defaults(clang::CompilerInvocation &inv,
clang::LangOptions &lopts, clang::InputKind ik,
inline void
add_link_bitcode_file(clang::CodeGenOptions &opts,
const std::string &path) {
-#if HAVE_LLVM >= 0x0308
+#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);
+#elif HAVE_LLVM >= 0x0308
opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
#else
opts.LinkBitcodeFile = path;
#endif
}
- inline std::unique_ptr<::llvm::Linker>
+ inline std::unique_ptr< ::llvm::Linker>
create_linker(::llvm::Module &mod) {
#if HAVE_LLVM >= 0x0308
- return std::unique_ptr<::llvm::Linker>(new ::llvm::Linker(mod));
+ return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker(mod));
#else
- return std::unique_ptr<::llvm::Linker>(new ::llvm::Linker(&mod));
+ return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker(&mod));
#endif
}
inline bool
link_in_module(::llvm::Linker &linker,
- std::unique_ptr<::llvm::Module> mod) {
+ std::unique_ptr< ::llvm::Module> mod) {
#if HAVE_LLVM >= 0x0308
return linker.linkInModule(std::move(mod));
#else
#endif
}
+#if HAVE_LLVM >= 0x0600
+ const auto default_code_model = ::llvm::None;
+#else
+ const auto default_code_model = ::llvm::CodeModel::Default;
+#endif
+
#if HAVE_LLVM >= 0x0309
const auto default_reloc_model = ::llvm::None;
#else
f(mod.getError().message());
#endif
}
+
+ template<typename T> void
+ set_diagnostic_handler(::llvm::LLVMContext &ctx,
+ T *diagnostic_handler, void *data) {
+#if HAVE_LLVM >= 0x0600
+ ctx.setDiagnosticHandlerCallBack(diagnostic_handler, data);
+#else
+ ctx.setDiagnosticHandler(diagnostic_handler, data);
+#endif
+ }
}
}
}