clover: add missing include to compat.h
[mesa.git] / src / gallium / state_trackers / clover / llvm / compat.hpp
index 81592ce7021762892ac1f9e1c134e8785d324970..f8b56516d5c541b974facf6bcc2d06eb2461846e 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "util/algorithm.hpp"
 
+#include <llvm/IR/LLVMContext.h>
 #include <llvm/Linker/Linker.h>
 #include <llvm/Transforms/IPO.h>
 #include <llvm/Target/TargetMachine.h>
@@ -55,6 +56,7 @@
 #include <llvm/Support/FormattedStream.h>
 #endif
 
+#include <clang/Basic/TargetInfo.h>
 #include <clang/Frontend/CodeGenOptions.h>
 #include <clang/Frontend/CompilerInstance.h>
 
@@ -67,6 +69,14 @@ namespace clover {
          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,
@@ -83,7 +93,14 @@ namespace clover {
          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;
@@ -118,18 +135,18 @@ namespace clover {
 #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
@@ -158,6 +175,12 @@ namespace clover {
 #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
@@ -176,6 +199,16 @@ namespace clover {
                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
+        }
       }
    }
 }