builtins.c (DEF_BUILTIN): Add COND argument.
authorRichard Henderson <rth@gcc.gnu.org>
Thu, 10 Feb 2005 00:22:25 +0000 (16:22 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 10 Feb 2005 00:22:25 +0000 (16:22 -0800)
        * builtins.c (DEF_BUILTIN): Add COND argument.
        * tree.h (DEF_BUILTIN): Likewise.
        * builtins.def (DEF_GCC_BUILTIN, DEF_LIB_BUILTIN, DEF_EXT_LIB_BUILTIN,
        DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C99_C90RES_BUILTIN): Update to
        match.
        (DEF_BUILTIN_STUB): New.
        (BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_INIT_TRAMPOLINE,
        BUILT_IN_ADJUST_TRAMPOLINE, BUILT_IN_NONLOCAL_GOTO,
        BUILT_IN_PROFILE_FUNC_ENTER, BUILT_IN_PROFILE_FUNC_EXIT): Use it.
        * c-common.c (DEF_BUILTIN): Add COND argument.
        * tree.c (local_define_builtin): New.
        (build_common_builtin_nodes): New.
ada/
        * utils.c (gnat_define_builtin): Remove.
        (gnat_install_builtins): Use build_common_builtin_nodes.
fortran/
        * f95-lang.c (gfc_init_builtin_functions): Call
        build_common_builtin_nodes; do not define any functions handled
        by it.
java/
        * builtins.c (initialize_builtins): Call build_common_builtin_nodes.
        * decl.c (java_init_decl_processing): Initialize const_ptr_type_node.
treelang/
        * treetree.c (treelang_init_decl_processing): Call
        build_common_builtin_nodes.

From-SVN: r94785

15 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/utils.c
gcc/builtins.c
gcc/builtins.def
gcc/c-common.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/java/ChangeLog
gcc/java/builtins.c
gcc/java/decl.c
gcc/tree.c
gcc/tree.h
gcc/treelang/ChangeLog
gcc/treelang/treetree.c

index f9d60dfd78dfebd3457f496c415076d26247ffc0..785eae5075150588e900a6ffb0c46213c15ebc51 100644 (file)
@@ -1,3 +1,18 @@
+2005-02-09  Richard Henderson  <rth@redhat.com>
+
+       * builtins.c (DEF_BUILTIN): Add COND argument.
+       * tree.h (DEF_BUILTIN): Likewise.
+       * builtins.def (DEF_GCC_BUILTIN, DEF_LIB_BUILTIN, DEF_EXT_LIB_BUILTIN,
+       DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C99_C90RES_BUILTIN): Update to
+       match.
+       (DEF_BUILTIN_STUB): New.
+       (BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_INIT_TRAMPOLINE,
+       BUILT_IN_ADJUST_TRAMPOLINE, BUILT_IN_NONLOCAL_GOTO,
+       BUILT_IN_PROFILE_FUNC_ENTER, BUILT_IN_PROFILE_FUNC_EXIT): Use it.
+       * c-common.c (DEF_BUILTIN): Add COND argument.
+       * tree.c (local_define_builtin): New.
+       (build_common_builtin_nodes): New.
+
 2005-02-09  Roger Sayle  <roger@eyesopen.com>
 
        * fold-const.c (fold_strip_sign_ops): New function to simplify a
index a4adba5fda62c5a32e508f988dcc363ee1582a20..f6b7f6891ab7302a69f091c33e6be7ecf3d16108 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-09  Richard Henderson  <rth@redhat.com>
+
+       * utils.c (gnat_define_builtin): Remove.
+       (gnat_install_builtins): Use build_common_builtin_nodes.
+
 2005-02-09  Arnaud Charlet  <charlet@adacore.com>
 
        * a-rbtgso.adb, a-crbtgo.ads, a-crbtgo.adb, a-crbtgk.ads,
index b92fe4bd7c6f89cedbc9ea341704f3cbe40f682c..4d4fad4ecadeefd827edea1d0a966df87e46f60e 100644 (file)
@@ -118,7 +118,6 @@ struct language_function GTY(())
   int unused;
 };
 
-static void gnat_define_builtin (const char *, tree, int, const char *, bool);
 static void gnat_install_builtins (void);
 static tree merge_sizes (tree, tree, tree, bool, bool);
 static tree compute_related_constant (tree, tree);
