[Beignet] [PATCH] Compile against upstream LLVM 3.3

Steven Newbury steve at snewbury.org.uk
Sun Apr 21 04:27:08 PDT 2013


"LLVM_33" isn't exactly future-proof, but this is enough to build
against LLVM trunk.  Currently, it's not working at run-time possibly
due to changes to the clang frontend arguments/backend selection?  Or
perhaps it's my clang build..?  It was working for me against an earlier
clang/llvm checkout.

Signed-off-by: Steven Newbury <steve at snewbury.org.uk>

---

diff -urN beignet-9999/backend/src/llvm/llvm_gen_backend.cpp beignet-9999.bump/backend/src/llvm/llvm_gen_backend.cpp
--- beignet-9999/backend/src/llvm/llvm_gen_backend.cpp	2013-04-20 23:17:13.884556973 +0100
+++ beignet-9999.bump/backend/src/llvm/llvm_gen_backend.cpp	2013-04-21 00:03:58.097348955 +0100
@@ -71,16 +71,30 @@
  *   is intercepted, we just abort
  */
 
+#ifndef LLVM_33
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
+#else
+#include "llvm/IR/CallingConv.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Instructions.h"
+#endif
 #include "llvm/Pass.h"
 #include "llvm/PassManager.h"
+#ifndef LLVM_33
 #include "llvm/Intrinsics.h"
 #include "llvm/IntrinsicInst.h"
 #include "llvm/InlineAsm.h"
+#else
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/InlineAsm.h"
+#endif
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
@@ -102,13 +116,17 @@
 #if !defined(LLVM_VERSION_MAJOR) || (LLVM_VERSION_MINOR == 1)
 #include "llvm/Target/TargetData.h"
 #endif
+#ifndef LLVM_33
 #include "llvm/DataLayout.h"
+#else
+#include "llvm/IR/DataLayout.h"
+#endif
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
-#ifdef LLVM_32
+#ifndef LLVM_33
 #include "llvm/Support/InstVisitor.h"
 #else
 #include "llvm/InstVisitor.h"
@@ -138,9 +156,9 @@
 #define LLVM_VERSION_MINOR 0
 #endif /* !defined(LLVM_VERSION_MINOR) */
 
-#if (LLVM_VERSION_MAJOR != 3) || (LLVM_VERSION_MINOR > 2)
-#error "Only LLVM 3.0 / 3.1 is supported"
-#endif /* (LLVM_VERSION_MAJOR != 3) && (LLVM_VERSION_MINOR >= 2) */
+#if (LLVM_VERSION_MAJOR != 3) || (LLVM_VERSION_MINOR < 3)
+#error "Only LLVM 3.x (x =< 3) is supported"
+#endif /* (LLVM_VERSION_MAJOR != 3) || (LLVM_VERSION_MINOR < 3) */
 
 using namespace llvm;
 
diff -urN beignet-9999/backend/src/llvm/llvm_passes.cpp beignet-9999.bump/backend/src/llvm/llvm_passes.cpp
--- beignet-9999/backend/src/llvm/llvm_passes.cpp	2013-04-20 23:17:13.884556973 +0100
+++ beignet-9999.bump/backend/src/llvm/llvm_passes.cpp	2013-04-21 00:15:31.437973694 +0100
@@ -30,16 +30,30 @@
  * Segovia) the right to use another license for it (MIT here)
  */
 
+#ifndef LLVM_33
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
+#else
+#include "llvm/IR/CallingConv.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Instructions.h"
+#endif
 #include "llvm/Pass.h"
 #include "llvm/PassManager.h"
+#ifndef LLVM_33
 #include "llvm/Intrinsics.h"
 #include "llvm/IntrinsicInst.h"
 #include "llvm/InlineAsm.h"
+#else
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/InlineAsm.h"
+#endif
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/STLExtras.h"
@@ -61,13 +75,17 @@
 #if !defined(LLVM_VERSION_MAJOR) || (LLVM_VERSION_MINOR == 1)
 #include "llvm/Target/TargetData.h"
 #endif
+#ifndef LLVM_33
 #include "llvm/DataLayout.h"
+#else
+#include "llvm/IR/DataLayout.h"
+#endif
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
-#ifdef LLVM_32
+#ifndef LLVM_33
 #include "llvm/Support/InstVisitor.h"
 #else
 #include "llvm/InstVisitor.h"
diff -urN beignet-9999/backend/src/llvm/llvm_to_gen.cpp beignet-9999.bump/backend/src/llvm/llvm_to_gen.cpp
--- beignet-9999/backend/src/llvm/llvm_to_gen.cpp	2013-04-20 23:17:13.884556973 +0100
+++ beignet-9999.bump/backend/src/llvm/llvm_to_gen.cpp	2013-04-21 00:23:23.963170501 +0100
@@ -22,12 +22,24 @@
  * \author Benjamin Segovia <benjamin.segovia at intel.com>
  */
 
+#ifndef LLVM_33
 #include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
+#else
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#endif
 #include "llvm/PassManager.h"
 #include "llvm/Pass.h"
+#ifndef LLVM_33
 #include "llvm/Support/IRReader.h"
+#else
+#include "llvm/IRReader/IRReader.h"
+#endif
 #include "llvm/Support/raw_ostream.h"
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR > 2)
+#include "llvm/Support/SourceMgr.h"
+#endif
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Assembly/PrintModulePass.h"
 
@@ -58,7 +70,11 @@
       o = std::unique_ptr<llvm::raw_fd_ostream>(new llvm::raw_fd_ostream(fileno(stdout), false));
 
     // Get the module from its file
+#ifndef LLVM_33
     SMDiagnostic Err;
+#else
+    llvm::SMDiagnostic Err;
+#endif
     std::auto_ptr<Module> M;
     M.reset(ParseIRFile(fileName, Err, c));
     if (M.get() == 0) return false;




More information about the Beignet mailing list