#include <stdio.h>#include "linear.h"#include "genC.h"#include "ri.h"#include "misc.h"#include "ri-util.h"#include "text-util.h"
Go to the source code of this file.
layouts are independent ?
| a1 | 1 | |
| a2 | 2 |
Definition at line 341 of file type.c.
References area_size, area_undefined, FALSE, and TRUE.
Referenced by type_equal_p().
00342 { 00343 if(a1 == a2) 00344 return TRUE; 00345 else if (a1 == area_undefined && a2 != area_undefined) 00346 return FALSE; 00347 else if (a1 != area_undefined && a2 == area_undefined) 00348 return FALSE; 00349 else 00350 /* layouts are independent ? */ 00351 return (area_size(a1) == area_size(a2)); 00352 }

Definition at line 2168 of file type.c.
References NIL, type_variable, type_variable_p, and variable_dimensions.
Referenced by generic_c_words_simplified_entity().
02169 { 02170 return (type_variable_p(t) && (variable_dimensions(type_variable(t)) != NIL)); 02171 }

| t | is a type |
Definition at line 2358 of file type.c.
References basic_concrete_type(), basic_pointer, basic_pointer_p, basic_to_string(), basic_typedef, basic_typedef_p, copy_type(), e, entity_type, gen_full_copy_list(), gen_length(), gen_nconc(), ifdebug, is_type_variable, make_basic_pointer(), make_type_variable(), make_variable(), pips_assert, pips_debug, TRUE, type_tag, type_to_string(), type_variable, type_variable_p, variable_basic, variable_dimensions, and variable_qualifiers.
Referenced by basic_concrete_type(), basic_of_intrinsic(), c_convex_effects_on_formal_parameter_backward_translation(), effect_indices_contain_pointer_dimension_p(), effect_pointer_type_p(), effect_reference_contains_pointer_dimension_p(), entity_non_pointer_scalar_p(), generic_p_proper_effect_of_reference(), generic_proper_effects_of_declaration(), make_reference_region(), make_whole_array_predicate(), reference_to_simple_effect(), reference_to_type(), rw_effects_of_declarations(), and simple_effect_reference_type().
02359 { 02360 type nt; 02361 02362 pips_debug(9, "Begin with type \"%s\"\n", type_to_string(t)); 02363 02364 switch (type_tag(t)) 02365 { 02366 case is_type_variable: 02367 { 02368 variable vt = type_variable(t); 02369 basic bt = variable_basic(vt); 02370 list lt = variable_dimensions(vt); 02371 02372 pips_debug(9, "of basic \"%s\"and number of dimensions %d.\n", 02373 basic_to_string(bt), 02374 (int) gen_length(lt)); 02375 02376 if(basic_typedef_p(bt)) 02377 { 02378 entity e = basic_typedef(bt); 02379 type st = entity_type(e); 02380 02381 pips_debug(9, "typedef : %s\n", type_to_string(st)); 02382 nt = basic_concrete_type(st); 02383 if (type_variable_p(nt)) 02384 { 02385 variable_dimensions(type_variable(nt)) = 02386 gen_nconc(gen_full_copy_list(lt), 02387 variable_dimensions(type_variable(nt))); 02388 } 02389 } 02390 else if(basic_pointer_p(bt)) 02391 { 02392 type npt = basic_concrete_type(basic_pointer(bt)); 02393 02394 pips_debug(9, "pointer \n"); 02395 nt = make_type_variable 02396 (make_variable(make_basic_pointer(npt), 02397 gen_full_copy_list(lt), 02398 gen_full_copy_list(variable_qualifiers(vt)))); 02399 } 02400 else 02401 { 02402 pips_debug(9, "other variable case \n"); 02403 nt = copy_type(t); 02404 } 02405 } 02406 break; 02407 02408 default: 02409 nt = copy_type(t); 02410 } 02411 02412 pips_debug(9, "Ends with type \"%s\"\n", type_to_string(nt)); 02413 ifdebug(9) 02414 { 02415 if(type_variable_p(nt)) 02416 { 02417 variable nvt = type_variable(nt); 02418 basic nbt = variable_basic(nvt); 02419 list nlt = variable_dimensions(nvt); 02420 pips_debug(9, "of basic \"%s\"and number of dimensions %d.\n", 02421 basic_to_string(nbt), 02422 (int) gen_length(nlt)); 02423 } 02424 } 02425 02426 pips_assert("nt is not a typedef", 02427 type_variable_p(nt)? 02428 !basic_typedef_p(variable_basic(type_variable(nt))) : TRUE); 02429 02430 return nt; 02431 }


| int basic_depth | ( | basic | b | ) |
Definition at line 3342 of file type.c.
References basic_derived, basic_tag, basic_typedef, e, entity_type, is_basic_bit, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, pips_internal_error, and type_depth().
Referenced by type_depth().
03343 { 03344 int d = 0; 03345 03346 switch(basic_tag(b)) { 03347 case is_basic_int: 03348 case is_basic_float: 03349 case is_basic_logical: 03350 case is_basic_overloaded: 03351 case is_basic_complex: 03352 case is_basic_string: 03353 case is_basic_bit: 03354 case is_basic_pointer: 03355 break; 03356 case is_basic_derived: 03357 { 03358 entity e = basic_derived(b); 03359 type t = entity_type(e); 03360 d = type_depth(t); 03361 break; 03362 } 03363 case is_basic_typedef: 03364 { 03365 entity e = basic_typedef(b); 03366 type t = entity_type(e); 03367 03368 d = type_depth(t); 03369 break; 03370 } 03371 default: 03372 pips_internal_error("Unexpected basic tag %d\n", basic_tag(b)); 03373 } 03374 03375 return d; 03376 }


| b1 | 1 | |
| b2 | 2 |
Definition at line 465 of file type.c.
References basic_equal_strict_p(), basic_typedef, basic_typedef_p, entity_type, type_variable, ultimate_type(), and variable_basic.
Referenced by add_formal_to_actual_bindings(), basic_equal_strict_p(), c_user_function_call_to_transformer(), convert_constant(), declaration_to_transformer(), fortran_user_call_to_transformer(), fortran_user_function_call_to_transformer(), is_constant_of_basic(), is_varibale_array_element_specifier(), make_substitution(), same_basic_and_scalar_p(), simd_check_argType(), simplification_conversion(), store_initial_value(), type_loop_range(), type_this_entity_if_needed(), typing_arguments(), typing_arguments_of_user_function(), typing_of_assign(), typing_power_operator(), and variable_equal_p().
00466 { 00467 if( basic_typedef_p(b1) ) 00468 { 00469 type t1 = ultimate_type( entity_type(basic_typedef(b1)) ); 00470 b1 = variable_basic(type_variable(t1)); 00471 } 00472 00473 if( basic_typedef_p(b2) ) 00474 { 00475 type t2 = ultimate_type( entity_type(basic_typedef(b2)) ); 00476 b2 = variable_basic(type_variable(t2)); 00477 } 00478 return basic_equal_strict_p(b1,b2); 00479 00480 }


assertion: b1 and b2 are defined and have the same tag (see previous tests)
Do we want string types to be equal only if lengths are equal? I do not think so
could be a star or an expression; a value_equal_p() is needed!
FI->BC (?): suffixes _p should be removed
just to avoid a warning
| b1 | 1 | |
| b2 | 2 |
Definition at line 405 of file type.c.
References basic_complex, basic_derived, basic_equal_p(), basic_float, basic_int, basic_logical, basic_pointer, basic_tag, basic_typedef_p, basic_undefined, FALSE, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, pips_error(), same_entity_p(), TRUE, type_variable, type_variable_p, and variable_basic.
Referenced by add_declaration_statement(), and basic_equal_p().
00406 { 00407 if(b1 == b2) 00408 return TRUE; 00409 else if (b1 == basic_undefined && b2 != basic_undefined) 00410 return FALSE; 00411 else if (b1 != basic_undefined && b2 == basic_undefined) 00412 return FALSE; 00413 else if (basic_tag(b1) != basic_tag(b2)) 00414 return FALSE; 00415 00416 /* assertion: b1 and b2 are defined and have the same tag 00417 (see previous tests) */ 00418 00419 switch(basic_tag(b1)) { 00420 case is_basic_int: 00421 return basic_int(b1) == basic_int(b2); 00422 case is_basic_float: 00423 return basic_float(b1) == basic_float(b2); 00424 case is_basic_logical: 00425 return basic_logical(b1) == basic_logical(b2); 00426 case is_basic_overloaded: 00427 return TRUE; 00428 case is_basic_complex: 00429 return basic_complex(b1) == basic_complex(b2); 00430 case is_basic_pointer: 00431 { 00432 type t1 = basic_pointer(b1); 00433 type t2 = basic_pointer(b2); 00434 00435 return type_variable_p(t1) && 00436 type_variable_p(t2) && 00437 basic_equal_p( variable_basic(type_variable(t1)) , variable_basic(type_variable(t2)) ); 00438 } 00439 case is_basic_derived: 00440 { 00441 entity e1 = basic_derived(b1); 00442 entity e2 = basic_derived(b2); 00443 00444 return e1==e2; 00445 } 00446 case is_basic_string: 00447 /* Do we want string types to be equal only if lengths are equal? 00448 * I do not think so 00449 */ 00450 /* 00451 pips_error("basic_equal_p", 00452 "string type comparison not implemented\n"); 00453 */ 00454 /* could be a star or an expression; a value_equal_p() is needed! */ 00455 return TRUE; 00456 case is_basic_typedef: 00457 /* FI->BC (?): suffixes _p should be removed */ 00458 return basic_typedef_p(b2) 00459 && same_entity_p(basic_typedef_p(b1),basic_typedef_p(b2)); 00460 default: pips_error("basic_equal_p", "unexpected tag %d\n", basic_tag(b1)); 00461 } 00462 return FALSE; /* just to avoid a warning */ 00463 }


FI: I do not believe this is correct for all intrinsics!
Type checking problem for ? : with gcc...
NN: More cases are added for C. To be refined
bit is a lesser type
Are they really comparable?
How can we compare two pointer types? Equality? Comparison of the pointed types?
pips_internal_error("Comparison of two pointer types not implemented\n");
FI: not convvincing. As in other palces, assuming this is meaning ful, it would be better to use a basic comparator, basic_greater_p(), which could return 1, -1 or 0 or ??? and deal with non comparable type.
How do you compare a structure or a union to another type? The only case which seems to make sense is equality.
| fb1 | b1 | |
| fb2 | b2 |
Definition at line 1264 of file type.c.
References b, b1, b2, basic_bit, basic_bit_p, basic_complex_p, basic_derived, basic_derived_p, basic_float_p, basic_int_p, basic_logical, basic_logical_p, basic_maximum(), basic_overloaded_p, basic_pointer, basic_pointer_p, basic_string_p, basic_tag, basic_typedef_p, basic_ultimate(), basic_undefined, copy_basic(), entity_enum_p(), free_basic(), is_basic_bit, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, make_basic(), pips_debug, pips_internal_error, s1, SizeOfElements(), type_variable, type_variable_p, type_void_p, UU, UUINT, and variable_basic.
Referenced by basic_maximum(), basic_of_intrinsic(), basic_union(), and intrinsic_call_to_type().
01265 { 01266 basic b = basic_undefined; 01267 basic b1 = basic_ultimate(fb1); 01268 basic b2 = basic_ultimate(fb2); 01269 01270 01271 if(basic_derived_p(fb1)) { 01272 entity e1 = basic_derived(fb1); 01273 01274 if(entity_enum_p(e1)) { 01275 b1 = make_basic(is_basic_int, (void *) 4); 01276 b = basic_maximum(b1, fb2); 01277 free_basic(b1); 01278 return b; 01279 } 01280 else 01281 pips_internal_error("Unanalyzed derived basic b1\n"); 01282 } 01283 01284 if(basic_derived_p(fb2)) { 01285 entity e2 = basic_derived(fb2); 01286 01287 if(entity_enum_p(e2)) { 01288 b2 = make_basic(is_basic_int, (void *) 4); 01289 b = basic_maximum(fb1, b2); 01290 free_basic(b2); 01291 return b; 01292 } 01293 else 01294 pips_internal_error("Unanalyzed derived basic b2\n"); 01295 } 01296 01297 /* FI: I do not believe this is correct for all intrinsics! */ 01298 01299 pips_debug(7, "Tags: tag exp1 = %d, tag exp2 = %d\n", 01300 basic_tag(b1), basic_tag(b2)); 01301 01302 01303 if(basic_overloaded_p(b2)) { 01304 b = copy_basic(b2); 01305 } 01306 else { 01307 switch(basic_tag(b1)) { 01308 01309 case is_basic_overloaded: 01310 b = copy_basic(b1); 01311 break; 01312 01313 case is_basic_string: 01314 if(basic_string_p(b2)) { 01315 int s1 = SizeOfElements(b1); 01316 int s2 = SizeOfElements(b2); 01317 01318 /* Type checking problem for ? : with gcc... */ 01319 if(s1>s2) 01320 b = copy_basic(b1); 01321 else 01322 b = copy_basic(b2); 01323 } 01324 else 01325 b = make_basic(is_basic_overloaded, UU); 01326 break; 01327 01328 case is_basic_logical: 01329 if(basic_logical_p(b2)) { 01330 _int s1 = basic_logical(b1); 01331 _int s2 = basic_logical(b2); 01332 01333 b = make_basic(is_basic_logical,UUINT(s1>s2?s1:s2)); 01334 } 01335 else 01336 b = make_basic(is_basic_overloaded, UU); 01337 break; 01338 01339 case is_basic_complex: 01340 if(basic_complex_p(b2) || basic_float_p(b2) || basic_int_p(b2)) { 01341 _int s1 = SizeOfElements(b1); 01342 _int s2 = SizeOfElements(b2); 01343 01344 b = make_basic(is_basic_complex, UUINT(s1>s2?s1:s2)); 01345 } 01346 else 01347 b = make_basic(is_basic_overloaded, UU); 01348 break; 01349 01350 case is_basic_float: 01351 if(basic_complex_p(b2)) { 01352 _int s1 = SizeOfElements(b1); 01353 _int s2 = SizeOfElements(b2); 01354 01355 b = make_basic(is_basic_complex, UUINT(s1>s2?s1:s2)); 01356 } 01357 else if(basic_float_p(b2) || basic_int_p(b2)) { 01358 _int s1 = SizeOfElements(b1); 01359 _int s2 = SizeOfElements(b2); 01360 01361 b = make_basic(is_basic_float, UUINT(s1>s2?s1:s2)); 01362 } 01363 else 01364 b = make_basic(is_basic_overloaded, UU); 01365 break; 01366 01367 case is_basic_int: 01368 if(basic_complex_p(b2) || basic_float_p(b2)) { 01369 _int s1 = SizeOfElements(b1); 01370 _int s2 = SizeOfElements(b2); 01371 01372 b = make_basic(basic_tag(b2), UUINT(s1>s2?s1:s2)); 01373 } 01374 else if(basic_int_p(b2)) { 01375 _int s1 = SizeOfElements(b1); 01376 _int s2 = SizeOfElements(b2); 01377 01378 b = make_basic(is_basic_int, UUINT(s1>s2?s1:s2)); 01379 } 01380 else 01381 b = make_basic(is_basic_overloaded, UU); 01382 break; 01383 /* NN: More cases are added for C. To be refined */ 01384 case is_basic_bit: 01385 if(basic_bit_p(b2)) { 01386 if(basic_bit(b1)>=basic_bit(b2)) 01387 b = copy_basic(b1); 01388 else 01389 b = copy_basic(b2); 01390 } 01391 else 01392 /* bit is a lesser type */ 01393 b = copy_basic(b2); 01394 break; 01395 case is_basic_pointer: 01396 { 01397 if(basic_int_p(b2) || basic_bit_p(b2)) 01398 b = copy_basic(b1); 01399 else if(basic_float_p(b2) || basic_logical_p(b2) || basic_complex_p(b2)) { 01400 /* Are they really comparable? */ 01401 b = copy_basic(b1); 01402 } 01403 else if(basic_overloaded_p(b2)) 01404 b = copy_basic(b1); 01405 else if(basic_pointer_p(b2)) { 01406 /* How can we compare two pointer types? Equality? Comparison of the pointed types? */ 01407 /* pips_internal_error("Comparison of two pointer types not implemented\n"); */ 01408 type t1 = basic_pointer(b1); 01409 type t2 = basic_pointer(b2); 01410 01411 if(type_variable_p(t1) && type_variable_p(t2)) { 01412 basic nb1 = variable_basic(type_variable(t1)); 01413 basic nb2 = variable_basic(type_variable(t2)); 01414 01415 /* FI: not convvincing. As in other palces, assuming this 01416 is meaning ful, it would be better to use a basic 01417 comparator, basic_greater_p(), which could return 1, -1 01418 or 0 or ??? and deal with non comparable type. */ 01419 b = basic_maximum(nb1, nb2); 01420 } 01421 else if (type_void_p(t1) && type_void_p(t2) ) 01422 b = copy_basic(b1); 01423 else 01424 pips_internal_error("Comparison of two pointer types not meaningful\n"); 01425 } 01426 else if(basic_derived_p(b2)) 01427 pips_internal_error("Comparison between pointer and struct/union not implemented\n"); 01428 else if(basic_typedef_p(b2)) 01429 pips_internal_error("b2 cannot be a typedef basic\n"); 01430 else 01431 pips_internal_error("unknown tag %d for basic b2\n", basic_tag(b2)); 01432 break; 01433 } 01434 case is_basic_derived: 01435 /* How do you compare a structure or a union to another type? 01436 The only case which seems to make sense is equality. */ 01437 pips_internal_error("Derived basic b1 it not comparable to another basic\n"); 01438 break; 01439 case is_basic_typedef: 01440 pips_internal_error("b1 cannot be a typedef basic\n"); 01441 break; 01442 default: pips_internal_error("Ill. basic tag %d\n", basic_tag(b1)); 01443 } 01444 } 01445 01446 return b; 01447 01448 /* 01449 if( (t1 != is_basic_complex) && (t1 != is_basic_float) && 01450 (t1 != is_basic_int) && (t2 != is_basic_complex) && 01451 (t2 != is_basic_float) && (t2 != is_basic_int) ) 01452 pips_error("basic_union", 01453 "Bad basic tag for expression in numerical function"); 01454 01455 if(t1 == is_basic_complex) 01456 return(b1); 01457 if(t2 == is_basic_complex) 01458 return(b2); 01459 if(t1 == is_basic_float) { 01460 if( (t2 != is_basic_float) || 01461 (basic_float(b1) == DOUBLE_PRECISION_SIZE) ) 01462 return(b1); 01463 return(b2); 01464 } 01465 if(t2 == is_basic_float) 01466 return(b2); 01467 return(b1); 01468 */ 01469 }