@@ -405,110 +404,13 @@ gnat_init_decl_processing (void)
   gnat_install_builtins ();
 }
 
-/* Define a builtin function.  This is temporary and is just being done
-   to initialize *_built_in_decls for the middle-end.  We'll want
-   to do full builtin processing soon.  */
-
-static void
-gnat_define_builtin (const char *name, tree type,
-                    int function_code, const char *library_name, bool const_p)
-{
-  tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
-
-  DECL_EXTERNAL (decl) = 1;
-  TREE_PUBLIC (decl) = 1;
-  if (library_name)
-    SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
-  make_decl_rtl (decl);
-  gnat_pushdecl (decl, Empty);
-  DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL;
-  DECL_FUNCTION_CODE (decl) = function_code;
-  TREE_READONLY (decl) = const_p;
-
-  implicit_built_in_decls[function_code] = decl;
-  built_in_decls[function_code] = decl;
-}
-
 /* Install the builtin functions the middle-end needs.  */
 
 static void
 gnat_install_builtins ()
 {
-  tree ftype;
-  tree tmp;
-
-  tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
-  ftype = build_function_type (long_integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
-                      "__builtin_expect", true);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  ftype = build_function_type (ptr_void_type_node, tmp);
-  gnat_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
-                      "memcpy", false);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  ftype = build_function_type (integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
-                      "memcmp", false);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  ftype = build_function_type (integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
-                      "memset", false);
-
-  tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
-  ftype = build_function_type (integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ, "clz", true);
-
-  tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
-  ftype = build_function_type (integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL, "clzl", true);
-
-  tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
-  ftype = build_function_type (integer_type_node, tmp);
-  gnat_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL, "clzll",
-                      true);
-
-  /* The init_trampoline and adjust_trampoline builtins aren't used directly.
-     They are inserted during lowering of nested functions.  */
-
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
-  ftype = build_function_type (void_type_node, tmp);
-  gnat_define_builtin ("__builtin_init_trampoline", ftype,
-                      BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", false);
-
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
-  ftype = build_function_type (ptr_void_type_node, tmp);
-  gnat_define_builtin ("__builtin_adjust_trampoline", ftype,
-                      BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", true);
-
-  /* The stack_save, stack_restore, and alloca builtins aren't used directly.
-     They are inserted during gimplification to implement variable sized stack
-     allocation.  */
-
-  ftype = build_function_type (ptr_void_type_node, void_list_node);
-  gnat_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
-                      "stack_save", false);
-
-  tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
-  ftype = build_function_type (void_type_node, tmp);
-  gnat_define_builtin ("__builtin_stack_restore", ftype,
-                      BUILT_IN_STACK_RESTORE, "stack_restore", false);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  ftype = build_function_type (ptr_void_type_node, tmp);
-  gnat_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
-                      "alloca", false);
+  /* Builtins used by generic optimizers.  */
+  build_common_builtin_nodes ();
 
   /* Target specific builtins, such as the AltiVec family on ppc.  */
   targetm.init_builtins ();
index 56e7eb00e398b74430871d6f9a356a0876222348..432ecc64b7f28c4178a146b962d342b0c5caf7ca 100644 (file)
@@ -59,7 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 const char *const built_in_class_names[4]
   = {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"};
 
-#define DEF_BUILTIN(X, N, C, T, LT, B, F, NA, AT, IM) #X,
+#define DEF_BUILTIN(X, N, C, T, LT, B, F, NA, AT, IM, COND) #X,
 const char *const built_in_names[(int) END_BUILTINS] =
 {
 #include "builtins.def"
index 972b6a2ee83da25520650b82457fa725d02f73c7..8857a936bb98018d20ef8699cefdff71978bab86 100644 (file)
@@ -69,7 +69,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #undef DEF_GCC_BUILTIN
 #define DEF_GCC_BUILTIN(ENUM, NAME, TYPE, ATTRS)               \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, BT_LAST,        \
-               false, false, false, ATTRS, true)
+               false, false, false, ATTRS, true, true)
 
 /* A library builtin (like __builtin_strchr) is a builtin equivalent
    of an ANSI/ISO standard library function.  In addition to the
@@ -80,7 +80,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #undef DEF_LIB_BUILTIN                                 
 #define DEF_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS)       \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
-              true, true, false, ATTRS, true)
+              true, true, false, ATTRS, true, true)
 
 /* Like DEF_LIB_BUILTIN, except that the function is not one that is
    specified by ANSI/ISO C.  So, when we're being fully conformant we
@@ -89,21 +89,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #undef DEF_EXT_LIB_BUILTIN                             
 #define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS)   \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
-              true, true, true, ATTRS, false)
+              true, true, true, ATTRS, false, true)
 
 /* Like DEF_LIB_BUILTIN, except that the function is only a part of
    the standard in C94 or above.  */
 #undef DEF_C94_BUILTIN                                 
 #define DEF_C94_BUILTIN(ENUM, NAME, TYPE, ATTRS)       \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
