From 544d14e1b42eeb337fcefb1efe9d108e71a06d52 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 23 Sep 2022 12:18:22 +0200 Subject: 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) : 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) : Also preserve the 4th operand. (Attribute_to_gnu): Deal with LOAD_EXPR of unconstrained array type. : Call INSTANTIATE_LOAD_IN_EXPR for a storage model. : Likewise. : 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) : Adjust call to Call_to_gnu. : Deal with a storage model access. : Likewise. : Likewise. : Likewise. : Adjust call to Call_to_gnu. Deal with a storage model access either on the LHS, on the RHS or on both. : Adjust call to Call_to_gnu. : Deal with a pool that is a storage model. Replace test for UNCONSTRAINED_ARRAY_REF with test on the type. (gnat_gimplify_expr) : Tidy up. : New case. : 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) : Also preserve the 4th operand. (get_inner_constant_reference) : Remove useless test. (gnat_invariant_expr) : Rewrite test. --- gcc/ada/gcc-interface/ada-tree.def | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/ada/gcc-interface/ada-tree.def') diff --git a/gcc/ada/gcc-interface/ada-tree.def b/gcc/ada/gcc-interface/ada-tree.def index 8eb4688..7fc95cb 100644 --- a/gcc/ada/gcc-interface/ada-tree.def +++ b/gcc/ada/gcc-interface/ada-tree.def @@ -35,6 +35,10 @@ DEFTREECODE (UNCONSTRAINED_ARRAY_TYPE, "unconstrained_array_type", tcc_type, 0) DEFTREECODE (UNCONSTRAINED_ARRAY_REF, "unconstrained_array_ref", tcc_reference, 1) +/* Same as SAVE_EXPR, but operand 1 contains the statement used to initialize + the temporary instead of using the value of operand 0 directly. */ +DEFTREECODE (LOAD_EXPR, "load_expr", tcc_expression, 2) + /* An expression that returns an RTL suitable for its type. Operand 0 is an expression to be evaluated for side effects only. */ DEFTREECODE (NULL_EXPR, "null_expr", tcc_expression, 1) -- cgit v1.1