OSDN Git Service

* gcc-interface/gigi.h (create_index_type): Adjust head comment.
[pf3gnuchains/gcc-fork.git] / gcc / ada / gcc-interface / misc.c
index 7c7dc02..b67b845 100644 (file)
@@ -6,24 +6,17 @@
  *                                                                          *
  *                           C Implementation File                          *
  *                                                                          *
- *          Copyright (C) 1992-2008, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2009, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
- * ware  Foundation;  either version 2,  or (at your option) any later ver- *
+ * ware  Foundation;  either version 3,  or (at your option) any later ver- *
  * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
  * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License *
  * for  more details.  You should have  received  a copy of the GNU General *
- * Public License  distributed with GNAT;  see file COPYING.  If not, write *
- * to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, *
- * Boston, MA 02110-1301, USA.                                              *
- *                                                                          *
- * As a  special  exception,  if you  link  this file  with other  files to *
- * produce an executable,  this file does not by itself cause the resulting *
- * executable to be covered by the GNU General Public License. This except- *
- * ion does not  however invalidate  any other reasons  why the  executable *
- * file might be covered by the  GNU Public License.                        *
+ * Public License  distributed  with GNAT;  see file  COPYING3.  If not see *
+ * <http://www.gnu.org/licenses/>.                                          *
  *                                                                          *
  * GNAT was originally developed  by the GNAT team at  New York University. *
  * Extensive contributions were provided by Ada Core Technologies Inc.      *
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "real.h"
-#include "rtl.h"
 #include "diagnostic.h"
+#include "target.h"
 #include "expr.h"
 #include "libfuncs.h"
 #include "ggc.h"
 #include "flags.h"
 #include "debug.h"
 #include "cgraph.h"
-#include "tree-inline.h"
-#include "insn-codes.h"
-#include "insn-flags.h"
-#include "insn-config.h"
 #include "optabs.h"
-#include "recog.h"
 #include "toplev.h"
-#include "output.h"
 #include "except.h"
-#include "tm_p.h"
 #include "langhooks.h"
 #include "langhooks-def.h"
-#include "target.h"
+#include "opts.h"
+#include "options.h"
+#include "tree-inline.h"
 
 #include "ada.h"
+#include "adadecode.h"
 #include "types.h"
 #include "atree.h"
 #include "elists.h"
 #include "einfo.h"
 #include "ada-tree.h"
 #include "gigi.h"
-#include "adadecode.h"
-#include "opts.h"
-#include "options.h"
-
-extern FILE *asm_out_file;
-
-/* The largest alignment, in bits, that is needed for using the widest
-   move instruction.  */
-unsigned int largest_move_alignment;
 
 static bool gnat_init                  (void);
-static void gnat_finish_incomplete_decl        (tree);
 static unsigned int gnat_init_options  (unsigned int, const char **);
 static int gnat_handle_option          (size_t, const char *, int);
 static bool gnat_post_options          (const char **);
@@ -98,8 +76,6 @@ static const char *gnat_dwarf_name    (tree, int);
 static tree gnat_return_tree           (tree);
 static int gnat_eh_type_covers         (tree, tree);
 static void gnat_parse_file            (int);
-static rtx gnat_expand_expr            (tree, rtx, enum machine_mode, int,
-                                        rtx *);
 static void internal_error_function    (const char *, va_list *);
 static tree gnat_type_max_size         (const_tree);
 
@@ -127,12 +103,8 @@ static tree gnat_type_max_size             (const_tree);
 #define LANG_HOOKS_PUSHDECL            gnat_return_tree
 #undef  LANG_HOOKS_WRITE_GLOBALS
 #define LANG_HOOKS_WRITE_GLOBALS       gnat_write_global_declarations
-#undef  LANG_HOOKS_FINISH_INCOMPLETE_DECL
-#define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl
 #undef  LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET       gnat_get_alias_set
-#undef  LANG_HOOKS_EXPAND_EXPR
-#define LANG_HOOKS_EXPAND_EXPR         gnat_expand_expr
 #undef  LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE    gnat_mark_addressable
 #undef  LANG_HOOKS_PRINT_DECL