-              true, true, !flag_isoc94, ATTRS, TARGET_C99_FUNCTIONS)
+              true, true, !flag_isoc94, ATTRS, TARGET_C99_FUNCTIONS, true)
 
 /* Like DEF_LIB_BUILTIN, except that the function is only a part of
    the standard in C99 or above.  */
 #undef DEF_C99_BUILTIN                                 
 #define DEF_C99_BUILTIN(ENUM, NAME, TYPE, ATTRS)       \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
-              true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS)
+              true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS, true)
 
 /* Builtin that is specified by C99 and C90 reserve the name for future use.
    We can still recognize the builtin in C90 mode but we can't produce it
@@ -111,7 +111,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #undef DEF_C99_C90RES_BUILTIN                                  
 #define DEF_C99_C90RES_BUILTIN(ENUM, NAME, TYPE, ATTRS)        \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,   \
-              true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS)
+              true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS, true)
+
+/* Allocate the enum and the name for a builtin, but do not actually
+   define it here at all.  */
+#undef DEF_BUILTIN_STUB
+#define DEF_BUILTIN_STUB(ENUM, NAME) \
+  DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, 0, 0, false, false, \
+              false, 0, false, false)
 
 /* Define an attribute list for math functions that are normally
    "impure" because some of them may write into global memory for
@@ -610,8 +617,6 @@ DEF_GCC_BUILTIN        (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN
 DEF_GCC_BUILTIN        (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_NULL)
-DEF_GCC_BUILTIN        (BUILT_IN_STACK_SAVE, "stack_save", BT_FN_PTR, ATTR_NULL)
-DEF_GCC_BUILTIN        (BUILT_IN_STACK_RESTORE, "stack_restore", BT_FN_VOID_PTR, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_STDARG_START, "stdarg_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_3_4)
 DEF_LIB_BUILTIN        (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR, ATTR_FORMAT_STRFTIME_3_0)
@@ -623,12 +628,16 @@ DEF_GCC_BUILTIN        (BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, ATTR_N
 DEF_GCC_BUILTIN        (BUILT_IN_VA_START, "va_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN__EXIT, "_exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
 DEF_C99_BUILTIN        (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
-DEF_GCC_BUILTIN        (BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
-DEF_GCC_BUILTIN        (BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", BT_FN_PTR_PTR, ATTR_CONST_NOTHROW_LIST)
-DEF_GCC_BUILTIN        (BUILT_IN_NONLOCAL_GOTO, "nonlocal_goto", BT_FN_PTR_PTR, ATTR_NORETURN_NOTHROW_LIST)
+
+/* Implementing nested functions.  */
+DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
+DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
+DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto")
+
+/* Implementing variable sized local variables.  */
+DEF_BUILTIN_STUB (BUILT_IN_STACK_SAVE, "__builtin_stack_save")
+DEF_BUILTIN_STUB (BUILT_IN_STACK_RESTORE, "__builtin_stack_restore")
 
 /* Profiling hooks.  */
-DEF_GCC_BUILTIN (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter",
-                BT_FN_VOID, ATTR_NULL)
-DEF_GCC_BUILTIN (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 
-                BT_FN_VOID, ATTR_NULL)
+DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter")
+DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit")
index 72fd8466df78a047ed9b14c5b1e56e8d6e22b388..15f364800c6b2fdcc5070e6cc4b95b8332cb16d8 100644 (file)
@@ -3199,9 +3199,9 @@ c_common_nodes_and_builtins (void)
 
   c_init_attributes ();
 
