PIPS
newblockalgo.c File Reference

Go to the source code of this file.

Functions

complexity new_block_to_complexity (list block, transformer precond, list effects_list)
 

Function Documentation

◆ new_block_to_complexity()

complexity new_block_to_complexity ( list  block,
transformer  precond,
list  effects_list 
)

initilize the complexity as zero complexity

variables in final complexity result

get reverse order, because we want to go over the complexity bottom-up

Get the must_be_written variables from the block effects, which means that these variables should NOT be contained in the block complexity results

begining of trace

find each stmt of the block

Get the un-evaluated complexity for the stmt

Get the precondition for the stmt

Get the cumulated effects of the stmt

Obtain all the eventual variables from the complexity result

Find from effects that which variable is must be written

if var is in var_comp and is must_be_written variable

Evaluate that variable to complexity

add the complexity togather

verification of the final complexity

end of trace

Definition at line 27 of file newblockalgo.c.

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 }
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
#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

References CAR, complexity_add(), complexity_check_and_warn(), complexity_var_subst(), evaluate_var_to_complexity(), gen_nreverse(), load_statement_precondition(), make_zero_complexity(), MAPL, NIL, STATEMENT, statement_to_complexity(), trace_off(), and trace_on().

+ Here is the call graph for this function: