OpenScop
0.9.0
|
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <osl/macros.h>
#include <osl/util.h>
Go to the source code of this file.
Functions | |
char * | osl_util_skip_blank_and_comments (FILE *file, char *str) |
void | osl_util_sskip_blank_and_comments (char **str) |
int | osl_util_read_int (FILE *file, char **str) |
char * | osl_util_read_string (FILE *file, char **str) |
char * | osl_util_read_line (FILE *file, char **str) |
char * | osl_util_read_tag (FILE *file, char **str) |
char * | osl_util_read_uptoflag (FILE *file, char **str, char *flag) |
char * | osl_util_read_uptotag (FILE *file, char **str, char *name) |
char * | osl_util_read_uptoendtag (FILE *file, char **str, char *name) |
char * | osl_util_tag_content (char *str, char *name) |
void | osl_util_safe_strcat (char **dst, char *src, int *hwm) |
char * | osl_util_strdup (char const *str) |
String duplicate. | |
int | osl_util_get_precision () |
void | osl_util_print_provided (FILE *file, int provided, char *title) |
static int | osl_util_identifier_is_here (char *expression, char *identifier, int index) |
static int | osl_util_lazy_isolated_identifier (char *expression, char *identifier, int index) |
char * | osl_util_identifier_substitution (char *expression, char **identifiers) |
int osl_util_get_precision | ( | ) |
osl_util_get_precision function: this function returns the precision defined by the precision environment variable or the highest available precision if it is not defined.
Definition at line 518 of file util.c.
References OSL_PRECISION_DP, OSL_PRECISION_ENV, OSL_PRECISION_ENV_DP, OSL_PRECISION_ENV_MP, OSL_PRECISION_ENV_SP, OSL_PRECISION_MP, OSL_PRECISION_SP, and OSL_warning.
Referenced by osl_dependence_sread(), osl_relation_list_read(), osl_relation_malloc(), osl_relation_read(), osl_relation_sread(), osl_scop_read(), osl_statement_read(), and osl_vector_malloc().
static int osl_util_identifier_is_here | ( | char * | expression, |
char * | identifier, | ||
int | index | ||
) | [static] |
osl_util_identifier_is_here function: this function returns 1 if the input "identifier" is found at the "index" position in the "expression" input string, 0 otherwise.
[in] | expression | The input expression. |
[in] | identifier | The identifier to look for. |
[in] | index | The position in the expression where to look. |
Definition at line 579 of file util.c.
Referenced by osl_util_identifier_substitution().
char* osl_util_identifier_substitution | ( | char * | expression, |
char ** | identifiers | ||
) |
osl_util_identifier_substitution function: this function replaces some identifiers in an input expression string and returns the final string. The list of identifiers to replace are provided as an array of strings. They are replaced from the input string with the new substring "@i@" or "(@i@)" where i is the rank of the identifier in the array of identifiers. The parentheses are added when it is not obvious that the identifier can be replaced with an arbitrary expression without the need of parentheses. For instance, let us consider the input expression "C[i+j]+=A[2*i]*B[j];" and the array of strings {"i", "j"}: the resulting string would be "C[@0@+@1@]+=A[2*(@0@)]*B[@1@];".
[in] | expression | The original expression. |
[in] | identifiers | NULL-terminated array of identifiers. |
Definition at line 682 of file util.c.
References OSL_malloc, OSL_MAX_STRING, osl_util_identifier_is_here(), osl_util_lazy_isolated_identifier(), and osl_util_safe_strcat().
static int osl_util_lazy_isolated_identifier | ( | char * | expression, |
char * | identifier, | ||
int | index | ||
) | [static] |
osl_util_lazy_isolated_identifier function: this function returns 1 if the identifier at the "index" position in the "expression" is guaranteed not to need parenthesis around is we substitute it with anything. For instance the identifier "i" can be always substituted in "A[i]" with no need of parenthesis but not in "A[2*i]". This function is lazy in the sense that it just check obvious cases, not all of them. The identifier must already be at the indicated position, this function does not check that.
[in] | expression | The input expression. |
[in] | identifier | The identifier to check. |
[in] | index | The position of the identifier in the expression. |
Definition at line 625 of file util.c.
Referenced by osl_util_identifier_substitution().
void osl_util_print_provided | ( | FILE * | file, |
int | provided, | ||
char * | title | ||
) |
osl_util_print_provided function: this function prints a "provided" boolean in a file (file, possibly stdout), with a comment title according to the OpenScop specification.
[in] | file | File where the information has to be printed. |
[in] | provided | The provided boolean to print. |
[in] | title | A string to use as a title for the provided booblean. |
Definition at line 557 of file util.c.
Referenced by osl_scop_print(), and osl_scop_print_scoplib().
int osl_util_read_int | ( | FILE * | file, |
char ** | str | ||
) |
osl_util_read_int function: reads an int on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL).
[in] | file | The file where to read an int (if not NULL). |
[in,out] | str | The string where to read an int (if not NULL). This pointer is updated to reflect the read and points after the int in the input string. |
Definition at line 140 of file util.c.
References OSL_error, OSL_MAX_STRING, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().
Referenced by osl_arrays_sread(), osl_body_sread(), osl_coordinates_sread(), osl_dependence_psread(), osl_dependence_read_one_dep(), osl_extbody_sread(), osl_loop_sread(), osl_pluto_unroll_sread(), osl_relation_list_pread(), osl_scop_pread(), osl_statement_pread(), and osl_symbols_sread().
char* osl_util_read_line | ( | FILE * | file, |
char ** | str | ||
) |
osl_util_read_line function: reads a line on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL). A line is defined as the array of characters before the comment tag or the end of line (it may include spaces).
[in] | file | The file where to read a line (if not NULL). |
[in,out] | str | The string where to read a line (if not NULL). This pointer is updated to reflect the read and points after the line in the input string. |
Definition at line 226 of file util.c.
References OSL_error, OSL_malloc, OSL_MAX_STRING, OSL_realloc, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().
Referenced by osl_body_sread(), osl_coordinates_sread(), osl_loop_sread(), and osl_pluto_unroll_sread().
char* osl_util_read_string | ( | FILE * | file, |
char ** | str | ||
) |
osl_util_read_string function: reads a string on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL).
[in] | file | The file where to read a string (if not NULL). |
[in,out] | str | The string where to read a string (if not NULL). This pointer is updated to reflect the read and points after the string in the input string. |
Definition at line 181 of file util.c.
References OSL_error, OSL_malloc, OSL_MAX_STRING, OSL_realloc, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().
Referenced by osl_arrays_sread(), osl_dependence_read_one_dep(), osl_loop_sread(), and osl_symbols_sread().
char* osl_util_read_tag | ( | FILE * | file, |
char ** | str | ||
) |
osl_util_read_int internal function: reads a tag (the form of a tag with name "name" is <name>) on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL). It returns the name of the tag (thus without the < and > as a string. Note that in the case of an ending tag, e.g., </foo>, the slash is returned as a part of the name, e.g., /foo. If no tag is found the function returns NULL.
[in] | file | The file where to read a tag (if not NULL). |
[in,out] | str | The string where to read a tag (if not NULL). This pointer is updated to reflect the read and points after the tag in the input string. |
Definition at line 268 of file util.c.
References OSL_error, OSL_malloc, OSL_MAX_STRING, osl_util_skip_blank_and_comments(), and osl_util_sskip_blank_and_comments().
Referenced by osl_generic_read_one(), and osl_generic_sread_one().
char* osl_util_read_uptoendtag | ( | FILE * | file, |
char ** | str, | ||
char * | name | ||
) |
osl_util_read_uptoendtag function: this function reads a string up to a given end tag (the end tag is read) on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL) and returns that string without the end tag. It returns NULL if the end tag is not found.
[in] | file | The file where to read up to end tag (if not NULL). |
[in,out] | str | The string where to read up to end tag (if not NULL). This pointer is updated to reflect the read and points after the end tag in the input string. |
[in] | name | The name of the end tag to the file reading. |
Definition at line 413 of file util.c.
References osl_util_read_uptoflag().
Referenced by osl_generic_read(), osl_generic_read_one(), and osl_generic_sread_one().
char* osl_util_read_uptoflag | ( | FILE * | file, |
char ** | str, | ||
char * | flag | ||
) |
osl_util_read_uptoflag function: this function reads a string up to a given flag (the flag is read) on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL) and returns that string without the flag. It returns NULL if the flag is not found.
[in] | file | The file where to read up to flag (if not NULL). |
[in,out] | str | The string where to read up to flag (if not NULL). This pointer is updated to reflect the read and points after the flag in the input string. |
[in] | flag | The flag which, when reached, stops the reading. |
Definition at line 334 of file util.c.
References OSL_debug, OSL_error, OSL_malloc, OSL_MAX_STRING, and OSL_realloc.
Referenced by osl_util_read_uptoendtag(), and osl_util_read_uptotag().
char* osl_util_read_uptotag | ( | FILE * | file, |
char ** | str, | ||
char * | name | ||
) |
osl_util_read_uptotag function: this function reads a string up to a given (start) tag (the tag is read) on the input 'file' or the input string 'str' depending on which one is not NULL (exactly one of them must not be NULL) and returns that string without the tag. It returns NULL if the tag is not found.
[in] | file | The file where to read up to tag (if not NULL). |
[in,out] | str | The string where to read up to tag (if not NULL). This pointer is updated to reflect the read and points after the tag in the input string. |
[in] | name | The name of the tag to the file reading. |
Definition at line 392 of file util.c.
References osl_util_read_uptoflag().
Referenced by osl_scop_pread().
void osl_util_safe_strcat | ( | char ** | dst, |
char * | src, | ||
int * | hwm | ||
) |
osl_util_safe_strcat function: this function concatenates the string src to the string *dst and reallocates *dst if necessary. The current size of the *dst buffer must be *hwm (high water mark), if there is some reallocation, this value is updated.
[in,out] | dst | pointer to the destination string (may be reallocated). |
[in] | src | string to concatenate to dst. |
[in,out] | hwm | pointer to the size of the *dst buffer (may be updated). |
Definition at line 483 of file util.c.
References OSL_MAX_STRING, and OSL_realloc.
Referenced by osl_arrays_sprint(), osl_body_sprint(), osl_clay_sprint(), osl_comment_sprint(), osl_coordinates_sprint(), osl_dependence_sprint(), osl_extbody_sprint(), osl_generic_sprint(), osl_irregular_sprint(), osl_loop_sprint(), osl_relation_spprint(), osl_relation_spprint_polylib(), osl_relation_spprint_polylib_scoplib(), osl_relation_spprint_scoplib(), osl_relation_sprint_comment(), osl_strings_sprint(), osl_symbols_sprint(), and osl_util_identifier_substitution().
char* osl_util_skip_blank_and_comments | ( | FILE * | file, |
char * | str | ||
) |
osl_util_skip_blank_and_comments "file skip" function: this function reads the open file 'file' line by line and skips blank/comment lines and spaces. The first line where there is some useful information is stored at the address 'str' (the memory to store the line must be allocated before the call to this function and must be at least OSL_MAX_STRING * sizeof(char)). The pointer to the first useful information in this line is returned by the function.
[in] | file | The (opened) file to read. |
[in] | str | Address of an allocated space to store the first line that contains useful information. |
Definition at line 91 of file util.c.
References OSL_MAX_STRING.
Referenced by osl_relation_pread(), osl_strings_read(), osl_util_read_int(), osl_util_read_line(), osl_util_read_string(), and osl_util_read_tag().
void osl_util_sskip_blank_and_comments | ( | char ** | str | ) |
osl_util_sskip_blank_and_comments "string skip" function: this function updates the str pointer, which initialy points to a string, to the first character in this string which is not a space or a comment (comments start at '#' and end at '
'), or to the end of string.
[in,out] | str | Address of a string, updated to the address of the first non-space or comment character. |
Definition at line 113 of file util.c.
Referenced by osl_relation_psread(), osl_strings_sread(), osl_util_read_int(), osl_util_read_line(), osl_util_read_string(), and osl_util_read_tag().
char* osl_util_strdup | ( | char const * | str | ) |
String duplicate.
osl_util_strdup function: this function return a copy of the string str.
[in] | str | string to be copied. |
Definition at line 504 of file util.c.
References OSL_malloc.
Referenced by osl_relation_spprint_polylib(), and osl_relation_spprint_polylib_scoplib().
char* osl_util_tag_content | ( | char * | str, |
char * | name | ||
) |
osl_util_tag_content function: this function returns a freshly allocated string containing the content, in the given string 'str', between the tag '<name>' and the tag '</name>'. If the tag '<name>' is not found, it returns NULL.
[in] | str | The string where to find a given content. |
[in] | name | The name of the tag we are looking for. |
Definition at line 430 of file util.c.
References OSL_malloc.