-#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE,                  \
-                   BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT)     \
-  if (NAME)                                                            \
+#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
+                   NONANSI_P, ATTRS, IMPLICIT, COND)                   \
+  if (NAME && COND)                                                    \
     {                                                                  \
       tree decl;                                                       \
                                                                        \
@@ -3234,6 +3234,8 @@ c_common_nodes_and_builtins (void)
 #include "builtins.def"
 #undef DEF_BUILTIN
 
+  build_common_builtin_nodes ();
+
   targetm.init_builtins ();
   if (flag_mudflap)
     mudflap_init ();
index b1918a3445afb613df38c17020c30b1fe993c801..6db9cd9f57d93ac88ee6df85fabecaff7a14c5df 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-09  Richard Henderson  <rth@redhat.com>
+
+       * f95-lang.c (gfc_init_builtin_functions): Call
+       build_common_builtin_nodes; do not define any functions handled
+       by it.
+
 2005-02-08  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * expr.c (gfc_copy_expr): Don't copy 'op1' and 'op2' for
index b406bf041a0ff42d64e1ff4854282614071e341f..7f04b7ca2614442374249f559cfeef181e4f2c5c 100644 (file)
@@ -794,8 +794,7 @@ gfc_init_builtin_functions (void)
                      BUILT_IN_CABS, "cabs", true);
   gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, 
                      BUILT_IN_CABSF, "cabsf", true);
-                     
-  
   gfc_define_builtin ("__builtin_copysign", mfunc_double[1], 
                      BUILT_IN_COPYSIGN, "copysign", true);
   gfc_define_builtin ("__builtin_copysignf", mfunc_float[1], 
@@ -809,61 +808,28 @@ gfc_init_builtin_functions (void)
 
   /* Other builtin functions we use.  */
 
-  tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
-  ftype = build_function_type (long_integer_type_node, tmp);
-  gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
-                     "__builtin_expect", true);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
-  ftype = build_function_type (pvoid_type_node, tmp);
-  gfc_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
-                     "memcpy", false);
-
   tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
   ftype = build_function_type (integer_type_node, tmp);
-  gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ, "clz", true);
+  gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
+                     "__builtin_clz", true);
 
   tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
   ftype = build_function_type (integer_type_node, tmp);
-  gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL, "clzl", true);
+  gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
+                     "__builtin_clzl", true);
 
   tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
   ftype = build_function_type (integer_type_node, tmp);
-  gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL, "clzll", true);
-
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
-  ftype = build_function_type (void_type_node, tmp);
-  gfc_define_builtin ("__builtin_init_trampoline", ftype,
-                     BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", false);
-
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
-  ftype = build_function_type (pvoid_type_node, tmp);
-  gfc_define_builtin ("__builtin_adjust_trampoline", ftype,
-                     BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", true);
-
-  /* The stack_save, stack_restore, and alloca builtins aren't used directly.
-     They are inserted during gimplification to implement variable sized
-     stack allocation.  */
-
-  ftype = build_function_type (pvoid_type_node, void_list_node);
-  gfc_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
-                     "stack_save", false);
-
-  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
-  ftype = build_function_type (void_type_node, tmp);
-  gfc_define_builtin ("__builtin_stack_restore", ftype, BUILT_IN_STACK_RESTORE,
-                     "stack_restore", false);
-
-  tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
-  ftype = build_function_type (pvoid_type_node, tmp);
-  gfc_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
-                     "alloca", false);
+  gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
+                     "__builtin_clzll", true);
+
+  tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
+  tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
+  ftype = build_function_type (long_integer_type_node, tmp);
+  gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
+                     "__builtin_expect", true);
 
+  build_common_builtin_nodes ();
   targetm.init_builtins ();
 }
 
index e68ffe3bc185f0d4007852d56e8a1a555f2097ec..a24d4a4903749a44e01689e3f3c1114d0e13518c 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-09  Richard Henderson  <rth@redhat.com>
+
+       * builtins.c (initialize_builtins): Call build_common_builtin_nodes.
+       * decl.c (java_init_decl_processing): Initialize const_ptr_type_node.
+
 2005-02-08  Marcin Dalecki  <martin@dalecki.de>
 
        * expr.c (add_type_assertion): Use the proper enumeration type,
