aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-09-23 12:18:22 +0200
committerMarc Poulhiès <poulhies@adacore.com>2022-10-06 11:22:49 +0200
commit544d14e1b42eeb337fcefb1efe9d108e71a06d52 (patch)
treebd0c716d39a7a07baa17c0edafe236a405387eca /gcc/ada/gcc-interface/decl.cc
parent6c62d9b7b44b10ff272d11bcc430538ab07ef8f6 (diff)
downloadgcc-544d14e1b42eeb337fcefb1efe9d108e71a06d52.zip
gcc-544d14e1b42eeb337fcefb1efe9d108e71a06d52.tar.gz
gcc-544d14e1b42eeb337fcefb1efe9d108e71a06d52.tar.bz2
ada: Implementation of support for storage models in gigi
It is based on a new LOAD_EXPR node in GENERIC that is later turned into a bona-fide temporary during gimplification. gcc/ada/ * gcc-interface/ada-tree.def (LOAD_EXPR): New expression code. * gcc-interface/gigi.h (build_storage_model_load): Declare. (build_storage_model_store): Likewise. (instantiate_load_in_expr): Likewise. (INSTANTIATE_LOAD_IN_EXPR): New macro. (instantiate_load_in_array_ref): Declare. * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Type>: Set a fake discriminant number on the fields of the template type. (gnat_to_gnu_field): Use integer for DECL_DISCRIMINANT_NUMBER. * gcc-interface/misc.cc (gnat_init_ts): Mark LOAD_EXPR as typed. * gcc-interface/trans.cc (fold_constant_decl_in_expr) <ARRAY_REF>: Also preserve the 4th operand. (Attribute_to_gnu): Deal with LOAD_EXPR of unconstrained array type. <Attr_Size>: Call INSTANTIATE_LOAD_IN_EXPR for a storage model. <Attr_Length>: Likewise. <Attr_Bit_Position>: Likewise. (get_storage_model): New function. (get_storage_model_access): Likewise. (storage_model_access_required_p): Likewise. (Call_to_gnu): Add GNAT_STORAGE_MODEL parameter and deal with it. Also deal with actual parameters that have a storage model. (gnat_to_gnu) <N_Object_Declaratio>: Adjust call to Call_to_gnu. <N_Explicit_Dereference>: Deal with a storage model access. <N_Indexed_Component>: Likewise. <N_Slice>: Likewise. <N_Selected_Component>: Likewise. <N_Assignment_Statement>: Adjust call to Call_to_gnu. Deal with a storage model access either on the LHS, on the RHS or on both. <N_Function_Cal>: Adjust call to Call_to_gnu. <N_Free_Statement>: Deal with a pool that is a storage model. Replace test for UNCONSTRAINED_ARRAY_REF with test on the type. (gnat_gimplify_expr) <CALL_EXPR>: Tidy up. <LOAD_EXPR>: New case. <UNCONSTRAINED_ARRAY_REF>: Move down. * gcc-interface/utils.cc (maybe_unconstrained_array): Deal with a LOAD_EXPR by recursing on its first operand. * gcc-interface/utils2.cc (build_allocator): Deal with a pool that is a storage model. (build_storage_model_copy): New function. (build_storage_model_load): Likewise. (build_storage_model_store): Likewise. (instantiate_load_in_expr): Likewise. (instantiate_load_in_array_ref): Likewise. (gnat_rewrite_reference) <ARRAY_REF>: Also preserve the 4th operand. (get_inner_constant_reference) <ARRAY_REF>: Remove useless test. (gnat_invariant_expr) <ARRAY_REF>: Rewrite test.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.cc')
-rw-r--r--gcc/ada/gcc-interface/decl.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index c5a93fb..f8c7698 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2279,6 +2279,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_index_type,
gnu_template_type, NULL_TREE,
NULL_TREE, 0, 0);
+ /* Mark the field specifically for INSTANTIATE_LOAD_IN_EXPR. */
+ DECL_DISCRIMINANT_NUMBER (gnu_lb_field) = integer_minus_one_node;
Sloc_to_locus (Sloc (gnat_entity),
&DECL_SOURCE_LOCATION (gnu_lb_field));
@@ -2287,6 +2289,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_index_type,
gnu_template_type, NULL_TREE,
NULL_TREE, 0, 0);
+ /* Mark the field specifically for INSTANTIATE_LOAD_IN_EXPR. */
+ DECL_DISCRIMINANT_NUMBER (gnu_hb_field) = integer_minus_one_node;
Sloc_to_locus (Sloc (gnat_entity),
&DECL_SOURCE_LOCATION (gnu_hb_field));
@@ -7694,7 +7698,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
if (Ekind (gnat_field) == E_Discriminant)
{
DECL_DISCRIMINANT_NUMBER (gnu_field)
- = UI_To_gnu (Discriminant_Number (gnat_field), sizetype);
+ = UI_To_gnu (Discriminant_Number (gnat_field), integer_type_node);
DECL_INVARIANT_P (gnu_field)
= No (Discriminant_Default_Value (gnat_field));
DECL_NONADDRESSABLE_P (gnu_field) = 0;