PIPS
pragma.c File Reference
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "ri-util.h"
#include "text-util.h"
#include "prettyprint.h"
+ Include dependency graph for pragma.c:

Go to the source code of this file.

Functions

string close_pragma (pragma p __attribute__((unused)))
 
string pragma_to_string (pragma p)
 
void add_expr_to_pragma_expr_list (pragma pr, expression ex)
 Add an expression to the pragma current expression list. More...
 

Function Documentation

◆ add_expr_to_pragma_expr_list()

void add_expr_to_pragma_expr_list ( pragma  pr,
expression  ex 
)

Add an expression to the pragma current expression list.

Returns
void
Parameters
pr,thepragma to process.
ex,theexpression to add.

Add the new pragma to the extension list:

Parameters
prr
exx

Definition at line 147 of file pragma.c.

147  {
148  pips_assert ("the pragma need to be an expression", pragma_expression_p (pr) );
149  /* Add the new pragma to the extension list: */
150  list exprs = pragma_expression (pr);
151  exprs = gen_expression_cons (ex, exprs);
152  pragma_expression (pr) = exprs;
153  string str = pragma_to_string (pr);
154  pips_debug(5, "after: %s", str);
155  free (str);
156  return;
157 }
list gen_expression_cons(expression p, list l)
Definition: ri.c:866
void free(void *)
#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
string pragma_to_string(pragma p)
Definition: pragma.c:69
#define pragma_expression_p(x)
Definition: ri.h:2034
#define pragma_expression(x)
Definition: ri.h:2036
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References free(), gen_expression_cons(), pips_assert, pips_debug, pragma_expression, pragma_expression_p, and pragma_to_string().

Referenced by add_loop_parallel_threshold().

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

◆ close_pragma()

string close_pragma ( pragma p   __attribute__(unused))
Returns
a new allocated string to close the pragma.
Parameters
p,thepragma to be closed

STEP -> les pragma ne sont pas toujours fermés par des "omp end parallel do"

result = strdup(concatenate(FORTRAN_PRAGMA_HEADER, "omp end parallel do", NULL));

Definition at line 53 of file pragma.c.

53  {
54  string result = string_undefined;
56  /* STEP -> les pragma ne sont pas toujours fermés par des "omp end parallel do"
57 
58  result = strdup(concatenate(FORTRAN_PRAGMA_HEADER,
59  "omp end parallel do",
60  NULL));
61  */
62  }
63  return result;
64 }
bool prettyprint_language_is_fortran_p()
Definition: language.c:75
#define string_undefined
Definition: newgen_types.h:40

References prettyprint_language_is_fortran_p(), and string_undefined.

Referenced by close_extension().

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

◆ pragma_to_string()

string pragma_to_string ( pragma  p)
Returns
a new allocated string with the pragma textual representation.

Definition at line 69 of file pragma.c.

69  {
70  bool flg = false;
71  list l_str = NULL; //list of string
72  list l_expr = NULL; // list of expression
73  size_t line_sz = 0; // the pragma line size
74  string s = string_undefined;
76 
77  switch(pragma_tag (p)) {
78  case is_pragma_string:
79  s = pragma_string(p);
80  break;
82  l_expr = gen_nreverse(pragma_expression (p));
83  FOREACH (EXPRESSION, e, l_expr)
84  {
85  if(flg ) {
87  line_sz += 1;
88  }
89  flg = true;
90  list pdl = NIL;
91  l_str = words_expression(e, &pdl);
92  gen_free_list(pdl);
93  // l_str = gen_nreverse (l_str);
95  // In fortran line size can not be more than 72
96  FOREACH (STRING, str, l_str)
97  {
98  pips_assert ("algo bug", line_sz < MAX_LINE_LENGTH - 7);
99  size_t size = strlen(str);
100  pips_assert ("not handled case need to split the str between two lines",
101  size < (MAX_LINE_LENGTH - 7));
102  line_sz += size;
103  if(line_sz >= MAX_LINE_LENGTH - 8) {
105  str,
106  l_str);
107  line_sz = size;
108  }
109  }
110  }
112  gen_free_list(l_str);
113  }
115  // Free the buffer with its strings
117  // restore the list as it was at the begining
118  gen_nreverse(l_expr);
119  break;
120  default:
121  pips_internal_error("Unknown pragma type");
122  break;
123  }
124  if(s != string_undefined) {
125  switch(get_prettyprint_language_tag()) {
126  case is_language_fortran:
129  break;
130  case is_language_c:
131  s = strdup(concatenate(C_PRAGMA_HEADER_STRING, " ", s, NULL));
132  break;
133  default:
134  pips_internal_error("Language unknown !");
135  break;
136  }
137  }
138  return s;
139 }
#define STRING(x)
Definition: genC.h:87
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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#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
list gen_insert_before(const void *no, const void *o, list l)
Definition: list.c:238
enum language_utype get_prettyprint_language_tag()
Definition: language.c:67
#define pips_internal_error
Definition: misc-local.h:149
#define FORTRAN_PRAGMA_HEADER_STRING
Definition: naming-local.h:116
#define C_PRAGMA_HEADER_STRING
Constants for pragma management.
Definition: naming-local.h:115
#define FORTRAN_OMP_CONTINUATION_STRING
Definition: naming-local.h:117
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void string_buffer_free_all(string_buffer *)
free string buffer structure and force string freeing
Definition: string_buffer.c:94
void string_buffer_append(string_buffer, const string)
append string s (if non empty) to string buffer sb, the duplication is done if needed according to th...
string string_buffer_to_string(const string_buffer)
return malloc'ed string from string buffer sb
string_buffer string_buffer_make(bool dup)
allocate a new string buffer
Definition: string_buffer.c:58
void string_buffer_append_list(string_buffer, const list)
append a list of string to a string buffer.
list words_expression(expression obj, list *ppdl)
This one is exported.
Definition: misc.c:2611
#define pragma_string(x)
Definition: ri.h:2033
@ is_pragma_expression
Definition: ri.h:2013
@ is_pragma_string
Definition: ri.h:2012
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define pragma_tag(x)
Definition: ri.h:2030
@ is_language_fortran
Definition: ri.h:1566
@ is_language_fortran95
Definition: ri.h:1568
@ is_language_c
Definition: ri.h:1567
char * strdup()
internally defined structure.
Definition: string_buffer.c:47
Definition: statement.c:4047
#define MAX_LINE_LENGTH
maximum length of a line when prettyprinting...

References C_PRAGMA_HEADER_STRING, concatenate(), EXPRESSION, FOREACH, FORTRAN_OMP_CONTINUATION_STRING, FORTRAN_PRAGMA_HEADER_STRING, gen_free_list(), gen_insert_before(), gen_nreverse(), get_prettyprint_language_tag(), is_language_c, is_language_fortran, is_language_fortran95, is_pragma_expression, is_pragma_string, MAX_LINE_LENGTH, NIL, pips_assert, pips_internal_error, pragma_expression, pragma_string, pragma_tag, prettyprint_language_is_fortran_p(), strdup(), STRING, string_buffer_append(), string_buffer_append_list(), string_buffer_free_all(), string_buffer_make(), string_buffer_to_string(), string_undefined, and words_expression().

Referenced by add_expr_to_pragma_expr_list(), build_omp_pragma_list(), build_outer(), extension_to_string(), inner_rewrite(), and pragma_scmp_task_p().

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