changeset 17170:36fd98b9ce48

Add support for llvm 3.3 * configure.ac: Add check for LLVM IR directory. * jit-ir.cc: Update includes. * jit-util.h: Define HAVE_LLVM_DATALAYOUT. * jit-typeinfo.cc: Update includes. * pt-jit.cc: Update includes. * acinclude.m4: Update checks for llvm 3.3
author Max Brister <max@2bass.com>
date Sat, 03 Aug 2013 16:53:46 -0600
parents 4b834dbe4b3e
children bb60b1bb47cf
files configure.ac libinterp/corefcn/jit-ir.cc libinterp/corefcn/jit-typeinfo.cc libinterp/corefcn/jit-util.cc libinterp/corefcn/jit-util.h libinterp/corefcn/pt-jit.cc m4/acinclude.m4
diffstat 7 files changed, 108 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac
+++ b/configure.ac
@@ -712,7 +712,7 @@
   AC_DEFINE(HAVE_ZLIB, 1, [Define to 1 if ZLIB is available.])
 fi
 
-### Check for the LLVM library
+ ### Check for the LLVM library
 
 build_jit=no
 AC_ARG_ENABLE([jit],
@@ -766,6 +766,7 @@
     AC_CHECK_HEADER([llvm/Support/TargetSelect.h], [
       warn_llvm=
       XTRA_CXXFLAGS="$XTRA_CXXFLAGS $LLVM_CXXFLAGS $LLVM_CPPFLAGS"])
+    OCTAVE_LLVM_IR_DIR
     OCTAVE_LLVM_IRBUILDER_HEADER
     OCTAVE_LLVM_DATALAYOUT_HEADER
     OCTAVE_LLVM_FUNCTION_ADDATTRIBUTE_API
--- a/libinterp/corefcn/jit-ir.cc
+++ b/libinterp/corefcn/jit-ir.cc
@@ -34,8 +34,13 @@
 
 #include "jit-ir.h"
 
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+#include <llvm/IR/BasicBlock.h>
+#include <llvm/IR/Instructions.h>
+#else
 #include <llvm/BasicBlock.h>
 #include <llvm/Instructions.h>
+#endif
 
 #include "error.h"
 
--- a/libinterp/corefcn/jit-typeinfo.cc
+++ b/libinterp/corefcn/jit-typeinfo.cc
@@ -35,17 +35,30 @@
 #include "jit-typeinfo.h"
 
 #include <llvm/Analysis/Verifier.h>
+#include <llvm/ExecutionEngine/ExecutionEngine.h>
+
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+#include <llvm/IR/GlobalVariable.h>
+#include <llvm/IR/LLVMContext.h>
+#include <llvm/IR/Function.h>
+#include <llvm/IR/Instructions.h>
+#include <llvm/IR/Intrinsics.h>
+#else
 #include <llvm/GlobalVariable.h>
-#include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/LLVMContext.h>
 #include <llvm/Function.h>
 #include <llvm/Instructions.h>
 #include <llvm/Intrinsics.h>
-#ifdef IRBUILDER_HEADER_IN_SUPPORT_DIR
+#endif
+
+#ifdef HAVE_LLVM_SUPPORT_IRBUILDER_H
 #include <llvm/Support/IRBuilder.h>
+#elif defined(HAVE_LLVM_IR_IRBUILDER_H)
+#include <llvm/IR/IRBuilder.h>
 #else
 #include <llvm/IRBuilder.h>
 #endif
+
 #include <llvm/Support/raw_os_ostream.h>
 
 #include "jit-ir.h"
--- a/libinterp/corefcn/jit-util.cc
+++ b/libinterp/corefcn/jit-util.cc
@@ -32,7 +32,12 @@
 
 #ifdef HAVE_LLVM
 
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+#include <llvm/IR/Value.h>
+#else
 #include <llvm/Value.h>
+#endif
+
 #include <llvm/Support/raw_os_ostream.h>
 
 std::ostream&
--- a/libinterp/corefcn/jit-util.h
+++ b/libinterp/corefcn/jit-util.h
@@ -31,6 +31,10 @@
 
 #include <stdexcept>
 
+#if defined(HAVE_LLVM_IR_DATALAYOUT_H) || defined(HAVE_LLVM_DATALAYOUT_H)
+#define HAVE_LLVM_DATALAYOUT
+#endif
+
 // we don't want to include llvm headers here, as they require
 // __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS be defined in the entire
 // compilation unit
--- a/libinterp/corefcn/pt-jit.cc
+++ b/libinterp/corefcn/pt-jit.cc
@@ -50,23 +50,37 @@
 #include <llvm/Analysis/Passes.h>
 #include <llvm/Analysis/Verifier.h>
 #include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/LLVMContext.h>
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/ExecutionEngine/JIT.h>
+#include <llvm/PassManager.h>
+
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+#include <llvm/IR/LLVMContext.h>
+#include <llvm/IR/Module.h>
+#else
+#include <llvm/LLVMContext.h>
 #include <llvm/Module.h>
-#include <llvm/PassManager.h>
-#ifdef IRBUILDER_HEADER_IN_SUPPORT_DIR
+#endif
+
+#ifdef HAVE_LLVM_SUPPORT_IRBUILDER_H
 #include <llvm/Support/IRBuilder.h>
+#elif defined(HAVE_LLVM_IR_IRBUILDER_H)
+#include <llvm/IR/IRBuilder.h>
 #else
 #include <llvm/IRBuilder.h>
 #endif
+
 #include <llvm/Support/raw_os_ostream.h>
 #include <llvm/Support/TargetSelect.h>
-#ifdef HAVE_DATALAYOUT
+
+#ifdef HAVE_LLVM_IR_DATALAYOUT_H
+#include <llvm/IR/DataLayout.h>
+#elif defined(HAVE_LLVM_DATALAYOUT_H)
 #include <llvm/DataLayout.h>
 #else
 #include <llvm/Target/TargetData.h>
 #endif
+
 #include <llvm/Transforms/IPO.h>
 #include <llvm/Transforms/Scalar.h>
 
@@ -1872,7 +1886,7 @@
   module_pass_manager->add (llvm::createAlwaysInlinerPass ());
 
   pass_manager = new llvm::FunctionPassManager (module);
-#if HAVE_DATALAYOUT
+#ifdef HAVE_LLVM_DATALAYOUT
   pass_manager->add (new llvm::DataLayout (*engine->getDataLayout ()));
 #else
   pass_manager->add (new llvm::TargetData (*engine->getTargetData ()));
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -1431,11 +1431,15 @@
     [octave_cv_callinst_addattribute_arg_is_attributes],
     [AC_LANG_PUSH(C++)
       AC_COMPILE_IFELSE(
-        [AC_LANG_PROGRAM([[
+        [AC_LANG_PROGRAM([
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+          #include <llvm/IR/Instructions.h>
+          #include <llvm/IR/Attributes.h>
+#else
           #include <llvm/Instructions.h>
           #include <llvm/Attributes.h>
-          #include <llvm/LLVMContext.h>
-          ]], [[
+#endif
+          ], [[
           llvm::CallInst *callinst;
           llvm::AttrBuilder attr_builder;
           attr_builder.addAttribute(llvm::Attributes::StructRet);
@@ -1455,8 +1459,13 @@
       [AC_LANG_PUSH(C++)
         AC_COMPILE_IFELSE(
           [AC_LANG_PROGRAM([[
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+            #include <llvm/IR/Instructions.h>
+            #include <llvm/IR/Attributes.h>
+#else
             #include <llvm/Instructions.h>
             #include <llvm/Attributes.h>
+#endif
             ]], [[
             llvm::CallInst *callinst;
             callinst->addAttribute (1, llvm::Attribute::StructRet);
@@ -1474,16 +1483,13 @@
 dnl Detect TargetData.h or DataLayout.h.
 dnl
 AC_DEFUN([OCTAVE_LLVM_DATALAYOUT_HEADER], [
-  AC_CHECK_HEADER([llvm/DataLayout.h], [
-    octave_is_datalayout_header=yes], [
-    AC_CHECK_HEADER([llvm/Target/TargetData.h], [
-      octave_is_datalayout_header=no], [
-      AC_MSG_ERROR([DataLayout.h or Target/TargetData.h is required.])
-    ])
+  OCTAVE_LLVM_DATALAYOUT_HEADER_FOUND=no
+  AC_CHECK_HEADERS([llvm/Target/TargetData.h llvm/IR/DataLayout.h llvm/DataLayout.h], [
+    OCTAVE_LLVM_DATALAYOUT_HEADER_FOUND=yes
+    break
   ])
-  if test $octave_is_datalayout_header = yes; then
-    AC_DEFINE(HAVE_DATALAYOUT, 1,
-      [Define to 1 if DataLayout.h exist.])
+  if test OCTAVE_LLVM_DATALAYOUT_HEADER_FOUND = no; then
+    AC_MSG_ERROR([DataLayout.h or TargetLayout.h is required.])
   fi
 ])
 dnl
@@ -1495,9 +1501,15 @@
     [AC_LANG_PUSH(C++)
       AC_COMPILE_IFELSE(
         [AC_LANG_PROGRAM([[
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+          #include <llvm/IR/Function.h>
+          #include <llvm/IR/Attributes.h>
+          #include <llvm/IR/LLVMContext.h>
+#else
           #include <llvm/Function.h>
           #include <llvm/Attributes.h>
           #include <llvm/LLVMContext.h>
+#endif
           ]], [[
           llvm::Function *llvm_function;
           llvm::AttrBuilder attr_builder;
@@ -1518,8 +1530,13 @@
       [AC_LANG_PUSH(C++)
         AC_COMPILE_IFELSE(
           [AC_LANG_PROGRAM([[
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+            #include <llvm/IR/Function.h>
+            #include <llvm/IR/Attributes.h>
+#else
             #include <llvm/Function.h>
             #include <llvm/Attributes.h>
+#endif
             ]], [[
             llvm::Function *llvm_function;
             llvm_function->addAttribute (1, llvm::Attribute::StructRet);
@@ -1542,8 +1559,13 @@
     [AC_LANG_PUSH(C++)
       AC_COMPILE_IFELSE(
         [AC_LANG_PROGRAM([[
+#ifdef LLVM_HAVE_IR_FUNCTION_H
           #include <llvm/Function.h>
           #include <llvm/Attributes.h>
+#else
+          #include <llvm/Function.h>
+          #include <llvm/Attributes.h>
+#endif
           ]], [[
           llvm::Function *llvm_function;
           llvm_function->addFnAttr (llvm::Attributes::AlwaysInline);
@@ -1561,8 +1583,13 @@
       [AC_LANG_PUSH(C++)
         AC_COMPILE_IFELSE(
           [AC_LANG_PROGRAM([[
+#ifdef HAVE_LLVM_IR_FUNCTION_H
+            #include <llvm/IR/Function.h>
+            #include <llvm/IR/Attributes.h>
+#else
             #include <llvm/Function.h>
             #include <llvm/Attributes.h>
+#endif
             ]], [[
             llvm::Function *llvm_function;
             llvm_function->addFnAttr (llvm::Attribute::AlwaysInline);
@@ -1577,19 +1604,28 @@
   fi
 ])
 dnl
-dnl Check whether IRBuilder.h is in Support directory.
+dnl Check whether IRBuilder.h is in llvm/Support, llvm/IR, or llvm directory.
 dnl
 AC_DEFUN([OCTAVE_LLVM_IRBUILDER_HEADER], [
-  AC_CHECK_HEADER([llvm/IRBuilder.h], [
-    octave_irbuilder_header_in_support_dir=no], [
-    AC_CHECK_HEADER([llvm/Support/IRBuilder.h], [
-      octave_irbuilder_header_in_support_dir=yes], [
-      AC_MSG_ERROR([IRBuilder.h is required.])
-    ])
+  OCTAVE_LLVM_IRBUILDER_HEADER_FOUND=no
+  AC_CHECK_HEADERS([llvm/Support/IRBuilder.h llvm/IR/IRBuilder.h llvm/IRBuilder.h], [
+    OCTAVE_LLVM_IRBUILDER_HEADER_FOUND=yes
+    break
   ])
-  if test $octave_irbuilder_header_in_support_dir = yes; then
-    AC_DEFINE(IRBUILDER_HEADER_IN_SUPPORT_DIR, 1,
-      [Define to 1 if IRBuilder.h in Support directory.])
+
+  if test OCTAVE_LLVM_IRBUILDER_HEADER_FOUND = no; then
+    AC_MSG_ERROR([Could not find IRBuilder.h])
+  fi
+])
+AC_DEFUN([OCTAVE_LLVM_IR_DIR], [
+  OCTAVE_LLVM_FUNCTION_FOUNDR=no
+  AC_CHECK_HEADERS([llvm/IR/Function.h llvm/Function.h], [
+    OCTAVE_LLVM_FUNCTION_FOUNDR=yes
+    break
+  ])
+
+  if test OCTAVE_LLVM_FUNCTION_FOUNDR = no; then
+    AC_MSG_ERROR([Could not find Function.h])
   fi
 ])
 dnl