@@ -164,18 +136,14 @@ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
    are incompatible with regular GDB versions, so we must make sure to only
    produce them on explicit request.  This is eventually reflected into the
    use_gnu_debug_info_extensions common flag for later processing.  */
-
 static int gnat_dwarf_extensions = 0;
 
-/* Command-line argc and argv.
-   These variables are global, since they are imported and used in
-   back_end.adb  */
-
+/* Command-line argc and argv.  These variables are global
+   since they are imported in back_end.adb.  */
 unsigned int save_argc;
 const char **save_argv;
 
-/* gnat standard argc argv */
-
+/* GNAT argc and argv.  */
 extern int gnat_argc;
 extern char **gnat_argv;
 
@@ -213,8 +181,8 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 
 /* Decode all the language specific options that cannot be decoded by GCC.
    The option decoding phase of GCC calls this routine on the flags that
-   it cannot decode.  This routine returns the number of consecutive arguments
-   from ARGV that it successfully decoded; 0 indicates failure.  */
+   it cannot decode.  Return the number of consecutive arguments from ARGV
+   that have been successfully decoded or 0 on failure.  */
 
 static int
 gnat_handle_option (size_t scode, const char *arg, int value)
@@ -337,9 +305,19 @@ gnat_init_options (unsigned int argc, const char **argv)
 bool
 gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
 {
+  /* Excess precision other than "fast" requires front-end
+     support.  */
+  if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD
+      && TARGET_FLT_EVAL_METHOD_NON_DEFAULT)
+    sorry ("-fexcess-precision=standard for Ada");
+  flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+
   /* ??? The warning machinery is outsmarted by Ada.  */
   warn_unused_parameter = 0;
 
+  /* No psABI change warnings for Ada.  */
+  warn_psabi = 0;
+
   /* Force eliminate_unused_debug_types to 0 unless an explicit positive
      -f has been passed.  This forces the default to 0 for Ada, which might
      differ from the common default.  */
@@ -428,34 +406,6 @@ gnat_init (void)
   return true;
 }
 
-/* This function is called indirectly from toplev.c to handle incomplete
-   declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero.  To be precise,
-   compile_file in toplev.c makes an indirect call through the function pointer
-   incomplete_decl_finalize_hook which is initialized to this routine in
-   init_decl_processing.  */
-
-static void
-gnat_finish_incomplete_decl (tree dont_care ATTRIBUTE_UNUSED)
-{
-  gcc_unreachable ();
-}
-\f
-/* Compute the alignment of the largest mode that can be used for copying
-   objects.  */
-
-void
-gnat_compute_largest_alignment (void)
-{
-  enum machine_mode mode;
-
-  for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
-       mode = GET_MODE_WIDER_MODE (mode))
-    if (optab_handler (mov_optab, mode)->insn_code != CODE_FOR_nothing)
-      largest_move_alignment = MIN (BIGGEST_ALIGNMENT,
-                                   MAX (largest_move_alignment,
-                                        GET_MODE_ALIGNMENT (mode)));
-}
-
 /* If we are using the GCC mechanism to process exception handling, we
    have to register the personality routine for Ada and to initialize
    various language dependent hooks.  */
@@ -507,7 +457,7 @@ gnat_init_gcc_eh (void)
 #endif
 }
 
-/* Language hooks, first one to print language-specific items in a DECL.  */
+/* Print language-specific items in declaration NODE.  */
 
 static void
 gnat_print_decl (FILE *file, tree node, int indent)
@@ -534,6 +484,8 @@ gnat_print_decl (FILE *file, tree node, int indent)
     }
 }
 
