PIPS
parser.c File Reference
#include "defines-local.h"
#include <ctype.h>
#include "workspace-util.h"
#include "prettyprint.h"
+ Include dependency graph for parser.c:

Go to the source code of this file.

Functions

void step_bison_parse (pragma pgm, statement stmt)
 
void step_comment2pragma_handle (statement stmt)
 
static void print_step_blocks ()
 
static step_directive new_step_directive (statement directive_stmt, int type, string s)
 Functions used for gen_multi_recurse. More...
 
static void reset_step_transform ()
 
static step_directive get_current_step_directive (bool open)
 
 DEFINE_LOCAL_STACK (step_blocks, sequence)
 
void set_current_transform (int transform)
 Functions called from the BISON parser. More...
 
void insert_optional_pragma (int type)
 
entity entity_from_user_name (string name)
 
void remove_old_pragma (void)
 
step_directive begin_omp_construct (int type, string s)
 
step_directive end_omp_construct (int type)
 
static void step_pragma_handle (statement stmt)
 
static bool statement_filter (statement stmt)
 
static void statement_rewrite (statement stmt)
 
static bool sequence_filter (sequence __attribute__((unused)) seq)
 
static void sequence_rewrite (sequence seq)
 
static void step_directive_parser (statement body)
 
bool step_parser (const char *module_name)
 

Variables

static statement current_statement = statement_undefined
 
static pragma current_pragma = pragma_undefined
 
static int current_transform = -1
 

Function Documentation

◆ begin_omp_construct()

step_directive begin_omp_construct ( int  type,
string  s 
)

In C, these OpenMP pragmas are already supported by blocks: no block conversion needed

Definition at line 159 of file parser.c.

