PIPS
rstream_interface.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "boolean.h"
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "database.h"
#include "misc.h"
#include "text.h"
#include "text-util.h"
#include "ri-util.h"
#include "effects-util.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "pipsdbm.h"
#include "resources.h"
#include "control.h"
#include "conversion.h"
#include "properties.h"
#include "transformations.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrix.h"
#include "graph.h"
#include "paf_ri.h"
#include "constants.h"
#include "paf-util.h"
#include "static_controlize.h"
#include "pocc-interface.h"
#include "preprocessor.h"
#include "callgraph.h"
#include "accel-util.h"
+ Include dependency graph for rstream_interface.c:

Go to the source code of this file.

Macros

#define PRAGMA_TEMP_BEGIN   "nonscop"
 
#define PRAGMA_TEMP_END   "endnonscop"
 
#define PREFIX_TEMP   "nonscopf"
 
#define statement_has_this_pragma_string_p(stmt, str)   (get_extension_from_statement_with_pragma(stmt,str)!=NULL)
 

Typedefs

typedef void * arc_label
 tatic_control More...
 
typedef void * vertex_label
 

Functions

static bool statement_with_pragma_p_inv (statement s)
 
static bool searchPragma (statement s)
 
static void insert_endscop_before_stmt (statement stmt, bool *pragma_added_p, sequence seqInst, list stmts, statement last_added_pragma)
 
static void insert_endscop_after_stmt (statement stmt, bool *pragma_added_p, sequence seqInst, statement last_added_pragma)
 
static void insert_endscop_in_sequence (statement stmt, bool *pragma_added_p, bool insertBefore)
 
static void add_to_stmt (statement stmt, bool *pragma_added_p)
 
void pragma_nonscop (statement s, bool pragma_added_p, bool in_loop_p)
 Warning! Do not modify this file that is automatically generated! More...
 
bool rstream_interface (char *module_name)
 Phase in charge of putting pragmas around the non-SCoP of the code This phase only works if there has been a previous phase applied putting pragmas around SCoP of the code. More...
 

Variables

static statement_mapping Gsc_map
 
static int hasPragma = 0
 

Macro Definition Documentation

◆ PRAGMA_TEMP_BEGIN

#define PRAGMA_TEMP_BEGIN   "nonscop"

Definition at line 68 of file rstream_interface.c.

◆ PRAGMA_TEMP_END

#define PRAGMA_TEMP_END   "endnonscop"

Definition at line 69 of file rstream_interface.c.

◆ PREFIX_TEMP

#define PREFIX_TEMP   "nonscopf"

Definition at line 70 of file rstream_interface.c.

◆ statement_has_this_pragma_string_p

#define statement_has_this_pragma_string_p (   stmt,
  str 
)    (get_extension_from_statement_with_pragma(stmt,str)!=NULL)

Definition at line 72 of file rstream_interface.c.

Typedef Documentation

◆ arc_label

typedef void* arc_label

tatic_control

Pips includes
Types arc_label and vertex_label must be defined although they are not used

Definition at line 48 of file rstream_interface.c.

◆ vertex_label

typedef void* vertex_label

Definition at line 49 of file rstream_interface.c.

Function Documentation

◆ add_to_stmt()

static void add_to_stmt ( statement  stmt,
bool pragma_added_p 
)
static

Definition at line 123 of file rstream_interface.c.

123  {
125  *pragma_added_p = true;
126 }
void add_pragma_str_to_statement(statement st, const char *s, bool copy_flag)
Add a string as a pragma to a statement.
Definition: pragma.c:425
#define PRAGMA_TEMP_BEGIN
Definition: statement.c:54

References add_pragma_str_to_statement(), and PRAGMA_TEMP_BEGIN.

Referenced by pragma_nonscop().

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

◆ insert_endscop_after_stmt()

static void insert_endscop_after_stmt ( statement  stmt,
bool pragma_added_p,
sequence  seqInst,
statement  last_added_pragma 
)
static

Definition at line 106 of file rstream_interface.c.

