* gcc-interface/utils.c (add_parallel_type): Take a TYPE instead of a
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Mar 2012 16:58:48 +0000 (16:58 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Mar 2012 16:58:48 +0000 (16:58 +0000)
DECL and adjust.  Move around.
(has_parallel_type): New predicate.
(rest_of_record_type_compilation): Return early if the type already
has a parallel type.
* gcc-interface/gigi.h (add_parallel_type): Adjust.
* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185779 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/utils.c

index c9b1aee..efd3446 100644 (file)
@@ -1,5 +1,15 @@
 2012-03-25  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gcc-interface/utils.c (add_parallel_type): Take a TYPE instead of a
+       DECL and adjust.  Move around.
+       (has_parallel_type): New predicate.
+       (rest_of_record_type_compilation): Return early if the type already
+       has a parallel type.
+       * gcc-interface/gigi.h (add_parallel_type): Adjust.
+       * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes.
+
+2012-03-25  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gcc-interface/utils.c (finish_record_type): Return early for padded
        types and tidy up.
 
index a3320ed..2139fbd 100644 (file)
@@ -1779,7 +1779,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
       if (debug_info_p
          && Is_Packed_Array_Type (gnat_entity)
          && present_gnu_tree (Original_Array_Type (gnat_entity)))
-       add_parallel_type (TYPE_STUB_DECL (gnu_type),
+       add_parallel_type (gnu_type,
                           gnat_to_gnu_type
                           (Original_Array_Type (gnat_entity)));
 
@@ -1854,7 +1854,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            {
              /* Make the original array type a parallel type.  */
              if (present_gnu_tree (Original_Array_Type (gnat_entity)))
-               add_parallel_type (TYPE_STUB_DECL (gnu_type),
+               add_parallel_type (gnu_type,
                                   gnat_to_gnu_type
                                   (Original_Array_Type (gnat_entity)));
 
@@ -2637,7 +2637,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                }
 
              finish_record_type (gnu_bound_rec, gnu_field_list, 0, true);
-             add_parallel_type (TYPE_STUB_DECL (gnu_type), gnu_bound_rec);
+             add_parallel_type (gnu_type, gnu_bound_rec);
            }
 
          /* If this is a packed array type, make the original array type a
@@ -2647,7 +2647,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            {
              if (Is_Packed_Array_Type (gnat_entity)
                  && present_gnu_tree (Original_Array_Type (gnat_entity)))
-               add_parallel_type (TYPE_STUB_DECL (gnu_type),
+               add_parallel_type (gnu_type,
                                   gnat_to_gnu_type
                                   (Original_Array_Type (gnat_entity)));
              else
@@ -2655,7 +2655,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                  tree gnu_base_decl
                    = gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, 0);
                  if (!DECL_ARTIFICIAL (gnu_base_decl))
-                   add_parallel_type (TYPE_STUB_DECL (gnu_type),
+                   add_parallel_type (gnu_type,
                                       TREE_TYPE (TREE_TYPE (gnu_base_decl)));
                }
            }
@@ -3529,8 +3529,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                                                         0, 0),
                                      0, true);
 
-                 add_parallel_type (TYPE_STUB_DECL (gnu_type),
-                                    gnu_subtype_marker);
+                 add_parallel_type (gnu_type, gnu_subtype_marker);
 
                  if (definition
                      && TREE_CODE (gnu_size_unit) != INTEGER_CST
@@ -6643,7 +6642,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
                                             0, 0),
                          0, true);
 
-      add_parallel_type (TYPE_STUB_DECL (record), marker);
+      add_parallel_type (record, marker);
 
       if (definition && size && TREE_CODE (size) != INTEGER_CST)
        TYPE_SIZE_UNIT (marker)
index 8a83647..c507615 100644 (file)
@@ -560,8 +560,8 @@ extern void finish_record_type (tree record_type, tree field_list,
    a parallel type is to be attached to the record type.  */
 extern void rest_of_record_type_compilation (tree record_type);
 
-/* Append PARALLEL_TYPE on the chain of parallel types for decl.  */
-extern void add_parallel_type (tree decl, tree parallel_type);
+/* Append PARALLEL_TYPE on the chain of parallel types for TYPE.  */
+extern void add_parallel_type (tree type, tree parallel_type);
 
 /* Return a FUNCTION_TYPE node.  RETURN_TYPE is the type returned by the
    subprogram.  If it is VOID_TYPE, then we are dealing with a procedure,
index 18f9dac..1460a43 100644 (file)
@@ -855,6 +855,29 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
     rest_of_record_type_compilation (record_type);
 }
 
+/* Append PARALLEL_TYPE on the chain of parallel types of TYPE.  */
+
+void
+add_parallel_type (tree type, tree parallel_type)
+{
+  tree decl = TYPE_STUB_DECL (type);
+
+  while (DECL_PARALLEL_TYPE (decl))
+    decl = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (decl));
+
+  SET_DECL_PARALLEL_TYPE (decl, parallel_type);
+}
+
+/* Return true if TYPE has a parallel type.  */
+
+static bool
+has_parallel_type (tree type)
+{
+  tree decl = TYPE_STUB_DECL (type);
+
+  return DECL_PARALLEL_TYPE (decl) != NULL_TREE;
+}
+
 /* Wrap up compilation of RECORD_TYPE, i.e. output all the debug information
    associated with it.  It need not be invoked directly in most cases since
    finish_record_type takes care of doing so, but this can be necessary if
@@ -871,6 +894,10 @@ rest_of_record_type_compilation (tree record_type)
   if (TYPE_IS_PADDING_P (record_type))
     return;
 
+  /* If the type already has a parallel type (XVS type), then we're done.  */
+  if (has_parallel_type (record_type))
+    return;
+
   for (field = TYPE_FIELDS (record_type); field; field = DECL_CHAIN (field))
     {
       /* We need to make an XVE/XVU record if any field has variable size,
@@ -1054,23 +1081,10 @@ rest_of_record_type_compilation (tree record_type)
 
       TYPE_FIELDS (new_record_type) = nreverse (TYPE_FIELDS (new_record_type));
 
-      add_parallel_type (TYPE_STUB_DECL (record_type), new_record_type);
+      add_parallel_type (record_type, new_record_type);
     }
 }
 
-/* Append PARALLEL_TYPE on the chain of parallel types for decl.  */
-
-void
-add_parallel_type (tree decl, tree parallel_type)
-{
-  tree d = decl;
-
-  while (DECL_PARALLEL_TYPE (d))
-    d = TYPE_STUB_DECL (DECL_PARALLEL_TYPE (d));
-
-  SET_DECL_PARALLEL_TYPE (d, parallel_type);
-}
-
 /* Utility function of above to merge LAST_SIZE, the previous size of a record
    with FIRST_BIT and SIZE that describe a field.  SPECIAL is true if this
    represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and