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

Go to the source code of this file.

Functions

string close_extension (extension e)
 extension.c More...
 
string close_extensions (extensions es, bool nl)
 
string extension_to_string (extension e)
 
string extensions_to_string (extensions es, bool nl)
 return a new allocated string with the string representation of the extensions. More...
 

Function Documentation

◆ close_extension()

string close_extension ( extension  e)

extension.c

Returns
a new allocated string to close the extension.
Parameters
es,theextension to be closed

Today we only generate omp parallel do pragma so the close is pretty easy. Later we will have to analyze the extension to generate the close string accordingly.

Definition at line 49 of file extension.c.

49  {
50  return close_pragma (extension_pragma(e));
51 }
string close_pragma(pragma p __attribute__((unused)))
Definition: pragma.c:53
#define extension_pragma(x)
Definition: ri.h:1295

References close_pragma(), and extension_pragma.

Referenced by close_extensions().

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

◆ close_extensions()

string close_extensions ( extensions  es,
bool  nl 
)
Returns
a new allocated string to close the extensions.
Parameters
es,theextensions to be closed
nl,setto true to get the string with a final new line character

Use a string_buffer for efficient string concatenation:

Free the buffer with its strings:

Parameters
ess
nll

Definition at line 58 of file extension.c.

58  {
59  string s = string_undefined;
60 
61  if (!empty_extensions_p (es) ) {
62  /* Use a string_buffer for efficient string concatenation: */
64 
65  list el = extensions_extension(es);
66  FOREACH(EXTENSION, e, el) {
67  s = close_extension(e);
68  if (s != string_undefined) {
70  if (nl ) string_buffer_append(sb, strdup ("\n"));
71  nl = true;
72  }
73  }
75  /* Free the buffer with its strings: */
77  }
78 
79  return s;
80 }
#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
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
#define string_undefined
Definition: newgen_types.h:40
string close_extension(extension e)
extension.c
Definition: extension.c:49
bool empty_extensions_p(extensions es)
Definition: extension.c:50
#define EXTENSION(x)
EXTENSION.
Definition: ri.h:1253
#define extensions_extension(x)
Definition: ri.h:1330
char * strdup()
internally defined structure.
Definition: string_buffer.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:4047

References close_extension(), empty_extensions_p(), EXTENSION, extensions_extension, FOREACH, strdup(), string_buffer_append(), string_buffer_free_all(), string_buffer_make(), string_buffer_to_string(), and string_undefined.

+ Here is the call graph for this function:

◆ extension_to_string()

string extension_to_string ( extension  e)
Returns
a new allocated string with the extension textual representation.

to be added later when extension can be something else than pragma switch (extension_tag(e)) { case is_extension_pragma:

default: pips_internal_error("Unknown extension type"); }

Definition at line 86 of file extension.c.

86  {
87  string s;
88  /* to be added later when extension can be something else than pragma
89  switch (extension_tag(e)) {
90  case is_extension_pragma:
91  */
93  /* default:
94  pips_internal_error("Unknown extension type");
95  }*/
96  return s;
97 }
string pragma_to_string(pragma p)
Definition: pragma.c:69

References extension_pragma, and pragma_to_string().

Referenced by extensions_to_string().

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

◆ extensions_to_string()

string extensions_to_string ( extensions  es,
bool  nl 
)

return a new allocated string with the string representation of the extensions.

Basically you'll get one extension per line

Assume that all the extension from the extensions (note the presence or not of the "s"...) are defined below.

Returns
string_undefined if es is extension_undefined, an malloc()ed textual string either.
Parameters
es,theextensions to translate to strings
nl,setto true to get the string with a final new line character

Prettyprint in the correct language:

Use a string_buffer for efficient string concatenation:

Free the buffer with its strings:

Parameters
ess
nll

Definition at line 111 of file extension.c.

111  {
112  string s = string_undefined;
113 
114  /* Prettyprint in the correct language: */
115 // set_prettyprint_language_from_property ();
116 
117  if (!empty_extensions_p (es) ) {
118  /* Use a string_buffer for efficient string concatenation: */
120 
121  list el = extensions_extension(es);
122  FOREACH(EXTENSION, e, el) {
123  s = extension_to_string(e);
125  if (nl ) string_buffer_append(sb, strdup ("\n"));
126  nl = true;
127  }
129  /* Free the buffer with its strings: */
131  }
132 
133  return s;
134 }
string extension_to_string(extension e)
Definition: extension.c:86

References empty_extensions_p(), EXTENSION, extension_to_string(), extensions_extension, FOREACH, strdup(), string_buffer_append(), string_buffer_free_all(), string_buffer_make(), string_buffer_to_string(), and string_undefined.

Referenced by loop_pragma().

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