PIPS
call.c
Go to the documentation of this file.
1 /*
2 
3  $Id: call.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /*
28  * Fabien COELHO
29  */
30 
31 #include "local-header.h"
32 
33 /* these functions must translate external reductions into local ones if
34  * must be. thus it is similar to summary effects call translations.
35  * I do reuse some functions there by generating fake effects...
36  * I think they should be cleaned so as to offer reference plus predicate
37  * translations, and then would be used by reductions and effects.
38  * Fabien.
39  */
40 
41 /* translation of a reference, based on effect translations...
42  * such an interface should be available?
43  */
44 list /* of reference */
46  call c,
47  reference r)
48 {
49  effect e = make_simple_effect(r, /* persistent! */
52  list /* of effect */ lef, /* of reference */ lref = NIL;
53 
54  pips_debug(7, "reference to %s\n", entity_name(reference_variable(r)));
55 
57 
58  FOREACH (EFFECT, ef, lef) {
59  lref = CONS(REFERENCE, effect_any_reference(ef), lref);
60  }
61 
63  gen_free_list(lef);
64  return lref;
65 }
66 
67 static list /* of reduction */
69 
70  reference ref = reduction_reference(external_red);
72  list /* of reference */ lref = summary_to_proper_reference(c, ref);
73  list /* of reduction */ lrds = NIL;
74 
75  pips_debug(7, "reduction %s[%s] (%td reductions)\n",
76  reduction_name(external_red),
77  entity_name(var), gen_length(lref));
78 
79  FOREACH (REFERENCE, r, lref) {
80  reduction red = copy_reduction(external_red);
81 
84 
87 
90  reduction_trusted(red) = NIL;
91 
92  /* ??? what about effects on commons hidden in the call?
93  * I do not know the reference to trust in the effects...
94  */
96 
97  pips_debug(7, "reduction on %s translated on %s\n",
99 
100  lrds = CONS(REDUCTION, red, lrds);
101  }
102 
103  gen_free_list(lref); /* just the backbone, refs are real in the code? */
104  return lrds;
105 }
106 
107 /**@return the list of proper reduction applicable to the call according to
108  * the summary reduction computed earlier.
109  * @param c, the call to check for proper reductions
110  */
111 list /* of reduction */
113  call c)
114 {
115  entity fun = call_function(c);
116  list /* of reduction */ lr = NIL;
117 
118  if (!entity_module_p(fun))
119  return NIL;
120 
122  lr = gen_nconc(translate_reduction(c, r), lr);
123  }
124 
125  return lr;
126 }
127 /* end of it
128  */
approximation make_approximation(enum approximation_utype tag, void *val)
Definition: effects.c:176
reduction copy_reduction(reduction p)
REDUCTION.
void free_reference(reference p)
Definition: ri.c:2050
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
preference make_preference(reference a1)
Definition: ri.c:1862
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
static list translate_reduction(call c, reduction external_red)
of reduction
Definition: call.c:68
list summary_to_proper_reference(call c, reference r)
these functions must translate external reductions into local ones if must be.
Definition: call.c:45
list translate_reductions(call c)
of reduction
Definition: call.c:112
list summary_effect_to_proper_effect(call, effect)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define make_simple_effect(reference, action, approximation)
action make_action_write_memory(void)
To ease the extension of action with action_kind.
Definition: effects.c:1011
@ is_approximation_exact
Definition: effects.h:343
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
#define UU
Definition: newgen_types.h:98
reductions load_summary_reductions(entity f)
Fortran 77 anti aliasing rules implies that sg that looks like a reduction within a subroutine can be...
Definition: reductions.c:55
#define reduction_variable(r)
shorthands for REDUCTION:
#define REDUCTION(x)
REDUCTION.
#define reduction_dependences(x)
#define reduction_reference(x)
#define reduction_trusted(x)
#define reductions_list(x)
bool entity_module_p(entity e)
Definition: entity.c:683
#define PREFERENCE(x)
PREFERENCE.
Definition: ri.h:2073
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define entity_name(x)
Definition: ri.h:2790
static char * reduction_name(int kind)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41