| basic basic_of_any_expression | ( | expression | exp, | |
| bool | apply_p | |||
| ) |
| exp | xp | |
| apply_p | pply_p |
Definition at line 925 of file type.c.
References some_basic_of_any_expression(), and TRUE.
Referenced by basic_of_expression(), and some_basic_of_any_expression().
00926 { 00927 return some_basic_of_any_expression(exp, apply_p, TRUE); 00928 }


basic basic_of_call(call c): returns the basic of the result given by the call "c".
If ultimate_p is true, replaced typdef'ed types by their definitions recursively. If not, preserve typedef'ed types.
WARNING: a new basic is allocated
b = make_basic(is_basic_overloaded, UU);
Never go there...
| apply_p | pply_p | |
| ultimate_p | ltimate_p |
Definition at line 971 of file type.c.
References b, basic_of_constant(), basic_of_external(), basic_of_intrinsic(), basic_undefined, call_function, copy_basic(), e, entity_initial, entity_name, is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, pips_debug, pips_internal_error, tag, and value_tag.
Referenced by c_user_function_call_to_transformer(), fortran_user_function_call_to_transformer(), some_basic_of_any_expression(), and type_this_call().
00972 { 00973 entity e = call_function(c); 00974 tag t = value_tag(entity_initial(e)); 00975 basic b = basic_undefined; 00976 00977 switch (t) 00978 { 00979 case is_value_code: 00980 b = copy_basic(basic_of_external(c)); 00981 break; 00982 case is_value_intrinsic: 00983 b = basic_of_intrinsic(c, apply_p, ultimate_p); 00984 break; 00985 case is_value_symbolic: 00986 /* b = make_basic(is_basic_overloaded, UU); */ 00987 b = copy_basic(basic_of_constant(c)); 00988 break; 00989 case is_value_constant: 00990 b = copy_basic(basic_of_constant(c)); 00991 break; 00992 case is_value_unknown: 00993 pips_debug(1, "function %s has no initial value.\n" 00994 " Maybe it has not been parsed yet.\n", 00995 entity_name(e)); 00996 b = copy_basic(basic_of_external(c)); 00997 break; 00998 default: pips_internal_error("unknown tag %d\n", t); 00999 /* Never go there... */ 01000 } 01001 return b; 01002 }


basic basic_of_constant(call c): returns the basic of the call to a constant.
WARNING: returns a pointer towards an existing data structure
Definition at line 1211 of file type.c.
References call_function, debug(), entity_type, functional_result, is_type_functional, is_type_variable, pips_error(), type_functional, type_tag, type_variable, and variable_basic.
Referenced by basic_of_call(), and call_to_type().
01212 { 01213 type call_type, return_type; 01214 01215 debug(7, "basic_of_constant", "Constant call\n"); 01216 01217 call_type = entity_type(call_function(c)); 01218 01219 if (type_tag(call_type) != is_type_functional) 01220 pips_error("basic_of_constant", "Bad call type tag"); 01221 01222 return_type = functional_result(type_functional(call_type)); 01223 01224 if (type_tag(return_type) != is_type_variable) 01225 pips_error("basic_of_constant", "Bad return call type tag"); 01226 01227 return(variable_basic(type_variable(return_type))); 01228 }


| basic basic_of_expression | ( | expression | exp | ) |
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Indeed, "exp" will be assigned to a temporary variable, which will have the same declaration as "exp".
Does not work if the expression is a reference to a functional entity, as may be the case in a Fortran call.
WARNING: a new basic object is allocated
PREFER (???) expression_basic
| exp | xp |
Definition at line 942 of file type.c.
References basic_of_any_expression(), and FALSE.
Referenced by add_formal_to_actual_bindings(), any_expression_to_transformer(), any_user_call_site_to_transformer(), assign_tmp_to_exp(), atomize_this_expression(), atomizer_of_external(), basic_of_intrinsic(), basic_of_reference(), basic_union(), condition_to_transformer(), declaration_to_transformer(), do_loop_expansion(), fortran_user_call_to_transformer(), get_optimal_opcode(), get_vect_name_from_data(), integer_expression_p(), inv_call_flt(), logical_binary_function_to_transformer(), make_substitution(), MakeComplexConstantExpression(), MemberIdentifierToExpression(), partial_eval_minus_c_operator(), partial_eval_plus_c_operator(), simd_atomize_this_expression(), simd_fill_curArgType_call(), simplify_C_expression(), simplify_complex_expression(), simplify_subscript(), SizeOfArray(), some_basic_of_any_expression(), split_update_call(), store_initial_value(), transformer_add_any_relation_information(), update_functional_type_with_actual_arguments(), and words_infix_binary_op().
00943 { 00944 return basic_of_any_expression(exp, FALSE); 00945 }


basic basic_of_external(call c): returns the basic of the result given by the call to an external function.
WARNING: returns a pointer
Definition at line 1011 of file type.c.
References b, basic_to_string(), basic_undefined, call_function, entity_name, entity_type, f, functional_result, is_type_functional, pips_debug, pips_error(), pips_internal_error, pips_user_error, type_functional, type_tag, type_to_string(), type_undefined, type_variable, type_variable_p, type_void_p, and variable_basic.
Referenced by basic_of_call(), and call_to_type().
01012 { 01013 type return_type = type_undefined; 01014 entity f = call_function(c); 01015 basic b = basic_undefined; 01016 type call_type = entity_type(f); 01017 01018 pips_debug(7, "External call to %s\n", entity_name(f)); 01019 01020 if (type_tag(call_type) != is_type_functional) 01021 pips_error("basic_of_external", "Bad call type tag"); 01022 01023 return_type = functional_result(type_functional(call_type)); 01024 01025 if (!type_variable_p(return_type)) { 01026 if(type_void_p(return_type)) { 01027 pips_user_error("A subroutine or void returning function is used as an expression\n"); 01028 } 01029 else { 01030 pips_internal_error("Bad return call type tag \"%s\"\n", type_to_string(return_type)); 01031 } 01032 } 01033 01034 b = (variable_basic(type_variable(return_type))); 01035 01036 pips_debug(7, "Returned type is %s\n", basic_to_string(b)); 01037 01038 return b; 01039 }


