Fix compile error when use llvm-3.1 and InstVisitor.h path for llvm-3.3
authorChuanbo Weng <chuanbo.weng@intel.com>
Fri, 3 May 2013 15:56:24 +0000 (23:56 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Tue, 7 May 2013 06:50:27 +0000 (14:50 +0800)
DataLayout.h only exist in llvm-3.2. InstVisitor.h is also contained
in 'llvm/Support/InstVisitor.h' directory in llvm-3.0, 3.1 and 3.2,
but is contained in 'llvm/InstVisitor.h'. argID and PAL is needed in
llvm-3.1. After applying this patch, beignet can build successfully
and all test cases can run successfully using llvm-3.1.

Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/llvm/llvm_gen_backend.cpp
backend/src/llvm/llvm_passes.cpp

index 637e7be..f04a6ba 100644 (file)
 #if !defined(LLVM_VERSION_MAJOR) || (LLVM_VERSION_MINOR == 1)
 #include "llvm/Target/TargetData.h"
 #endif
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 2)
 #include "llvm/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
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR <= 2)
 #include "llvm/Support/InstVisitor.h"
 #else
 #include "llvm/InstVisitor.h"
@@ -869,7 +871,13 @@ namespace gbe
       Function::arg_iterator I = F.arg_begin(), E = F.arg_end();
 
       // Insert a new register for each function argument
+#if LLVM_VERSION_MINOR <= 1
+      const AttrListPtr &PAL = F.getAttributes();
+      uint32_t argID = 1; // Start at one actually
+      for (; I != E; ++I, ++argID) {
+#else
       for (; I != E; ++I) {
+#endif /* LLVM_VERSION_MINOR <= 1 */
         const std::string &argName = I->getName().str();
         Type *type = I->getType();
         GBE_ASSERTM(isScalarType(type) == true,
index 1a7a658..40c0e62 100644 (file)
 #if !defined(LLVM_VERSION_MAJOR) || (LLVM_VERSION_MINOR == 1)
 #include "llvm/Target/TargetData.h"
 #endif
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 2)
 #include "llvm/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
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR <= 2)
 #include "llvm/Support/InstVisitor.h"
 #else
 #include "llvm/InstVisitor.h"