浏览代码

gcc: Update compatibility layer for GCC 4.5.

* gcc-plugin/src/starpu-gcc-config.h.in (HAVE_DECL_BUILD_ZERO_CST): New
  macro.

* gcc-plugin/src/starpu.c (build_zero_cst)[!HAVE_DECL_BUILD_ZERO_CST]:
  New function.
  (VEC_qsort): New macro.
  (handle_pragma_register): Check whether `DECL_READ_P' is defined
  before using it.

* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Check for `build_zero_cst'.
Ludovic Courtès 13 年之前
父节点
当前提交
65746184a0
共有 3 个文件被更改,包括 36 次插入1 次删除
  1. 2 0
      gcc-plugin/src/starpu-gcc-config.h.in
  2. 32 0
      gcc-plugin/src/starpu.c
  3. 2 1
      m4/gcc.m4

+ 2 - 0
gcc-plugin/src/starpu-gcc-config.h.in

@@ -24,6 +24,8 @@
 
 #undef HAVE_DECL_BUILD_ARRAY_REF
 
+#undef HAVE_DECL_BUILD_ZERO_CST
+
 #undef HAVE_C_FAMILY_C_COMMON_H
 #undef HAVE_C_COMMON_H
 

+ 32 - 0
gcc-plugin/src/starpu.c

@@ -134,6 +134,34 @@ build_call_expr_loc_vec (location_t loc, tree fndecl, VEC(tree,gc) *vec)
 
 #endif
 
+#if !HAVE_DECL_BUILD_ZERO_CST
+
+static tree
+build_zero_cst (tree type)
+{
+  switch (TREE_CODE (type))
+    {
+    case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
+    case POINTER_TYPE: case REFERENCE_TYPE:
+    case OFFSET_TYPE:
+      return build_int_cst (type, 0);
+
+    default:
+      abort ();
+    }
+}
+
+#endif
+
+#ifndef VEC_qsort
+
+/* This macro is missing in GCC 4.5.  */
+
+# define VEC_qsort(T,V,CMP) qsort(VEC_address (T,V), VEC_length(T,V),	\
+				  sizeof (T), CMP)
+
+#endif
+
 
 /* Helpers.  */
 
@@ -510,8 +538,10 @@ handle_pragma_register (struct cpp_reader *reader)
     }
 
   TREE_USED (ptr) = true;
+#ifdef DECL_READ_P
   if (DECL_P (ptr))
     DECL_READ_P (ptr) = true;
+#endif
 
   if (TREE_CODE (TREE_TYPE (ptr)) == ARRAY_TYPE
       && !DECL_EXTERNAL (ptr)
@@ -570,8 +600,10 @@ handle_pragma_register (struct cpp_reader *reader)
   else
     {
       TREE_USED (count_arg) = true;
+#ifdef DECL_READ_P
       if (DECL_P (count_arg))
 	DECL_READ_P (count_arg) = true;
+#endif
 
       if (count != NULL_TREE)
 	{

+ 2 - 1
m4/gcc.m4

@@ -63,9 +63,10 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
     dnl   build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
     dnl   build_call_expr_loc_vec   -- likewise
     dnl   build_array_ref           -- present but undeclared in 4.6.1
+    dnl   build_zero_cst            -- not in GCC 4.5.x; appears in 4.6
     _STARPU_WITH_GCC_PLUGIN_API([
       AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
-                      build_array_ref],
+                      build_array_ref, build_zero_cst],
         [], [], [#include <gcc-plugin.h>
 	         #include <tree.h>])