106  {
107  if (!is_SCOP_rich(seqInst, last_added_pragma, stmt, pragma_added_p))
108  return;
111  *pragma_added_p = false;
112  gen_insert_after(endscop, stmt, sequence_statements(seqInst));
113 }
void gen_insert_after(const void *no, const void *o, list l)
Definition: list.c:223
statement make_continue_statement(entity)
Definition: statement.c:953
bool is_SCOP_rich(sequence, statement, statement, bool *)
Checks if there is at least one loop in the sequence.
entity entity_empty_label(void)
Definition: entity.c:1105
#define sequence_statements(x)
Definition: ri.h:2360
#define PRAGMA_TEMP_END

References add_pragma_str_to_statement(), entity_empty_label(), gen_insert_after(), is_SCOP_rich(), make_continue_statement(), PRAGMA_TEMP_END, and sequence_statements.

Referenced by pragma_nonscop().

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

◆ insert_endscop_before_stmt()

static void insert_endscop_before_stmt ( statement  stmt,
bool pragma_added_p,
sequence  seqInst,
list  stmts,
statement  last_added_pragma 
)
static

Definition at line 97 of file rstream_interface.c.

97  {
98  if (!is_SCOP_rich(seqInst, last_added_pragma, stmt, pragma_added_p))
99  return;
102  *pragma_added_p = false;
103  sequence_statements(seqInst) = gen_insert_before(endscop, stmt, stmts);
104 }
list gen_insert_before(const void *no, const void *o, list l)
Definition: list.c:238

References add_pragma_str_to_statement(), entity_empty_label(), gen_insert_before(), is_SCOP_rich(), make_continue_statement(), PRAGMA_TEMP_END, and sequence_statements.

Referenced by pragma_nonscop().

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

◆ insert_endscop_in_sequence()

static void insert_endscop_in_sequence ( statement  stmt,
bool pragma_added_p,
bool  insertBefore 
)
static

Definition at line 115 of file rstream_interface.c.

115  {
118  *pragma_added_p = false;
119  // Insert the continue statement after the statement parameter, thereby creating a sequence
120  insert_statement(stmt, endscop, insertBefore);
121 }
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570

References add_pragma_str_to_statement(), entity_empty_label(), insert_statement(), make_continue_statement(), and PRAGMA_TEMP_END.

Referenced by pragma_nonscop().

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

◆ pragma_nonscop()

void pragma_nonscop ( statement  s,
bool  pragma_added_p,
bool  in_loop_p 
)

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/rstream_interface/rstream_interface-local.h instead, to add your own modifications. header file built by cproto rstream_interface-local.h cproto-generated files rstream_interface.c

Parameters
pragma_added_pragma_added_p
in_loop_pn_loop_p

Definition at line 129 of file rstream_interface.c.

129  {
130 
131  statement save_stmt = statement_undefined,
132  last_added_pragma = statement_undefined;
133  instruction instTop = statement_instruction(s);
134 
135  switch (instruction_tag(instTop)) {
136 
138  {
139  sequence seqInst = instruction_sequence(instTop);
140  list stmts = sequence_statements(seqInst);
141  FOREACH(statement, stmt, stmts) {
142  save_stmt = stmt;
144  static_control sc;
145  switch (instruction_tag(inst)) {
146  case is_instruction_loop :
147  {
148  bool insideScop = searchPragma(stmt);
149  bool currentScop = statement_with_pragma_p(stmt);
150  loop l = instruction_loop(inst);
152  if (!static_control_yes(sc) && !pragma_added_p && !insideScop) {
153  add_to_stmt(stmt, &pragma_added_p);
154  last_added_pragma = stmt;
155  }
156  else if (!static_control_yes(sc) && !pragma_added_p && insideScop && !currentScop) {
157  pragma_nonscop(stmt, pragma_added_p, true);
158  }
159  else if (static_control_yes(sc) && pragma_added_p) {
160  insert_endscop_before_stmt(stmt, &pragma_added_p, seqInst, stmts, last_added_pragma);
161  }
162  }
163  break;
164  case is_instruction_test :
165  {
166  bool insideScop = searchPragma(stmt);
168  if (!static_control_yes(sc) && !pragma_added_p && !insideScop) {
169  add_to_stmt(stmt, &pragma_added_p);
170  last_added_pragma = stmt;
171  }
172  else if (!in_loop_p && !pragma_added_p && insideScop) {
173  pragma_nonscop(stmt, pragma_added_p, in_loop_p);
174  }
175  else if (static_control_yes(sc) && pragma_added_p) {
176  insert_endscop_before_stmt(stmt, &pragma_added_p, seqInst, stmts, last_added_pragma);
177  }
178  }
179  break;
181  {
182  bool insideScop = searchPragma(stmt);
183  if (!insideScop && !pragma_added_p) {
184  add_to_stmt(stmt, &pragma_added_p);
185  last_added_pragma = stmt;
186  }
187  else if (insideScop) {
188  pragma_nonscop(whileloop_body(instruction_whileloop(inst)), pragma_added_p, in_loop_p);
189  }
190  }
191  break;
192  case is_instruction_call :
193  {
195  bool isDeclaration = declaration_statement_p(stmt);
196  if (return_statement_p(stmt) && pragma_added_p) {
197  insert_endscop_before_stmt(stmt, &pragma_added_p, seqInst, stmts, last_added_pragma);
198  }
199  else if (!static_control_yes(sc) && !pragma_added_p && !isDeclaration) {
200  add_to_stmt(stmt, &pragma_added_p);
201  last_added_pragma = stmt;
202  }
203  else if (static_control_yes(sc) && pragma_added_p) {
204  insert_endscop_before_stmt(stmt, &pragma_added_p, seqInst, stmts, last_added_pragma);
205  }
206  }
207  break;
208  default :
209  {
211  bool currentScop = statement_with_pragma_p(stmt);
212  bool insideScop = searchPragma(stmt);
213  if (pragma_added_p && static_control_yes(sc)) {
214  insert_endscop_before_stmt(stmt, &pragma_added_p, seqInst, stmts, last_added_pragma);
215  }
216  else if (!pragma_added_p && !static_control_yes(sc) && !currentScop && !insideScop) {
217  add_to_stmt(stmt, &pragma_added_p);
218  last_added_pragma = stmt;
219  }
220  }
221  break;
222  }
223  }
224  if (pragma_added_p) {
225  insert_endscop_after_stmt(save_stmt, &pragma_added_p, seqInst, last_added_pragma);
226  }
227  }
228  break;
229  case is_instruction_loop :
230  {
231  loop loopAlone = instruction_loop(instTop);
233  bool insideScop = searchPragma(s);
234  bool currentScop = statement_with_pragma_p(s);
235  if (!static_control_yes(scAlone) && !pragma_added_p && !insideScop && !currentScop) {
236  add_to_stmt(s, &pragma_added_p);
237  last_added_pragma = s;
238  insert_endscop_in_sequence(s, &pragma_added_p, false);
239  }
240  else if (!static_control_yes(scAlone) && insideScop && !currentScop) {
241  pragma_nonscop(loop_body(loopAlone), pragma_added_p, in_loop_p);
242  }
243  }
244  break;
245 
247  {
248  }
249  break;
250 
252  {
253  whileloop whileAlone = instruction_whileloop(instTop);
254  bool currentScop = statement_with_pragma_p(s);
255  if (!currentScop)
256  pragma_nonscop(whileloop_body(whileAlone), pragma_added_p, in_loop_p);
257  }
258  break;
259 
260  case is_instruction_test :
261  {
262  test testAlone = instruction_test(instTop);
263  bool currentScop = statement_with_pragma_p(s);
264  if (!currentScop) {
265  pragma_nonscop(test_true(testAlone), pragma_added_p, in_loop_p);
266  pragma_nonscop(test_false(testAlone), pragma_added_p, in_loop_p);
267  }
268  }
269  break;
270 
271  default :
272  break;
273  }
274  return;
275 }
#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
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
bool statement_with_pragma_p(statement)
Test if a statement has some pragma.
Definition: statement.c:3836
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
struct _newgen_struct_static_control_ * static_control
Definition: paf_ri.h:184
#define static_control_yes(x)
Definition: paf_ri.h:753
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define instruction_sequence(x)
Definition: ri.h:1514
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
#define statement_undefined
Definition: ri.h:2419
static void add_to_stmt(statement stmt, bool *pragma_added_p)
static bool searchPragma(statement s)
static statement_mapping Gsc_map
static void insert_endscop_after_stmt(statement stmt, bool *pragma_added_p, sequence seqInst, statement last_added_pragma)
static void insert_endscop_in_sequence(statement stmt, bool *pragma_added_p, bool insertBefore)
static void insert_endscop_before_stmt(statement stmt, bool *pragma_added_p, sequence seqInst, list stmts, statement last_added_pragma)
void pragma_nonscop(statement s, bool pragma_added_p, bool in_loop_p)
Warning! Do not modify this file that is automatically generated!
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References add_to_stmt(), declaration_statement_p(), FOREACH, GET_STATEMENT_MAPPING, Gsc_map, insert_endscop_after_stmt(), insert_endscop_before_stmt(), insert_endscop_in_sequence(), instruction_loop, instruction_sequence, instruction_tag, instruction_test, instruction_whileloop, is_instruction_call, is_instruction_forloop, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_whileloop, loop_body, return_statement_p(), searchPragma(), sequence_statements, statement_instruction, statement_undefined, statement_with_pragma_p(), static_control_yes, test_false, test_true, and whileloop_body.

Referenced by rstream_interface().

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

◆ rstream_interface()

bool rstream_interface ( char *  module_name)

Phase in charge of putting pragmas around the non-SCoP of the code This phase only works if there has been a previous phase applied putting pragmas around SCoP of the code.

Parameters
module_nameodule_name

Definition at line 281 of file rstream_interface.c.

281  {
282  statement module_stat;
285 
286  module_stat = get_current_module_statement();
287 
288  Gsc_map = (statement_mapping)db_get_memory_resource(DBR_STATIC_CONTROL, module_name, true);
289 
290  pragma_nonscop(module_stat, false, false);
291 
292  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name,module_stat);
293 
296 
297  return true;
298 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
hash_table statement_mapping
these macros are obsolete! newgen functions (->) should be used instead
Definition: newgen-local.h:42
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, get_current_module_statement(), Gsc_map, local_name_to_top_level_entity(), module_name(), pragma_nonscop(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().

+ Here is the call graph for this function:

◆ searchPragma()

static bool searchPragma ( statement  s)
static

Definition at line 85 of file rstream_interface.c.

85  {
87  if (hasPragma != 0) {
88  hasPragma = 0;
89  return true;
90  }
91  else {
92  hasPragma = 0;
93  return false;
94  }
95 }
#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 statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
static int hasPragma
static bool statement_with_pragma_p_inv(statement s)

References gen_null(), gen_recurse, hasPragma, statement_domain, and statement_with_pragma_p_inv().

Referenced by pragma_nonscop().

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

◆ statement_with_pragma_p_inv()

static bool statement_with_pragma_p_inv ( statement  s)
static

Definition at line 78 of file rstream_interface.c.

78  {
79  if (statement_with_pragma_p(s)) {
80  hasPragma++;
81  }
82  return true;
83 }

References hasPragma, and statement_with_pragma_p().

Referenced by searchPragma().

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

Variable Documentation

◆ Gsc_map

statement_mapping Gsc_map
static

Definition at line 75 of file rstream_interface.c.

Referenced by pragma_nonscop(), and rstream_interface().

◆ hasPragma

int hasPragma = 0
static

Definition at line 76 of file rstream_interface.c.

Referenced by searchPragma(), and statement_with_pragma_p_inv().