25 #include "pips_config.h"
42 #include "pips-libs.h"
80 #define INTEGER_CONSTANT_NAME_CHARS \
93 if(strlen(name)==3 && name[0]==
'\'' && name[2]==
'\'')
95 else if(strlen(name)==4 && name[0]==
'\'' && name[1]==
'\\' && name[3]==
'\'')
109 else if(strlen(name)==6 && name[0]==
'\'' && name[1]==
'\\' && name[5]==
'\'') {
113 r = strtol(&name[2], &error_string, 8);
153 bool (*error_manager)(
const char *,
const char *))
168 (
void*) (strlen(name)-2+1-is_fortran))))));
179 bool usuffix = (strchr(name,
'U') != NULL) || (strchr(name,
'u') != NULL);
180 bool lsuffix = (strchr(name,
'L') != NULL) || (strchr(name,
'l') != NULL);
181 int basis = is_fortran? 10 : 0;
184 int error_number = 0;
192 if(strstr(name,
"0x")==name) {
212 l = strtoull(name, &error_string, basis);
214 l = strtoul(name, &error_string, basis);
217 l = strtoll(name, &error_string, basis);
219 l = strtol(name, &error_string, basis);
220 error_number = errno;
222 pips_debug(8,
"value = %lld, errno=%d\n", l, error_number);
232 pips_assert(
"pointers have the right size",
sizeof(
void *)==8);
237 pips_assert(
"Integer constants are internally stored on 4 or 8 bytes",
240 if(error_number==EINVAL) {
241 pips_user_warning(
"Integer constant '%s' cannot be converted in %d bytes (%s)\n",
242 name, size, error_string);
243 (*error_manager)(__FUNCTION__,
244 "Integer constant conversion error.\n");
246 else if(error_number==ERANGE) {
247 pips_user_warning(
"Overflow, Integer constant '%s' cannot be stored in %d bytes\n",
249 (*error_manager)(__FUNCTION__,
250 "Integer constant too large for internal representation.\n");
252 else if(error_number!=0 && (l == LONG_MAX || l == LONG_MIN)) {
255 else if(*error_string!=
'\0' && strspn(error_string,
"LlUu")!=strlen(error_string)) {
258 else if(name==error_string) {
265 pips_user_warning(
"some data lost in conversion, %lli is not representatble in pips \n",l);
318 size_t len = strlen(name);
324 switch(name[len-1]) {
359 bool first_quote = eun[0]==
'"';
360 bool last_quote = eun[strlen(eun)-1] ==
'"';
361 return first_quote && last_quote;
388 int size = rsize>isize? rsize: isize;
407 int size = rsize>isize? rsize: isize;
418 bool is_complex_constant_p =
false;
427 return is_complex_constant_p;
441 string tz =
num+strlen(
num)-1;
455 pips_assert(
"no negative integer entity in pips",c>=0);
functional make_functional(list a1, type a2)
constant make_constant(enum constant_utype tag, void *val)
basic make_basic(enum basic_utype tag, void *val)
storage make_storage_rom(void)
value make_value(enum value_utype tag, void *val)
constant make_constant_int(intptr_t _field_)
symbolic make_symbolic(expression a1, constant a2)
constant make_constant_unknown(void)
type make_type(enum type_utype tag, void *val)
entity make_constant_entity(string name, tag bt, size_t size)
For historical reason, call the Fortran version.
bool constant_string_entity_p(entity e)
bool expression_is_constant_p(expression e)
BEGIN_EOLE.
expression MakeCharacterConstantExpression(string s)
END_EOLE.
static bool constant_error(const char *f, const char *m)
bool integer_constant_name_p(string name)
double float_constant_to_double(entity c)
bool integer_constant_p(entity ent, int *int_p)
Returns the double value associated to a PIPS constant.
entity float_to_entity(float c)
bool float_constant_p(entity ent)
ent can be either a numerical or a symbolic float constant
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
expression MakeComplexConstantExpression(expression r, expression i)
entity SafeMakeConstant(string name, tag bt, bool(*error_manager)(const char *, const char *))
END_EOLE.
#define INTEGER_CONSTANT_NAME_CHARS
BEGIN_EOLE.
int DefaultLengthOfBasic(tag t)
Deals with constant expressions and constant entities.
_int TK_CHARCON_to__int(const char *name)
basic constant_basic(entity c)
bool signed_constant_expression_p(expression e)
entity make_C_or_Fortran_constant_entity(const char *name, tag bt, size_t size, bool is_fortran, bool(*error_manager)(const char *, const char *))
This function creates a constant.
bool complex_constant_expression_p(expression cce)
bool integer_symbolic_constant_p(entity ent, int *int_p)
(*int_p) gets integer constant if any
bool logical_constant_p(entity ent)
value MakeValueSymbolic(expression e)
this function creates a value for a symbolic constant.
entity int_to_entity(_int c)
entity MakeComplexConstant(expression r, expression i)
make a complex constant from two calls to real or integer constants
entity get_current_module_entity(void)
Get the entity of the current module.
#define NIL
The empty list (nil in Lisp)
#define CAR(pcons)
Get the value of the first element of a list.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
#define DEFAULT_LOGICAL_TYPE_SIZE
#define DEFAULT_INTEGER_TYPE_SIZE
#define DEFAULT_REAL_TYPE_SIZE
The standard C integer types are represented as follow char = 1 short_int = 2 int = 4 long_int = 6 lo...
#define DEFAULT_COMPLEX_TYPE_SIZE
#define DEFAULT_CHARACTER_TYPE_SIZE
Default type sizes.
#define IMPLIED_DCOMPLEX_NAME
#define UNARY_MINUS_OPERATOR_NAME
#define entity_constant_p(e)
#define IMPLIED_COMPLEX_NAME
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
bool c_module_p(entity m)
Test if a module "m" is written in C.
const char * module_local_name(entity e)
Returns the module local user name.
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
value EvalExpression(expression e)
Evaluate statically an expression.
bool expression_call_p(expression e)
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
expression MakeNullaryCall(entity f)
Creates a call expression to a function with zero arguments.
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
int basic_type_size(basic)
See also SizeOfElements()
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
bool logical_type_p(type)
#define type_functional_p(x)
#define constant_logical_p(x)
#define functional_result(x)
#define value_constant(x)
#define constant_float_p(x)
#define symbolic_constant(x)
#define type_functional(x)
#define value_unknown_p(x)
#define entity_storage(x)
#define value_constant_p(x)
#define value_symbolic(x)
#define EXPRESSION(x)
EXPRESSION.
#define expression_undefined
#define constant_call_p(x)
#define call_arguments(x)
#define expression_syntax(x)
#define functional_undefined
#define constant_undefined
#define variable_basic(x)
#define entity_initial(x)
The structure used to build lists in NewGen.