basic basic_of_intrinsic(call c): returns the basic of the result given by call to an intrinsic function.
This basic must be computed with the basic of the arguments of the intrinsic for overloaded operators. It should be able to accomodate more than two arguments as for generic min and max operators. ultimate_p controls the behavior when typedef'ed types are encountered: should they be replaced by their definitions or not?
WARNING: returns a newly allocated basic object
I don't know the type since there is no arguments ! Bug encountered with a FMT=* in a PRINT. RK, 21/02/1994 :
leave it overloaded
Too bad, this may happen in the parser
Too bad for "void"...
This can also be a user error, but if the function is called from the parser, a CParserError() should be called: how to guess what to do?
We should reconstruct a struct type or an array type...
returns the type of the left hand side
The value returned is the value of the last expression in the list.
The value returned is the value of the first expression in the list after the condition. The second expression is assumed to have the same value because the code is assumed correct.
| apply_p | pply_p | |
| ultimate_p | ltimate_p |
Definition at line 1050 of file type.c.
References b, basic_concrete_type(), basic_maximum(), basic_of_expression(), basic_overloaded_p, basic_pointer, basic_pointer_p, basic_to_string(), basic_undefined, call_arguments, call_function, call_to_type(), CAR, CDR, copy_basic(), copy_type(), e, ENDP, ENTITY_ADDRESS_OF_P, ENTITY_ASSIGN_P, ENTITY_BRACE_INTRINSIC_P, ENTITY_COMMA_P, ENTITY_CONDITIONAL_P, ENTITY_DEREFERENCING_P, ENTITY_FIELD_P, ENTITY_POINT_TO_P, entity_type, EXPRESSION, f, FALSE, free_basic(), free_type(), functional_result, gen_last(), gen_length(), ifdebug, is_basic_pointer, is_type_variable, make_basic(), make_basic_overloaded(), make_type(), make_variable(), MAP, module_local_name(), NIL, pips_assert, pips_debug, pips_internal_error, print_expression(), rt, some_basic_of_any_expression(), type_consistent_p(), type_functional, type_functional_p, type_undefined, type_undefined_p, type_variable, type_variable_p, ultimate_type(), and variable_basic.
Referenced by basic_of_call().
01051 { 01052 entity f = call_function(c); 01053 type rt = functional_result(type_functional(entity_type(f))); 01054 basic rb = copy_basic(variable_basic(type_variable(rt))); 01055 01056 pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a priori result type \"%s\"\n", 01057 module_local_name(f), 01058 basic_to_string(rb)); 01059 01060 if(basic_overloaded_p(rb)) { 01061 list args = call_arguments(c); 01062 01063 if (ENDP(args)) { 01064 /* I don't know the type since there is no arguments ! 01065 Bug encountered with a FMT=* in a PRINT. 01066 RK, 21/02/1994 : */ 01067 /* leave it overloaded */ 01068 ; 01069 } 01070 else if(ENTITY_ADDRESS_OF_P(f)) { 01071 //string s = entity_user_name(f); 01072 //bool b = ENTITY_ADDRESS_OF_P(f); 01073 expression e = EXPRESSION(CAR(args)); 01074 basic eb = some_basic_of_any_expression(e, FALSE, ultimate_p); 01075 // Forget multidimensional types 01076 type et = make_type(is_type_variable, 01077 make_variable(eb, NIL, NIL)); 01078 01079 //fprintf(stderr, "b=%d, s=%s\n", b, s); 01080 free_basic(rb); 01081 rb = make_basic(is_basic_pointer, et); 01082 } 01083 else if(ENTITY_DEREFERENCING_P(f)) { 01084 expression e = EXPRESSION(CAR(args)); 01085 free_basic(rb); 01086 rb = basic_of_expression(e); 01087 if(basic_pointer_p(rb)) { 01088 type pt = type_undefined; 01089 01090 if(ultimate_p && !type_undefined_p(basic_pointer(rb))) 01091 pt = copy_type(ultimate_type(basic_pointer(rb))); 01092 else 01093 pt = copy_type(basic_pointer(rb)); 01094 01095 pips_assert("The pointed type is consistent", type_consistent_p(pt)); 01096 if(type_undefined_p(pt)) { 01097 /* Too bad, this may happen in the parser */ 01098 free_basic(rb); 01099 rb = basic_undefined; 01100 } 01101 else if(type_variable_p(pt) && !apply_p) { 01102 free_basic(rb); 01103 rb = copy_basic(variable_basic(type_variable(pt))); 01104 } 01105 else if(type_functional_p(pt)) { 01106 if(apply_p) { 01107 free_basic(rb); 01108 type rt = ultimate_type(functional_result(type_functional(pt))); 01109 if(type_variable_p(rt)) 01110 rb = copy_basic(variable_basic(type_variable(rt))); 01111 else { 01112 /* Too bad for "void"... */ 01113 pips_internal_error("result type of a functional type must be a variable type\n"); 01114 } 01115 } 01116 else { 01117 return rb; 01118 } 01119 } 01120 else { 01121 pips_internal_error("unhandled case\n"); 01122 } 01123 } 01124 else { 01125 type et = call_to_type(c); 01126 if(ultimate_p) et=basic_concrete_type(et); 01127 if( type_variable_p(et) ) 01128 { 01129 free_basic(rb); 01130 rb=copy_basic(variable_basic(type_variable(et))); 01131 } 01132 if( !type_variable_p(et) ) { 01133 01134 /* This can also be a user error, but if the function is 01135 called from the parser, a CParserError() should be called: 01136 how to guess what to do? */ 01137 pips_internal_error("Dereferencing of a non-pointer, non array expression\n" 01138 "Please use gcc to check that your source code is legal\n"); 01139 } 01140 if(ultimate_p) free_type(et); 01141 } 01142 } 01143 else if(ENTITY_POINT_TO_P(f)) { 01144 //pips_internal_error("Point to case not implemented yet\n"); 01145 expression e1 = EXPRESSION(CAR(args)); 01146 expression e2 = EXPRESSION(CAR(CDR(args))); 01147 free_basic(rb); 01148 pips_assert("Two arguments for ENTITY_POINT_TO", gen_length(args)==2); 01149 ifdebug(8) { 01150 pips_debug(8, "Point to case, e1 = "); 01151 print_expression(e1); 01152 pips_debug(8, " and e2 = "); 01153 print_expression(e1); 01154 pips_debug(8, "\n"); 01155 } 01156 rb = basic_of_expression(e2); 01157 } 01158 else if(ENTITY_BRACE_INTRINSIC_P(f)) { 01159 /* We should reconstruct a struct type or an array type... */ 01160 rb = make_basic_overloaded(); 01161 } 01162 else if(ENTITY_ASSIGN_P(f)) { 01163 /* returns the type of the left hand side */ 01164 rb = basic_of_expression(EXPRESSION(CAR(args))); 01165 } 01166 else if(ENTITY_FIELD_P(f)) { 01167 free_basic(rb); 01168 rb = basic_of_expression(EXPRESSION(CAR(CDR(args)))); 01169 } 01170 else if(ENTITY_COMMA_P(f)) { 01171 /* The value returned is the value of the last expression in the list. */ 01172 free_basic(rb); 01173 rb = basic_of_expression(EXPRESSION(CAR(gen_last(args)))); 01174 } 01175 else if(ENTITY_CONDITIONAL_P(f)) { 01176 /* The value returned is the value of the first expression in 01177 the list after the condition. The second expression is 01178 assumed to have the same value because the code is assumed 01179 correct. */ 01180 free_basic(rb); 01181 rb = basic_of_expression(EXPRESSION(CAR(CDR(args)))); 01182 } 01183 else { 01184 free_basic(rb); 01185 rb = basic_of_expression(EXPRESSION(CAR(args))); 01186 01187 MAP(EXPRESSION, arg, { 01188 basic b = basic_of_expression(arg); 01189 basic new_rb = basic_maximum(rb, b); 01190 01191 free_basic(rb); 01192 free_basic(b); 01193 rb = new_rb; 01194 }, CDR(args)); 01195 } 01196 01197 } 01198 01199 pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a posteriori result type \"%s\"\n", 01200 module_local_name(f), 01201 basic_to_string(rb)); 01202 01203 return rb; 01204 }


retreives the basic of a reference in a newly allocated bsaic object
| r | reference we want the basic of |
Definition at line 954 of file type.c.
References basic_of_expression(), expression_syntax, expression_undefined, expression_undefined_p, make_expression(), make_syntax_reference(), normalized_undefined, reference_undefined, and syntax_reference.
Referenced by build_new_ref(), generate_prelude(), generate_scalar_variables(), generate_scalar_variables_from_list(), get_type_max_width(), make_reduction_vector_entity(), make_substitution(), match_call(), my_build_new_ref(), process_true_call_stat(), rename_statement_reductions(), and variables_width_filter().
00955 { 00956 static expression sexp = expression_undefined; 00957 if(expression_undefined_p(sexp)) sexp=make_expression(make_syntax_reference(reference_undefined),normalized_undefined); 00958 syntax_reference(expression_syntax(sexp)) = r; 00959 return basic_of_expression(sexp); 00960 }


| sel | el | |
| vt | t |
Definition at line 2758 of file type.c.
References basic_bit, basic_bit_p, basic_complex_p, basic_derived, basic_derived_p, basic_float_p, basic_int_p, basic_logical_p, basic_overloaded_p, basic_pointer, basic_pointer_p, basic_string_p, basic_tag, basic_typedef, basic_typedef_p, CONS, ENTITY, entity_type, fprintf(), gen_nconc(), ifdebug, NIL, pips_debug, pips_internal_error, print_entities(), recursive_type_supporting_entities(), and symbolic_supporting_entities().
Referenced by variable_type_supporting_entities().
02759 { 02760 02761 ifdebug(8) { 02762 pips_debug(8, "Begin: "); 02763 print_entities(sel); 02764 fprintf(stderr, "\n\n"); 02765 } 02766 02767 if(basic_int_p(b) || 02768 basic_float_p(b) || 02769 basic_logical_p(b) || 02770 basic_overloaded_p(b) || 02771 basic_complex_p(b) || 02772 basic_string_p(b)) 02773 ; 02774 else if(basic_bit_p(b)) 02775 sel = symbolic_supporting_entities(sel, vt, basic_bit(b)); 02776 else if(basic_pointer_p(b)) 02777 sel = recursive_type_supporting_entities(sel, vt, basic_pointer(b)); 02778 else if(basic_derived_p(b)) { 02779 //sel = CONS(ENTITY, basic_derived(b), sel); 02780 sel = recursive_type_supporting_entities(sel, vt, entity_type(basic_derived(b))); 02781 sel = gen_nconc(sel, CONS(ENTITY, basic_derived(b), NIL)); 02782 } 02783 else if(basic_typedef_p(b)) { 02784 entity se = basic_typedef(b); 02785 //sel = CONS(ENTITY, se, sel); 02786 sel = recursive_type_supporting_entities(sel, vt, entity_type(se)); 02787 sel = gen_nconc(sel, CONS(ENTITY, se, NIL)); 02788 } 02789 else 02790 pips_internal_error("Unrecognized basic tag %d\n", basic_tag(b)); 02791 02792 ifdebug(8) { 02793 pips_debug(8, "End: "); 02794 print_entities(sel); 02795 fprintf(stderr, "\n\n"); 02796 } 02797 02798 return sel; 02799 }


| srl | rl |
Definition at line 3036 of file type.c.
References basic_bit, basic_bit_p, basic_complex_p, basic_derived, basic_derived_p, basic_float_p, basic_int_p, basic_logical_p, basic_overloaded_p, basic_pointer, basic_pointer_p, basic_string_p, basic_tag, basic_typedef, basic_typedef_p, entity_type, fprintf(), ifdebug, pips_debug, pips_internal_error, print_references(), recursive_type_supporting_references(), and symbolic_supporting_references().
Referenced by variable_type_supporting_references().
03037 { 03038 03039 ifdebug(9) { 03040 pips_debug(8, "Begin: "); 03041 print_references(srl); 03042 fprintf(stderr, "\n"); 03043 } 03044 03045 if(basic_int_p(b) || 03046 basic_float_p(b) || 03047 basic_logical_p(b) || 03048 basic_overloaded_p(b) || 03049 basic_complex_p(b) || 03050 basic_string_p(b)) 03051 ; 03052 else if(basic_bit_p(b)) 03053 srl = symbolic_supporting_references(srl, basic_bit(b)); 03054 else if(basic_pointer_p(b)) 03055 srl = recursive_type_supporting_references(srl, basic_pointer(b)); 03056 else if(basic_derived_p(b)) { 03057 //srl = CONS(ENTITY, basic_derived(b), srl); 03058 srl = recursive_type_supporting_references(srl, entity_type(basic_derived(b))); 03059 } 03060 else if(basic_typedef_p(b)) { 03061 entity se = basic_typedef(b); 03062 //srl = CONS(ENTITY, se, srl); 03063 srl = recursive_type_supporting_references(srl, entity_type(se)); 03064 } 03065 else 03066 pips_internal_error("Unrecognized basic tag %d\n", basic_tag(b)); 03067 03068 ifdebug(9) { 03069 pips_debug(8, "End: "); 03070 print_references(srl); 03071 fprintf(stderr, "\n"); 03072 } 03073 03074 return srl; 03075 }


Definition at line 3528 of file type.c.
References basic_bit_p, basic_complex_p, basic_derived, basic_derived_p, basic_float_p, basic_int_p, basic_logical_p, basic_overloaded_p, basic_pointer, basic_pointer_p, basic_string_p, basic_tag, basic_typedef, basic_typedef_p, CONS, ENTITY, entity_type, fprintf(), ifdebug, pips_debug, pips_internal_error, print_entities(), recursive_type_supporting_entities(), and recursive_type_supporting_types().
Referenced by variable_type_supporting_types().
03529 { 03530 03531 ifdebug(8) { 03532 pips_debug(8, "Begin: "); 03533 print_entities(stl); 03534 fprintf(stderr, "\n"); 03535 } 03536 03537 if(basic_int_p(b) || 03538 basic_float_p(b) || 03539 basic_logical_p(b) || 03540 basic_overloaded_p(b) || 03541 basic_complex_p(b) || 03542 basic_string_p(b)) 03543 ; 03544 else if(basic_bit_p(b)) 03545 ; 03546 else if(basic_pointer_p(b)) 03547 stl = recursive_type_supporting_types(stl, vt, basic_pointer(b)); 03548 else if(basic_derived_p(b)) { 03549 entity de = basic_derived(b); 03550 type dt = entity_type(de); 03551 stl = CONS(ENTITY, de, stl); 03552 stl = recursive_type_supporting_types(stl, vt, dt); 03553 } 03554 else if(basic_typedef_p(b)) { 03555 entity se = basic_typedef(b); 03556 type st = entity_type(se); 03557 stl = CONS(ENTITY, se, stl); 03558 stl = recursive_type_supporting_entities(stl, vt, st); 03559 } 03560 else 03561 pips_internal_error("Unrecognized basic tag %d\n", basic_tag(b)); 03562 03563 ifdebug(8) { 03564 pips_debug(8, "End: "); 03565 print_entities(stl); 03566 fprintf(stderr, "\n"); 03567 } 03568 03569 return stl; 03570 }


returns the corresponding generic conversion entity, if any.
otherwise returns entity_undefined.
what about INTEGER*{2,4,8} ?
Definition at line 2024 of file type.c.
References basic_complex, basic_float, basic_tag, CMPLX_GENERIC_CONVERSION_NAME, DBLE_GENERIC_CONVERSION_NAME, DCMPLX_GENERIC_CONVERSION_NAME, entity_intrinsic(), entity_undefined, INT_GENERIC_CONVERSION_NAME, is_basic_complex, is_basic_float, is_basic_int, and REAL_GENERIC_CONVERSION_NAME.
Referenced by make_substitution().
02025 { 02026 entity result; 02027 02028 switch (basic_tag(b)) 02029 { 02030 case is_basic_int: 02031 /* what about INTEGER*{2,4,8} ? 02032 */ 02033 result = entity_intrinsic(INT_GENERIC_CONVERSION_NAME); 02034 break; 02035 case is_basic_float: 02036 { 02037 if (basic_float(b)==4) 02038 result = entity_intrinsic(REAL_GENERIC_CONVERSION_NAME); 02039 else if (basic_float(b)==8) 02040 result = entity_intrinsic(DBLE_GENERIC_CONVERSION_NAME); 02041 else 02042 result = entity_undefined; 02043 break; 02044 } 02045 case is_basic_complex: 02046 { 02047 if (basic_complex(b)==8) 02048 result = entity_intrinsic(CMPLX_GENERIC_CONVERSION_NAME); 02049 else if (basic_complex(b)==16) 02050 result = entity_intrinsic(DCMPLX_GENERIC_CONVERSION_NAME); 02051 else 02052 result = entity_undefined; 02053 break; 02054 } 02055 default: 02056 result = entity_undefined; 02057 } 02058 02059 return result; 02060 }


BEGIN_EOLE.
Nga Nguyen, 19/09/2003: To not rewrite the same thing, I use the words_basic() function
Definition at line 736 of file type.c.
References list_to_string(), NIL, and words_basic().
Referenced by add_formal_to_actual_bindings(), any_expression_to_transformer(), any_user_call_site_to_transformer(), arguments_are_something(), basic_concrete_type(), basic_of_external(), basic_of_intrinsic(), can_terapixify_expression_p(), codegen_commenter(), DeclareVariable(), dump_functional(), fortran_user_call_to_transformer(), fprint_any_environment(), fprint_functional(), generic_p_proper_effect_of_reference(), get_symbol_table(), is_varibale_array_element_specifier(), register_scalar_communications(), relation_to_transformer(), sentence_basic_declaration(), some_basic_of_any_expression(), string_expression_to_transformer(), stub_head(), stub_var_decl(), this_entity_cdeclaration(), type_this_call(), type_this_entity_if_needed(), type_this_expression(), type_this_instruction(), TypeFunctionalEntity(), typing_arguments_of_user_function(), typing_function_argument_type_to_return_type(), ultimate_type(), and variable_to_string().
00737 { 00738 /* Nga Nguyen, 19/09/2003: To not rewrite the same thing, I use the words_basic() function*/ 00739 return list_to_string(words_basic(b, NIL)); 00740 }


Safer than the other implementation? bool pointer_type_p(type t) { bool is_pointer = FALSE;.
if (!type_undefined_p(t) && type_variable_p(t)) { basic b = variable_basic(type_variable(t)); if (!basic_undefined_p(b) && basic_pointer_p(b)) { is_pointer = TRUE; } } return is_pointer; }Here is the set of mapping functions, from the RI to C language typesReturns TRUE if t is one of the following types : void, char, short, int, long, float, double, signed, unsigned, and there is no array dimensions, of course
Definition at line 2155 of file type.c.
References b, basic_bit_p, basic_complex_p, basic_float_p, basic_int_p, basic_logical_p, basic_overloaded_p, basic_string_p, NIL, type_unknown_p, type_variable, type_variable_p, type_void_p, variable_basic, and variable_dimensions.
Referenced by generic_c_words_simplified_entity().
02156 { 02157 if (type_variable_p(t)) 02158 { 02159 basic b = variable_basic(type_variable(t)); 02160 return ((variable_dimensions(type_variable(t)) == NIL) && 02161 (basic_int_p(b) || basic_float_p(b) || basic_logical_p(b) 02162 || basic_overloaded_p(b) || basic_complex_p(b) || basic_string_p(b) 02163 || basic_bit_p(b))); 02164 } 02165 return (type_void_p(t) || type_unknown_p(t)) ; 02166 }

| int basic_type_size | ( | basic | b | ) |
See also SizeOfElements().
pips_error("basic_type_size", "undefined for type string\n");
Definition at line 561 of file type.c.
References basic_complex, basic_float, basic_int, basic_logical, basic_tag, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, pips_error(), and string_type_size().
Referenced by DeclareVariable(), MakeAtom(), MakeComplexConstant(), and MakeComplexConstantExpression().
00562 { 00563 int size = -1; 00564 00565 switch(basic_tag(b)) { 00566 case is_basic_int: size = basic_int(b); 00567 break; 00568 case is_basic_float: size = basic_float(b); 00569 break; 00570 case is_basic_logical: size = basic_logical(b); 00571 break; 00572 case is_basic_overloaded: 00573 pips_error("basic_type_size", "undefined for type overloaded\n"); 00574 break; 00575 case is_basic_complex: size = basic_complex(b); 00576 break; 00577 case is_basic_string: 00578 /* pips_error("basic_type_size", "undefined for type string\n"); */ 00579 size = string_type_size(b); 00580 break; 00581 default: size = basic_int(b); 00582 pips_error("basic_type_size", "ill. tag %d\n", basic_tag(b)); 00583 break; 00584 } 00585 00586 return size; 00587 }


get the ultimate basic from a basic typedef
Definition at line 1254 of file type.c.
References basic_typedef, basic_typedef_p, entity_type, pips_assert, type_variable, type_variable_p, ultimate_type(), and variable_basic.
Referenced by basic_maximum(), and make_new_scalar_variable_with_prefix().
01255 { 01256 if(basic_typedef_p(b)) { 01257 type t = ultimate_type(entity_type(basic_typedef(b))); 01258 pips_assert("typedef really has a variable type", type_variable_p(t) ); 01259 b = variable_basic(type_variable(t)); 01260 } 01261 return b; 01262 }


| basic basic_union | ( | expression | exp1, | |
| expression | exp2 | |||
| ) |
basic basic_union(expression exp1 exp2): returns the basic of the expression which has the most global basic.
Then, between "int" and "float", the most global is "float".
Note: there are two different "float" : DOUBLE PRECISION and REAL.
WARNING: a new basic data structure is allocated (because you cannot always find a proper data structure to return simply a pointer
| exp1 | xp1 | |
| exp2 | xp2 |
Definition at line 1240 of file type.c.
References b, b1, b2, basic_maximum(), basic_of_expression(), and free_basic().
01241 { 01242 basic b1 = basic_of_expression(exp1); 01243 basic b2 = basic_of_expression(exp2); 01244 basic b = basic_maximum(b1, b2); 01245 01246 free_basic(b1); 01247 free_basic(b2); 01248 return b; 01249 }

Definition at line 2098 of file type.c.
References b, basic_bit_p, basic_undefined_p, FALSE, TRUE, type_undefined_p, type_variable, type_variable_p, and variable_basic.
Referenced by generic_c_words_simplified_entity(), make_standard_integer_type(), make_standard_long_integer_type(), and UpdateDerivedEntity().
02099 { 02100 if (!type_undefined_p(t) && type_variable_p(t)) 02101 { 02102 basic b = variable_basic(type_variable(t)); 02103 if (!basic_undefined_p(b) && basic_bit_p(b)) 02104 return TRUE; 02105 } 02106 return FALSE; 02107 }

returns the type necessary to generate or check a call to an object of type t.
Does not allocate a new type. Previous function could be implemented with this one.
Definition at line 2461 of file type.c.
References b, basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, call_compatible_type(), entity_type, FALSE, pips_assert, type_consistent_p(), type_functional_p, type_variable, type_variable_p, and variable_basic.
Referenced by call_compatible_type(), check_C_function_type(), words_genuine_regular_call(), and words_regular_call().
02462 { 02463 type compatible = t; 02464 02465 pips_assert("t is a consistent type", type_consistent_p(t)); 02466 02467 if(!type_functional_p(t)) { 02468 if(type_variable_p(t)) { 02469 basic b = variable_basic(type_variable(t)); 02470 02471 if(basic_pointer_p(b)) 02472 compatible = call_compatible_type(basic_pointer(b)); 02473 else if(basic_typedef_p(b)) { 02474 entity te = basic_typedef(b); 02475 02476 compatible = call_compatible_type(entity_type(te)); 02477 } 02478 else 02479 compatible = FALSE; 02480 } 02481 else 02482 compatible = FALSE; 02483 } 02484 pips_assert("compatible is a functional type", type_functional_p(compatible)); 02485 pips_assert("compatible is a consistent type", type_consistent_p(compatible)); 02486 return compatible; 02487 }


Is an object of type t compatible with a call?
Definition at line 2434 of file type.c.
References b, basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, call_compatible_type_p(), entity_type, FALSE, TRUE, type_functional_p, type_variable, type_variable_p, and variable_basic.
Referenced by call_compatible_type_p(), check_C_function_type(), and MakeFunctionExpression().
02435 { 02436 bool compatible_p = TRUE; 02437 02438 if(!type_functional_p(t)) { 02439 if(type_variable_p(t)) { 02440 basic b = variable_basic(type_variable(t)); 02441 02442 if(basic_pointer_p(b)) 02443 compatible_p = call_compatible_type_p(basic_pointer(b)); 02444 else if(basic_typedef_p(b)) { 02445 entity te = basic_typedef(b); 02446 02447 compatible_p = call_compatible_type_p(entity_type(te)); 02448 } 02449 else 02450 compatible_p = FALSE; 02451 } 02452 else 02453 compatible_p = FALSE; 02454 } 02455 return compatible_p; 02456 }


The function called can have a functional type, or a typedef type or a pointer type to a functional type.
FI: I'm not sure this is correctly implemented. I do not know if a new type is always allocated. I do not understand the semantics if ultimate is turned off.
assertion will fail anyway
must be a functional type
| ultimate_p | ltimate_p |
Definition at line 2494 of file type.c.
References basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, call_function, copy_type(), entity_type, f, free_type(), pips_assert, pips_internal_error, rt, type_functional_p, type_undefined, type_variable, type_variable_p, ultimate_type(), and variable_basic.
Referenced by MemberIdentifierToExpression(), and simplify_C_expression().
02495 { 02496 entity f = call_function(c); 02497 type ft = entity_type(f); 02498 type rt = type_undefined; 02499 02500 if(type_functional_p(ft)) 02501 rt = entity_type(f); 02502 else if(type_variable_p(ft)) { 02503 basic ftb = variable_basic(type_variable(ft)); 02504 if(basic_pointer_p(ftb)) { 02505 type pt = basic_pointer(ftb); 02506 rt = ultimate_p? ultimate_type(pt) : copy_type(pt); 02507 } 02508 else if(basic_typedef_p(ftb)) { 02509 entity te = basic_typedef(ftb); 02510 type ut = ultimate_type(entity_type(te)); 02511 02512 if(type_variable_p(ut)) { 02513 basic utb = variable_basic(type_variable(ut)); 02514 if(basic_pointer_p(utb)) { 02515 type pt = basic_pointer(utb); 02516 rt = ultimate_p? ultimate_type(pt): copy_type(pt); 02517 } 02518 else 02519 /* assertion will fail anyway */ 02520 free_type(ut); 02521 } 02522 else /* must be a functional type */ 02523 rt = ut; 02524 } 02525 else { 02526 pips_internal_error("Basic for called function unknown"); 02527 } 02528 } 02529 else 02530 pips_internal_error("Type for called function unknown"); 02531 02532 pips_assert("The typedef type is functional", type_functional_p(rt)); 02533 02534 return rt; 02535 }


b = make_basic(is_basic_overloaded, UU);
Never go there...
Definition at line 1636 of file type.c.
References basic_of_constant(), basic_of_external(), call_function, copy_basic(), e, entity_initial, entity_name, intrinsic_call_to_type(), is_type_variable, is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, make_type(), make_variable(), NIL, pips_debug, pips_internal_error, type_undefined, and value_tag.
Referenced by basic_of_intrinsic(), and expression_to_type().
01637 { 01638 entity e = call_function(c); 01639 type t = type_undefined; 01640 01641 switch (value_tag(entity_initial(e))) 01642 { 01643 case is_value_code: 01644 t = make_type(is_type_variable, 01645 make_variable(copy_basic(basic_of_external(c)), 01646 NIL, NIL)); 01647 break; 01648 case is_value_intrinsic: 01649 t = intrinsic_call_to_type(c); 01650 break; 01651 case is_value_symbolic: 01652 /* b = make_basic(is_basic_overloaded, UU); */ 01653 t = make_type(is_type_variable, 01654 make_variable(copy_basic(basic_of_constant(c)), 01655 NIL, NIL)); 01656 break; 01657 case is_value_constant: 01658 t = make_type(is_type_variable, 01659 make_variable(copy_basic(basic_of_constant(c)), 01660 NIL, NIL)); 01661 break; 01662 case is_value_unknown: 01663 pips_debug(1, "function %s has no initial value.\n" 01664 " Maybe it has not been parsed yet.\n", 01665 entity_name(e)); 01666 t = make_type(is_type_variable, 01667 make_variable(copy_basic(basic_of_external(c)), 01668 NIL, NIL)); 01669 break; 01670 default: pips_internal_error("unknown tag %d\n", t); 01671 /* Never go there... */ 01672 } 01673 01674 return t; 01675 }


see words_basic()
Definition at line 2120 of file type.c.
References b, basic_int, basic_int_p, basic_undefined_p, FALSE, i, type_undefined_p, type_variable, type_variable_p, and variable_basic.
Referenced by SizeOfArray().
02121 { 02122 bool is_char = FALSE; 02123 02124 if (!type_undefined_p(t) && type_variable_p(t)) { 02125 basic b = variable_basic(type_variable(t)); 02126 if (!basic_undefined_p(b) && basic_int_p(b)) { 02127 int i = basic_int(b); 02128 is_char = (i==1); /* see words_basic() */ 02129 } 02130 } 02131 return is_char; 02132 }

Check that an effective parameter list is compatible with a function type.
Or improve the function type when it is not precise as with "extern int f()". This is (a bit/partially) redundant with undeclared function detection since undeclared functions are declared "extern int f()".
FI: well, for debugging only...
Use parms to improve the type of f, probably declared f() with no type information.
Should be very similar to call_to_functional_type().
Must be a typedef or a pointer to a function. No need to refine the type
Take care of the void case
Take care of the varargs case
Check type compatibility: find function in flint? type_equal_p() requires lots of extensions to handle C types. And you would probably need type conversion to concrete type.
| args | rgs |
Definition at line 3225 of file type.c.
References b, c_text_entity(), call_compatible_type(), call_compatible_type_p(), CAR, CONS, DEFAULT_INTEGER_TYPE_SIZE, e, ENDP, entity_type, entity_user_name(), EXPRESSION, expression_to_user_type(), FALSE, functional_parameters, functional_result, gen_last(), gen_length(), gen_nconc(), get_current_module_entity(), ifdebug, lp, make_basic_int(), make_dummy_unknown(), make_mode_value(), make_parameter(), make_type_variable(), make_variable(), MAP, NIL, ok, PARAMETER, parameter_type, pips_assert, pips_debug, pips_user_warning, pl, print_text(), TRUE, type_functional, type_functional_p, type_unknown_p, type_varargs_p, and type_void_p.
Referenced by MakeFunctionExpression().
03226 { 03227 bool ok = TRUE; 03228 type t = entity_type(f); 03229 type ct = call_compatible_type(t); 03230 list parms = functional_parameters(type_functional(ct)); 03231 extern void print_text(FILE *, text); /* FI: well, for debugging only... */ 03232 03233 pips_assert("f can be used to generate a call", call_compatible_type_p(t)); 03234 03235 if(ENDP(parms)) { 03236 if(ENDP(args)) 03237 ; 03238 else { 03239 if(type_functional_p(t)) { 03240 /* Use parms to improve the type of f, probably declared f() 03241 with no type information. */ 03242 /* Should be very similar to call_to_functional_type(). */ 03243 list pl = NIL; 03244 MAP(EXPRESSION, e, { 03245 type et = expression_to_user_type(e); 03246 parameter p = make_parameter(et, make_mode_value(), make_dummy_unknown()); 03247 pl = gen_nconc(pl, CONS(PARAMETER, p, NIL)); 03248 }, 03249 args); 03250 functional_parameters(type_functional(t)) = pl; 03251 03252 if(type_unknown_p(functional_result(type_functional(t)))) { 03253 basic b = make_basic_int(DEFAULT_INTEGER_TYPE_SIZE); 03254 functional_result(type_functional(t)) = make_type_variable(make_variable(b, NIL, NIL)); 03255 } 03256 03257 pips_user_warning("Type updated for function \"%s\"\n", entity_user_name(f)); 03258 ifdebug(8) { 03259 text txt = c_text_entity(get_current_module_entity(), f, 0, NIL); 03260 print_text(stderr, txt); 03261 } 03262 } 03263 else { 03264 /* Must be a typedef or a pointer to a function. No need to refine the type*/ 03265 ifdebug(8) { 03266 text txt = c_text_entity(get_current_module_entity(), f, 0, NIL); 03267 pips_debug(8, "Type not updated for function \"%s\"\n", entity_user_name(f)); 03268 print_text(stderr, txt); 03269 } 03270 } 03271 } 03272 } 03273 else if(gen_length(args)!=gen_length(parms)) { 03274 /* Take care of the void case */ 03275 if(gen_length(args)==0 && gen_length(parms)==1) { 03276 parameter p = PARAMETER(CAR(parms)); 03277 type pt = parameter_type(p); 03278 ok = type_void_p(pt); 03279 } 03280 /* Take care of the varargs case*/ 03281 else if(gen_length(parms) >= 2 && gen_length(args) > gen_length(parms)) { 03282 parameter lp = PARAMETER(CAR(gen_last(parms))); 03283 type pt = parameter_type(lp); 03284 ok = type_varargs_p(pt); 03285 } 03286 else 03287 ok = FALSE; 03288 } 03289 else { 03290 /* Check type compatibility: find function in flint? 03291 type_equal_p() requires lots of extensions to handle C 03292 types. And you would probably need type conversion to concrete 03293 type.*/ 03294 ; 03295 } 03296 03297 return ok; 03298 }


| list constant_expression_supporting_entities | ( | list | sel, | |
| set | vt, | |||
| expression | e | |||
| ) |
C version.
| sel | el | |
| vt | t |
Definition at line 2728 of file type.c.
References generic_constant_expression_supporting_entities(), and TRUE.
Referenced by enum_supporting_entities(), and variable_type_supporting_entities().
02729 { 02730 return generic_constant_expression_supporting_entities(sel, vt, e, TRUE); 02731 }


| list constant_expression_supporting_references | ( | list | srl, | |
| expression | e | |||
| ) |
Only applicable to C expressions.
We need to know if we are dealing with C or Fortran code.
In C, f cannot be declared directly, we need its enum
But in Fortran, we are done
FI: suggested kludge: use a Fortran incompatible type for enum member. But currently they are four byte signed integer (c89) and this Fortran INTEGER type :-(
Could be guarded so as not to be added twice. Guard might be useless with because types are visited only once.
do nothing for the time being...
| srl | rl |
Definition at line 2973 of file type.c.
References c, call_arguments, call_function, CONS, constant_expression_supporting_references(), enum_supporting_references(), EXPRESSION, expression_syntax, f, find_enum_of_member(), fprintf(), gen_nconc(), ifdebug, MAP, NIL, pips_debug, print_references(), REFERENCE, reference_indices, s, symbolic_constant_entity_p(), syntax_call, syntax_call_p, syntax_reference, and syntax_reference_p.
Referenced by constant_expression_supporting_references(), enum_supporting_references(), symbolic_supporting_references(), and variable_type_supporting_references().
02974 { 02975 syntax s = expression_syntax(e); 02976 02977 ifdebug(9) { 02978 pips_debug(8, "Begin: "); 02979 print_references(srl); 02980 fprintf(stderr, "\n"); 02981 } 02982 02983 if(syntax_call_p(s)) { 02984 call c = syntax_call(s); 02985 entity f = call_function(c); 02986 02987 if(symbolic_constant_entity_p(f)) { 02988 /* We need to know if we are dealing with C or Fortran code. */ 02989 /* In C, f cannot be declared directly, we need its enum */ 02990 /* But in Fortran, we are done */ 02991 /* FI: suggested kludge: use a Fortran incompatible type for 02992 enum member. But currently they are four byte signed integer (c89) 02993 and this Fortran INTEGER type :-( */ 02994 02995 extern entity find_enum_of_member(entity); 02996 entity e_of_f = find_enum_of_member(f); 02997 //srl = CONS(ENTITY, e_of_f, srl); 02998 srl = enum_supporting_references(srl, e_of_f); 02999 } 03000 03001 MAP(EXPRESSION, se, { 03002 srl = constant_expression_supporting_references(srl, se); 03003 }, call_arguments(c)); 03004 } 03005 else if(syntax_reference_p(s)) { 03006 reference r = syntax_reference(s); 03007 list inds = reference_indices(r); 03008 /* Could be guarded so as not to be added twice. Guard might be 03009 useless with because types are visited only once. */ 03010 srl = gen_nconc(srl, CONS(REFERENCE, r, NIL)); 03011 MAP(EXPRESSION, se, { 03012 srl = constant_expression_supporting_references(srl, se); 03013 }, inds); 03014 } 03015 else { 03016 /* do nothing for the time being... */ 03017 ; 03018 } 03019 03020 ifdebug(9) { 03021 pips_debug(8, "End: "); 03022 print_references(srl); 03023 fprintf(stderr, "\n"); 03024 } 03025 03026 return srl; 03027 }


Returns TRUE if t is of type struct, union or enum.
Need to distinguish with the case struct/union/enum in type in RI, these are the definitions of the struct/union/enum themselve, not a variable of this type.
Example : struct foo var;
Definition at line 2186 of file type.c.
References basic_derived_p, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.
Referenced by c_convex_effects_on_formal_parameter_backward_translation(), c_text_entities(), generic_c_words_simplified_entity(), and words_sizeofexpression().
02187 { 02188 return (type_variable_p(t) && basic_derived_p(variable_basic(type_variable(t))) 02189 && (variable_dimensions(type_variable(t)) == NIL)); 02190 }

Definition at line 643 of file type.c.
References copy_expression(), dimension_lower, dimension_upper, and make_dimension().
Referenced by ldimensions_dup().
00644 { 00645 return(make_dimension(copy_expression(dimension_lower(d)), 00646 copy_expression(dimension_upper(d)))); 00647 }


same values
and same names...
| d1 | 1 | |
| d2 | 2 |
Definition at line 355 of file type.c.
References dimension_lower, dimension_upper, same_expression_name_p(), and same_expression_p().
Referenced by variable_equal_p().
00356 { 00357 return /* same values */ 00358 same_expression_p(dimension_lower(d1), dimension_lower(d2)) && 00359 same_expression_p(dimension_upper(d1), dimension_upper(d2)) && 00360 /* and same names... */ 00361 same_expression_name_p(dimension_lower(d1), dimension_lower(d2)) && 00362 same_expression_name_p(dimension_upper(d1), dimension_upper(d2)); 00363 }


| int effect_basic_depth | ( | basic | b | ) |
Definition at line 3420 of file type.c.
References basic_derived, basic_pointer, basic_tag, basic_typedef, e, effect_type_depth(), entity_type, is_basic_bit, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, pips_internal_error, and type_depth().
Referenced by effect_type_depth().
03421 { 03422 int d = 0; 03423 03424 switch(basic_tag(b)) { 03425 case is_basic_int: 03426 case is_basic_float: 03427 case is_basic_logical: 03428 case is_basic_overloaded: 03429 case is_basic_complex: 03430 case is_basic_string: 03431 case is_basic_bit: 03432 break; 03433 case is_basic_pointer: 03434 { 03435 d = effect_type_depth(basic_pointer(b))+1; 03436 break; 03437 } 03438 case is_basic_derived: 03439 { 03440 entity e = basic_derived(b); 03441 type t = entity_type(e); 03442 d = type_depth(t); 03443 break; 03444 } 03445 case is_basic_typedef: 03446 { 03447 entity e = basic_typedef(b); 03448 type t = entity_type(e); 03449 03450 d = type_depth(t); 03451 break; 03452 } 03453 default: 03454 pips_internal_error("Unexpected basic tag %d\n", basic_tag(b)); 03455 } 03456 03457 return d; 03458 }


| int effect_type_depth | ( | type | t | ) |
Number of steps to access the lowest leave of type t.
Number of dimensions for an array. One for a struct or an union field, plus its dimension. The difference with type_depth is that it does not stop recursing when encountering a pointer, and that a pointer is considered as having dimension 1. (BC)
Definition at line 3383 of file type.c.
References e, effect_basic_depth(), ENTITY, entity_type, gen_length(), i, MAP, type_depth(), type_enum_p, type_struct, type_struct_p, type_union, type_union_p, type_varargs_p, type_variable, type_variable_p, type_void_p, v, variable_basic, and variable_dimensions.
Referenced by c_actual_argument_to_may_summary_effects(), effect_basic_depth(), generic_effect_generate_all_accessible_paths_effects(), and make_reference_region().
03384 { 03385 int d = 0; 03386 03387 if(type_variable_p(t)) { 03388 variable v = type_variable(t); 03389 03390 d = gen_length(variable_dimensions(v))+effect_basic_depth(variable_basic(v)); 03391 } 03392 else if(type_void_p(t)) 03393 d = 0; 03394 else if(type_varargs_p(t)) 03395 d = 0; 03396 else if(type_struct_p(t)) { 03397 list fl = type_struct(t); 03398 d = 0; 03399 MAP(ENTITY, e, { 03400 int i = type_depth(entity_type(e)); 03401 d = d>i?d:i; 03402 }, fl); 03403 d++; 03404 } 03405 else if(type_union_p(t)) { 03406 list fl = type_union(t); 03407 d = 0; 03408 MAP(ENTITY, e, { 03409 int i = type_depth(entity_type(e)); 03410 d = d>i?d:i; 03411 }, fl); 03412 d++; 03413 } 03414 else if(type_enum_p(t)) 03415 d = 0; 03416 03417 return d; 03418 }


| sel | el | |
| vt | t |
Definition at line 2629 of file type.c.
References CAR, constant_expression_supporting_entities(), ENDP, ENTITY, entity_initial, entity_type, fprintf(), ifdebug, list_undefined, pips_assert, pips_debug, POP, print_entities(), s, symbolic_expression, type_enum, type_enum_p, v, value_symbolic, and value_symbolic_p.
Referenced by generic_constant_expression_supporting_entities().
02630 { 02631 type t = entity_type(e); 02632 list ml = type_enum(t); 02633 list cm = list_undefined; 02634 02635 pips_assert("type is of enum kind", type_enum_p(t)); 02636 02637 ifdebug(8) { 02638 pips_debug(8, "Begin: "); 02639 print_entities(sel); 02640 fprintf(stderr, "\n\n"); 02641 } 02642 02643 for(cm = ml; !ENDP(cm); POP(cm)) { 02644 entity m = ENTITY(CAR(cm)); 02645 value v = entity_initial(m); 02646 symbolic s = value_symbolic(v); 02647 02648 pips_assert("m is an enum member", value_symbolic_p(v)); 02649 02650 sel = constant_expression_supporting_entities(sel, vt, symbolic_expression(s)); 02651 } 02652 02653 ifdebug(8) { 02654 pips_debug(8, "End: "); 02655 print_entities(sel); 02656 fprintf(stderr, "\n\n"); 02657 } 02658 02659 return sel; 02660 }


| srl | rl |
Definition at line 2939 of file type.c.
References CAR, constant_expression_supporting_references(), ENDP, ENTITY, entity_initial, entity_type, fprintf(), ifdebug, list_undefined, pips_assert, pips_debug, POP, print_references(), s, symbolic_expression, type_enum, type_enum_p, v, value_symbolic, and value_symbolic_p.
Referenced by constant_expression_supporting_references().
02940 { 02941 type t = entity_type(e); 02942 list ml = type_enum(t); 02943 list cm = list_undefined; 02944 02945 pips_assert("type is of enum kind", type_enum_p(t)); 02946 02947 ifdebug(9) { 02948 pips_debug(8, "Begin: "); 02949 print_references(srl); 02950 fprintf(stderr, "\n"); 02951 } 02952 02953 for(cm = ml; !ENDP(cm); POP(cm)) { 02954 entity m = ENTITY(CAR(cm)); 02955 value v = entity_initial(m); 02956 symbolic s = value_symbolic(v); 02957 02958 pips_assert("m is an enum member", value_symbolic_p(v)); 02959 02960 srl = constant_expression_supporting_references(srl, symbolic_expression(s)); 02961 } 02962 02963 ifdebug(9) { 02964 pips_debug(8, "End: "); 02965 print_references(srl); 02966 fprintf(stderr, "\n"); 02967 } 02968 02969 return srl; 02970 }


| basic expression_basic | ( | expression | expr | ) |
should be int
How to void a memory leak? Where can we find a basic int? A static variable?
| expr | xpr |
Definition at line 599 of file type.c.
References b, basic_undefined, c, call_function, cast_type, entity_basic(), expression_basic(), expression_syntax, is_basic_int, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, make_basic(), pips_assert, pips_internal_error, range_lower, reference_variable, syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_tag, type_variable, type_variable_p, ultimate_type(), and variable_basic.
Referenced by can_terapixify_expression_p(), change_basic_if_needed(), expression_basic(), prepare_expansion(), suggest_basic_for_expression(), and words_nullary_op_c().
00600 { 00601 syntax the_syntax=expression_syntax(expr); 00602 basic b = basic_undefined; 00603 00604 switch(syntax_tag(the_syntax)) 00605 { 00606 case is_syntax_reference: 00607 b = entity_basic(reference_variable(syntax_reference(the_syntax))); 00608 break; 00609 case is_syntax_range: 00610 /* should be int */ 00611 b = expression_basic(range_lower(syntax_range(the_syntax))); 00612 break; 00613 case is_syntax_call: 00614 /* 00615 * here is a little problem with pips... every intrinsics are 00616 * overloaded, what is not exactly what is desired... 00617 */ 00618 return(entity_basic(call_function(syntax_call(the_syntax)))); 00619 break; 00620 case is_syntax_cast: 00621 { 00622 cast c = syntax_cast(the_syntax); 00623 type t = cast_type(c); 00624 type ut = ultimate_type(t); 00625 b = variable_basic(type_variable(ut)); 00626 pips_assert("Type is \"variable\"", type_variable_p(ut)); 00627 break; 00628 } 00629 case is_syntax_sizeofexpression: 00630 { 00631 /* How to void a memory leak? Where can we find a basic int? A static variable? */ 00632 b = make_basic(is_basic_int, (void *) 4); 00633 break; 00634 } 00635 default: 00636 pips_internal_error("unexpected syntax tag\n"); 00637 break; 00638 } 00639 00640 return b; 00641 }


| type expression_to_type | ( | expression | exp | ) |
For an array declared as int a[10][20], the type returned for a[i] is int [20].
| exp | is an expression |
does not cover references to functions ...
Could be more elaborated with array types for array expressions
Well, let's assume range are well formed...
current type
current basic
current dimensions
Warning : qualifiers are set to NIL, because I do not see the need for something else for the moment. BC.
Never go there...
| exp | xp |
Definition at line 1759 of file type.c.
References application_function, basic_pointer, basic_pointer_p, call_to_type(), CAR, cast_type, CDR, copy_basic(), copy_type(), DEFAULT_POINTER_TYPE_SIZE, ENDP, expression_syntax, expression_to_type(), fprintf(), gen_full_copy_list(), ifdebug, is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, is_type_variable, make_basic_int(), make_type(), make_type_variable(), make_variable(), NIL, pips_assert, pips_debug, pips_internal_error, POP, print_expression(), range_lower, reference_to_type(), SIZEOFEXPRESSION, sizeofexpression_type, subscript_array, subscript_indices, syntax_application, syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_subscript, syntax_tag, syntax_va_arg, type_tag, type_undefined, type_variable, type_variable_p, type_void_p, variable_basic, variable_dimensions, words_to_string(), and words_type().
Referenced by any_user_call_site_to_transformer(), c_actual_argument_to_may_summary_effects(), c_convex_effects_on_formal_parameter_backward_translation(), c_simple_effects_on_formal_parameter_backward_translation(), c_summary_effect_to_proper_effects(), EvalSizeofexpression(), expression_to_transformer(), expression_to_type(), expression_to_uncasted_type(), generic_proper_effects_of_address_expression(), generic_proper_effects_of_complex_address_expression(), integer_expression_and_precondition_to_integer_interval(), and intrinsic_call_to_type().
01760 { 01761 /* does not cover references to functions ...*/ 01762 /* Could be more elaborated with array types for array expressions */ 01763 type t = type_undefined; 01764 01765 syntax s_exp = expression_syntax(exp); 01766 01767 ifdebug(6){ 01768 pips_debug(6, "begins with expression :"); 01769 print_expression(exp); 01770 fprintf(stderr, "\n"); 01771 } 01772 01773 switch(syntax_tag(s_exp)) 01774 { 01775 case is_syntax_reference: 01776 { 01777 pips_debug(6, "reference case \n"); 01778 t = reference_to_type(syntax_reference(s_exp)); 01779 break; 01780 } 01781 case is_syntax_call: 01782 { 01783 pips_debug(6, "call case \n"); 01784 t = call_to_type(syntax_call(s_exp)); 01785 break; 01786 } 01787 case is_syntax_range: 01788 { 01789 pips_debug(6, "range case \n"); 01790 /* Well, let's assume range are well formed... */ 01791 t = expression_to_type(range_lower(syntax_range(s_exp))); 01792 break; 01793 } 01794 case is_syntax_cast: 01795 { 01796 pips_debug(6, "cast case \n"); 01797 t = copy_type(cast_type(syntax_cast(s_exp))); 01798 if (!type_void_p(t) && type_tag(t) != is_type_variable) 01799 pips_internal_error("Bad reference type tag %d\n",type_tag(t)); 01800 break; 01801 } 01802 case is_syntax_sizeofexpression: 01803 { 01804 /* 01805 sizeofexpression se = syntax_sizeofexpression(s_exp); 01806 pips_debug(6, "size of case \n"); 01807 if (sizeofexpression_type_p(se)) 01808 { 01809 t = copy_type(sizeofexpression_type(se)); 01810 if (type_tag(t) != is_type_variable) 01811 pips_internal_error("Bad reference type tag %d\n",type_tag(t)); 01812 } 01813 else 01814 { 01815 t = expression_to_type(sizeofexpression_expression(se)); 01816 }*/ 01817 t = make_type_variable(make_variable(make_basic_int(DEFAULT_POINTER_TYPE_SIZE),NIL,NIL)); 01818 break; 01819 } 01820 case is_syntax_subscript: 01821 { 01822 /* current type */ 01823 type ct = expression_to_type(subscript_array(syntax_subscript(s_exp))); 01824 /* current basic */ 01825 basic cb = variable_basic(type_variable(ct)); 01826 /* current dimensions */ 01827 list cd = variable_dimensions(type_variable(ct)); 01828 list l_inds = subscript_indices(syntax_subscript(s_exp)); 01829 01830 pips_debug(6, "subscript case \n"); 01831 01832 while (!ENDP(l_inds)) 01833 { 01834 if(!ENDP(cd)) 01835 { 01836 POP(cd); 01837 } 01838 else 01839 { 01840 pips_assert("reference has too many indices : pointer expected\n", basic_pointer_p(cb)); 01841 ct= basic_pointer(cb); 01842 if( type_variable_p(ct) ) { 01843 cb = variable_basic(type_variable(ct)); 01844 cd = variable_dimensions(type_variable(ct)); 01845 } 01846 else { 01847 pips_internal_error("unhandled case\n"); 01848 } 01849 } 01850 POP(l_inds); 01851 } 01852 01853 /* Warning : qualifiers are set to NIL, because I do not see 01854 the need for something else for the moment. BC. 01855 */ 01856 t = make_type(is_type_variable, 01857 make_variable(copy_basic(cb), 01858 gen_full_copy_list(cd), 01859 NIL)); 01860 break; 01861 } 01862 case is_syntax_application: 01863 { 01864 pips_debug(6, "application case \n"); 01865 t = expression_to_type(application_function(syntax_application(s_exp))); 01866 break; 01867 } 01868 case is_syntax_va_arg: 01869 { 01870 pips_debug(6, "va_arg case\n"); 01871 list vararg_list = syntax_va_arg(s_exp); 01872 sizeofexpression soe = SIZEOFEXPRESSION(CAR(CDR(vararg_list))); 01873 01874 t = copy_type(sizeofexpression_type(soe)); 01875 break; 01876 } 01877 01878 default: 01879 pips_internal_error("Bad syntax tag %d\n", syntax_tag(s_exp)); 01880 /* Never go there... */ 01881 } 01882 01883 pips_debug(6, "returns with %s\n", words_to_string(words_type(t, NIL))); 01884 01885 return t; 01886 }


| type expression_to_uncasted_type | ( | expression | exp | ) |
If the expression is casted, return its type before cast.
| exp | xp |
Definition at line 1889 of file type.c.
References cast_expression, expression_syntax, expression_to_type(), expression_to_uncasted_type(), ifdebug, pips_debug, print_expression(), syntax_cast, syntax_cast_p, and type_undefined.
Referenced by expression_to_uncasted_type().
01890 { 01891 type t = type_undefined; 01892 syntax s_exp = expression_syntax(exp); 01893 01894 ifdebug(6){ 01895 pips_debug(6, "begins with expression :"); 01896 print_expression(exp); 01897 pips_debug(6, "\n"); 01898 } 01899 01900 if(syntax_cast_p(s_exp)) { 01901 expression sub_exp = cast_expression(syntax_cast(s_exp)); 01902 01903 t = expression_to_uncasted_type(sub_exp); 01904 } 01905 else { 01906 t = expression_to_type(exp); 01907 } 01908 01909 return t; 01910 }


| type expression_to_user_type | ( | expression | e | ) |
Preserve typedef'ed types when possible.
does not cover references to functions ...
Could be more elaborated with array types for array expressions
Definition at line 1913 of file type.c.
References b, FALSE, is_type_variable, make_type(), make_variable(), NIL, some_basic_of_any_expression(), type_undefined, and v.
Referenced by callnodeclfilter(), and check_C_function_type().
01914 { 01915 /* does not cover references to functions ...*/ 01916 /* Could be more elaborated with array types for array expressions */ 01917 type t = type_undefined; 01918 basic b = some_basic_of_any_expression(e, FALSE, FALSE); 01919 variable v = make_variable(b, NIL, NIL); 01920 01921 t = make_type(is_type_variable, v); 01922 01923 return t; 01924 }


Definition at line 663 of file type.c.
References CAR, CDR, DIMENSION, entity_type, NULL, pips_error(), pips_internal_error, type_variable, type_variable_p, and variable_dimensions.
Referenced by array_ranges_to_template_ranges(), complementary_range(), compute_receive_content(), create_init_common_param_for_arrays(), create_parameters_h(), expr_compute_local_index(), generate_one_message(), make_guard_expression(), processor_number(), same_alignment_p(), template_cell_local_mapping(), and template_ranges_to_processors_ranges().
00664 { 00665 cons * pc; 00666 00667 if (!type_variable_p(entity_type(e))) 00668 pips_error("FindIthDimension", "not a variable\n"); 00669 00670 if (i <= 0) 00671 pips_error("FindIthDimension", "invalid dimension\n"); 00672 00673 pc = variable_dimensions(type_variable(entity_type(e))); 00674 00675 while (pc != NULL && --i > 0) 00676 pc = CDR(pc); 00677 00678 if (pc == NULL) 00679 pips_internal_error("not enough dimensions\n"); 00680 00681 return(DIMENSION(CAR(pc))); 00682 }


| list fortran_constant_expression_supporting_entities | ( | list | sel, | |
| expression | e | |||
| ) |
Fortran version.
| sel | el |
Definition at line 2734 of file type.c.
References FALSE, generic_constant_expression_supporting_entities(), hash_pointer, set_free(), and set_make().
Referenced by fortran_type_supporting_entities().
02735 { 02736 set vt = set_make(hash_pointer); 02737 02738 sel = generic_constant_expression_supporting_entities(sel, vt, e, FALSE); 02739 02740 set_free(vt); 02741 02742 return sel; 02743 }


In Fortran, dependencies are due to the dimension expressions.
| srl | rl |
Definition at line 3106 of file type.c.
References DIMENSION, dimension_lower, dimension_upper, FOREACH, fortran_constant_expression_supporting_entities(), fprintf(), ifdebug, pips_debug, pips_internal_error, print_references(), type_functional_p, type_tag, type_variable, type_variable_p, type_void_p, v, and variable_dimensions.
Referenced by check_fortran_declaration_dependencies().
03107 { 03108 ifdebug(9) { 03109 pips_debug(8, "Begin: "); 03110 print_references(srl); 03111 fprintf(stderr, "\n"); 03112 } 03113 03114 if(type_functional_p(t)) 03115 ; 03116 else if(type_variable_p(t)) { 03117 /* In Fortran, dependencies are due to the dimension expressions.*/ 03118 variable v = type_variable(t); 03119 list dims = variable_dimensions(v); 03120 03121 FOREACH(DIMENSION, d, dims) { 03122 expression l = dimension_lower(d); 03123 expression u = dimension_upper(d); 03124 srl = fortran_constant_expression_supporting_entities(srl, l); 03125 srl = fortran_constant_expression_supporting_entities(srl, u); 03126 } 03127 } 03128 else if(type_void_p(t)) 03129 ; 03130 else 03131 pips_internal_error("Unexpected Fortran type with tag %d\n", type_tag(t)); 03132 03133 ifdebug(9) { 03134 pips_debug(8, "End: "); 03135 print_references(srl); 03136 fprintf(stderr, "\n"); 03137 } 03138 03139 return srl; 03140 }


| bool functional_equal_p | ( | functional | f1, | |
| functional | f2 | |||
| ) |
| f1 | 1 | |
| f2 | 2 |
Definition at line 482 of file type.c.
References CAR, ENDP, FALSE, functional_parameters, functional_result, functional_undefined, gen_length(), PARAMETER, parameter_equal_p(), POP, TRUE, and type_equal_p().
Referenced by type_equal_p().
00483 { 00484 if(f1 == f2) 00485 return TRUE; 00486 else if (f1 == functional_undefined && f2 != functional_undefined) 00487 return FALSE; 00488 else if (f1 != functional_undefined && f2 == functional_undefined) 00489 return FALSE; 00490 else { 00491 list lp1 = functional_parameters(f1); 00492 list lp2 = functional_parameters(f2); 00493 00494 if(gen_length(lp1) != gen_length(lp2)) 00495 return FALSE; 00496 00497 for( ; !ENDP(lp1); POP(lp1), POP(lp2)) { 00498 parameter p1 = PARAMETER(CAR(lp1)); 00499 parameter p2 = PARAMETER(CAR(lp2)); 00500 00501 if(!parameter_equal_p(p1, p2)) 00502 return FALSE; 00503 } 00504 00505 return type_equal_p(functional_result(f1), functional_result(f2)); 00506 } 00507 }


| list functional_type_supporting_entities | ( | list | sel, | |
| functional | f | |||
| ) |
| sel | el |
Definition at line 2618 of file type.c.
References hash_pointer, recursive_functional_type_supporting_entities(), set_free(), and set_make().
Referenced by compilation_unit_text().
02619 { 02620 set vt = set_make(hash_pointer); 02621 02622 sel = recursive_functional_type_supporting_entities(sel, vt, f); 02623 02624 set_free(vt); 02625 02626 return sel; 02627 }


| list functional_type_supporting_references | ( | list | srl, | |
| functional | f | |||
| ) |
| srl | rl |
Definition at line 2916 of file type.c.
References fprintf(), functional_parameters, functional_result, ifdebug, MAP, PARAMETER, parameter_type, pips_debug, print_references(), and recursive_type_supporting_references().
Referenced by recursive_type_supporting_references().
02917 { 02918 ifdebug(9) { 02919 pips_debug(8, "Begin: "); 02920 print_references(srl); 02921 fprintf(stderr, "\n"); 02922 } 02923 02924 MAP(PARAMETER, p, 02925 srl = recursive_type_supporting_references(srl, parameter_type(p)), 02926 functional_parameters(f)); 02927 02928 srl = recursive_type_supporting_references(srl, functional_result(f)); 02929 02930 ifdebug(9) { 02931 pips_debug(8, "End: "); 02932 print_references(srl); 02933 fprintf(stderr, "\n"); 02934 } 02935 02936 return srl; 02937 }


| list functional_type_supporting_types | ( | functional | f | ) |
FI: I'm not sure this function is of any use.
Definition at line 3516 of file type.c.
References hash_pointer, NIL, recursive_functional_type_supporting_types(), set_free(), and set_make().
03517 { 03518 set vt = set_make(hash_pointer); 03519 list stl = NIL; 03520 03521 stl = recursive_functional_type_supporting_types(stl, vt, f); 03522 03523 set_free(vt); 03524 03525 return stl; 03526 }

| list generic_constant_expression_supporting_entities | ( | list | sel, | |
| set | vt, | |||
| expression | e, | |||
| bool | language_c_p | |||
| ) |
In C, f cannot be declared directly, we need its enum
In Fortran, symbolic constant are declared directly, but the may depend on other symbolic constants
Could be guarded so as not to be added twice. Guard might be useless with because types are visited only once.
do nothing
| sel | el | |
| vt | t | |
| language_c_p | anguage_c_p |
Definition at line 2662 of file type.c.
References c, call_arguments, call_function, CONS, ENTITY, entity_initial, enum_supporting_entities(), EXPRESSION, expression_syntax, f, find_enum_of_member(), fprintf(), gen_nconc(), generic_constant_expression_supporting_entities(), generic_symbolic_supporting_entities(), ifdebug, MAP, NIL, pips_debug, print_entities(), reference_indices, reference_variable, s, symbolic_constant_entity_p(), syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, v, and value_symbolic.
Referenced by constant_expression_supporting_entities(), fortran_constant_expression_supporting_entities(), generic_constant_expression_supporting_entities(), and generic_symbolic_supporting_entities().
02663 { 02664 syntax s = expression_syntax(e); 02665 02666 ifdebug(8) { 02667 pips_debug(8, "Begin: "); 02668 print_entities(sel); 02669 fprintf(stderr, "\n\n"); 02670 } 02671 02672 if(syntax_call_p(s)) { 02673 call c = syntax_call(s); 02674 entity f = call_function(c); 02675 02676 if(symbolic_constant_entity_p(f)) { 02677 if(language_c_p) { 02678 /* In C, f cannot be declared directly, we need its enum */ 02679 extern entity find_enum_of_member(entity); 02680 entity e_of_f = find_enum_of_member(f); 02681 //sel = CONS(ENTITY, e_of_f, sel); 02682 sel = enum_supporting_entities(sel, vt, e_of_f); 02683 sel = gen_nconc(sel, CONS(ENTITY, e_of_f, NIL)); 02684 } 02685 else { 02686 /* In Fortran, symbolic constant are declared directly, but 02687 the may depend on other symbolic constants */ 02688 value v = entity_initial(f); 02689 symbolic s = value_symbolic(v); 02690 02691 //sel = CONS(ENTITY, f, sel); 02692 sel = generic_symbolic_supporting_entities(sel, vt, s, language_c_p); 02693 sel = gen_nconc(sel, CONS(ENTITY, f, NIL)); 02694 } 02695 } 02696 02697 MAP(EXPRESSION, se, { 02698 sel = generic_constant_expression_supporting_entities(sel, vt, se, language_c_p); 02699 }, call_arguments(c)); 02700 } 02701 else if(syntax_reference_p(s)) { 02702 reference r = syntax_reference(s); 02703 entity v = reference_variable(r); 02704 list inds = reference_indices(r); 02705 /* Could be guarded so as not to be added twice. Guard might be 02706 useless with because types are visited only once. */ 02707 //sel = gen_nconc(sel, CONS(ENTITY, v, NIL)); 02708 MAP(EXPRESSION, se, { 02709 sel = generic_constant_expression_supporting_entities(sel, vt, se, language_c_p); 02710 }, inds); 02711 sel = gen_nconc(sel, CONS(ENTITY, v, NIL)); 02712 } 02713 else { 02714 /* do nothing */ 02715 ; 02716 } 02717 02718 ifdebug(8) { 02719 pips_debug(8, "End: "); 02720 print_entities(sel); 02721 fprintf(stderr, "\n\n"); 02722 } 02723 02724 return sel; 02725 }


| sel | el | |
| vt | t | |
| language_c_p | anguage_c_p |
Definition at line 2745 of file type.c.
References e, generic_constant_expression_supporting_entities(), and symbolic_expression.
Referenced by generic_constant_expression_supporting_entities(), and symbolic_supporting_entities().
02746 { 02747 expression e = symbolic_expression(s); 02748 sel = generic_constant_expression_supporting_entities(sel, vt, e, language_c_p); 02749 return sel; 02750 }


END_EOLE.
This type must be computed with the basic of the arguments of the intrinsic for overloaded operators. It should be able to accomodate more than two arguments as for generic min and max operators.
the result
I don't know the type since there is no arguments ! Bug encountered with a FMT=* in a PRINT. RK, 21/02/1994 :
leave it overloaded
We should reconstruct a struct type or an array type...
returns the type of the left hand side
The value returned is the value of the last expression in the list.
let us assume that the two last arguments have the same type : basic_maximum does not preserve types enough (see Effects/lhs01.c, expression *(i>2?&i:&j) ). BC.
re-use an existing function. we do not take into account variable dimensions here. It may not be correct. but it's not worse than the previously existing version of expression_to_type
Definition at line 1484 of file type.c.
References b, basic_maximum(), basic_overloaded_p, basic_pointer, basic_pointer_p, basic_string_p, call_arguments, call_function, CAR, cons::cdr, CDR, copy_type(), DEFAULT_CHARACTER_TYPE_SIZE, e, ENDP, ENTITY_ADDRESS_OF_P, ENTITY_ASSIGN_P, ENTITY_BRACE_INTRINSIC_P, ENTITY_COMMA_P, ENTITY_CONDITIONAL_P, ENTITY_DEREFERENCING_P, ENTITY_FIELD_P, ENTITY_POINT_TO_P, entity_type, EXPRESSION, expression_to_type(), f, free_type(), functional_result, gen_full_free_list(), gen_last(), gen_length(), ifdebug, is_basic_pointer, is_type_variable, make_basic(), make_basic_int(), make_basic_overloaded(), make_type(), make_type_variable(), make_variable(), MAP, module_local_name(), NIL, pips_assert, pips_debug, pips_internal_error, print_expression(), rt, type_consistent_p(), type_functional, type_undefined, type_variable, type_variable_p, ultimate_type(), variable_basic, variable_dimensions, words_to_string(), and words_type().
Referenced by call_to_type().
01485 { 01486 01487 entity f = call_function(c); 01488 list args = call_arguments(c); 01489 01490 type rt = functional_result(type_functional(entity_type(f))); 01491 basic rb = variable_basic(type_variable(rt)); 01492 01493 type t = type_undefined; /* the result */ 01494 01495 pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a priori result type \"%s\"\n", 01496 module_local_name(f), 01497 words_to_string(words_type(rt, NIL))); 01498 01499 if(basic_overloaded_p(rb)) 01500 { 01501 01502 if (ENDP(args)) 01503 { 01504 /* I don't know the type since there is no arguments ! 01505 Bug encountered with a FMT=* in a PRINT. 01506 RK, 21/02/1994 : */ 01507 /* leave it overloaded */ 01508 t = copy_type(rt); 01509 } 01510 else if(ENTITY_ADDRESS_OF_P(f)) 01511 { 01512 expression e = EXPRESSION(CAR(args)); 01513 t = expression_to_type(e); 01514 t = make_type(is_type_variable, 01515 make_variable( make_basic(is_basic_pointer,t), 01516 NIL, NIL )); 01517 01518 } 01519 else if(ENTITY_DEREFERENCING_P(f)) 01520 { 01521 expression e = EXPRESSION(CAR(args)); 01522 type ct = expression_to_type(e); 01523 01524 if (type_variable_p(ct)) 01525 { 01526 variable cv = type_variable(ct); 01527 basic cb = variable_basic(cv); 01528 list cd = variable_dimensions(cv); 01529 01530 if(basic_pointer_p(cb)) 01531 { 01532 t = copy_type(ultimate_type(basic_pointer(cb))); 01533 pips_assert("The pointed type is consistent", 01534 type_consistent_p(t)); 01535 free_type(ct); 01536 } 01537 else if(basic_string_p(cb)) 01538 { 01539 t = make_type_variable(make_variable(make_basic_int(DEFAULT_CHARACTER_TYPE_SIZE), NIL, NIL)); 01540 } 01541 else 01542 { 01543 pips_assert("Dereferencing of a non-pointer expression : it must be an array\n", !ENDP(cd)); 01544 01545 variable_dimensions(cv) = CDR(cd); 01546 cd->cdr = NIL; 01547 gen_full_free_list(cd); 01548 t = ct; 01549 } 01550 } 01551 else 01552 { 01553 pips_internal_error("dereferencing of a non-variable : not handled yet\n"); 01554 } 01555 } 01556 else if(ENTITY_POINT_TO_P(f) || ENTITY_FIELD_P(f)) 01557 { 01558 expression e1 = EXPRESSION(CAR(args)); 01559 expression e2 = EXPRESSION(CAR(CDR(args))); 01560 01561 pips_assert("Two arguments for POINT_TO or FIELD \n", 01562 gen_length(args)==2); 01563 01564 ifdebug(8) 01565 { 01566 pips_debug(8, "Point to case, e1 = "); 01567 print_expression(e1); 01568 pips_debug(8, " and e2 = "); 01569 print_expression(e2); 01570 pips_debug(8, "\n"); 01571 } 01572 t = expression_to_type(e2); 01573 } 01574 else if(ENTITY_BRACE_INTRINSIC_P(f)) 01575 { 01576 /* We should reconstruct a struct type or an array type... */ 01577 t = make_type(is_type_variable, make_variable(make_basic_overloaded(), 01578 NIL,NIL)); 01579 } 01580 else if(ENTITY_ASSIGN_P(f)) 01581 { 01582 /* returns the type of the left hand side */ 01583 t = expression_to_type(EXPRESSION(CAR(args))); 01584 } 01585 else if(ENTITY_COMMA_P(f)) 01586 { 01587 /* The value returned is the value of the last expression in the list. */ 01588 01589 t = expression_to_type(EXPRESSION(CAR(gen_last(args)))); 01590 } 01591 else if( ENTITY_CONDITIONAL_P(f)) 01592 { 01593 /* let us assume that the two last arguments have the same 01594 type : basic_maximum does not preserve types enough 01595 (see Effects/lhs01.c, expression *(i>2?&i:&j) ). BC. 01596 */ 01597 t = expression_to_type(EXPRESSION(CAR(CDR(args)))); 01598 } 01599 else 01600 { 01601 01602 type ct = expression_to_type(EXPRESSION(CAR(args))); 01603 01604 MAP(EXPRESSION, arg, { 01605 type nt = expression_to_type(arg); 01606 basic nb = variable_basic(type_variable(nt)); 01607 basic cb = variable_basic(type_variable(ct)); 01608 01609 /* re-use an existing function. we do not take into 01610 account variable dimensions here. It may not be correct. 01611 but it's not worse than the previously existing version 01612 of expression_to_type 01613 */ 01614 basic b = basic_maximum(cb, nb); 01615 01616 free_type(ct); 01617 free_type(nt); 01618 ct = make_type(is_type_variable, make_variable(b, NIL, NIL)); 01619 01620 }, CDR(args)); 01621 t = ct; 01622 } 01623 } 01624 else { 01625 t = copy_type(rt); 01626 } 01627 01628 pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a posteriori result type \"%s\"\n", 01629 module_local_name(f), 01630 words_to_string(words_type(t, NIL))); 01631 01632 return t; 01633 }


bool is_inferior_basic(basic1, basic2) return TRUE if basic1 is less complex than basic2 ex: int is less complex than float*4, float*4 is less complex than float*8, .
..
| b1 | 1 | |
| b2 | 2 |
Definition at line 1953 of file type.c.
References basic_complex, basic_complex_p, basic_float, basic_float_p, basic_int, basic_int_p, basic_logical_p, basic_overloaded_p, basic_string_p, basic_undefined, FALSE, pips_error(), and TRUE.
Referenced by arguments_to_complexity(), basic_union_arguments(), indices_to_complexity(), intrinsic_cost(), and typing_power_operator().
01955 { 01956 if ( b1 == basic_undefined ) 01957 pips_error("is_inferior_basic", "first basic_undefined\n"); 01958 else if ( b2 == basic_undefined ) 01959 pips_error("is_inferior_basic", "second basic_undefined\n"); 01960 01961 if (basic_overloaded_p(b1)) 01962 return (TRUE); 01963 else if (basic_overloaded_p(b2)) 01964 return (FALSE); 01965 else if (basic_logical_p(b1)) 01966 return (TRUE); 01967 else if (basic_logical_p(b2)) 01968 return (FALSE); 01969 else if (basic_string_p(b1)) 01970 return (TRUE); 01971 else if (basic_string_p(b2)) 01972 return (FALSE); 01973 else if (basic_int_p(b1)) { 01974 if (basic_int_p(b2)) 01975 return (basic_int(b1) <= basic_int(b2)); 01976 else 01977 return (TRUE); 01978 } 01979 else if (basic_float_p(b1)) { 01980 if (basic_int_p(b2)) 01981 return (FALSE); 01982 else if (basic_float_p(b2)) 01983 return (basic_float(b1) <= basic_float(b2)); 01984 else 01985 return (TRUE); 01986 } 01987 else if (basic_complex_p(b1)) { 01988 if (basic_int_p(b2) || basic_float_p(b2)) 01989 return (FALSE); 01990 else if (basic_complex_p(b2)) 01991 return (basic_complex(b1) <= basic_complex(b2)); 01992 else 01993 return (TRUE); 01994 } 01995 else 01996 pips_error("is_inferior_basic", "Case never occurs.\n"); 01997 return (TRUE); 01998 }


Definition at line 649 of file type.c.
References CAR, CONS, DIMENSION, dimension_dup(), gen_nreverse(), MAPL, and NIL.
Referenced by type_variable_dup().
00650 { 00651 list result = NIL ; 00652 00653 MAPL(cd, 00654 { 00655 result = CONS(DIMENSION, dimension_dup(DIMENSION(CAR(cd))), 00656 result); 00657 }, 00658 l); 00659 00660 return(gen_nreverse(result)); 00661 }


Definition at line 2086 of file type.c.
References b, basic_int, basic_int_p, DEFAULT_LONG_INTEGER_TYPE_SIZE, FALSE, TRUE, type_variable, type_variable_p, and variable_basic.
Referenced by make_standard_long_integer_type().
02087 { 02088 if (type_variable_p(t)) 02089 { 02090 basic b = variable_basic(type_variable(t)); 02091 if (basic_int_p(b)) 02092 if (basic_int(b) == DEFAULT_LONG_INTEGER_TYPE_SIZE) 02093 return TRUE; 02094 } 02095 return FALSE; 02096 }

| type make_char_array_type | ( | int | n | ) |
Two options: a string of n characters or an array of n char, i.e. int.
Definition at line 3670 of file type.c.
References b, c, make_basic_string(), make_constant_int(), make_type_variable(), make_value_constant(), make_variable(), and NIL.
Referenced by init_c_implicit_variables().
03671 { 03672 /* Two options: a string of n characters or an array of n char, 03673 i.e. int. */ 03674 constant c = make_constant_int(n); 03675 value val = make_value_constant(c); 03676 basic b = make_basic_string(val); 03677 variable var = make_variable(b, NIL, NIL); 03678 type t = make_type_variable(var); 03679 03680 return t; 03681 }


| type make_scalar_complex_type | ( | _int | n | ) |
Definition at line 334 of file type.c.
References is_basic_complex, is_type_variable, make_basic(), make_type(), make_variable(), NIL, and UUINT.
00335 { 00336 type t = make_type(is_type_variable, 00337 make_variable(make_basic(is_basic_complex, UUINT(n)), NIL,NIL)); 00338 return t; 00339 }

| type make_scalar_integer_type | ( | _int | n | ) |
Definition at line 327 of file type.c.
References is_basic_int, is_type_variable, make_basic(), make_type(), make_variable(), NIL, and UUINT.
Referenced by CreateAbstractStateVariable(), make_beta_entity(), make_dummy_io_ptr(), make_phi_entity(), make_psi_entity(), make_rho_entity(), UpdateEntity(), and UpdateType().
00328 { 00329 type t = make_type(is_type_variable, 00330 make_variable(make_basic(is_basic_int, UUINT(n)), NIL,NIL)); 00331 return t; 00332 }


If it is int i:5, keep the bit basic type
| size | ize |
Definition at line 2204 of file type.c.
References b, basic_int, bit_type_p(), i, make_basic_int(), make_type_variable(), make_variable(), NIL, pips_debug, signed_type_p(), type_undefined, type_variable, unsigned_type_p(), user_warning(), v, and variable_basic.
Referenced by c_parse(), and yyparse().
02205 { 02206 if (t == type_undefined) 02207 { 02208 variable v = make_variable(make_basic_int(size),NIL,NIL); 02209 return make_type_variable(v); 02210 } 02211 else 02212 { 02213 if (signed_type_p(t) || unsigned_type_p(t)) 02214 { 02215 basic b = variable_basic(type_variable(t)); 02216 int i = basic_int(b); 02217 variable v = make_variable(make_basic_int(10*(i/10)+size),NIL,NIL); 02218 pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+size); 02219 return make_type_variable(v); 02220 } 02221 else 02222 { 02223 if (bit_type_p(t)) 02224 /* If it is int i:5, keep the bit basic type*/ 02225 return t; 02226 else 02227 user_warning("Parse error", "Standard integer types\n"); 02228 return type_undefined; 02229 } 02230 } 02231 }


long
long long
If it is long int i:5, keep the bit basic type
Definition at line 2233 of file type.c.
References b, basic_int, bit_type_p(), DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LONG_INTEGER_TYPE_SIZE, DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE, i, long_type_p(), make_basic_int(), make_type_variable(), make_variable(), NIL, pips_debug, signed_type_p(), type_undefined, type_variable, unsigned_type_p(), user_warning(), v, and variable_basic.
Referenced by c_parse(), and yyparse().
02234 { 02235 if (t == type_undefined) 02236 { 02237 variable v = make_variable(make_basic_int(DEFAULT_LONG_INTEGER_TYPE_SIZE),NIL,NIL); 02238 return make_type_variable(v); 02239 } 02240 else 02241 { 02242 if (signed_type_p(t) || unsigned_type_p(t) || long_type_p(t)) 02243 { 02244 basic b = variable_basic(type_variable(t)); 02245 int i = basic_int(b); 02246 variable v; 02247 if (i%10 == DEFAULT_INTEGER_TYPE_SIZE) 02248 { 02249 /* long */ 02250 v = make_variable(make_basic_int(10*(i/10)+DEFAULT_LONG_INTEGER_TYPE_SIZE),NIL,NIL); 02251 pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+DEFAULT_LONG_INTEGER_TYPE_SIZE); 02252 } 02253 else 02254 { 02255 /* long long */ 02256 v = make_variable(make_basic_int(10*(i/10)+DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE),NIL,NIL); 02257 pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE); 02258 } 02259 return make_type_variable(v); 02260 } 02261 else 02262 { 02263 if (bit_type_p(t)) 02264 /* If it is long int i:5, keep the bit basic type*/ 02265 return t; 02266 else 02267 user_warning("Parse error", "Standard long integer types\n"); 02268 return type_undefined; 02269 } 02270 } 02271 }


For Fortran.
| size | ize |
Definition at line 173 of file type.c.
References make_basic(), make_dummy_unknown(), make_mode_reference(), make_parameter(), MakeTypeArray(), NIL, and UUINT.
Referenced by MakeComplexParameter(), MakeDoublecomplexParameter(), MakeDoubleprecisionParameter(), MakeIntegerParameter(), MakeLogicalParameter(), MakeOverloadedParameter(), and MakeRealParameter().
00174 { 00175 return make_parameter(MakeTypeArray(make_basic(t, UUINT(size)), NIL), 00176 make_mode_reference(), 00177 make_dummy_unknown()); 00178 }


| size | ize |
Definition at line 228 of file type.c.
References make_basic(), MakeTypeArray(), NIL, and UUINT.
Referenced by MakeComplexResult(), MakeDoublecomplexResult(), MakeDoubleprecisionResult(), MakeIntegerResult(), MakeLogicalResult(), MakeOverloadedResult(), and MakeRealResult().
00229 { 00230 return MakeTypeArray(make_basic(t, UUINT(size)), NIL); 00231 }


| basic MakeBasic | ( | int | the_tag | ) |
END_EOLE.
| the_tag | he_tag |
Definition at line 87 of file type.c.
References basic_undefined, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, make_basic(), pips_error(), string_undefined, UU, and UUINT.
Referenced by add_one_bound_argument(), complexity_sigma(), create_integer_parameter_for_new_module(), create_new_integer_scalar_common_variable(), create_private_integer_variable_for_new_module(), DeclarePointer(), extract_lattice(), find_or_create_scalar_entity(), find_or_create_typed_entity(), generate_copy_loop_nest(), generate_optimized_code_for_loop_nest(), loop_flt(), loop_to_complexity(), remove_if_statement_according_to_write_effects(), simplify_sc_to_complexity(), and st_compute_ith_local_index().
00089 { 00090 switch(the_tag) 00091 { 00092 case is_basic_int: 00093 return(make_basic(is_basic_int, UUINT(4))); 00094 break; 00095 case is_basic_float: 00096 return(make_basic(is_basic_float, UUINT(4))); 00097 break; 00098 case is_basic_logical: 00099 return(make_basic(is_basic_logical, UUINT(4))); 00100 break; 00101 case is_basic_complex: 00102 return(make_basic(is_basic_complex, UUINT(8))); 00103 break; 00104 case is_basic_overloaded: 00105 return(make_basic(is_basic_overloaded, UU)); 00106 break; 00107 case is_basic_string: 00108 return(make_basic(is_basic_string, string_undefined)); 00109 break; 00110 default: 00111 pips_error("MakeBasic", "unexpected basic tag: %d\n", 00112 the_tag); 00113 break; 00114 } 00115 00116 return(basic_undefined); 00117 }


| basic MakeBasicOverloaded | ( | void | ) |
generation of types
Definition at line 40 of file type.c.
References is_basic_overloaded, make_basic(), and NIL.
00041 { 00042 return(make_basic(is_basic_overloaded, NIL)); 00043 }

| parameter MakeCharacterParameter | ( | void | ) |
Definition at line 161 of file type.c.
References DEFAULT_CHARACTER_TYPE_SIZE, is_basic_string, is_constant_int, is_mode_reference, is_value_constant, make_basic(), make_constant(), make_dummy_unknown(), make_mode(), make_parameter(), make_value(), MakeTypeArray(), NIL, UU, and UUINT.
Referenced by assign_substring_type(), character_to_character_type(), character_to_integer_type(), character_to_logical_type(), logical_to_logical_type(), and substring_type().
00162 { 00163 return make_parameter(MakeTypeArray(make_basic(is_basic_string, 00164 make_value(is_value_constant, 00165 make_constant(is_constant_int, 00166 UUINT(DEFAULT_CHARACTER_TYPE_SIZE)))), 00167 NIL), 00168 make_mode(is_mode_reference, UU), 00169 make_dummy_unknown()); 00170 }


| type MakeCharacterResult | ( | void | ) |
Definition at line 219 of file type.c.
References DEFAULT_CHARACTER_TYPE_SIZE, is_basic_string, is_constant_int, is_value_constant, make_basic(), make_constant(), make_value(), MakeTypeArray(), NIL, and UUINT.
Referenced by assign_substring_type(), char_pointer_to_double_type(), character_to_character_type(), and substring_type().
00220 { 00221 return MakeTypeArray(make_basic(is_basic_string, 00222 make_value(is_value_constant, 00223 make_constant(is_constant_int, 00224 UUINT(DEFAULT_CHARACTER_TYPE_SIZE)))), 00225 NIL); 00226 }


| parameter MakeComplexParameter | ( | void | ) |
Definition at line 151 of file type.c.
References DEFAULT_COMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarParameter().
Referenced by complex_to_complex_type(), and complex_to_real_type().
00152 { 00153 return MakeAnyScalarParameter(is_basic_complex, DEFAULT_COMPLEX_TYPE_SIZE); 00154 }


| type MakeComplexResult | ( | void | ) |
Definition at line 208 of file type.c.
References DEFAULT_COMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarResult().
Referenced by complex_to_complex_type(), and overloaded_to_complex_type().
00209 { 00210 return MakeAnyScalarResult(is_basic_complex, DEFAULT_COMPLEX_TYPE_SIZE); 00211 }


| parameter MakeDoublecomplexParameter | ( | void | ) |
Definition at line 156 of file type.c.
References DEFAULT_DOUBLECOMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarParameter().
Referenced by doublecomplex_to_double_type(), and doublecomplex_to_doublecomplex_type().
00157 { 00158 return MakeAnyScalarParameter(is_basic_complex, DEFAULT_DOUBLECOMPLEX_TYPE_SIZE); 00159 }


| type MakeDoublecomplexResult | ( | void | ) |
Definition at line 213 of file type.c.
References DEFAULT_DOUBLECOMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarResult().
Referenced by doublecomplex_to_doublecomplex_type(), and overloaded_to_doublecomplex_type().
00214 { 00215 return MakeAnyScalarResult(is_basic_complex, 00216 DEFAULT_DOUBLECOMPLEX_TYPE_SIZE); 00217 }


| parameter MakeDoubleprecisionParameter | ( | void | ) |
Definition at line 141 of file type.c.
References DEFAULT_DOUBLEPRECISION_TYPE_SIZE, is_basic_float, and MakeAnyScalarParameter().
Referenced by double_to_double_type(), and double_to_integer_type().
00142 { 00143 return MakeAnyScalarParameter(is_basic_float, DEFAULT_DOUBLEPRECISION_TYPE_SIZE); 00144 }


| type MakeDoubleprecisionResult | ( | void | ) |
Definition at line 198 of file type.c.
References DEFAULT_DOUBLEPRECISION_TYPE_SIZE, is_basic_float, and MakeAnyScalarResult().
Referenced by char_pointer_to_double_type(), double_to_double_type(), doublecomplex_to_double_type(), overloaded_to_double_type(), and real_to_double_type().
00199 { 00200 return MakeAnyScalarResult(is_basic_float, DEFAULT_DOUBLEPRECISION_TYPE_SIZE); 00201 }


| parameter MakeIntegerParameter | ( | void | ) |
Definition at line 131 of file type.c.
References DEFAULT_REAL_TYPE_SIZE, is_basic_int, and MakeAnyScalarParameter().
Referenced by assign_substring_type(), integer_to_integer_type(), integer_to_logical_type(), integer_to_overloaded_type(), integer_to_real_type(), integer_to_void_type(), and substring_type().
00132 { 00133 return MakeAnyScalarParameter(is_basic_int, DEFAULT_REAL_TYPE_SIZE); 00134 }


| type MakeIntegerResult | ( | void | ) |
Definition at line 188 of file type.c.
References DEFAULT_INTEGER_TYPE_SIZE, is_basic_int, and MakeAnyScalarResult().
Referenced by character_to_integer_type(), double_to_integer_type(), integer_to_integer_type(), MakeEntityFunction(), MakeFunctionExpression(), MakeRunTimeSupportFunction(), overloaded_to_integer_type(), real_to_integer_type(), void_to_integer_type(), void_to_void_to_int_pointer_type(), and yyparse().
00189 { 00190 return MakeAnyScalarResult(is_basic_int, DEFAULT_INTEGER_TYPE_SIZE); 00191 }


| parameter MakeLogicalParameter | ( | void | ) |
Definition at line 146 of file type.c.
References DEFAULT_LOGICAL_TYPE_SIZE, is_basic_logical, and MakeAnyScalarParameter().
00147 { 00148 return MakeAnyScalarParameter(is_basic_logical, DEFAULT_LOGICAL_TYPE_SIZE); 00149 }

| type MakeLogicalResult | ( | void | ) |
Definition at line 203 of file type.c.
References DEFAULT_LOGICAL_TYPE_SIZE, is_basic_logical, and MakeAnyScalarResult().
Referenced by character_to_logical_type(), integer_to_logical_type(), logical_to_logical_type(), and overloaded_to_logical_type().
00204 { 00205 return MakeAnyScalarResult(is_basic_logical, DEFAULT_LOGICAL_TYPE_SIZE); 00206 }


| mode MakeModeReference | ( | void | ) |
Definition at line 45 of file type.c.
References is_mode_reference, make_mode(), and NIL.
Referenced by outlining_make_argument(), step_add_formal_copy(), update_functional_type_with_actual_arguments(), and UpdateFunctionalType().
00046 { 00047 return(make_mode(is_mode_reference, NIL)); 00048 }


| mode MakeModeValue | ( | void | ) |
Definition at line 50 of file type.c.
References is_mode_value, make_mode(), and NIL.
00051 { 00052 return(make_mode(is_mode_value, NIL)); 00053 }

| parameter MakeOverloadedParameter | ( | void | ) |