PIPS
newblockalgo.c
Go to the documentation of this file.
1 /*
2 
3  $Id: newblockalgo.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 complexity new_block_to_complexity(block, precond, effects_list)
28 list block;
29 transformer precond;
30 list effects_list;
31 {
33  /* initilize the complexity as zero complexity */
34 
35  Pbase final_var_comp = NIL;
36  /* variables in final complexity result */
37 
38  list block_reverse = gen_nreverse(block);
39  /* get reverse order, because we want to go over the complexity
40  bottom-up */
41 
42  Pbase block_var_must = var_in_must_be_written(effects_list);
43  /* Get the must_be_written variables from the block effects,
44  which means that these variables should NOT be contained in
45  the block complexity results */
46 
47  trace_on("block"); /* begining of trace */
48 
49  MAPL (pa, {
50  statement stat = STATEMENT(CAR(pa)); /* find each stmt of the block */
51 
52  complexity ctemp = statement_to_complexity(stat, precond, effects_list);
53  /* Get the un-evaluated complexity for the stmt */
54 
56  /* Get the precondition for the stmt */
57 
58  list cumu_list = load_statement_cumulated_effects(stat);
59  /* Get the cumulated effects of the stmt */
60 
61  Pbase var_comp = var_in_comp(ctemp);
62  /* Obtain all the eventual variables from the complexity result */
63 
64  Pbase var_must = var_in_must_be_written(cumu_list);
65  /* Find from effects that which variable is must be written */
66 
67  for ( var in (var_comp and var_must) ) {
68  /* if var is in var_comp and is must_be_written variable */
69 
70  complexity csubst = evaluate_var_to_complexity(var, cumu_list, prec);
71  /* Evaluate that variable to complexity */
72 
73  if ( csubst is not unknown )
74  complexity_var_subst(ctmp, var, csubst);
75  else
76  complexity_var_subst(ctmp, var, UU_);
77  }
78 
79  complexity_add(&comp, ctemp);
80  /* add the complexity togather */
81  }, block_reverse);
82 
83  complexity_check_and_warn("block_to_complexity", comp);
84  /* verification of the final complexity */
85 
86  trace_off(); /* end of trace */
87  return(comp);
88 }
89 
90 
91 
complexity evaluate_var_to_complexity(entity var, transformer precond, list effects_list __attribute__((__unused__)), int maximize)
complexity evaluate_var_to_complexity(entity var, transformer precond, list effects_list,...
void complexity_add(complexity *pcomp1, complexity comp2)
void complexity_add(complexity *pcomp1, comp2) performs *pcomp1 = *pcomp1 + comp2; !...
Definition: comp_math.c:372
complexity make_zero_complexity()
make a zero complexity "0.0000 * TCST" with null statistics
Definition: comp_math.c:238
complexity complexity_var_subst(complexity comp, Variable var, complexity compsubst)
complexity complexity_var_subst(comp, var, compsubst) replaces every occurrence of variable var in co...
Definition: comp_math.c:155
complexity statement_to_complexity(statement stat, transformer precon __attribute__((__unused__)), list eff_list __attribute__((__unused__)))
starting point of Abstract Syntax Tree
Definition: comp_scan.c:230
void trace_on(char *fmt,...)
Definition: comp_util.c:684
void complexity_check_and_warn(char *s, complexity comp) const
Definition: comp_util.c:108
void trace_off()
"trace off"
Definition: comp_util.c:714
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
complexity new_block_to_complexity(list block, transformer precond, list effects_list)
Definition: newblockalgo.c:27
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
transformer load_statement_precondition(statement)
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
struct block block