160 {
161  statement directive_stmt;
162 
163  pips_debug(1,"begin type = %d, str = %s\n", type, s);
164 
165  directive_stmt = current_statement;
166 
168  {
169  switch(type)
170  {
171  case STEP_DO:
172  case STEP_PARALLEL_DO:
173  pips_assert("loop statement", statement_loop_p(directive_stmt)||statement_forloop_p(directive_stmt));
175  _FALLTHROUGH_; // is that so?
176  case STEP_PARALLEL:
177  case STEP_MASTER:
178  case STEP_SINGLE:
179  case STEP_BARRIER:
180  directive_stmt = make_empty_block_statement();
181  break;
182  case STEP_THREADPRIVATE:
183  directive_stmt = make_empty_block_statement();
184  break;
185  default:
186  pips_user_error("unknown directive type %d\n", type);
187  break;
188  }
189  }
191  {
192  switch(type)
193  {
194  case STEP_DO:
195  case STEP_PARALLEL_DO:
196  {
197  statement new_stmt;
198  pips_assert("loop statement", statement_loop_p(directive_stmt)||statement_forloop_p(directive_stmt));
199  pips_debug(2,"Block conversion (C)\n");
200 
201  new_stmt = instruction_to_statement(statement_instruction(directive_stmt));
202 
203  move_statement_attributes(directive_stmt, new_stmt);
204  statement_label(directive_stmt) = entity_empty_label();
205  statement_comments(directive_stmt) = empty_comments;
206  statement_declarations(directive_stmt) = NIL;
207  statement_decls_text(directive_stmt) = NULL;
208  statement_extensions(directive_stmt) = empty_extensions();
209  statement_instruction(directive_stmt) = make_instruction_block(CONS(STATEMENT, new_stmt, NIL));
210  }
211  case STEP_PARALLEL:
212  case STEP_MASTER:
213  case STEP_SINGLE:
214  /* In C, these OpenMP pragmas are already supported by blocks: no block conversion needed */
215  break;
216  case STEP_BARRIER:
217  directive_stmt = make_empty_block_statement();
218  break;
219  case STEP_THREADPRIVATE:
220  directive_stmt = make_empty_block_statement();
221  break;
222  default:
223  pips_user_error("unknown directive type %d\n", type);
224  break;
225  }
226  }
227  else
228  pips_user_error("language not supported");
229 
230  step_directive drt = new_step_directive(directive_stmt, type, s);
231 
233  {
234  step_blocks_push(statement_sequence(directive_stmt));
235  }
236 
237  pips_debug(1,"end drt = %p\n", drt);
238  return drt;
239 }
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
void move_statement_attributes(statement, statement)
Move all the attributes from one statement to another one.
Definition: statement.c:657
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
Definition: statement.c:1328
bool statement_forloop_p(statement)
Definition: statement.c:374
bool statement_loop_p(statement)
Definition: statement.c:349
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define _FALLTHROUGH_
Definition: misc-local.h:238
#define pips_user_error
Definition: misc-local.h:147
#define empty_comments
Empty comments (i.e.
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
entity entity_empty_label(void)
Definition: entity.c:1105
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define statement_label(x)
Definition: ri.h:2450
#define statement_extensions(x)
Definition: ri.h:2464
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define statement_decls_text(x)
Definition: ri.h:2462
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
static step_directive new_step_directive(statement directive_stmt, int type, string s)
Functions used for gen_multi_recurse.
Definition: parser.c:322
static statement current_statement
Definition: parser.c:11
void insert_optional_pragma(int type)
Definition: parser.c:46
#define STEP_THREADPRIVATE
Definition: step_common.h:50
#define STEP_SINGLE
Definition: step_common.h:49
#define STEP_PARALLEL
Handled construction.
Definition: step_common.h:43
#define STEP_PARALLEL_DO
Definition: step_common.h:45
#define STEP_MASTER
Definition: step_common.h:46
#define STEP_DO
Definition: step_common.h:44
#define STEP_BARRIER
Definition: step_common.h:48

References _FALLTHROUGH_, c_module_p(), CONS, current_statement, empty_comments, empty_extensions(), entity_empty_label(), fortran_module_p(), get_current_module_entity(), insert_optional_pragma(), instruction_to_statement(), make_empty_block_statement(), make_instruction_block(), move_statement_attributes(), new_step_directive(), NIL, pips_assert, pips_debug, pips_user_error, STATEMENT, statement_comments, statement_declarations, statement_decls_text, statement_extensions, statement_forloop_p(), statement_instruction, statement_label, statement_loop_p(), statement_sequence(), STEP_BARRIER, STEP_DO, STEP_MASTER, STEP_PARALLEL, STEP_PARALLEL_DO, STEP_SINGLE, and STEP_THREADPRIVATE.

+ Here is the call graph for this function:

◆ DEFINE_LOCAL_STACK()

DEFINE_LOCAL_STACK ( step_blocks  ,
sequence   
)

◆ end_omp_construct()

step_directive end_omp_construct ( int  type)

suppression du CONTINUE portant le pragma optionnel dans le futur block

Definition at line 248 of file parser.c.

249 {
250  step_directive drt;
251 
252  pips_debug(1,"begin type = %d\n", type);
253 
256  {
257  switch(type)
258  {
259  case STEP_DO:
260  case STEP_PARALLEL_DO:
261  {
262  sequence current_block;
263  statement last_stmt;
264 
265 
266  current_block = step_blocks_head();
267  last_stmt = STATEMENT(CAR(sequence_statements(current_block)));
268  /* suppression du CONTINUE portant le pragma optionnel dans le futur block */
269  while (empty_statement_or_labelless_continue_p(last_stmt))
270  {
271  pips_debug(2,"POP current_block");
272  POP(sequence_statements(current_block));
273  last_stmt = STATEMENT(CAR(sequence_statements(current_block)));
274  }
275  if(step_directives_bound_p(last_stmt))
276  {
277  drt = step_directives_load(last_stmt);
278  if (step_directive_type(drt) != type)
279  pips_user_error("\nDirective end-loop not well formed\n");
280  else
281  pips_debug(2,"loop directive already closed\n");
282  }
283  else if (!statement_loop_p(last_stmt))
284  pips_user_error("\nDirective end-loop after a no-loop statement\n");
285  }
286  default:
287  break;
288  }
289 
291  {
292  drt = get_current_step_directive(true);
293 
295  pips_user_error("\nDirective not well formed\n");
296 
297  int size = step_blocks_size();
298  sequence new_seq = step_blocks_pop();
299  pips_debug(2,"pop block directive\n");
300  pips_debug(2, "block_stack size :%d\t new_seq_length=%d\n", size, (int)gen_length(sequence_statements(new_seq)));
301 
302  statement directive_stmt = step_directive_block(drt);
303  sequence_statements(statement_sequence(directive_stmt)) = gen_nreverse(statement_block(directive_stmt));
304  }
305  }
306 
307  pips_debug(1, "end drt = %p\n", drt);
308  return drt;
309 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
bool empty_statement_or_labelless_continue_p(statement)
Return true if the statement is an empty instruction block without label or a continue without label ...
Definition: statement.c:446
#define sequence_statements(x)
Definition: ri.h:2360
bool step_directives_bound_p(statement stmt)
Definition: directives.c:121
step_directive step_directives_load(statement stmt)
Definition: directives.c:116
static step_directive get_current_step_directive(bool open)
Definition: parser.c:382
#define step_directive_undefined
Definition: step_private.h:404
#define step_directive_type(x)
Definition: step_private.h:429
#define step_directive_block(x)
Definition: step_private.h:431
#define step_directive_undefined_p(x)
Definition: step_private.h:405

References CAR, empty_statement_or_labelless_continue_p(), fortran_module_p(), gen_length(), gen_nreverse(), get_current_module_entity(), get_current_step_directive(), pips_debug, pips_user_error, POP, sequence_statements, STATEMENT, statement_block(), statement_loop_p(), statement_sequence(), step_directive_block, step_directive_type, step_directive_undefined, step_directive_undefined_p, step_directives_bound_p(), step_directives_load(), STEP_DO, and STEP_PARALLEL_DO.

+ Here is the call graph for this function:

◆ entity_from_user_name()

entity entity_from_user_name ( string  name)

passage de name a NAME

determiner le nom avec le bon scope...

Parameters
nameame

Definition at line 67 of file parser.c.

68 {
70 
71  pips_debug(1, "begin\n");
72 
74  {
75  /* passage de name a NAME */
76  size_t i;
77  for (i=0; i<strlen(name); i++)
78  name[i]=toupper(name[i]);
79 
82  if (entity_undefined_p(e))
83  pips_user_error("\nFortran entity \"%s\" not found\n", full_name);
84  free(full_name);
85  }
87  {
88  /* determiner le nom avec le bon scope... */
89  statement stmt_declaration = current_statement;
90  pips_debug(4,"##### ENTITY DECL #####\n");
91  while (entity_undefined_p(e) && stmt_declaration)
92  {
93  FOREACH(entity, ee, statement_declarations(stmt_declaration))
94  {
95  pips_debug(4, "entity decl : \"%s\"\n", entity_name(ee));
96  if (strcmp(name, entity_user_name(ee)) == 0)
97  {
98  e = ee;
99  break;
100  }
101  }
102  stmt_declaration = (statement)gen_get_ancestor(statement_domain, stmt_declaration);
103  }
104 
105  if (entity_undefined_p(e))
106  {
108  {
109  pips_debug(4, "entity decl : \"%s\"\n", entity_name(ee));
110  if (strcmp(name, entity_user_name(ee)) == 0)
111  {
112  e = ee;
113  break;
114  }
115  }
116  }
117  if (entity_undefined_p(e))
118  {
120  string full_name = strdup(concatenate(cu, MODULE_SEP_STRING, name, NULL));
122  free(full_name);
123  }
124  if (entity_undefined_p(e))
125  {
128  free(full_name);
129  }
130 
131  if (entity_undefined_p(e))
132  pips_user_error("\nC Entity \"%s\" not found\n", name);
133  }
134 
135  pips_debug(1, "end\n");;
136  return e;
137 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350
void free(void *)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
#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 full_name(dir, name)
Definition: compile.c:414
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
code entity_code(entity e)
Definition: entity.c:1098
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define code_declarations(x)
Definition: ri.h:784
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strdup()

References c_module_p(), code_declarations, compilation_unit_of_module(), concatenate(), current_statement, entity_code(), entity_domain, entity_name, entity_undefined, entity_undefined_p, entity_user_name(), FOREACH, fortran_module_p(), free(), full_name, gen_find_tabulated(), gen_get_ancestor(), get_current_module_entity(), get_current_module_name(), MODULE_SEP_STRING, pips_debug, pips_user_error, statement_declarations, statement_domain, strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by step_add_to_ident_list().

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

◆ get_current_step_directive()

static step_directive get_current_step_directive ( bool  open)
static

Definition at line 382 of file parser.c.

383 {
385  {
386  pips_assert("stack size", step_blocks_size() > 1);
387 
388  sequence parent_block = step_blocks_nth(2);
389 
390  statement last_stmt = STATEMENT(CAR(sequence_statements(parent_block)));
391  STEP_DEBUG_STATEMENT(1, "last_stmt 1", last_stmt);
392 
393  pips_assert("directive", step_directives_bound_p(last_stmt));
394  pips_assert("sequence", statement_sequence_p(last_stmt));
395  pips_assert("same sequence", statement_sequence(last_stmt)==step_blocks_head());
396 
397  return step_directives_load(last_stmt);
398  }
399  else if(!step_blocks_empty_p())
400  {
401  sequence current_block = step_blocks_head();
402 
403  if (!ENDP(sequence_statements(current_block)))
404  {
405  statement last_stmt = STATEMENT(CAR(sequence_statements(current_block)));
406  STEP_DEBUG_STATEMENT(1,"last_stmt 2",last_stmt);
407 
408  if(step_directives_bound_p(last_stmt))
409  return step_directives_load(last_stmt);
410  }
411  }
412 
414 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
bool statement_sequence_p(statement)
Statement classes induced from instruction type.
Definition: statement.c:335
#define STEP_DEBUG_STATEMENT(D, W, S)
Definition: defines-local.h:42

References CAR, ENDP, fortran_module_p(), get_current_module_entity(), pips_assert, sequence_statements, STATEMENT, statement_sequence(), statement_sequence_p(), STEP_DEBUG_STATEMENT, step_directive_undefined, step_directives_bound_p(), and step_directives_load().

Referenced by end_omp_construct().

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

◆ insert_optional_pragma()

void insert_optional_pragma ( int  type)

Definition at line 46 of file parser.c.

47 {
49 
50  switch (type)
51  {
52  case STEP_DO:
53  add_pragma_str_to_statement(new_stmt, "ompenddo\n", true);
54  break;
55  case STEP_PARALLEL_DO:
56  add_pragma_str_to_statement(new_stmt, "ompendparalleldo\n", true);
57  break;
58  default:
59  pips_user_error("Unexpected pragma type %d\n", type);
60  }
62  pips_assert("parent", parent_stmt != NULL);
63  pips_assert("block", statement_block_p(parent_stmt));
64  gen_insert_after(new_stmt, current_statement, statement_block(parent_stmt));
65 }
void gen_insert_after(const void *no, const void *o, list l)
Definition: list.c:223
statement make_plain_continue_statement(void)
Make a simple continue statement to be used as a NOP or ";" in C.
Definition: statement.c:964
#define statement_block_p(stat)
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

References add_pragma_str_to_statement(), current_statement, gen_get_ancestor(), gen_insert_after(), make_plain_continue_statement(), pips_assert, pips_user_error, statement_block(), statement_block_p, statement_domain, STEP_DO, and STEP_PARALLEL_DO.

Referenced by begin_omp_construct().

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

◆ new_step_directive()

static step_directive new_step_directive ( statement  directive_stmt,
int  type,
string  s 
)
static

Functions used for gen_multi_recurse.

Definition at line 322 of file parser.c.

323 {
324  step_directive drt;
325  sequence current_block;
326 
327  pips_debug(1,"begin directive_stmt = %p, type = %d, str = %s\n", directive_stmt, type, s);
328 
329  if(!statement_block_p(directive_stmt))
330  {
331  pips_debug(0,"Directive type : %s\n", s);
332  STEP_DEBUG_STATEMENT(0, "on statement", directive_stmt);
333  pips_assert("block statement", false);
334  }
335 
336 
337  pips_debug(2, "make_step_directive\n");
339  step_directives_store(directive_stmt, drt);
340  add_pragma_str_to_statement(directive_stmt, strdup(concatenate(STEP_SENTINELLE, s, NULL)), false);
341 
342  current_block = step_blocks_head();
343  sequence_statements(current_block) = CONS(STATEMENT, directive_stmt, sequence_statements(current_block));
344 
346 
347  pips_debug(1,"end drt = %p\n", drt);
348  return drt;
349 }
step_directive make_step_directive(intptr_t a1, statement a2, list a3)
Definition: step_private.c:405
step_clause make_step_clause_transformation(intptr_t _field_)
Definition: step_private.c:249
#define STEP_SENTINELLE
STEP sentinelle.
Definition: defines-local.h:48
void step_directives_store(statement stmt, step_directive d)
Definition: directives.c:126
static int current_transform
Definition: parser.c:13
static void reset_step_transform()
Definition: parser.c:362
#define STEP_CLAUSE(x)
STEP_CLAUSE.
Definition: step_private.h:227

References add_pragma_str_to_statement(), concatenate(), CONS, current_transform, make_step_clause_transformation(), make_step_directive(), NIL, pips_assert, pips_debug, reset_step_transform(), sequence_statements, STATEMENT, statement_block_p, STEP_CLAUSE, STEP_DEBUG_STATEMENT, step_directives_store(), STEP_SENTINELLE, and strdup().

Referenced by begin_omp_construct().

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

◆ print_step_blocks()

static void print_step_blocks ( )
static

Definition at line 352 of file parser.c.

353 {
354  int size;
355  int head_len;
356 
357  size = step_blocks_size();
358  head_len = size?gen_length(sequence_statements(step_blocks_head())):0;
359  pips_debug(4, "size = %d, head_length = %d\n", size, head_len);
360 }

References gen_length(), pips_debug, and sequence_statements.

Referenced by sequence_filter(), statement_filter(), and statement_rewrite().

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

◆ remove_old_pragma()

void remove_old_pragma ( void  )

Definition at line 139 of file parser.c.

140 {
141  pips_assert("statement defined", !statement_undefined_p(current_statement));
142  pips_assert("pragma defined", !pragma_undefined_p(current_pragma));
143 
145 
146  list el = extensions_extension(es);
147 
149  FOREACH(EXTENSION, e, el)
150  {
152  if (p != current_pragma)
154  }
155 
157 }
list gen_extension_cons(extension p, list l)
Definition: ri.c:908
#define extension_pragma(x)
Definition: ri.h:1295
#define EXTENSION(x)
EXTENSION.
Definition: ri.h:1253
#define extensions_extension(x)
Definition: ri.h:1330
#define statement_undefined_p(x)
Definition: ri.h:2420
#define pragma_undefined_p(x)
Definition: ri.h:1998
static pragma current_pragma
Definition: parser.c:12
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References current_pragma, current_statement, EXTENSION, extension_pragma, extensions_extension, FOREACH, gen_extension_cons(), gen_nreverse(), NIL, pips_assert, pragma_undefined_p, statement_extensions, and statement_undefined_p.

+ Here is the call graph for this function:

◆ reset_step_transform()

static void reset_step_transform ( )
static

Definition at line 362 of file parser.c.

363 {
364  const char* transformation = get_string_property("STEP_DEFAULT_TRANSFORMATION");
365 
372  else
374 
375  pips_debug(2, "step transform type : %d\n", current_transform);
376 }
char * get_string_property(const char *)
#define STEP_TRANSFORMATION_HYBRID
Definition: defines-local.h:57
#define STEP_TRANSFORMATION_SEQ
Definition: defines-local.h:58
#define STEP_TRANSFORMATION_OMP
Definition: defines-local.h:55
#define STEP_DEFAULT_TRANSFORMATION_HYBRID_TXT
Definition: defines-local.h:52
#define STEP_TRANSFORMATION_MPI
Definition: defines-local.h:56
#define STEP_DEFAULT_TRANSFORMATION_MPI_TXT
Definition: defines-local.h:53
#define STEP_DEFAULT_TRANSFORMATION_OMP_TXT
Definition: defines-local.h:51

References current_transform, get_string_property(), pips_debug, STEP_DEFAULT_TRANSFORMATION_HYBRID_TXT, STEP_DEFAULT_TRANSFORMATION_MPI_TXT, STEP_DEFAULT_TRANSFORMATION_OMP_TXT, STEP_TRANSFORMATION_HYBRID, STEP_TRANSFORMATION_MPI, STEP_TRANSFORMATION_OMP, and STEP_TRANSFORMATION_SEQ.

Referenced by new_step_directive(), and step_pragma_handle().

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

◆ sequence_filter()

static bool sequence_filter ( sequence __attribute__((unused))  seq)
static

Definition at line 536 of file parser.c.

537 {
538  pips_debug(1,"begin\n");
539  pips_debug(2,"PUSH empty sequence on step_blocks\n");
540  step_blocks_push(make_sequence(NIL));
541 
543  pips_debug(1,"end\n");
544  return true;
545 }
sequence make_sequence(list a)
Definition: ri.c:2125
static void print_step_blocks()
Definition: parser.c:352

References make_sequence(), NIL, pips_debug, and print_step_blocks().

Referenced by step_directive_parser().

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

◆ sequence_rewrite()

static void sequence_rewrite ( sequence  seq)
static

Definition at line 547 of file parser.c.

548 {
549  int size;
550  sequence previous_block;
551 
552  pips_debug(1,"begin\n");
553 
554  size = step_blocks_size();
555  previous_block = step_blocks_nth(2);
556 
557  if(previous_block && !sequence_undefined_p(previous_block))
558  {
559  statement last_stmt = STATEMENT(CAR(sequence_statements(previous_block)));
561  pips_user_error("\nDirective not well formed\n");
562  }
563 
564  sequence new_seq = step_blocks_pop();
565  pips_debug(2, "POP step_blocks\n");
566  pips_debug(2, "block_stack size :%d\t new_seq_length=%d\n", size, (int)gen_length(sequence_statements(new_seq)));
567 
570  sequence_statements(new_seq) = NIL;
571  free_sequence(new_seq);
572 
573  pips_debug(1,"end\n");
574  return;
575 }
void free_sequence(sequence p)
Definition: ri.c:2092
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define sequence_undefined_p(x)
Definition: ri.h:2339

References CAR, fortran_module_p(), free_sequence(), gen_free_list(), gen_length(), gen_nreverse(), get_current_module_entity(), NIL, pips_debug, pips_user_error, sequence_statements, sequence_undefined_p, STATEMENT, and step_directives_bound_p().

Referenced by step_directive_parser().

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

◆ set_current_transform()

void set_current_transform ( int  transform)

Functions called from the BISON parser.

First part of user prologue.

parser.c

Parameters
transformransform

Definition at line 41 of file parser.c.

42 {
43  current_transform = transform;
44 }

References current_transform.

◆ statement_filter()

static bool statement_filter ( statement  stmt)
static

For fortran programs, converting comments into pragmas

Definition at line 448 of file parser.c.

449 {
450  pips_debug(1,"begin\n");
451  STEP_DEBUG_STATEMENT(2,"begin in stmt",stmt);
452  pips_debug(2,"end in stmt\n");
453 
455 
456  /* For fortran programs, converting comments into pragmas */
459 
460  if (step_blocks_empty_p())
461  {
462  pips_debug(2,"empty step_blocks: nothing to do in the module body\n");
463  }
464  else
465  {
466  statement parent_stmt;
467 
468  pips_debug(2,"Analysing and handling pragmas\n");
469 
471  pips_assert("parent", parent_stmt != NULL);
472 
474  !statement_block_p(parent_stmt))
475  {
476  /*
477  On transforme un statement portant un pragma en block s'il ne l'etait pas deja.
478  L'analyse aura lieu lors du parcours du block nouvellement cree
479  */
480  pips_debug(2,"Block conversion (Fortran)\n");
481 
483  move_statement_attributes(stmt, new_stmt);
484 
488  statement_decls_text(stmt) = NULL;
490 
492  }
493  else
494  {
496 
497  /*
498  Si dans une sequence (== block), on met a jour le block courant
499  Si c'est une directive, elle a ete ajoute a son identification
500  */
501  if(!step_directives_bound_p(stmt) && statement_block_p(parent_stmt))
502  {
503  sequence current_block = step_blocks_head();
504  pips_debug(2,"ADD stmt to the current block\n");
505  sequence_statements(current_block)=CONS(STATEMENT, stmt,
506  sequence_statements(current_block));
507  }
508  else
509  {
510  pips_debug(2,"NOT added to current step_blocks\n");
511  }
512  }
513  }
514 
515  STEP_DEBUG_STATEMENT(2,"begin out stmt",stmt);
516  pips_debug(2,"end out stmt\n");
517  pips_debug(1,"end\n");
518  return true;
519 }
static void step_pragma_handle(statement stmt)
Definition: parser.c:420
void step_comment2pragma_handle(statement stmt)
Definition: statement.c:54

References CONS, empty_comments, empty_extensions(), ENDP, entity_empty_label(), extensions_extension, fortran_module_p(), gen_get_ancestor(), get_current_module_entity(), instruction_to_statement(), make_instruction_block(), move_statement_attributes(), NIL, pips_assert, pips_debug, print_step_blocks(), sequence_statements, STATEMENT, statement_block_p, statement_comments, statement_declarations, statement_decls_text, statement_domain, statement_extensions, statement_instruction, statement_label, step_comment2pragma_handle(), STEP_DEBUG_STATEMENT, step_directives_bound_p(), and step_pragma_handle().

Referenced by step_directive_parser().

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

◆ statement_rewrite()

static void statement_rewrite ( statement  stmt)
static

Definition at line 521 of file parser.c.

522 {
523  pips_debug(1,"begin\n");
524  STEP_DEBUG_STATEMENT(5, "begin in stmt", stmt);
525  pips_debug(5, "end in stmt");
526 
528 
529  STEP_DEBUG_STATEMENT(5, "begin out stmt", stmt);
530  pips_debug(5, "end out stmt");
531 
532  pips_debug(1,"end\n");
533  return;
534 }

References pips_debug, print_step_blocks(), and STEP_DEBUG_STATEMENT.

Referenced by step_directive_parser().

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

◆ step_bison_parse()

void step_bison_parse ( pragma  pgm,
statement  stmt 
)

Definition at line 1901 of file step_bison_parser.c.

1902 {
1903  string pragma_str = pragma_string(pgm);
1904 
1905  if(pragma_str[strlen(pragma_str)-1]!= '\n')
1906  pragma_str = strdup(concatenate(pragma_string(pgm),"\n",NULL));
1907  else
1908  pragma_str = strdup(pragma_string(pgm));
1909 
1910  pips_debug(1, "############### PARSER BEGIN ################\nwith :\n%s\non stmt : %p\n", pragma_str, stmt);
1911  ifdebug(4)
1912  yydebug=1;
1913  pragma_str_original = strdup(pragma_str);
1914  step_lexer_scan_string(pragma_str);
1915  step_lexerparse();
1917  pips_debug(1, "############### PARSER END ################\n");
1918 
1919  free(pragma_str);
1920 }
#define pragma_string(x)
Definition: ri.h:2033
#define ifdebug(n)
Definition: sg.c:47
int step_lexerparse(void)
static string pragma_str_original
#define yydebug
void free(void *)

References concatenate(), free(), ifdebug, pips_debug, pragma_str_original, pragma_string, step_lexerparse(), strdup(), and yydebug.

Referenced by step_pragma_handle().

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

◆ step_comment2pragma_handle()

void step_comment2pragma_handle ( statement  stmt)

Referenced by statement_filter(), and step_directive_parser().

+ Here is the caller graph for this function:

◆ step_directive_parser()

static void step_directive_parser ( statement  body)
static

For fortran programs, converting comments into pragmas into declaration txt

Definition at line 577 of file parser.c.

578 {
579  /* For fortran programs, converting comments into pragmas into declaration txt */
582 
583  make_step_blocks_stack();
584 
585  // where the OpenMP constructs are identified
586  gen_multi_recurse(body,
589  NULL);
590 
591  free_step_blocks_stack();
592 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
#define sequence_domain
newgen_reference_domain_defined
Definition: ri.h:346
#define statement_undefined
Definition: ri.h:2419
static bool statement_filter(statement stmt)
Definition: parser.c:448
static bool sequence_filter(sequence __attribute__((unused)) seq)
Definition: parser.c:536
static void statement_rewrite(statement stmt)
Definition: parser.c:521
static void sequence_rewrite(sequence seq)
Definition: parser.c:547

References fortran_module_p(), gen_multi_recurse(), get_current_module_entity(), sequence_domain, sequence_filter(), sequence_rewrite(), statement_domain, statement_filter(), statement_rewrite(), statement_undefined, and step_comment2pragma_handle().

Referenced by step_parser().

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

◆ step_parser()

bool step_parser ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 594 of file parser.c.

595 {
596  debug_on("STEP_PARSER_DEBUG_LEVEL");
597  pips_debug(1, "%d module_name = %s\n", __LINE__, module_name);
598 
601 
603 
605 
607 
608  ifdebug(1)
609  {
611  }
612 
615 
616 
620 
622 
623  pips_debug(1, "End step_parser\n");
624  debug_off();
625 
626  return true;
627 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
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
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
bool ordering_to_statement_initialized_p()
Test if the ordering to statement is initialized.
Definition: ordering.c:63
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
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
void step_directives_save()
Definition: directives.c:108
void step_directives_print()
Definition: directives.c:79
void step_directives_init(bool first_p)
Definition: directives.c:88
static void step_directive_parser(statement body)
Definition: parser.c:577

References CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, ifdebug, local_name_to_top_level_entity(), make_block_statement(), module_name(), module_reorder(), NIL, ordering_to_statement_initialized_p(), pips_debug, reset_current_module_entity(), reset_ordering_to_statement(), set_current_module_entity(), STATEMENT, step_directive_parser(), step_directives_init(), step_directives_print(), and step_directives_save().

+ Here is the call graph for this function:

◆ step_pragma_handle()

static void step_pragma_handle ( statement  stmt)
static

Definition at line 420 of file parser.c.

421 {
422  pips_debug(1,"begin\n");
423 
424  pips_assert("statement undefined", statement_undefined_p(current_statement));
425  pips_assert("pragma undefined", pragma_undefined_p(current_pragma));
426 
428 
430 
431  STEP_DEBUG_STATEMENT(1, "begin stmt", current_statement);
432  pips_debug(1,"end stmt\n");
433 
435  {
436  pips_debug(2,"for each extension\n");
439  {
441  }
442  }
445  pips_debug(1,"end\n");
446 }
#define pragma_undefined
Definition: ri.h:1997
#define pragma_string_p(x)
Definition: ri.h:2031
void step_bison_parse(pragma pgm, statement stmt)

References current_pragma, current_statement, EXTENSION, extension_pragma, extensions_extension, FOREACH, pips_assert, pips_debug, pragma_string_p, pragma_undefined, pragma_undefined_p, reset_step_transform(), statement_extensions, statement_undefined, statement_undefined_p, step_bison_parse(), and STEP_DEBUG_STATEMENT.

Referenced by statement_filter().

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

Variable Documentation

◆ current_pragma

pragma current_pragma = pragma_undefined
static

Definition at line 12 of file parser.c.

Referenced by remove_old_pragma(), and step_pragma_handle().

◆ current_statement

◆ current_transform

int current_transform = -1
static

Definition at line 13 of file parser.c.

Referenced by new_step_directive(), reset_step_transform(), and set_current_transform().