OSDN Git Service

2008-12-12 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / langhooks.c
index 6a9a74d..ebbec95 100644 (file)
@@ -1,5 +1,5 @@
 /* Default language-specific hooks.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Alexandre Oliva  <aoliva@redhat.com>
 
@@ -27,7 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "tree.h"
 #include "tree-inline.h"
-#include "tree-gimple.h"
+#include "gimple.h"
 #include "rtl.h"
 #include "insn-config.h"
 #include "integrate.h"
@@ -133,7 +133,7 @@ lhd_warn_unused_global_decl (const_tree decl)
   /* This is what used to exist in check_global_declarations.  Probably
      not many of these actually apply to non-C languages.  */
 
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
+  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
     return false;
   if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl))
     return false;
@@ -227,18 +227,6 @@ lhd_expand_expr (tree ARG_UNUSED (t), rtx ARG_UNUSED (r),
   gcc_unreachable ();
 }
 
-/* The default language-specific function for expanding a decl.  After
-   the language-independent cases are handled, this function will be
-   called.  If this function is not defined, it is assumed that
-   declarations other than those for variables and labels do not require
-   any RTL generation.  */
-
-int
-lhd_expand_decl (tree ARG_UNUSED (t))
-{
-  return 0;
-}
-
 /* This is the default decl_printable_name function.  */
 
 const char *
@@ -303,8 +291,9 @@ lhd_expr_size (const_tree exp)
 /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form.  */
 
 int
-lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED, tree *pre_p ATTRIBUTE_UNUSED,
-                  tree *post_p ATTRIBUTE_UNUSED)
+lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED,
+                  gimple_seq *pre_p ATTRIBUTE_UNUSED,
+                  gimple_seq *post_p ATTRIBUTE_UNUSED)
 {
   return GS_UNHANDLED;
 }
@@ -394,7 +383,9 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
          if (abstract_origin)
            {
              ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
-             while (TREE_CODE (ao) == BLOCK && BLOCK_ABSTRACT_ORIGIN (ao))
+             while (TREE_CODE (ao) == BLOCK
+                    && BLOCK_ABSTRACT_ORIGIN (ao)
+                    && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
                ao = BLOCK_ABSTRACT_ORIGIN (ao);
              gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
              fndecl = ao;
@@ -424,7 +415,9 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
                {
                  ao = BLOCK_ABSTRACT_ORIGIN (block);
 
-                 while (TREE_CODE (ao) == BLOCK && BLOCK_ABSTRACT_ORIGIN (ao))
+                 while (TREE_CODE (ao) == BLOCK
+                        && BLOCK_ABSTRACT_ORIGIN (ao)
+                        && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
                    ao = BLOCK_ABSTRACT_ORIGIN (ao);
 
                  if (TREE_CODE (ao) == FUNCTION_DECL)
@@ -455,14 +448,12 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
                  pp_newline (context->printer);
                  if (s.file != NULL)
                    {
-#ifdef USE_MAPPED_LOCATION
                      if (flag_show_column && s.column != 0)
                        pp_printf (context->printer,
                                   _("    inlined from %qs at %s:%d:%d"),
                                   lang_hooks.decl_printable_name (fndecl, 2),
                                   s.file, s.line, s.column);
                      else
-#endif
                        pp_printf (context->printer,
                                   _("    inlined from %qs at %s:%d"),
                                   lang_hooks.decl_printable_name (fndecl, 2),
@@ -486,8 +477,7 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
 
 tree
 lhd_callgraph_analyze_expr (tree *tp ATTRIBUTE_UNUSED,
-                           int *walk_subtrees ATTRIBUTE_UNUSED,
-                           tree decl ATTRIBUTE_UNUSED)
+                           int *walk_subtrees ATTRIBUTE_UNUSED)
 {
   return NULL;
 }
@@ -505,8 +495,7 @@ lhd_to_target_charset (HOST_WIDE_INT c)
 }
 
 tree
-lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED,
-                 bool *ti ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
+lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
 {
   return expr;
 }
@@ -527,7 +516,7 @@ lhd_omp_predetermined_sharing (tree decl ATTRIBUTE_UNUSED)
 tree
 lhd_omp_assignment (tree clause ATTRIBUTE_UNUSED, tree dst, tree src)
 {
-  return build_gimple_modify_stmt (dst, src);
+  return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
 }
 
 /* Register language specific type size variables as potentially OpenMP
@@ -539,13 +528,16 @@ lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
 {
 }
 
-tree
-add_builtin_function (const char *name,
-                     tree type,
-                     int function_code,
-                     enum built_in_class cl,
-                     const char *library_name,
-                     tree attrs)
+/* Common function for add_builtin_function and
+   add_builtin_function_ext_scope.  */
+static tree
+add_builtin_function_common (const char *name,
+                            tree type,
+                            int function_code,
+                            enum built_in_class cl,
+                            const char *library_name,
+                            tree attrs,
+                            tree (*hook) (tree))
 {
   tree   id = get_identifier (name);
   tree decl = build_decl (FUNCTION_DECL, id, type);
@@ -570,8 +562,43 @@ add_builtin_function (const char *name,
   else
     decl_attributes (&decl, NULL_TREE, 0);
 
-  return lang_hooks.builtin_function (decl);
+  return hook (decl);
+
+}
 
+/* Create a builtin function.  */
+
+tree
+add_builtin_function (const char *name,
+                     tree type,
+                     int function_code,
+                     enum built_in_class cl,
+                     const char *library_name,
+                     tree attrs)
+{
+  return add_builtin_function_common (name, type, function_code, cl,
+                                     library_name, attrs,
+                                     lang_hooks.builtin_function);
+}
+
+/* Like add_builtin_function, but make sure the scope is the external scope.
+   This is used to delay putting in back end builtin functions until the ISA
+   that defines the builtin is declared via function specific target options,
+   which can save memory for machines like the x86_64 that have multiple ISAs.
+   If this points to the same function as builtin_function, the backend must
+   add all of the builtins at program initialization time.  */
+
+tree
+add_builtin_function_ext_scope (const char *name,
+                               tree type,
+                               int function_code,
+                               enum built_in_class cl,
+                               const char *library_name,
+                               tree attrs)
+{
+  return add_builtin_function_common (name, type, function_code, cl,
+                                     library_name, attrs,
+                                     lang_hooks.builtin_function_ext_scope);
 }
 
 tree