index 8230036aa7fc42dfe4d0385032ae466c654f87e4..fd8aa5a886692373598701681942973cd4d12e50 100644 (file)
@@ -216,6 +216,8 @@ initialize_builtins (void)
                  double_ftype_double, "_ZN4java4lang4Math4sqrtEd");
   define_builtin (BUILT_IN_TAN, "__builtin_tan",
                  double_ftype_double, "_ZN4java4lang4Math3tanEd");
+
+  build_common_builtin_nodes ();
 }
 
 /* If the call matches a builtin, return the
index 1343ebfe3f056455d44b6c3edf209d171142b702..ad1b55e5dfab4a5dd06ae8eca407eab3fcef1b74 100644 (file)
@@ -692,7 +692,11 @@ java_init_decl_processing (void)
   void_type_node = make_node (VOID_TYPE);
   pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
   layout_type (void_type_node);        /* Uses size_zero_node */
+
   ptr_type_node = build_pointer_type (void_type_node);
+  const_ptr_type_node
+    = build_pointer_type (build_type_variant (void_type_node, 1, 0));
+
   t = make_node (VOID_TYPE);
   layout_type (t); /* Uses size_zero_node */
   return_address_type_node = build_pointer_type (t);
index 6afc17f1f46652a39507f190fe2b060c9eb459d3..4e7f7bfcf9bb33c2607b470983be863e0c55d2bf 100644 (file)
@@ -5782,6 +5782,124 @@ build_common_tree_nodes_2 (int short_double)
   }
 }
 
+/* A subroutine of build_common_builtin_nodes.  Define a builtin function.  */
+
+static void
+local_define_builtin (const char *name, tree type, enum built_in_function code,
+                      const char *library_name, int ecf_flags)
+{
+  tree decl;
+
+  decl = lang_hooks.builtin_function (name, type, code, BUILT_IN_NORMAL,
+                                     library_name, NULL_TREE);
+  if (ecf_flags & ECF_CONST)
+    TREE_READONLY (decl) = 1;
+  if (ecf_flags & ECF_PURE)
+    DECL_IS_PURE (decl) = 1;
+  if (ecf_flags & ECF_NORETURN)
+    TREE_THIS_VOLATILE (decl) = 1;
+  if (ecf_flags & ECF_NOTHROW)
+    TREE_NOTHROW (decl) = 1;
+  if (ecf_flags & ECF_MALLOC)
+    DECL_IS_MALLOC (decl) = 1;
+
+  built_in_decls[code] = decl;
+  implicit_built_in_decls[code] = decl;
+}
+
+/* Call this function after instantiating all builtins that the language
+   front end cares about.  This will build the rest of the builtins that
+   are relied upon by the tree optimizers and the middle-end.  */
+
+void
+build_common_builtin_nodes (void)
+{
+  tree tmp, ftype;
+
+  if (built_in_decls[BUILT_IN_MEMCPY] == NULL
+      || built_in_decls[BUILT_IN_MEMMOVE] == NULL)
+    {
+      tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
+      tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
+      tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+      ftype = build_function_type (ptr_type_node, tmp);
+
+      if (built_in_decls[BUILT_IN_MEMCPY] == NULL)
+       local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
+                             "memcpy", ECF_NOTHROW);
+      if (built_in_decls[BUILT_IN_MEMMOVE] == NULL)
+       local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
+                             "memmove", ECF_NOTHROW);
+    }
+
+  if (built_in_decls[BUILT_IN_MEMCMP] == NULL)
+    {
+      tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
+      tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
+      tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
+      ftype = build_function_type (ptr_type_node, tmp);
+      local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
+                           "memcmp", ECF_PURE | ECF_NOTHROW);
+    }
+
+  if (built_in_decls[BUILT_IN_MEMSET] == NULL)
+    {
+      tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
+      tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
+      tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+      ftype = build_function_type (ptr_type_node, tmp);
+      local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
+                           "memset", ECF_NOTHROW);
+    }
+
+  if (built_in_decls[BUILT_IN_ALLOCA] == NULL)
+    {
+      tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
+      ftype = build_function_type (ptr_type_node, tmp);
+      local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
+                           "alloca", ECF_NOTHROW | ECF_MALLOC);
+    }
+
+  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+  tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+  tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+  ftype = build_function_type (void_type_node, tmp);
+  local_define_builtin ("__builtin_init_trampoline", ftype,
+                       BUILT_IN_INIT_TRAMPOLINE,
+                       "__builtin_init_trampoline", ECF_NOTHROW);
+
+  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+  ftype = build_function_type (ptr_type_node, tmp);
+  local_define_builtin ("__builtin_adjust_trampoline", ftype,
+                       BUILT_IN_ADJUST_TRAMPOLINE,
+                       "__builtin_adjust_trampoline",
+                       ECF_CONST | ECF_NOTHROW);
+
+  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+  tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
+  ftype = build_function_type (void_type_node, tmp);
+  local_define_builtin ("__builtin_nonlocal_goto", ftype,
+                       BUILT_IN_NONLOCAL_GOTO,
+                       "__builtin_nonlocal_goto",
+                       ECF_NORETURN | ECF_NOTHROW);
+
+  ftype = build_function_type (ptr_type_node, void_list_node);
+  local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
+                       "__builtin_stack_save", ECF_NOTHROW);
+
+  tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+  ftype = build_function_type (void_type_node, tmp);
+  local_define_builtin ("__builtin_stack_restore", ftype,
+                       BUILT_IN_STACK_RESTORE,
+                       "__builtin_stack_restore", ECF_NOTHROW);
+
+  ftype = build_function_type (void_type_node, void_list_node);
+  local_define_builtin ("__builtin_profile_func_enter", ftype,
+                       BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0);
+  local_define_builtin ("__builtin_profile_func_exit", ftype,
+                       BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
+}
+
 /* HACK.  GROSS.  This is absolutely disgusting.  I wish there was a
    better way.
 
index e64fb99d78d141cc2a976340bc60d79ce1935feb..60ebc737b5caca0328b7608eab7cc6266bf8934e 100644 (file)
@@ -182,7 +182,7 @@ extern const char *const built_in_class_names[4];
 /* Codes that identify the various built in functions
    so that expand_call can identify them quickly.  */
 
