diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-14 19:27:21 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-14 19:27:21 +0000 |
commit | cf07a5908aeeb95b9662cb7b523d30a61cc15cce (patch) | |
tree | 60a554690ff540bb38e350af14ceebfd44fee09f /gcc | |
parent | e38def9ca7953bb5611d08ce8617249516ba5a99 (diff) | |
download | gcc-cf07a5908aeeb95b9662cb7b523d30a61cc15cce.tar.gz |
* exp_dbug.ads (Packed Array Encoding): Document the new encoding for
the unconstrained case.
* gcc-interfaces/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Implement
the encoding. Do not give a name to the pointer type to the XUT type.
* gcc-interfaces/utils.c (gnat_pushdecl): Propagate DECL_ORIGINAL_TYPE
for fat pointer types, if any. Make sure DECL_ARTIFICIAL is cleared
on nodes with DECL_ORIGINAL_TYPE set.
(update_pointer_to): Set DECL_ORIGINAL_TYPE to the original pointer
for fat pointer types. Make sure DECL_ARTIFICIAL is cleared.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151697 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/ada/exp_dbug.ads | 26 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 18 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 18 |
4 files changed, 59 insertions, 15 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5747227dc2b..110d7357c22 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2009-09-14 Eric Botcazou <ebotcazou@adacore.com> + + * exp_dbug.ads (Packed Array Encoding): Document the new encoding for + the unconstrained case. + * gcc-interfaces/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Implement + the encoding. Do not give a name to the pointer type to the XUT type. + * gcc-interfaces/utils.c (gnat_pushdecl): Propagate DECL_ORIGINAL_TYPE + for fat pointer types, if any. Make sure DECL_ARTIFICIAL is cleared + on nodes with DECL_ORIGINAL_TYPE set. + (update_pointer_to): Set DECL_ORIGINAL_TYPE to the original pointer + for fat pointer types. Make sure DECL_ARTIFICIAL is cleared. + 2009-09-14 Richard Henderson <rth@redhat.com> * gcc-interface/misc.c (gnat_init_gcc_eh): Don't call diff --git a/gcc/ada/exp_dbug.ads b/gcc/ada/exp_dbug.ads index 2b30248a78c..3c3144641d8 100644 --- a/gcc/ada/exp_dbug.ads +++ b/gcc/ada/exp_dbug.ads @@ -1094,8 +1094,8 @@ package Exp_Dbug is -- Packed Array Encoding -- --------------------------- - -- For every packed array, two types are created, and both appear in - -- the debugging output. + -- For every constrained packed array, two types are created, and both + -- appear in the debugging output: -- The original declared array type is a perfectly normal array type, -- and its index bounds indicate the original bounds of the array. @@ -1110,12 +1110,27 @@ package Exp_Dbug is -- ttt___XPnnn -- where + -- ttt is the name of the original declared array -- nnn is the component size in bits (1-31) - -- When the debugger sees that an object is of a type that is encoded - -- in this manner, it can use the original type to determine the bounds, - -- and the component size to determine the packing details. + -- When the debugger sees that an object is of a type that is encoded in + -- this manner, it can use the original type to determine the bounds and + -- the component type, and the component size to determine the packing + -- details. + + -- For an unconstrained packed array, the corresponding packed array type + -- is neither used in the generated code nor for debugging information, + -- only the original type is used. In order to convey the packing in the + -- debugging information, the compiler generates the associated fat- and + -- thin-pointer types (see the Pointers to Unconstrained Array section + -- below) using the name of the corresponding packed array type as the + -- base name, i.e. ttt___XPnnn___XUP and ttt___XPnnn___XUT respectively. + + -- When the debugger sees that an object is of a type that is encoded in + -- this manner, it can use the type of the fields to determine the bounds + -- and the component type, and the component size to determine the packing + -- details. ------------------------------------------- -- Packed Array Representation in Memory -- @@ -1257,6 +1272,7 @@ package Exp_Dbug is -- fat-pointer type whose name is "arr___XUP", where "arr" is the name -- of the array type, and use it to represent the array type itself in -- the debugging information. + -- For each pointer to this unconstrained array type, the compiler will -- generate a typedef that points to the above "arr___XUP" fat-pointer -- type. As a consequence, when it comes to fat-pointer types: diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 255821e49c8..ed393388c5c 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1782,7 +1782,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) case E_String_Type: case E_Array_Type: { - Entity_Id gnat_index; + Entity_Id gnat_index, gnat_name; const bool convention_fortran_p = (Convention (gnat_entity) == Convention_Fortran); const int ndim = Number_Dimensions (gnat_entity); @@ -2066,8 +2066,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) tem, NULL, !Comes_From_Source (gnat_entity), debug_info_p, gnat_entity); - /* Give the fat pointer type a name. */ - create_type_decl (create_concat_name (gnat_entity, "XUP"), + /* Give the fat pointer type a name. If this is a packed type, tell + the debugger how to interpret the underlying bits. */ + if (Present (Packed_Array_Type (gnat_entity))) + gnat_name = Packed_Array_Type (gnat_entity); + else + gnat_name = gnat_entity; + create_type_decl (create_concat_name (gnat_name, "XUP"), gnu_fat_type, NULL, true, debug_info_p, gnat_entity); @@ -2075,16 +2080,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) record type for the object and its template with the field offsets shifted to have the template at a negative offset. */ tem = build_unc_object_type (gnu_template_type, tem, - create_concat_name (gnat_entity, "XUT")); + create_concat_name (gnat_name, "XUT")); shift_unc_components_for_thin_pointers (tem); SET_TYPE_UNCONSTRAINED_ARRAY (tem, gnu_type); TYPE_OBJECT_RECORD_TYPE (gnu_type) = tem; - - /* Give the thin pointer type a name. */ - create_type_decl (create_concat_name (gnat_entity, "XUX"), - build_pointer_type (tem), NULL, true, - debug_info_p, gnat_entity); } break; diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index bd6a840b245..31f24ce0340 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -495,8 +495,12 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) TYPE_NAME (tt) = decl; TREE_USED (tt) = TREE_USED (t); TREE_TYPE (decl) = tt; - DECL_ORIGINAL_TYPE (decl) = t; + if (DECL_ORIGINAL_TYPE (TYPE_NAME (t))) + DECL_ORIGINAL_TYPE (decl) = DECL_ORIGINAL_TYPE (TYPE_NAME (t)); + else + DECL_ORIGINAL_TYPE (decl) = t; t = NULL_TREE; + DECL_ARTIFICIAL (decl) = 0; } else if (DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl)) ; @@ -3665,6 +3669,18 @@ update_pointer_to (tree old_type, tree new_type) TYPE_POINTER_TO (new_type) = TYPE_REFERENCE_TO (new_type) = TREE_TYPE (new_type) = ptr; + /* And show the original pointer NEW_PTR to the debugger. This is the + counterpart of the equivalent processing in gnat_pushdecl when the + unconstrained array type is frozen after access types to it. Note + that update_pointer_to can be invoked multiple times on the same + couple of types because of the type variants. */ + if (TYPE_NAME (ptr) + && TREE_CODE (TYPE_NAME (ptr)) == TYPE_DECL + && !DECL_ORIGINAL_TYPE (TYPE_NAME (ptr))) + { + DECL_ORIGINAL_TYPE (TYPE_NAME (ptr)) = new_ptr; + DECL_ARTIFICIAL (TYPE_NAME (ptr)) = 0; + } for (var = TYPE_MAIN_VARIANT (ptr); var; var = TYPE_NEXT_VARIANT (var)) SET_TYPE_UNCONSTRAINED_ARRAY (var, new_type); |