PIPS
postcondition.c File Reference
#include <stdio.h>
#include <string.h>
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "misc.h"
#include "semantics.h"
#include "transformer.h"
+ Include dependency graph for postcondition.c:

Go to the source code of this file.

Macros

#define StorePost(stat, val)
 
#define StorePre(stat, val)
 
#define LoadPost(stat)
 
#define LoadPre(stat)
 

Functions

static bool postcondition_filter (statement stat)
 filter used by gen_recurse: Top-down computation of the postcondition mapping More...
 
statement_mapping compute_postcondition (statement stat, statement_mapping post_map, statement_mapping pre_map)
 statement_mapping compute_postcondition(stat, post_map, pre_map) statement stat; statement_mapping post_map, pre_map; More...
 

Variables

static statement_mapping current_precondition_map = hash_table_undefined
 filtering of postconditions More...
 
static statement_mapping current_postcondition_map = hash_table_undefined
 

Macro Definition Documentation

◆ LoadPost

#define LoadPost (   stat)
Value:
(debug(9, "LoadPost", "loading 0x%x\n", stat), \
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
static statement_mapping current_postcondition_map
Definition: postcondition.c:67
struct _newgen_struct_transformer_ * transformer
Definition: ri.h:431

Definition at line 77 of file postcondition.c.

◆ LoadPre

#define LoadPre (   stat)
Value:
(debug(9, "LoadPre", "loading 0x%x\n", stat), \
static statement_mapping current_precondition_map
filtering of postconditions
Definition: postcondition.c:66

Definition at line 81 of file postcondition.c.

◆ StorePost

#define StorePost (   stat,
  val 
)
Value:
(debug(9, "StorePost", "storing 0x%x, 0x%x\n", stat, val), \
hash_put(current_postcondition_map, (char*) (stat), (char*) (val)))

Definition at line 69 of file postcondition.c.

◆ StorePre

#define StorePre (   stat,
  val 
)
Value:
(debug(9, "StorePre", "storing 0x%x, 0x%x\n", stat, val), \
hash_put(current_precondition_map, (char*) (stat), (char*) (val)))

Definition at line 73 of file postcondition.c.

Function Documentation

◆ compute_postcondition()

statement_mapping compute_postcondition ( statement  stat,
statement_mapping  post_map,
statement_mapping  pre_map 
)

statement_mapping compute_postcondition(stat, post_map, pre_map) statement stat; statement_mapping post_map, pre_map;

computes the postcondition mapping post_map from the precondition mapping pre_map and the related statement tree starting from stat. The rule applied is that the postcondition of one statement is the precondition of the following one. The last postcondition is arbitrary set to transformer_identity, what is not enough. (??? should I take the stat transformer?)

the initial postcondition is empty ???

Top-down definition

Parameters
stattat
post_mapost_map
pre_mapre_map

Definition at line 186 of file postcondition.c.

190 {
191  debug_on("SEMANTICS_POSTCONDITION_DEBUG_LEVEL");
192  pips_debug(1, "computing!\n");
193 
194  current_postcondition_map = post_map;
195  current_precondition_map = pre_map;
196 
197  /* the initial postcondition is empty ??? */
199 
200  /* Top-down definition */
202 
205 
206  debug_off();
207  return post_map;
208 }
transformer transformer_identity()
Allocate an identity transformer.
Definition: basic.c:110
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
#define StorePost(stat, val)
Definition: postcondition.c:69
static bool postcondition_filter(statement stat)
filter used by gen_recurse: Top-down computation of the postcondition mapping
Definition: postcondition.c:88
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References current_postcondition_map, current_precondition_map, debug_off, debug_on, gen_null(), gen_recurse, hash_table_undefined, pips_debug, postcondition_filter(), statement_domain, StorePost, and transformer_identity().

Referenced by set_resources_for_module().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postcondition_filter()

static bool postcondition_filter ( statement  stat)
static

filter used by gen_recurse: Top-down computation of the postcondition mapping

??? may happen in obscure unstructured...

??? may be false...

??? is just false...

generates the full list

???

must go downward

Definition at line 88 of file postcondition.c.

89 {
91  transformer post = LoadPost(stat);
92 
93  pips_debug(5, "statement %p (post %p)\n", stat, post);
94 
95  ifdebug(9) {
96  pips_debug(9, "statement is\n");
97  print_statement(stat);
98  }
99 
100  /* ??? may happen in obscure unstructured... */
101  if (transformer_undefined_p(post)) return true;
102 
103  switch(instruction_tag(inst))
104  {
106  {
108 
109  pips_debug(6, "in block\n");
110 
111  MAP(STATEMENT, s,
112  {
113  StorePost(s, post);
114  post = LoadPre(s);
115  },
116  ls);
117 
118  gen_free_list(ls);
119  break;
120  }
121  case is_instruction_test:
122  {
123  test t = instruction_test(inst);
124  pips_debug(6, "in test\n");
125 
126  StorePost(test_true(t), post);
127  StorePost(test_false(t), post);
128 
129  break;
130  }
131  case is_instruction_loop:
132  pips_debug(6, "in loop\n");
133  StorePost(loop_body(instruction_loop(inst)), post);
134  break;
135  case is_instruction_goto:
136  /* ??? may be false... */
137  pips_internal_error("unexpected goto encountered");
138  break;
139  case is_instruction_call:
140  break;
142  /* ??? is just false... */
143  {
145  list blocks = NIL;
146 
147  pips_debug(6, "in unstructured\n");
148 
149  /* generates the full list */
150  CONTROL_MAP(__attribute__ ((unused)) ct, {}, c, blocks);
151 
153 
154  MAP(CONTROL, c,
155  {
157  StorePost(s, post);
158  post = LoadPre(s); /* ??? */
159  },
160  blocks);
161 
163 
164  break;
165  }
166  default:
167  pips_internal_error("unexpected instruction tag");
168  break;
169  }
170 
171  return true; /* must go downward */
172 }
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
Definition: 3dnow.h:3
static list blocks
lisp of loops
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
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
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define pips_internal_error
Definition: misc-local.h:149
#define LoadPre(stat)
Definition: postcondition.c:81
#define LoadPost(stat)
Definition: postcondition.c:77
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define transformer_undefined_p(x)
Definition: ri.h:2848
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define statement_instruction(x)
Definition: ri.h:2458
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define instruction_unstructured(x)
Definition: ri.h:1532
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References blocks, CONTROL, CONTROL_MAP, control_statement, gen_copy_seq(), gen_free_list(), gen_nreverse(), ifdebug, instruction_block, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, LoadPost, LoadPre, loop_body, MAP, NIL, pips_debug, pips_internal_error, print_statement(), STATEMENT, statement_instruction, StorePost, test_false, test_true, transformer_undefined_p, and unstructured_control.

Referenced by compute_postcondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ current_postcondition_map

statement_mapping current_postcondition_map = hash_table_undefined
static

Definition at line 67 of file postcondition.c.

Referenced by compute_postcondition().

◆ current_precondition_map

statement_mapping current_precondition_map = hash_table_undefined
static

filtering of postconditions

Standard includes Psystems stuff Newgen stuff PIPS stuff

Definition at line 66 of file postcondition.c.

Referenced by compute_postcondition().