-#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM) ENUM,
+#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) ENUM,
 enum built_in_function
 {
 #include "builtins.def"
@@ -3591,6 +3591,7 @@ extern int real_minus_onep (tree);
 extern void init_ttree (void);
 extern void build_common_tree_nodes (bool, bool);
 extern void build_common_tree_nodes_2 (int);
+extern void build_common_builtin_nodes (void);
 extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
 extern tree build_range_type (tree, tree, tree);
 extern HOST_WIDE_INT int_cst_value (tree);
index 75d20824041ff41fbd9149b028c89126ffc4882e..35d4710d1c7cfac77d12135edb187081f87e400c 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-09  Richard Henderson  <rth@redhat.com>
+
+       * treetree.c (treelang_init_decl_processing): Call
+       build_common_builtin_nodes.
+
 2005-02-06  Joseph S. Myers  <joseph@codesourcery.com>
 
        * treelang.texi: Don't use local treelang version number.  Don't
@@ -5,7 +10,7 @@
 
 2005-02-01  James A. Morrison  <phython@gcc.gnu.org>
 
-       * (lex.l): Undef LINEMAP_POSITION_FOR_COLUMN before defining it.
+       * lex.l: Undef LINEMAP_POSITION_FOR_COLUMN before defining it.
 
 2005-02-01  James A. Morrison  <phython@gcc.gnu.org>
 
index b621fadf1832b7dc9ab1cc16e917d2a505cbc7a4..54dcb46fd1cef568e4c47ebc788af8df354f40a2 100644 (file)
@@ -1209,7 +1209,7 @@ treelang_init_decl_processing (void)
   tree_push_type_decl (get_identifier ("long double"), long_double_type_node);
   tree_push_type_decl (get_identifier ("void"), void_type_node);
 
-  /* Add any target-specific builtin functions.  */
+  build_common_builtin_nodes ();
   (*targetm.init_builtins) ();
 
   pedantic_lvalues = pedantic;