[Beignet] [PATCH 2/2] Change CMake to support LLVM 3.1.

Yang Rong rong.r.yang at intel.com
Wed May 22 22:48:47 PDT 2013


Also fix LLVM 3.1 build errors caused by my vector scalarize commit.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 CMake/FindLLVM.cmake                  |    4 ++--
 CMakeLists.txt                        |    2 +-
 backend/src/llvm/llvm_gen_backend.cpp |    7 ++-----
 backend/src/llvm/llvm_scalarize.cpp   |   10 ++++------
 4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake
index b320639..e76ab42 100644
--- a/CMake/FindLLVM.cmake
+++ b/CMake/FindLLVM.cmake
@@ -7,9 +7,9 @@
 # LLVM_MODULE_LIBS - list of llvm libs for working with modules.
 # LLVM_FOUND       - True if llvm found.
 if (LLVM_INSTALL_DIR)
-  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-32 llvm-config-3.2 llvm-config DOC "llvm-config executable" PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
+  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-32 llvm-config-3.2 llvm-config-31 llvm-config-3.1 llvm-config DOC "llvm-config executable" PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
 else (LLVM_INSTALL_DIR)
-  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-32 llvm-config-3.2 llvm-config DOC "llvm-config executable")
+  find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config-32 llvm-config-3.2 llvm-config-31 llvm-config-3.1 llvm-config DOC "llvm-config executable")
 endif (LLVM_INSTALL_DIR)
 
 if (LLVM_CONFIG_EXECUTABLE)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d0d291..c6a5d49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,7 @@ SET(CMAKE_C_FLAGS "-Wall -mfpmath=sse -msse2 -Wcast-align -msse2 -msse3 -mssse3
 
 # Front end stuff we need
 #INCLUDE(CMake/FindLLVM.cmake)
-Find_Package(LLVM 3.2)
+Find_Package(LLVM 3.1)
 
 # XLib
 Find_Package(X11)
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index a0946ef..3fe0cbf 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -853,11 +853,8 @@ namespace gbe
       // 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, ++argID) {
 #endif /* LLVM_VERSION_MINOR <= 1 */
+      for (; I != E; ++I, ++argID) {
         const std::string &argName = I->getName().str();
         Type *type = I->getType();
 
@@ -892,7 +889,7 @@ namespace gbe
           PointerType *pointerType = dyn_cast<PointerType>(type);
           // By value structure
 #if LLVM_VERSION_MINOR <= 1
-          if (PAL.paramHasAttr(argID, Attribute::ByVal)) {
+          if (PAL.paramHasAttr(argID+1, Attribute::ByVal)) {
 #else
           if (I->hasByValAttr()) {
 #endif /* LLVM_VERSION_MINOR <= 1 */
diff --git a/backend/src/llvm/llvm_scalarize.cpp b/backend/src/llvm/llvm_scalarize.cpp
index f7ef375..bc66549 100644
--- a/backend/src/llvm/llvm_scalarize.cpp
+++ b/backend/src/llvm/llvm_scalarize.cpp
@@ -71,7 +71,11 @@
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
+#if LLVM_VERSION_MINOR <= 1
+#include "llvm/Support/IRBuilder.h"
+#else
 #include "llvm/IRBuilder.h"
+#endif /* LLVM_VERSION_MINOR <= 1 */
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/raw_ostream.h"
@@ -730,13 +734,7 @@ namespace gbe {
 
     Function::arg_iterator I = F.arg_begin(), E = F.arg_end();
 
-#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 */
       Type *type = I->getType();
 
       if(type->isVectorTy())
-- 
1.7.9.5



More information about the Beignet mailing list