PIPS
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri-util.h"
#include "pips-libs.h"
Go to the source code of this file.
Macros | |
#define | INTEGER_CONSTANT_NAME_CHARS "0123456789" |
BEGIN_EOLE. More... | |
Functions | |
int | DefaultLengthOfBasic (tag t) |
Deals with constant expressions and constant entities. More... | |
bool | integer_constant_name_p (string name) |
_int | TK_CHARCON_to__int (const char *name) |
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. More... | |
static bool | constant_error (const char *f, const char *m) |
entity | make_constant_entity (string name, tag bt, size_t size) |
For historical reason, call the Fortran version. More... | |
entity | SafeMakeConstant (string name, tag bt, bool(*error_manager)(const char *, const char *)) |
END_EOLE. More... | |
entity | MakeConstant (string name, tag bt) |
Make a Fortran constant. More... | |
bool | constant_string_entity_p (entity e) |
entity | MakeComplexConstant (expression r, expression i) |
make a complex constant from two calls to real or integer constants More... | |
expression | MakeComplexConstantExpression (expression r, expression i) |
bool | complex_constant_expression_p (expression cce) |
entity | float_to_entity (float c) |
entity | int_to_entity (_int c) |
bool | logical_constant_p (entity ent) |
bool | float_constant_p (entity ent) |
ent can be either a numerical or a symbolic float constant More... | |
bool | integer_constant_p (entity ent, int *int_p) |
Returns the double value associated to a PIPS constant. More... | |
bool | integer_symbolic_constant_p (entity ent, int *int_p) |
(*int_p) gets integer constant if any More... | |
expression | MakeCharacterConstantExpression (string s) |
END_EOLE. More... | |
value | MakeValueSymbolic (expression e) |
this function creates a value for a symbolic constant. More... | |
bool | signed_constant_expression_p (expression e) |
basic | constant_basic (entity c) |
double | float_constant_to_double (entity c) |
bool | expression_is_constant_p (expression e) |
BEGIN_EOLE. More... | |
#define INTEGER_CONSTANT_NAME_CHARS "0123456789" |
BEGIN_EOLE.
Definition at line 80 of file constant.c.
bool complex_constant_expression_p | ( | expression | cce | ) |
cce | ce |
Definition at line 416 of file constant.c.
References call_function, entity_local_name(), expression_call_p(), expression_syntax, f(), IMPLIED_COMPLEX_NAME, IMPLIED_DCOMPLEX_NAME, and syntax_call.
Referenced by MakeDataValueSet().
Definition at line 633 of file constant.c.
References entity_type, functional_result, type_functional, type_variable, and variable_basic.
Referenced by constant_constraint_check(), and float_constant_to_double().
|
static |
Definition at line 287 of file constant.c.
References f(), and pips_internal_error.
Referenced by MakeConstant().
Definition at line 356 of file constant.c.
References entity_user_name().
Referenced by entities_maymust_conflict_p(), expression_string_constant_p(), filter_formal_context_according_to_actual_context(), new_filter_formal_context_according_to_actual_context(), and points_to_translation_mapping_is_typed_p().
Deals with constant expressions and constant entities.
Definition at line 44 of file constant.c.
References DEFAULT_CHARACTER_TYPE_SIZE, DEFAULT_COMPLEX_TYPE_SIZE, DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LOGICAL_TYPE_SIZE, DEFAULT_REAL_TYPE_SIZE, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, and pips_internal_error.
Referenced by InitImplicit(), MakeFortranType(), and SafeMakeConstant().
bool expression_is_constant_p | ( | expression | e | ) |
BEGIN_EOLE.
Definition at line 666 of file constant.c.
References call_function, entity_constant_p, expression_syntax, false, syntax_call, and syntax_call_p.
Referenced by gfc2pips_reduce_repeated_values(), handle_set_directive(), and points_to_indices_to_unbounded_indices().
ent can be either a numerical or a symbolic float constant
In the initial internal representation, only integer constants were distinguished
ent | nt |
Definition at line 487 of file constant.c.
References constant_call_p, constant_float_p, entity_initial, entity_type, f(), float_type_p(), functional_result, type_functional, type_functional_p, value_constant, and value_constant_p.
Referenced by constant_to_transformer(), and simplify_float_constraint().
double float_constant_to_double | ( | entity | c | ) |
Definition at line 639 of file constant.c.
References basic_float_p, constant_basic(), entity_constant_p, module_local_name(), pips_assert, and pips_internal_error.
Referenced by constant_constraint_check(), constant_to_transformer(), and simplify_float_constraint().
entity float_to_entity | ( | float | c | ) |
Definition at line 430 of file constant.c.
References asprintf, free(), is_basic_float, MakeConstant(), and num.
Referenced by float_to_expression(), simplify_float_constraint(), and string_to_entity().
Definition at line 453 of file constant.c.
References asprintf, free(), is_basic_int, MakeConstant(), num, and pips_assert.
Referenced by int_to_expression(), partial_eval_syntax(), string_to_entity(), substitute_unbounded_call(), and zero_expression_p().
name | ame |
Definition at line 83 of file constant.c.
References INTEGER_CONSTANT_NAME_CHARS.
Returns the double value associated to a PIPS constant.
A simpler function alreay exists... and is better for litteral constants... BEGIN_EOLE
ent | nt |
int_p | nt_p |
Definition at line 542 of file constant.c.
References constant_int, constant_tag, entity_initial, entity_type, is_constant_int, is_type_functional, is_value_constant, type_tag, value_constant, and value_tag.
Referenced by constant_to_transformer(), integer_constant_expression_p(), logical_expression_to_transformer(), partial_eval_call(), and verify_formal_and_common_variables().
(*int_p) gets integer constant if any
ent | nt |
int_p | nt_p |
Definition at line 556 of file constant.c.
References constant_int, constant_tag, entity_initial, entity_type, is_constant_int, is_type_functional, is_value_symbolic, symbolic_constant, type_tag, value_symbolic, and value_tag.
Referenced by integer_constant_expression_p(), and partial_eval_call().
In the initial internal representation, only integer constants were distinguished
ent | nt |
Definition at line 463 of file constant.c.
References constant_call_p, constant_logical_p, entity_initial, entity_type, f(), functional_result, logical_type_p(), type_functional, type_functional_p, value_constant, and value_constant_p.
Referenced by logical_expression_to_transformer().
entity make_C_or_Fortran_constant_entity | ( | const char * | name, |
tag | bt, | ||
size_t | size, | ||
bool | is_fortran, | ||
bool(*)(const char *, const char *) | error_manager | ||
) |
This function creates a constant.
a constant is represented in our internal representation by a function. Its name is the name of the constant, its type is a functional that gives the type of the constant, its storage is rom.
Its initial value is the value of the constant. In case of integer constant, the actual value is stored (as an integer) in constant_int. values of other constants have to be computed with the name, if necessary.
name is the name of the constant 12, 123E10, '3I12', 015 (C octal constant), 0x1ae; (C hexadecimal), 890L (C long constant) ... Initial and final quotes are included in the names of string constants.
basic is the basic type of the constant: int, float, ...
Character constants are typed as int.
Drop the two quotes, but add space for '\0' in C
See all hexadecimal constant as unsigned on 64 bits, elses 0xffffffff generates an overflow, not a -1 (see C-syntax/constants03.c
ld, long; zd, size_t; td, ptrdiff_t
Since the value is stored in a NewGen int that has the size of a pointer, verify is is OK to store it. In should not assume this...
Check conversion errors and make the constant
SG :this ensure everything is ok on 32 bits
name | ame |
bt | t |
size | ize |
is_fortran | s_fortran |
Definition at line 148 of file constant.c.
References basic_undefined, constant_undefined, entity_initial, entity_storage, entity_type, FindOrCreateEntity(), functional_undefined, intptr_t, is_basic_int, is_basic_string, is_constant_call, is_constant_int, is_type_functional, is_value_constant, make_basic(), make_constant(), make_constant_int(), make_functional(), make_storage_rom(), make_type(), make_value(), MakeTypeVariable(), NIL, pips_assert, pips_debug, pips_internal_error, pips_user_warning, string_undefined, TK_CHARCON_to__int(), TOP_LEVEL_MODULE_NAME, and type_undefined.
Referenced by make_C_constant_entity(), make_constant_entity(), make_Fortran_constant_entity(), and SafeMakeConstant().
For historical reason, call the Fortran version.
It is used in bootstrap, instrumentation, ri-util/constant.c, semantics and task_parallelization.
It is assumed that no errors can be detected, or it would be a PIPS internal error.
name | ame |
bt | t |
size | ize |
Definition at line 301 of file constant.c.
References make_C_or_Fortran_constant_entity().
Referenced by cast_constant(), cluster_stage_spire(), constant_to_transformer(), convert_constant_from_double_to_dcomplex(), convert_constant_from_double_to_real(), convert_constant_from_int_to_double(), convert_constant_from_int_to_real(), convert_constant_from_real_to_complex(), convert_constant_from_real_to_double(), convert_constant_from_real_to_int(), edge_cost_polynome(), gen_mpi_send_recv(), make_com_loopbody(), make_special_value(), make_test_condition(), MakeComplexConstant(), mpi_finalize(), mpi_initialize(), mpi_recv_ctx(), mpi_send_ctx(), read_new_entities_from_eole(), simplification_conversion(), and task_time_polynome().
expression MakeCharacterConstantExpression | ( | string | s | ) |
END_EOLE.
this function creates an character constant and then a call to that constant.
Definition at line 573 of file constant.c.
References is_basic_string, MakeConstant(), and MakeNullaryCall().
Referenced by do_simplify_constant_address_expression(), entity_hpf_number(), generate_string_for_alternate_return_argument(), gfc2pips_code2instruction_(), gfc2pips_expr2expression(), gfc2pips_exprIO(), gfc2pips_exprIO2(), gfc2pips_exprIO3(), hpfc_array_bound(), insert_check_alias_before_statement(), make_print_statement(), make_simple_Fortran_io_instruction(), MakeIoList(), MakeReturn(), MakeSimpleIoInst1(), pvm_encoding_option(), and pvm_what_option_expression().
entity MakeComplexConstant | ( | expression | r, |
expression | i | ||
) |
make a complex constant from two calls to real or integer constants
Problem: does not work if either of the components is negative because negative constants are stored as expressions. For instance, (0, -1) is not a complex constant for PIPS but an expression: cmplx(0,unary_minus(1)).
Note: I might have changed that to store DATA statements... (FI)
name has to be allocated by strdup because of nested calls to concatenate
Definition at line 373 of file constant.c.
References asprintf, basic_type_size(), call_function, entity_local_name(), entity_type, expression_syntax, free(), functional_result, is_basic_complex, make_constant_entity(), syntax_call, type_functional, type_variable, and variable_basic.
expression MakeComplexConstantExpression | ( | expression | r, |
expression | i | ||
) |
Definition at line 397 of file constant.c.
References basic_of_expression(), basic_type_size(), expression_undefined, IMPLIED_COMPLEX_NAME, IMPLIED_DCOMPLEX_NAME, local_name_to_top_level_entity(), MakeBinaryCall(), and signed_constant_expression_p().
Referenced by complex_to_expression(), gfc2pips_expr2expression(), gfc2pips_make_zero_for_symbol(), and set_the_i().
Make a Fortran constant.
Apparently partly extended fo C...
name | ame |
bt | t |
Definition at line 351 of file constant.c.
References constant_error(), and SafeMakeConstant().
Referenced by bool_to_expression(), buffer_full_condition(), compile_reduction(), float_to_entity(), gfc2pips_int_const2entity(), gfc2pips_logical2entity(), gfc2pips_real2entity(), int_to_entity(), make_C_print_statement(), make_false_expression(), make_special_value(), make_stop_statement(), make_true_expression(), MakeCharacterConstantExpression(), and step_type().
value MakeValueSymbolic | ( | expression | e | ) |
this function creates a value for a symbolic constant.
the expression e must be evaluable. Well, it does not seem necessary any more...
pips_internal_error("value of parameter must be constant");
s = make_symbolic(e, make_constant(is_constant_unknown, UU));
Definition at line 581 of file constant.c.
References constant_undefined, EvalExpression(), free_value(), is_value_symbolic, make_constant_unknown(), make_symbolic(), make_value(), pips_assert, value_constant, value_constant_p, and value_unknown_p.
Referenced by gfc2pips_vars_(), and MakeParameter().
END_EOLE.
Make a Fortran constant
Apparently partly extended fo C...
SG : I like accurate knowledge of constant suffix to fill all cases accurately, there is still work to do there
The LengthOfBasic should be updated for type "string"
name | ame |
bt | t |
Definition at line 315 of file constant.c.
References c_module_p(), DefaultLengthOfBasic(), get_current_module_entity(), is_basic_float, and make_C_or_Fortran_constant_entity().
Referenced by MakeConstant().
bool signed_constant_expression_p | ( | expression | e | ) |
Definition at line 604 of file constant.c.
References call_arguments, call_function, CAR, CreateIntrinsic(), entity_constant_p, EXPRESSION, expression_syntax, ok, syntax_call, syntax_call_p, and UNARY_MINUS_OPERATOR_NAME.
Referenced by MakeComplexConstantExpression().
_int TK_CHARCON_to__int | ( | const char * | name | ) |
Should be able to decode any C character constant...
octal constant
name | ame |
Definition at line 88 of file constant.c.
References pips_internal_error, pips_user_warning, and string_undefined.
Referenced by make_C_or_Fortran_constant_entity().