+/* Print language-specific items in type NODE.  */
+
 static void
 gnat_print_type (FILE *file, tree node, int indent)
 {
@@ -543,14 +495,9 @@ gnat_print_type (FILE *file, tree node, int indent)
       print_node (file, "ci_co_list", TYPE_CI_CO_LIST (node), indent + 4);
       break;
 
-    case ENUMERAL_TYPE:
-    case BOOLEAN_TYPE:
-      print_node (file, "RM size", TYPE_RM_SIZE_NUM (node), indent + 4);
-      break;
-
     case INTEGER_TYPE:
       if (TYPE_MODULAR_P (node))
-       print_node (file, "modulus", TYPE_MODULUS (node), indent + 4);
+       print_node_brief (file, "modulus", TYPE_MODULUS (node), indent + 4);
       else if (TYPE_HAS_ACTUAL_BOUNDS_P (node))
        print_node (file, "actual bounds", TYPE_ACTUAL_BOUNDS (node),
                    indent + 4);
@@ -559,7 +506,11 @@ gnat_print_type (FILE *file, tree node, int indent)
       else
        print_node (file, "index type", TYPE_INDEX_TYPE (node), indent + 4);
 
-      print_node (file, "RM size", TYPE_RM_SIZE_NUM (node), indent + 4);
+      /* ... fall through ... */
+
+    case ENUMERAL_TYPE:
+    case BOOLEAN_TYPE:
+      print_node_brief (file, "RM size", TYPE_RM_SIZE (node), indent + 4);
       break;
 
     case ARRAY_TYPE:
@@ -584,13 +535,7 @@ gnat_print_type (FILE *file, tree node, int indent)
     }
 }
 
-static const char *
-gnat_dwarf_name (tree t, int verbosity ATTRIBUTE_UNUSED)
-{
-  gcc_assert (DECL_P (t));
-
-  return (const char *) IDENTIFIER_POINTER (DECL_NAME (t));
-}
+/* Return the name to be printed for DECL.  */
 
 static const char *
 gnat_printable_name (tree decl, int verbosity)
@@ -600,52 +545,22 @@ gnat_printable_name (tree decl, int verbosity)
 
   __gnat_decode (coded_name, ada_name, 0);
 
-  if (verbosity == 2)
+  if (verbosity == 2 && !DECL_IS_BUILTIN (decl))
     {
       Set_Identifier_Casing (ada_name, (char *) DECL_SOURCE_FILE (decl));
-      ada_name = Name_Buffer;
+      return ggc_strdup (Name_Buffer);
     }
 
-  return (const char *) ada_name;
+  return ada_name;
 }
 
-/* Expands GNAT-specific GCC tree nodes.  The only ones we support
-   here are  and NULL_EXPR.  */
+/* Return the name to be used in DWARF debug info for DECL.  */
 
-static rtx
-gnat_expand_expr (tree exp, rtx target, enum machine_mode tmode,
-                 int modifier, rtx *alt_rtl)
+static const char *
+gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED)
 {
-  tree type = TREE_TYPE (exp);
-  tree new;
-
-  /* Update EXP to be the new expression to expand.  */
-  switch (TREE_CODE (exp))
-    {
-#if 0
-    case ALLOCATE_EXPR:
-      return
-       allocate_dynamic_stack_space
-         (expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, TYPE_MODE (sizetype),
-                       EXPAND_NORMAL),
-          NULL_RTX, tree_low_cst (TREE_OPERAND (exp, 1), 1));
-#endif
-
-    case UNCONSTRAINED_ARRAY_REF:
-      /* If we are evaluating just for side-effects, just evaluate our
-        operand.  Otherwise, abort since this code should never appear
-        in a tree to be evaluated (objects aren't unconstrained).  */
-      if (target == const0_rtx || TREE_CODE (type) == VOID_TYPE)
-       return expand_expr (TREE_OPERAND (exp, 0), const0_rtx,
-                           VOIDmode, modifier);
-
-      /* ... fall through ... */
-
-    default:
-      gcc_unreachable ();
-    }
-
-  return expand_expr_real (new, target, tmode, modifier, alt_rtl);
+  gcc_assert (DECL_P (decl));
+  return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl));
 }
 
 /* Do nothing (return the tree node passed).  */
@@ -850,6 +765,8 @@ enumerate_modes (void (*f) (int, int, int, int, int, int, unsigned int))
     }
 }
 
+/* Return the size of the FP mode with precision PREC.  */
+
 int
 fp_prec_to_size (int prec)
 {
@@ -863,6 +780,8 @@ fp_prec_to_size (int prec)
   gcc_unreachable ();
 }
 
+/* Return the precision of the FP mode with size SIZE.  */
+
 int
 fp_size_to_prec (int size)
 {