From: Chuanbo Weng Date: Fri, 3 May 2013 15:56:24 +0000 (+0800) Subject: Fix compile error when use llvm-3.1 and InstVisitor.h path for llvm-3.3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e22bbe82133ad3c2c21a6cfa6407fe235c4bf18;p=contrib%2Fbeignet.git Fix compile error when use llvm-3.1 and InstVisitor.h path for llvm-3.3 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 --- diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index 637e7be..f04a6ba 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -102,13 +102,15 @@ #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, diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp index 1a7a658..40c0e62 100644 --- a/backend/src/llvm/llvm_passes.cpp +++ b/backend/src/llvm/llvm_passes.cpp @@ -61,13 +61,15 @@ #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"