PIPS
type.c File Reference
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "misc.h"
#include "properties.h"
#include "ri-util.h"
+ Include dependency graph for type.c:

Go to the source code of this file.

Macros

#define BCTYPES_TABLE_INIT_SIZE   10
 basic_concrete_types More...
 

Functions

string type_to_string (const type t)
 type.c More...
 
string safe_type_to_string (const type t)
 
basic MakeBasicOverloaded ()
 bool same_type_name_p(const type t0, const type t1) { More...
 
mode MakeModeReference ()
 
mode MakeModeValue ()
 
type MakeTypeStatement ()
 
type MakeTypeUnknown ()
 
type MakeTypeVoid ()
 
type MakeTypeOverloaded ()
 
type MakeTypeVariable (basic b, cons *ld)
 BEGIN_EOLE. More...
 
basic MakeBasic (int the_tag)
 END_EOLE. More...
 
type MakeTypeArray (basic b, cons *ld)
 functions on types More...
 
parameter MakeOverloadedParameter ()
 
parameter MakePointerParameter ()
 
parameter MakeVoidPointerParameter ()
 
parameter MakeIntegerParameter ()
 
parameter MakeLongIntegerParameter ()
 
parameter MakeUnsignedIntegerParameter ()
 
parameter MakeLongLongIntegerParameter ()
 MB. More...
 
parameter MakeRealParameter ()
 
parameter MakeDoubleprecisionParameter ()
 
parameter MakeQuadprecisionParameter ()
 MB. More...
 
parameter MakeLogicalParameter ()
 
parameter MakeComplexParameter ()
 
parameter MakeDoublecomplexParameter ()
 
parameter MakeLongDoublecomplexParameter ()
 MB. More...
 
parameter MakeCharacterParameter ()
 
parameter MakeAnyScalarParameter (tag t, _int size)
 For Fortran. More...
 
type MakeOverloadedResult ()
 this function creates a default fortran operator result, i.e. More...
 
type MakeUnsignedIntegerResult ()
 
type MakeVoidPointerResult ()
 
type MakeIntegerResult ()
 
type MakeLongIntegerResult ()
 MB. More...
 
type MakeLongLongIntegerResult ()
 MB. More...
 
type MakeRealResult ()
 
type MakeDoubleprecisionResult ()
 
type MakeQuadprecisionResult ()
 MB. More...
 
type MakeLogicalResult ()
 
type MakeComplexResult ()
 
type MakeDoublecomplexResult ()
 
type MakeLongDoublecomplexResult ()
 MB. More...
 
type MakeCharacterResult ()
 
type MakeAnyScalarResult (tag t, _int size)
 
bool same_type_p (type t1, type t2)
 Type equality and equivalence. More...
 
static bool generic_type_equal_p (type t1, type t2, bool strict_p, bool qualifier_p, hash_table structural_table)
 Warning: the lengths of string basics are not checked!!! string_type_size() could be used but it is probably not very robust. More...
 
static bool generic_field_list_equal_p (list fl1, list fl2, bool strict_p, bool qualifier_p, hash_table structural_table)
 This function is only used for structural type equality. More...
 
static bool generic_field_list_names_equal_p (list fl1, list fl2)
 In case you are not protected against recursivity, check field names only. More...
 
bool type_equal_p (type t1, type t2)
 
bool type_equal_up_to_qualifiers_p (type t1, type t2)
 
bool type_equal_up_to_typedefs_and_qualifiers_p (type t1, type t2)
 
bool ultimate_type_equal_p (type t1, type t2)
 
bool concrete_type_equal_p (type t1, type t2)
 Expand typedefs before the type comparison. More...
 
bool type_structurally_equal_p (type t1, type t2)
 Type t1 and t2 are equal if their basic concrete components are equal. More...
 
type array_type_projection (type t)
 T is assumed to be an array type. More...
 
bool array_pointer_type_equal_p (type t1, type t2)
 assume that a pointer to type x is equal to a 1-D array of x More...
 
bool array_pointer_string_type_equal_p (type t1, type t2)
 Assume that a pointer to type x is equal to a 1-D array of x. More...
 
bool array_element_type_p (type at, type et)
 is "et" the type of an element of an array of type "at"? More...
 
bool concrete_array_pointer_type_equal_p (type t1, type t2)
 Same as above, but resolve typedefs first. More...
 
type make_scalar_integer_type (_int n)
 
type make_scalar_complex_type (_int n)
 
type make_scalar_overloaded_type ()
 
bool area_equal_p (area a1, area a2)
 
bool dimension_equal_p (dimension d1, dimension d2)
 
bool dimensions_equal_p (list dims1, list dims2)
 
bool qualifiers_equal_p (list dims1, list dims2)
 
bool generic_variable_equal_p (variable v1, variable v2, bool strict_p, bool qualifier_p, hash_table structural_table)
 
bool variable_equal_p (variable v1, variable v2)
 
bool generic_basic_equal_p (basic b1, basic b2, bool strict_p, bool qualifier_p, hash_table structural_table)
 
bool basic_equal_p (basic b1, basic b2)
 
static bool compare_basic_p (basic b1, basic b2, bool same_p)
 Used to implement the next two functions. More...
 
bool same_basic_p (basic b1, basic b2)
 check if two basics are similar. More...
 
bool compatible_basic_p (basic b1, basic b2)
 check if two basics are similar. More...
 
bool generic_functional_equal_p (functional f1, functional f2, bool strict_p, bool qualifier_p, hash_table structural_table)
 
bool functional_equal_p (functional f1, functional f2)
 
bool generic_parameter_equal_p (parameter p1, parameter p2, bool strict_p, bool qualifier_p, hash_table structural_table)
 
bool parameter_equal_p (parameter p1, parameter p2)
 
bool mode_equal_p (mode m1, mode m2)
 
int string_type_size (basic b)
 
int basic_type_size (basic b)
 See also SizeOfElements() More...
 
basic expression_basic (expression expr)
 
dimension dimension_dup (dimension d)
 
list ldimensions_dup (list l)
 
dimension FindIthDimension (entity e, int i)
 
static basic basic_and_indices_to_basic (basic b, list indices, bool ultimate_p)
 BEGIN_EOLE. More...
 
basic some_basic_of_any_expression (expression exp, bool apply_p, bool ultimate_p)
 basic basic_of_any_expression(expression exp, bool apply_p): Makes a basic of the same basic as the expression "exp" if "apply_p" is FALSE. More...
 
basic basic_of_any_expression (expression exp, bool apply_p)
 
basic basic_of_expression (expression exp)
 basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp". More...
 
basic basic_of_any_reference (reference r, bool apply_p, bool ultimate_p)
 Retrieves the basic of a reference in a newly allocated basic object. More...
 
basic basic_of_reference (reference r)
 Retrieves the basic of a reference in a newly allocated basic object. More...
 
basic basic_of_call (call c, bool apply_p, bool ultimate_p)
 basic basic_of_call(call c): returns the basic of the result given by the call "c". More...
 
basic basic_of_external (call c)
 basic basic_of_external(call c): returns the basic of the result given by the call to an external function. More...
 
basic basic_of_intrinsic (call c, bool apply_p, bool ultimate_p)
 basic basic_of_intrinsic(call c): returns the basic of the result given by call to an intrinsic function. More...
 
basic basic_of_constant (call c)
 basic basic_of_constant(call c): returns the basic of the call to a constant. More...
 
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. More...
 
basic basic_ultimate (basic b)
 get the ultimate basic from a basic typedef More...
 
basic basic_maximum (basic fb1, basic fb2)
 
basic basic_of_expressions (list expressions, bool skip_overloaded)
 
type intrinsic_call_to_type (call c)
 END_EOLE. More...
 
type call_to_type (call c)
 
type reference_to_type (reference ref)
 
type expression_to_type (expression exp)
 For an array declared as int a[10][20], the type returned for a[i] is int [20]. More...
 
type expression_to_uncasted_type (expression exp)
 If the expression is casted, return its type before cast. More...
 
type expression_to_user_type (expression e)
 Preserve typedef'ed types when possible. More...
 
bool overloaded_type_p (type t)
 Returns true if t is a variable type with a basic overloaded. More...
 
bool is_inferior_basic (basic b1, basic b2)
 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, ... More...
 
basic simple_basic_dup (basic b)
 
entity basic_to_generic_conversion (basic b)
 returns the corresponding generic conversion entity, if any. More...
 
bool signed_type_p (type t)
 
bool unsigned_basic_p (basic b)
 
bool unsigned_type_p (type t)
 Predicates on types. More...
 
bool long_type_p (type t)
 
bool bit_type_p (type t)
 
bool string_type_p (type t)
 
bool logical_type_p (type t)
 
bool char_type_p (type t)
 return true whether ‘t’ is a char or an unsigned char More...
 
bool basic_type_p (type t)
 Safer than the other implementation? bool pointer_type_p(type t) { bool is_pointer = false;. More...
 
bool type_fundamental_basic_p (type t)
 
bool array_type_p (type t)
 
unsigned int array_type_dimension (type t)
 
bool scalar_type_p (type t)
 
bool type_pointer_on_struct_variable_p (type t)
 
bool variable_length_array_type_p (type t)
 Is this equivalent to dependent_type_p()? More...
 
bool fixed_length_array_type_p (type t)
 
bool pointer_type_p (type t)
 Check for scalar pointers. More...
 
bool C_pointer_type_p (type t)
 Returns OK for "char[]" as well as for "char *". More...
 
bool array_of_pointers_type_p (type t)
 
type pointed_type (type t)
 returns the type pointed by the input type if it is a pointer or an array of pointers More...
 
bool FILE_star_type_p (type t)
 
list type_fields (type t)
 
bool derived_type_p (type t)
 Returns true if t is of type struct, union or enum. More...
 
bool array_of_derived_type_p (type t)
 
bool struct_type_p (type t)
 Returns true if t is of type derived and if the derived type is a struct. More...
 
bool array_of_struct_type_p (type t)
 
bool union_type_p (type t)
 Returns true if t is of type derived and if the derived type is a union. More...
 
bool enum_type_p (type t)
 Returns true if t is of type derived and if the derived type is a enum. More...
 
bool typedef_type_p (type t)
 Returns true if t is a typedefED type. More...
 
type make_standard_integer_type (type t, int size)
 
bool standard_long_integer_type_p (type t)
 Used to encode the long keyword in the parser. More...
 
bool default_complex_type_p (type t)
 
bool float_type_p (type t)
 
bool scalar_integer_type_p (type t)
 
bool integer_type_p (type t)
 
type make_standard_long_integer_type (type t)
 
static type private_ultimate_type (type t, bool arrays_only)
 FI: there are different notions of "ultimate" types in C. More...
 
type ultimate_type (type t)
 
type ultimate_array_type (type t)
 
void entity_basic_concrete_types_init ()
 
void entity_basic_concrete_types_reset ()
 
list dimensions_to_normalized_dimensions (list dl)
 evaluate constant expressions appearing in dimensions of list dl More...
 
type compute_basic_concrete_type (type t)
 computes a new type which is the basic concrete type of the input type (this new type is not stored in the entity_types_to_bctypes table). More...
 
type entity_basic_concrete_type (entity e)
 retrieves or computes and then returns the basic concrete type of an entity More...
 
bool basic_concrete_type_leads_to_pointer_p (type bct)
 returns true when the input type successors may be pointers More...
 
type expression_to_concrete_type (expression e)
 A new type is allocated. More...
 
bool call_compatible_type_p (type t)
 end of basic_concrete_types More...
 
type call_compatible_type (type t)
 returns the type necessary to generate or check a call to an object of type t. More...
 
type call_to_functional_type (call c, bool ultimate_p)
 The function called can have a functional type, or a typedef type or a pointer type to a functional type. More...
 
bool type_struct_variable_p (type t)
 
bool type_union_variable_p (type t)
 
int number_of_fields (type t)
 Recursive number of fields in a data structure... More...
 
int number_of_items (type t)
 Same as above, but arrays in struct are taken into account. More...
 
list recursive_functional_type_supporting_entities (list sel, set vt, functional f)
 
list functional_type_supporting_entities (list sel, functional f)
 
list enum_supporting_entities (list sel, set vt, entity e)
 
list generic_constant_expression_supporting_entities (list sel, set vt, expression e, bool language_c_p)
 
list constant_expression_supporting_entities (list sel, set vt, expression e)
 C version. More...
 
list fortran_constant_expression_supporting_entities (list sel, expression e)
 Fortran version. More...
 
list generic_symbolic_supporting_entities (list sel, set vt, symbolic s, bool language_c_p)
 
list symbolic_supporting_entities (list sel, set vt, symbolic s)
 C version. More...
 
list basic_supporting_entities (list sel, set vt, basic b)
 
list variable_type_supporting_entities (list sel, set vt, variable v)
 
list recursive_type_supporting_entities (list sel, set vt, type t)
 
list type_supporting_entities (list sel, type t)
 
bool declarable_type_p (type t, list pdl)
 Are all types necessary to define fully type "t" listed in list "pdl"? More...
 
static list recursive_type_supporting_references (list srl, type t)
 Compute the list of references implied in the definition of a type. More...
 
list functional_type_supporting_references (list srl, functional f)
 
list enum_supporting_references (list srl, entity e)
 
list constant_expression_supporting_references (list srl, expression e)
 Only applicable to C expressions. More...
 
list symbolic_supporting_references (list srl, symbolic s)
 
list basic_supporting_references (list srl, basic b)
 
list variable_type_supporting_references (list srl, variable v)
 
list fortran_type_supporting_entities (list srl, type t)
 
list type_supporting_references (list srl, type t)
 
bool check_C_function_type (entity f, list args)
 Check that an effective parameter list is compatible with a function type. More...
 
static size_t generic_basic_depth (basic b, set vt)
 
static size_t generic_type_depth (type t, set vt)
 
size_t maximal_type_depth (type t)
 Number of steps to access the lowest leave of type t without a recursive test. More...
 
size_t type_depth (type t)
 Number of steps to access the lowest leave of type t without dereferencing. More...
 
int effect_type_depth (type t)
 Number of steps to access the lowest leave of type t. More...
 
int effect_basic_depth (basic b)
 
static list recursive_type_supporting_types (list stl, set vt, type t)
 Compute the list of types implied in the definition of a type. More...
 
static list recursive_functional_type_supporting_types (list stl, set vt, functional f)
 
list functional_type_supporting_types (functional f)
 FI: I'm not sure this function is of any use. More...
 
static list basic_supporting_types (list stl, set vt, basic b)
 
static list variable_type_supporting_types (list stl, set vt, variable v)
 
list type_supporting_types (type t)
 Return the list of types used to define type t. More...
 
type make_char_array_type (int n)
 
type make_scalar_char_pointer_type ()
 Allocate a char * pointer type. More...
 
bool overloaded_parameters_p (list lparams)
 
type type_to_pointer_type (type t)
 allocate a new type "pt" which includes directly "t". More...
 
type type_to_pointed_type (type t)
 returns t if t is not a pointer type, and the pointed type if t is a pointer type. More...
 
type C_type_to_pointed_type (type t)
 returns a copy of t if t is not a pointer type, and the pointed type if t is a pointer type or. More...
 
type type_to_returned_type (type t)
 returns t if t is not a functoional type, and the returned type if t is a functional type. More...
 
type type_to_final_pointed_type (type t)
 returns t if t is not a pointer type, and the first indirectly pointed type that is not a pointer if t is a pointer type. More...
 
list derived_type_fields (type t)
 
list derived_type_to_fields (type t)
 
entity find_field_in_field_list (entity f, list fl)
 To deal with fields declared in different C files. More...
 
bool qualifier_equal_p (qualifier q1, qualifier q2)
 
string qualifier_to_string (qualifier q)
 
bool qualifiers_const_p (list ql)
 Check that a qualifier list contains the const qualifier. More...
 
bool qualifiers_restrict_p (list ql)
 Check that a qualifier list contains the restrict qualifier. More...
 
bool type_with_const_qualifier_p (type t)
 Is there a const qualifier associated to type t. More...
 
static type subscripted_field_list_to_type (list fl, expression se)
 returns the type associated to se. More...
 
type subscripted_type_to_type (type t, expression se)
 Returns the type of an object of type t subscripted by expression se. More...
 
dimension find_ith_dimension (list dims, int n)
 This function returns the ith dimension of a list of dimensions. More...
 
int variable_dimension_number (variable v)
 
type type_to_array_type (type t)
 convert a type "t" into a newly allocated array type "at" whose elements are of type "t", unless "t" is void. More...
 
type array_type_to_element_type (type t)
 returns the type of the elements of an array type, as a newly allocated type. More...
 
type array_type_to_sub_array_type (type t)
 Allocate a new type, the sub-array type of "t". More...
 
type array_type_to_pointer_type (type t)
 Allocate a new type that is the type of an array constant. More...
 
list make_unbounded_dimensions (int d)
 Minimal information to build a d-dimensional array type. More...
 
bool type_void_star_p (type t)
 
bool char_star_type_p (type t)
 Beware of typedefs. More...
 
bool char_star_constant_function_type_p (type t)
 Beware of typedefs. More...
 
list struct_type_to_fields (type lt)
 
static bool dependent_basic_p (basic b)
 
bool dependent_type_p (type t)
 A type is dependent in many ways according to definitions given in Wikipedia. More...
 
static void reference_dependence_variable_check_and_add (reference ref, list *dependence_list)
 
static list dependence_of_dependent_basic (basic b)
 
list dependence_of_dependent_type (type t)
 similar to dependent_type_p but return a list of reference on which the type depend. More...
 

Variables

static hash_table entity_types_to_bctypes = hash_table_undefined
 
static set supporting_types = set_undefined
 Compute the list of entities implied in the definition of a type. More...
 

Macro Definition Documentation

◆ BCTYPES_TABLE_INIT_SIZE

#define BCTYPES_TABLE_INIT_SIZE   10

basic_concrete_types

Definition at line 3495 of file type.c.

Function Documentation

◆ area_equal_p()

bool area_equal_p ( area  a1,
area  a2 
)

layouts are independent ?

Parameters
a11
a22

Definition at line 733 of file type.c.

734 {
735  if(a1 == a2)
736  return true;
737  else if (a1 == area_undefined && a2 != area_undefined)
738  return false;
739  else if (a1 != area_undefined && a2 == area_undefined)
740  return false;
741  else
742  /* layouts are independent ? */
743  return (area_size(a1) == area_size(a2));
744 }
#define area_size(x)
Definition: ri.h:544
#define area_undefined
Definition: ri.h:520

References area_size, and area_undefined.

Referenced by generic_type_equal_p().

+ Here is the caller graph for this function:

◆ array_element_type_p()

bool array_element_type_p ( type  at,
type  et 
)

is "et" the type of an element of an array of type "at"?

Parameters
att
ett

Definition at line 684 of file type.c.

685 {
686  bool equal_p = false;
687 
688  if(array_type_p(at)) {
689  if(type_variable_p(et)) {
692  equal_p = basic_equal_p(ab, eb);
693  }
694  }
695 
696  return equal_p;
697 }
bool array_type_p(type t)
Definition: type.c:2942
bool basic_equal_p(basic b1, basic b2)
Definition: type.c:927
#define type_variable(x)
Definition: ri.h:2949
#define type_variable_p(x)
Definition: ri.h:2947
#define variable_basic(x)
Definition: ri.h:3120

References array_type_p(), basic_equal_p(), type_variable, type_variable_p, and variable_basic.

Referenced by expression_to_points_to_sources().

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

◆ array_of_derived_type_p()

bool array_of_derived_type_p ( type  t)

Definition at line 3109 of file type.c.

3110 {
3112  && (variable_dimensions(type_variable(t)) != NIL));
3113 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define basic_derived_p(x)
Definition: ri.h:638
#define variable_dimensions(x)
Definition: ri.h:3122

References basic_derived_p, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by array_of_struct_type_p().

+ Here is the caller graph for this function:

◆ array_of_pointers_type_p()

◆ array_of_struct_type_p()

bool array_of_struct_type_p ( type  t)

◆ array_pointer_string_type_equal_p()

bool array_pointer_string_type_equal_p ( type  t1,
type  t2 
)

Assume that a pointer to type x is equal to a 1-D array of x.

And do not forget the PIPS "string" exception. Constants strings are given type void->string instead of char[n] or char *.

Convert t1

Convert t2

Parameters
t11
t22

Definition at line 658 of file type.c.

659 {
660  bool equal_p = true;
661  if(string_type_p(t1))
662  if(string_type_p(t2))
663  equal_p = type_equal_p(t1,t2);
664  else {
665  /* Convert t1 */
667  equal_p = array_pointer_type_equal_p(nt1, t2);
668  free_type(nt1);
669  }
670  else
671  if(string_type_p(t2)) {
672  /* Convert t2 */
674  equal_p = array_pointer_type_equal_p(t1, nt2);
675  free_type(nt2);
676  }
677  else
678  equal_p = array_pointer_type_equal_p(t1, t2);
679 
680  return equal_p;
681 }
void free_type(type p)
Definition: ri.c:2658
bool type_equal_p(type t1, type t2)
Definition: type.c:547
bool string_type_p(type t)
Definition: type.c:2854
type make_scalar_char_pointer_type()
Allocate a char * pointer type.
Definition: type.c:5227
bool array_pointer_type_equal_p(type t1, type t2)
assume that a pointer to type x is equal to a 1-D array of x
Definition: type.c:609

References array_pointer_type_equal_p(), free_type(), make_scalar_char_pointer_type(), string_type_p(), and type_equal_p().

Referenced by adapt_reference_to_type(), expression_to_points_to_cells(), filter_formal_context_according_to_actual_context(), new_filter_formal_context_according_to_actual_context(), points_to_translation_mapping_is_typed_p(), and points_to_translation_of_formal_parameters().

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

◆ array_pointer_type_equal_p()

bool array_pointer_type_equal_p ( type  t1,
type  t2 
)

assume that a pointer to type x is equal to a 1-D array of x

Reduce the number of dimensions and try again

Parameters
t11
t22

Definition at line 609 of file type.c.

610 {
611  bool equal_p = true;
612  if(!type_equal_up_to_qualifiers_p(t1,t2)) {
613  if(pointer_type_p(t1) && array_type_p(t2)) {
614  type pt = type_to_pointed_type(t1);
615  if(type_void_p(pt)) {
616  // Conventionally, you should have an array of overloaded elements...
617  //array_element_type();
618  equal_p = false;
619  }
620  else {
621  // Generalization
623  equal_p = array_pointer_type_equal_p(pt, st);
624  free_type(st);
625  }
626  }
627  else if(pointer_type_p(t2) && array_type_p(t1)) {
628  type pt = type_to_pointed_type(t2);
629  if(type_void_p(pt)) {
630  // Conventionally, you should have an array of overloaded elements...
631  //array_element_type();
632  equal_p = false;
633  }
634  else {
635  // Generalization
637  equal_p = array_pointer_type_equal_p(pt, st);
638  free_type(st);
639  }
640  }
641  else if(array_type_p(t1) && array_type_p(t2)) {
642  /* Reduce the number of dimensions and try again */
643  type nt1 = array_type_projection(t1);
644  type nt2 = array_type_projection(t2);
645  equal_p = array_pointer_type_equal_p(nt1, nt2);
646  free_type(nt1), free_type(nt2);
647  }
648  else
649  equal_p = false;
650  }
651  return equal_p;
652 }
bool type_equal_up_to_qualifiers_p(type t1, type t2)
Definition: type.c:552
type type_to_pointed_type(type t)
returns t if t is not a pointer type, and the pointed type if t is a pointer type.
Definition: type.c:5265
type array_type_to_sub_array_type(type t)
Allocate a new type, the sub-array type of "t".
Definition: type.c:5718
type array_type_projection(type t)
T is assumed to be an array type.
Definition: type.c:596
bool pointer_type_p(type t)
Check for scalar pointers.
Definition: type.c:2993
#define type_void_p(x)
Definition: ri.h:2959

References array_pointer_type_equal_p(), array_type_p(), array_type_projection(), array_type_to_sub_array_type(), free_type(), pointer_type_p(), type_equal_up_to_qualifiers_p(), type_to_pointed_type(), and type_void_p.

Referenced by adapt_reference_to_type(), array_pointer_string_type_equal_p(), array_pointer_type_equal_p(), check_type_of_points_to_cells(), concrete_array_pointer_type_equal_p(), create_scalar_stub_sink_cell(), create_stub_entity(), declaration_statement_to_points_to(), expression_to_points_to_sources(), find_points_to_subscript_for_type(), offset_cell(), points_to_cell_types_compatibility(), points_to_reference_to_typed_index(), process_casted_sinks(), and process_casted_sources().

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

◆ array_type_dimension()

unsigned int array_type_dimension ( type  t)

Definition at line 2947 of file type.c.

2948 {
2949  int d = -1;
2950  if(type_variable_p(t))
2952  return d;
2953 }
void const char const char const int
size_t gen_length(const list l)
Definition: list.c:150

References gen_length(), int, type_variable, type_variable_p, and variable_dimensions.

Referenced by memory_dereferencing_p(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), normalize_subscript_expression(), and recursive_store_independent_points_to_reference_p().

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

◆ array_type_p()

bool array_type_p ( type  t)

Definition at line 2942 of file type.c.

2943 {
2944  return (type_variable_p(t) && (variable_dimensions(type_variable(t)) != NIL));
2945 }

References NIL, type_variable, type_variable_p, and variable_dimensions.

Referenced by analyzed_entity_p(), analyzed_struct_type_p(), anywhere_source_to_sinks(), array_bounded_p(), array_element_type_p(), array_location_entity_of_module_p(), array_pointer_type_equal_p(), array_type_to_pointer_type(), array_type_to_sub_array_type(), binary_arithmetic_operator_to_post_pv(), binary_intrinsic_call_to_points_to_sinks(), C_type_to_pointed_type(), cell_must_point_to_nowhere_sink_in_set_p(), cell_points_to_non_null_sink_in_set_p(), cell_points_to_nowhere_sink_in_set_p(), cell_points_to_null_sink_in_set_p(), check_rhs_value_types(), check_type_of_points_to_cells(), compute_points_to_binded_set(), compute_points_to_gen_set(), create_advanced_stub_points_to(), create_scalar_stub_sink_cell(), declaration_statement_to_points_to(), dereferencing_subscript_to_points_to(), dereferencing_to_sinks(), do_array_to_pointer_type(), do_array_to_pointer_walk_call_and_patch(), do_brace_expression_to_statements(), do_gpu_qualify_pointers(), do_linearize_array_manage_callers(), do_linearize_prepatch_subscript(), do_linearize_prepatch_type(), entity_array_p(), entity_flow_or_context_sentitive_heap_location(), expression_to_points_to_cells(), expression_to_points_to_sinks_with_offset(), filter_formal_context_according_to_actual_context(), fixed_length_array_type_p(), formal_points_to_parameter(), formal_source_to_sinks(), generic_c_words_simplified_entity(), generic_points_to_cells_translation(), generic_reference_to_transformer(), generic_stub_source_to_sinks(), generic_substitute_formal_array_elements_in_transformer(), global_source_to_sinks(), initialization_list_to_statements(), internal_pointer_assignment_to_points_to(), intrinsic_call_to_type(), memory_dereferencing_p(), new_filter_formal_context_according_to_actual_context(), normalize_subscript_expression(), offset_cell(), outliner_patch_parameters(), perform_array_element_substitutions_in_transformer(), pointer_formal_parameter_to_stub_points_to(), pointer_source_to_sinks(), points_to_array_reference_p(), points_to_cell_types_compatibility(), points_to_cells_parameters(), points_to_expression_to_pointed_type(), points_to_function_projection(), points_to_translation_of_formal_parameters(), process_casted_sinks(), process_casted_sources(), recursive_cell_to_pointer_cells(), recursive_store_independent_points_to_reference_p(), reference_dereferencing_to_points_to(), reference_to_points_to_sinks(), source_to_sinks(), struct_assignment_to_points_to(), struct_variable_to_pointer_locations(), subscript_to_points_to_sinks(), substitute_struct_stub_in_transformer(), variable_length_array_type_p(), and words_points_to_reference().

◆ array_type_projection()

type array_type_projection ( type  t)

T is assumed to be an array type.

Get rid of the last dimension and allocate the new type.

Definition at line 596 of file type.c.

597 {
598  variable v = type_variable(t);
599  list dl = variable_dimensions(v);
600  list ndl = gen_full_copy_list(dl); // new dimension list
601  list lndl = gen_last(ndl); // last dimension
602  gen_list_and_not(&ndl, lndl); // the discarded element is freed
604  type nt = make_type_variable(nv);
605  return nt;
606 }
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
Definition: list.c:963
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References copy_basic(), gen_full_copy_list(), gen_last(), gen_list_and_not(), make_type_variable(), make_variable(), NIL, type_variable, variable_basic, and variable_dimensions.

Referenced by array_pointer_type_equal_p().

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

◆ array_type_to_element_type()

type array_type_to_element_type ( type  t)

returns the type of the elements of an array type, as a newly allocated type.

It is not clear if it should fail when the argument is not an array type, or if an undefined type should be returned.

The qualifiers are dropped.

Definition at line 5700 of file type.c.

5701 {
5702  type et = type_undefined;
5703  if(type_variable_p(t)) {
5704  variable v = type_variable(t);
5705  //list dl = variable_dimensions(v);
5706  basic b = variable_basic(v);
5708  }
5709  else
5710  pips_internal_error("Ill. arg.\n");
5711  return et;
5712 }
#define pips_internal_error
Definition: misc-local.h:149
#define type_undefined
Definition: ri.h:2883

References copy_basic(), make_type_variable(), make_variable(), NIL, pips_internal_error, type_undefined, type_variable, type_variable_p, and variable_basic.

Referenced by analyzed_array_p(), analyzed_array_type_p(), check_rhs_value_types(), compute_points_to_binded_set(), expression_to_points_to_cells(), generic_substitute_formal_array_elements_in_transformer(), memory_dereferencing_p(), perform_array_element_substitutions_in_transformer(), points_to_cell_types_compatibility(), points_to_translation_of_struct_formal_parameter(), process_casted_sinks(), and recursive_store_independent_points_to_reference_p().

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

◆ array_type_to_pointer_type()

type array_type_to_pointer_type ( type  t)

Allocate a new type that is the type of an array constant.

For instance, int t[10] gives type int * to t, int t[10][20] gives type int (*)[20]

Definition at line 5739 of file type.c.

5740 {
5741  type et = type_undefined;
5742  if(array_type_p(t)) {
5744  et = type_to_pointer_type(sat);
5745  }
5746  else
5747  pips_internal_error("Ill. arg.\n");
5748  return et;
5749 }
type type_to_pointer_type(type t)
allocate a new type "pt" which includes directly "t".
Definition: type.c:5253

References array_type_p(), array_type_to_sub_array_type(), pips_internal_error, type_to_pointer_type(), and type_undefined.

+ Here is the call graph for this function:

◆ array_type_to_sub_array_type()

type array_type_to_sub_array_type ( type  t)

Allocate a new type, the sub-array type of "t".

It "t" is "int[10][20][30]", the sub-array type is "int[20][30]".

No sharing is created between argument "t" and result "et"

Definition at line 5718 of file type.c.

5719 {
5720  type et = type_undefined;
5721  if(array_type_p(t)) {
5722  variable v = type_variable(t);
5723  list dl = variable_dimensions(v);
5724  basic b = variable_basic(v);
5725  POP(dl);
5727  gen_full_copy_list(dl),
5728  NIL));
5729  }
5730  else
5731  pips_internal_error("Ill. arg.\n");
5732  return et;
5733 }
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59

References array_type_p(), copy_basic(), gen_full_copy_list(), make_type_variable(), make_variable(), NIL, pips_internal_error, POP, type_undefined, type_variable, variable_basic, and variable_dimensions.

Referenced by array_pointer_type_equal_p(), array_type_to_pointer_type(), check_type_of_points_to_cells(), and intrinsic_call_to_type().

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

◆ basic_and_indices_to_basic()

static basic basic_and_indices_to_basic ( basic  b,
list  indices,
bool  ultimate_p 
)
static

BEGIN_EOLE.

  • please do not remove this line Lines between BEGIN_EOLE and END_EOLE tags are automatically included in the EOLE project (JZ - 11/98) SG: added so that the basic of a dereferenced pointer is the basic of the dereferenced value BC : modified because it was assumed that each dimension was of pointer type which is not true when tab is declared int ** tab[10] and the expression is tab[3][4][5].

The expression can denote a function, because a function is equivalent to a pointer towards a function

FI: we might as well return a pointer to a function

the basic type is reached. Should I add pips_assert("basic reached, it should be the last index\n", ENDP(CAR(l_ind)))?

Definition at line 1209 of file type.c.

1210 {
1211  bool finished = false;
1212  for(list l_ind = indices ; !ENDP(l_ind) && !finished ; POP(l_ind) )
1213  {
1214  if(basic_pointer_p(b))
1215  {
1216  type t = basic_pointer(b);
1217  if(type_variable_p(t)) {
1218  basic bt =
1220  ultimate_p?ultimate_type(t):t)));
1221  free_basic(b);
1222  b=bt;
1223  }
1224  else if(type_functional_p(t)) {
1225  /* The expression can denote a function, because a
1226  function is equivalent to a pointer towards a
1227  function */
1228  /* FI: we might as well return a pointer to a
1229  function */
1230  ;
1231  }
1232  else if(type_void_p(t))
1233  pips_user_error("Apparent dereferencing of a void object. "
1234  "Check gcc warnings about typing.\n");
1235  else
1236  pips_internal_error("Unexpected basic kind");
1237  }
1238  else
1239  {
1240  /* the basic type is reached. Should I add pips_assert("basic reached, it should be the last index\n", ENDP(CAR(l_ind)))? */
1241  finished = true;
1242  }
1243  }
1244  return b;
1245 }
void free_basic(basic p)
Definition: ri.c:107
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
static list indices
Definition: icm.c:204
#define pips_user_error
Definition: misc-local.h:147
type ultimate_type(type t)
Definition: type.c:3466
#define type_functional_p(x)
Definition: ri.h:2950
#define basic_pointer(x)
Definition: ri.h:637

References basic_pointer, basic_pointer_p, copy_basic(), ENDP, free_basic(), indices, pips_internal_error, pips_user_error, POP, type_functional_p, type_variable, type_variable_p, type_void_p, ultimate_type(), and variable_basic.

Referenced by basic_of_any_reference(), and some_basic_of_any_expression().

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

◆ basic_concrete_type_leads_to_pointer_p()

bool basic_concrete_type_leads_to_pointer_p ( type  bct)

returns true when the input type successors may be pointers

the input type is supposed to be a basic_concrete_type

If the basic is a pointer type, return true;

witch

Parameters
bctct

Definition at line 3699 of file type.c.

3700 {
3701  bool res = false;
3702 
3703  switch (type_tag(bct))
3704  {
3705  case is_type_variable :
3706  {
3707  variable v = type_variable(bct);
3708  basic b = variable_basic(v);
3709 
3710  /* If the basic is a pointer type, return true;
3711  */
3712  if(basic_pointer_p(b))
3713  {
3714  res = true;
3715  }
3716  else if (basic_derived_p(b))
3717  {
3718  list l_fields = type_fields(entity_type(basic_derived(b)));
3719  while(!res && !ENDP(l_fields))
3720  {
3721  type current_type = entity_basic_concrete_type(ENTITY(CAR(l_fields)));
3722  // we call ourselves recursively
3723  res = basic_concrete_type_leads_to_pointer_p(current_type);
3724  POP(l_fields);
3725  }
3726  }
3727  else if (!basic_typedef_p(b))
3728  {
3729  res = false;
3730  }
3731  else
3732  {
3733  pips_internal_error("unexpected typedef basic");
3734  }
3735  break;
3736  }
3737  case is_type_void:
3738  {
3739  res = false;
3740  break;
3741  }
3742  default:
3743  {
3744  pips_internal_error("case not handled yet");
3745  }
3746  } /*switch */
3747  return res;
3748 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list type_fields(type t)
Definition: type.c:3073
type entity_basic_concrete_type(entity e)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
bool basic_concrete_type_leads_to_pointer_p(type bct)
returns true when the input type successors may be pointers
Definition: type.c:3699
#define basic_typedef_p(x)
Definition: ri.h:641
#define type_tag(x)
Definition: ri.h:2940
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
@ is_type_void
Definition: ri.h:2904
@ is_type_variable
Definition: ri.h:2900

References basic_concrete_type_leads_to_pointer_p(), basic_derived, basic_derived_p, basic_pointer_p, basic_typedef_p, CAR, ENDP, ENTITY, entity_basic_concrete_type(), entity_type, is_type_variable, is_type_void, pips_internal_error, POP, type_fields(), type_tag, type_variable, and variable_basic.

Referenced by assignment_to_post_pv(), basic_concrete_type_leads_to_pointer_p(), declaration_to_post_pv(), and sequence_to_post_pv().

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

◆ basic_equal_p()

bool basic_equal_p ( basic  b1,
basic  b2 
)
Parameters
b11
b22

Definition at line 927 of file type.c.

928 {
929  return generic_basic_equal_p(b1, b2, true, false, hash_table_undefined);
930 }
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
bool generic_basic_equal_p(basic b1, basic b2, bool strict_p, bool qualifier_p, hash_table structural_table)
Definition: type.c:824
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105

References b1, b2, generic_basic_equal_p(), and hash_table_undefined.

Referenced by _expression_similar_p(), add_declaration_to_declaration_statement_p(), array_element_type_p(), basic_concrete_types_compatible_for_effects_interprocedural_translation_p(), compare_basic_p(), convert_constant(), create_scalar_stub_sink_cell(), entity_flow_or_context_sentitive_heap_location(), fortran_user_call_to_transformer(), fortran_user_function_call_to_transformer(), is_constant_of_basic(), is_varibale_array_element_specifier(), make_substitution(), points_to_cell_types_compatibility(), same_basic_and_scalar_p(), simd_check_argType(), simplification_conversion(), simplify_expression(), store_initial_value(), struct_assignment_to_points_to(), type_loop_range(), type_this_entity_if_needed(), typing_arguments(), typing_arguments_of_user_function(), typing_of_assign(), and typing_power_operator().

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

◆ basic_maximum()

basic basic_maximum ( basic  fb1,
basic  fb2 
)

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");

SG checks for equality, he doesn't understand the meaning of having a float as the basic maximum of two float* and cowardly refuses to fix the code

FI: not convincing. As in other places, assuming this is meaningful, 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.

Parameters
fb1b1
fb2b2

Definition at line 1816 of file type.c.

1817 {
1818  basic b = basic_undefined;
1819  basic b1 = basic_ultimate(fb1);
1820  basic b2 = basic_ultimate(fb2);
1821 
1822 
1823  if(basic_derived_p(fb1)) {
1824  entity e1 = basic_derived(fb1);
1825 
1826  if(entity_enum_p(e1)) {
1827  b1 = make_basic(is_basic_int, (void *) 4);
1828  b = basic_maximum(b1, fb2);
1829  free_basic(b1);
1830  return b;
1831  }
1832  else
1833  pips_internal_error("Unanalyzed derived basic b1");
1834  }
1835 
1836  if(basic_derived_p(fb2)) {
1837  entity e2 = basic_derived(fb2);
1838 
1839  if(entity_enum_p(e2)) {
1840  b2 = make_basic(is_basic_int, (void *) 4);
1841  b = basic_maximum(fb1, b2);
1842  free_basic(b2);
1843  return b;
1844  }
1845  else
1846  pips_internal_error("Unanalyzed derived basic b2");
1847  }
1848 
1849  /* FI: I do not believe this is correct for all intrinsics! */
1850 
1851  pips_debug(7, "Tags: tag exp1 = %d, tag exp2 = %d\n",
1852  basic_tag(b1), basic_tag(b2));
1853 
1854 
1855  if(basic_overloaded_p(b2)) {
1856  b = copy_basic(b2);
1857  }
1858  else {
1859  switch(basic_tag(b1)) {
1860 
1861  case is_basic_overloaded:
1862  b = copy_basic(b1);
1863  break;
1864 
1865  case is_basic_string:
1866  if(basic_string_p(b2)) {
1867  int s1 = SizeOfElements(b1);
1868  int s2 = SizeOfElements(b2);
1869 
1870  /* Type checking problem for ? : with gcc... */
1871  if(s1>s2)
1872  b = copy_basic(b1);
1873  else
1874  b = copy_basic(b2);
1875  }
1876  else
1878  break;
1879 
1880  case is_basic_logical:
1881  if(basic_logical_p(b2)) {
1882  _int s1 = basic_logical(b1);
1883  _int s2 = basic_logical(b2);
1884 
1885  b = make_basic(is_basic_logical,UUINT(s1>s2?s1:s2));
1886  }
1887  else if(basic_int_p(b2)) {
1888  b = copy_basic(b2);
1889  }
1890  else
1892  break;
1893 
1894  case is_basic_complex:
1896  _int s1 = SizeOfElements(b1);
1897  _int s2 = SizeOfElements(b2);
1898 
1899  b = make_basic(is_basic_complex, UUINT(s1>s2?s1:s2));
1900  }
1901  else
1903  break;
1904 
1905  case is_basic_float:
1906  if(basic_complex_p(b2)) {
1907  _int s1 = SizeOfElements(b1);
1908  _int s2 = SizeOfElements(b2);
1909 
1910  b = make_basic(is_basic_complex, UUINT(s1>s2?s1:s2));
1911  }
1912  else if(basic_float_p(b2) || basic_int_p(b2)) {
1913  _int s1 = SizeOfElements(b1);
1914  _int s2 = SizeOfElements(b2);
1915 
1916  b = make_basic(is_basic_float, UUINT(s1>s2?s1:s2));
1917  }
1918  else
1920  break;
1921 
1922  case is_basic_int:
1923  if(basic_complex_p(b2) || basic_float_p(b2)) {
1924  _int s1 = SizeOfElements(b1);
1925  _int s2 = SizeOfElements(b2);
1926 
1927  b = make_basic(basic_tag(b2), UUINT(s1>s2?s1:s2));
1928  }
1929  else if(basic_int_p(b2)) {
1930  _int s1 = SizeOfElements(b1);
1931  _int s2 = SizeOfElements(b2);
1932 
1933  b = make_basic(is_basic_int, UUINT(s1>s2?s1:s2));
1934  }
1935  else if(basic_logical_p(b2)) {
1936  b = copy_basic(b1);
1937  }
1938  else if(basic_pointer_p(b2)) {
1939  return copy_basic(b2);
1940  }
1941  else
1943  break;
1944  /* NN: More cases are added for C. To be refined */
1945  case is_basic_bit:
1946  if(basic_bit_p(b2)) {
1947  if(basic_bit(b1)>=basic_bit(b2))
1948  b = copy_basic(b1);
1949  else
1950  b = copy_basic(b2);
1951  }
1952  else
1953  /* bit is a lesser type */
1954  b = copy_basic(b2);
1955  break;
1956  case is_basic_pointer:
1957  {
1958  if(basic_int_p(b2) || basic_bit_p(b2))
1959  b = copy_basic(b1);
1960  else if(basic_float_p(b2) || basic_logical_p(b2) || basic_complex_p(b2)) {
1961  /* Are they really comparable? */
1962  b = copy_basic(b1);
1963  }
1964  else if(basic_overloaded_p(b2))
1965  b = copy_basic(b1);
1966  else if(basic_pointer_p(b2)) {
1967  /* How can we compare two pointer types? Equality? Comparison of the pointed types? */
1968  /* pips_internal_error("Comparison of two pointer types not implemented"); */
1969  type t1 = basic_pointer(b1);
1970  type t2 = basic_pointer(b2);
1971 
1972  if(type_variable_p(t1) && type_variable_p(t2)) {
1973  /* SG checks for equality, he doesn't understand the meaning of
1974  * having a float as the basic maximum of two float*
1975  * and cowardly refuses to fix the code */
1976  if(type_equal_p(t1,t2))
1977  b = copy_basic(b1);
1978  else {
1979  basic nb1 = variable_basic(type_variable(t1));
1980  basic nb2 = variable_basic(type_variable(t2));
1981 
1982 
1983  /* FI: not convincing. As in other places, assuming this
1984  is meaningful, it would be better to use a basic
1985  comparator, basic_greater_p(), which could return 1, -1
1986  or 0 or ??? and deal with non comparable type. */
1987  b = basic_maximum(nb1, nb2);
1988  }
1989 
1990  }
1991  else if (type_void_p(t1) && type_void_p(t2) )
1992  b = copy_basic(b1);
1993  else
1994  pips_internal_error("Comparison of two pointer types not meaningful");
1995  }
1996  else if(basic_derived_p(b2))
1997  pips_internal_error("Comparison between pointer and struct/union not implemented");
1998  else if(basic_typedef_p(b2))
1999  pips_internal_error("b2 cannot be a typedef basic");
2000  else
2001  pips_internal_error("unknown tag %d for basic b2", basic_tag(b2));
2002  break;
2003  }
2004  case is_basic_derived:
2005  /* How do you compare a structure or a union to another type?
2006  The only case which seems to make sense is equality. */
2007  pips_internal_error("Derived basic b1 it not comparable to another basic");
2008  break;
2009  case is_basic_typedef:
2010  pips_internal_error("b1 cannot be a typedef basic");
2011  break;
2012  default: pips_internal_error("Ill. basic tag %d", basic_tag(b1));
2013  }
2014  }
2015 
2016  return b;
2017 
2018  /*
2019  if( (t1 != is_basic_complex) && (t1 != is_basic_float) &&
2020  (t1 != is_basic_int) && (t2 != is_basic_complex) &&
2021  (t2 != is_basic_float) && (t2 != is_basic_int) )
2022  pips_internal_error("Bad basic tag for expression in numerical function");
2023 
2024  if(t1 == is_basic_complex)
2025  return(b1);
2026  if(t2 == is_basic_complex)
2027  return(b2);
2028  if(t1 == is_basic_float) {
2029  if( (t2 != is_basic_float) ||
2030  (basic_float(b1) == DOUBLE_PRECISION_SIZE) )
2031  return(b1);
2032  return(b2);
2033  }
2034  if(t2 == is_basic_float)
2035  return(b2);
2036  return(b1);
2037  */
2038 }
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define UUINT(i)
Definition: newgen_types.h:99
intptr_t _int
_INT
Definition: newgen_types.h:53
#define UU
Definition: newgen_types.h:98
bool entity_enum_p(entity e)
Definition: entity.c:968
basic basic_maximum(basic fb1, basic fb2)
Definition: type.c:1816
basic basic_ultimate(basic b)
get the ultimate basic from a basic typedef
Definition: type.c:1806
_int SizeOfElements(basic)
This function returns the length in bytes of the Fortran or C type represented by a basic,...
Definition: size.c:297
@ is_basic_derived
Definition: ri.h:579
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_bit
Definition: ri.h:577
@ is_basic_pointer
Definition: ri.h:578
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
@ is_basic_logical
Definition: ri.h:573
@ is_basic_typedef
Definition: ri.h:580
@ is_basic_complex
Definition: ri.h:575
#define basic_complex_p(x)
Definition: ri.h:626
#define basic_int_p(x)
Definition: ri.h:614
#define basic_tag(x)
Definition: ri.h:613
#define basic_overloaded_p(x)
Definition: ri.h:623
#define basic_undefined
Definition: ri.h:556
#define basic_logical(x)
Definition: ri.h:622
#define basic_bit(x)
Definition: ri.h:634
#define basic_string_p(x)
Definition: ri.h:629
#define basic_bit_p(x)
Definition: ri.h:632
#define basic_logical_p(x)
Definition: ri.h:620
#define basic_float_p(x)
Definition: ri.h:617
s1
Definition: set.c:247

References 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_equal_p(), type_variable, type_variable_p, type_void_p, UU, UUINT, and variable_basic.

Referenced by _expression_similar_p(), basic_maximum(), basic_of_expressions(), basic_of_intrinsic(), basic_union(), do_group_basics_maximum_reduce(), intrinsic_call_to_type(), and ppt_math().

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

◆ basic_of_any_expression()

basic basic_of_any_expression ( expression  exp,
bool  apply_p 
)
Parameters
expxp
apply_ppply_p

Definition at line 1364 of file type.c.

1365 {
1366  return some_basic_of_any_expression(exp, apply_p, true);
1367 }
basic some_basic_of_any_expression(expression exp, bool apply_p, bool ultimate_p)
basic basic_of_any_expression(expression exp, bool apply_p): Makes a basic of the same basic as the e...
Definition: type.c:1258
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References exp, and some_basic_of_any_expression().

Referenced by basic_of_expression(), and some_basic_of_any_expression().

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

◆ basic_of_any_reference()

basic basic_of_any_reference ( reference  r,
bool  apply_p,
bool  ultimate_p 
)

Retrieves the basic of a reference in a newly allocated basic object.

Parameters
rreference we want the basic of
Returns
allocated basic of the reference

When called from the parser, the entity type may not yet be stored in the field type. This happens when simplify_C_expression is called for initialization expressions which are grouped in one statement.

BC : if the variable has dimensions, then it's an array name which is converted into a pointer itself. And each dimension is converted into a pointer on the next one. (except in a few cases which should be handled in basic_of_call) to be verified or done

A reference to a function returns a pointer to a function of the very same time

Parameters
apply_ppply_p
ultimate_pltimate_p

Definition at line 1395 of file type.c.

1395  {
1396  basic b = basic_undefined;
1397  entity v = reference_variable(r);
1398  type vt = entity_type(v);
1399 
1400  /* When called from the parser, the entity type may not yet be
1401  stored in the field type. This happens when
1402  simplify_C_expression is called for initialization
1403  expressions which are grouped in one statement. */
1404  if(!type_undefined_p(vt)) {
1405  type exp_type = ultimate_p ? ultimate_type(vt) : copy_type(entity_type(v));
1406  list l_dim = NIL;
1407 
1408  if(apply_p) {
1409  if(!type_functional_p(exp_type))
1410  pips_internal_error("Bad reference type tag %d \"%s\"",
1411  type_tag(exp_type));
1412  else {
1413  type rt = functional_result(type_functional(exp_type));
1414  type urt = ultimate_p ? ultimate_type(rt) : copy_type(rt);
1415 
1416  if(type_variable_p(urt))
1418  else {
1419  pips_internal_error("Unexpected type tag %s", type_to_string(urt));
1420  }
1421  }
1422  } else {
1423  if(type_variable_p(exp_type)) {
1424  b = copy_basic(variable_basic(type_variable(exp_type)));
1425 
1426  /* BC : if the variable has dimensions, then it's an array name which is converted
1427  into a pointer itself. And each dimension is converted into a pointer on the next one.
1428  (except in a few cases which should be handled in basic_of_call)
1429  to be verified or done
1430  */
1431 
1432  for (l_dim = variable_dimensions(type_variable(exp_type)); !ENDP(l_dim); POP(l_dim)) {
1433  b
1435  }
1436  } else if(type_functional_p(exp_type)) {
1437  /* A reference to a function returns a pointer to a function of the very same time */
1438  b = make_basic_pointer(copy_type(exp_type));
1439  } else {
1440  pips_internal_error("Bad reference type tag %d \"%s\"",
1441  type_tag(exp_type), type_to_string(exp_type));
1442  }
1443  }
1445  reference_indices(r),
1446  ultimate_p);
1447  }
1448  return b;
1449 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
basic make_basic_pointer(type _field_)
Definition: ri.c:179
static basic basic_and_indices_to_basic(basic b, list indices, bool ultimate_p)
BEGIN_EOLE.
Definition: type.c:1209
string type_to_string(const type t)
type.c
Definition: type.c:51
#define functional_result(x)
Definition: ri.h:1444
#define reference_variable(x)
Definition: ri.h:2326
#define type_functional(x)
Definition: ri.h:2952
#define type_undefined_p(x)
Definition: ri.h:2884
#define reference_indices(x)
Definition: ri.h:2328

References basic_and_indices_to_basic(), basic_undefined, copy_basic(), copy_type(), ENDP, entity_type, functional_result, make_basic_pointer(), make_type_variable(), make_variable(), NIL, pips_internal_error, POP, reference_indices, reference_variable, type_functional, type_functional_p, type_tag, type_to_string(), type_undefined_p, type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by basic_of_reference(), and some_basic_of_any_expression().

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

◆ basic_of_call()

basic basic_of_call ( call  c,
bool  apply_p,
bool  ultimate_p 
)

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...

Parameters
apply_ppply_p
ultimate_pltimate_p

Definition at line 1469 of file type.c.

1470 {
1471  entity e = call_function(c);
1472  tag t = value_tag(entity_initial(e));
1473  basic b = basic_undefined;
1474 
1475  switch (t)
1476  {
1477  case is_value_code:
1478  b = copy_basic(basic_of_external(c));
1479  break;
1480  case is_value_intrinsic:
1481  b = basic_of_intrinsic(c, apply_p, ultimate_p);
1482  break;
1483  case is_value_symbolic:
1484  /* b = make_basic(is_basic_overloaded, UU); */
1485  b = copy_basic(basic_of_constant(c));
1486  break;
1487  case is_value_constant:
1488  b = copy_basic(basic_of_constant(c));
1489  break;
1490  case is_value_unknown:
1491  pips_debug(1, "function %s has no initial value.\n"
1492  " Maybe it has not been parsed yet.\n",
1493  entity_name(e));
1494  b = copy_basic(basic_of_external(c));
1495  break;
1496  default: pips_internal_error("unknown tag %d", t);
1497  /* Never go there... */
1498  }
1499  return b;
1500 }
int tag
TAG.
Definition: newgen_types.h:92
basic basic_of_external(call c)
basic basic_of_external(call c): returns the basic of the result given by the call to an external fun...
Definition: type.c:1509
basic basic_of_constant(call c)
basic basic_of_constant(call c): returns the basic of the call to a constant.
Definition: type.c:1763
basic basic_of_intrinsic(call c, bool apply_p, bool ultimate_p)
basic basic_of_intrinsic(call c): returns the basic of the result given by call to an intrinsic funct...
Definition: type.c:1555
#define value_tag(x)
Definition: ri.h:3064
#define call_function(x)
Definition: ri.h:709
@ is_value_intrinsic
Definition: ri.h:3034
@ is_value_unknown
Definition: ri.h:3035
@ is_value_constant
Definition: ri.h:3033
@ is_value_code
Definition: ri.h:3031
@ is_value_symbolic
Definition: ri.h:3032
#define entity_name(x)
Definition: ri.h:2790
#define entity_initial(x)
Definition: ri.h:2796

References basic_of_constant(), basic_of_external(), basic_of_intrinsic(), basic_undefined, call_function, copy_basic(), entity_initial, entity_name, is_value_code, is_value_constant, is_value_intrinsic, is_value_symbolic, is_value_unknown, pips_debug, pips_internal_error, and value_tag.

Referenced by c_user_function_call_to_transformer(), commutative_call_p(), fortran_user_function_call_to_transformer(), some_basic_of_any_expression(), and type_this_call().

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

◆ basic_of_constant()

basic basic_of_constant ( call  c)

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 1763 of file type.c.

1764 {
1765  type call_type, return_type;
1766 
1767  debug(7, "basic_of_constant", "Constant call\n");
1768 
1769  call_type = entity_type(call_function(c));
1770 
1771  if (type_tag(call_type) != is_type_functional)
1772  pips_internal_error("Bad call type tag");
1773 
1774  return_type = functional_result(type_functional(call_type));
1775 
1776  if (type_tag(return_type) != is_type_variable)
1777  pips_internal_error("Bad return call type tag");
1778 
1779  return(variable_basic(type_variable(return_type)));
1780 }
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
@ is_type_functional
Definition: ri.h:2901

References call_function, debug(), entity_type, functional_result, is_type_functional, is_type_variable, pips_internal_error, type_functional, type_tag, type_variable, and variable_basic.

Referenced by basic_of_call(), and call_to_type().

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

◆ basic_of_expression()

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 or a C functional pointer initialization. For C, a pointer to a functional should be/is returned.

WARNING: a new basic object is allocated

PREFER (???) expression_basic

Parameters
expxp

Definition at line 1383 of file type.c.

1384 {
1385  return basic_of_any_expression(exp, false);
1386 }
basic basic_of_any_expression(expression exp, bool apply_p)
Definition: type.c:1364

References basic_of_any_expression(), and exp.

Referenced by _expression_similar_p(), 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_expressions(), basic_of_intrinsic(), basic_union(), condition_to_transformer(), consecutive_expression_p(), do_atomize_call(), do_convert_to_standard_operators(), do_linearize_expression_is_pointer(), do_linearize_pointer_is_expression(), do_loop_expansion(), do_loop_nest_unswitching(), do_simplify_c_operator(), fortran_user_call_to_transformer(), get_optimal_opcode(), get_type_max_width(), integer_expression_p(), inv_call_flt(), logical_binary_function_to_transformer(), make_substitution(), MakeComplexConstantExpression(), MemberIdentifierToExpression(), outliner_extract_loop_bound(), partial_eval_minus_c_operator(), partial_eval_plus_c_operator(), precondition_minmax_of_expression(), reorder_pointer_expression(), simd_atomize_this_expression(), simd_fill_curArgType_call(), simplify_C_expression(), simplify_complex_expression(), simplify_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().

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

◆ basic_of_expressions()

basic basic_of_expressions ( list  expressions,
bool  skip_overloaded 
)
Parameters
expressionsxpressions
skip_overloadedkip_overloaded

Definition at line 2040 of file type.c.

2041 {
2042  if(ENDP(expressions)) return basic_undefined;
2043  else if(ENDP(CDR(expressions))) return basic_of_expression(EXPRESSION(CAR(expressions)));
2044  else {
2045  basic out = basic_of_expression(EXPRESSION(CAR(expressions)));
2046  FOREACH(EXPRESSION,exp,CDR(expressions)) {
2048  if(skip_overloaded && basic_overloaded_p(out)) {
2049  free_basic(out);
2050  out=b;
2051  }
2052  else if( skip_overloaded && basic_overloaded_p(b)) {
2053  free_basic(b);
2054  }
2055  else {
2056  basic tmp =basic_maximum(out,b);
2057  free_basic(b);
2058  free_basic(out);
2059  out=tmp;
2060  }
2061  }
2062  return out;
2063  }
2064 }
static FILE * out
Definition: alias_check.c:128
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
basic basic_of_expression(expression exp)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
Definition: type.c:1383
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References basic_maximum(), basic_of_expression(), basic_overloaded_p, basic_undefined, CAR, CDR, ENDP, exp, EXPRESSION, FOREACH, free_basic(), and out.

Referenced by get_vect_name_from_data(), and make_loadsave_statement().

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

◆ basic_of_external()

basic basic_of_external ( call  c)

basic basic_of_external(call c): returns the basic of the result given by the call to an external function.

WARNING: returns a pointer

support calling a function pointer :)

pips_debug(7, "Returned type is %s\n", basic_to_string(b));

Definition at line 1509 of file type.c.

1510 {
1511  type return_type = type_undefined;
1512  entity f = call_function(c);
1513  basic b = basic_undefined;
1514  type call_type = entity_type(f);
1515 
1516 
1517  pips_debug(7, "External call to %s\n", entity_name(f));
1518 
1519  /* support calling a function pointer :) */
1520  type ut = ultimate_type(call_type);
1521  if(type_variable_p(ut) &&
1524 
1525  if (! type_functional_p(ut) )
1526  pips_internal_error("Bad call type tag");
1527 
1528  return_type = functional_result(type_functional(ut));
1529 
1530  if (!type_variable_p(return_type)) {
1531  if(type_void_p(return_type)) {
1532  pips_user_error("A subroutine or void returning function is used as an expression\n");
1533  }
1534  else {
1535  pips_internal_error("Bad return call type tag \"%s\"", type_to_string(return_type));
1536  }
1537  }
1538 
1539  b = (variable_basic(type_variable(return_type)));
1540 
1541  /* pips_debug(7, "Returned type is %s\n", basic_to_string(b)); */
1542 
1543  return b;
1544 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15

References basic_pointer, basic_pointer_p, basic_undefined, call_function, entity_name, entity_type, f(), functional_result, pips_debug, pips_internal_error, pips_user_error, type_functional, type_functional_p, type_to_string(), type_undefined, type_variable, type_variable_p, type_void_p, ultimate_type(), and variable_basic.

Referenced by basic_of_call(), and call_to_type().

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

◆ basic_of_intrinsic()

basic basic_of_intrinsic ( call  c,
bool  apply_p,
bool  ultimate_p 
)

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 accommodate 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

pips_debug(7, "Intrinsic call to intrinsic \"s" with a priori result type "s"
",

module_local_name(f),

basic_to_string(rb));

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

consider int a[12][13] is of type int (*)[13]

Too bad for "void"... SG: should not happen because dereferencing a void* is a mistake

consider int a[12][13] is of type int (*)[13]

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?

ifdebug(8) {

pips_debug(8, "Point to case, e1 = ");

print_expression(e1);

pips_debug(8, " and e2 = ");

print_expression(e1);

pips_debug(8, "\n");

}

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.

This must be a pointer difference. Else, the parser would have used ENTITY_MINUS (see simplify_C_expression()).

logical variables can be used as integer arguments

pips_debug(7, "Intrinsic call to intrinsic \"s" with a posteriori result type "s"
",

module_local_name(f),

basic_to_string(rb));

Parameters
apply_ppply_p
ultimate_pltimate_p

Definition at line 1555 of file type.c.

1556 {
1557  entity f = call_function(c);
1559  pips_assert("not calling basic_of_intrinsic on something returning void",!type_void_p(rt));
1561 
1562  /* pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a priori result type \"%s\"\n", */
1563  /* module_local_name(f), */
1564  /* basic_to_string(rb)); */
1565 
1566  if(basic_overloaded_p(rb)) {
1567  list args = call_arguments(c);
1568 
1569  if (ENDP(args)) {
1570  /* I don't know the type since there is no arguments !
1571  Bug encountered with a FMT=* in a PRINT.
1572  RK, 21/02/1994 : */
1573  /* leave it overloaded */
1574  ;
1575  }
1576  else if(ENTITY_ADDRESS_OF_P(f)) {
1577  //string s = entity_user_name(f);
1578  //bool b = ENTITY_ADDRESS_OF_P(f);
1579  expression e = EXPRESSION(CAR(args));
1580  basic eb = some_basic_of_any_expression(e, false, ultimate_p);
1581  // Forget multidimensional types
1583  make_variable(eb, NIL, NIL));
1584 
1585  //fprintf(stderr, "b=%d, s=%s\n", b, s);
1586  free_basic(rb);
1587  rb = make_basic(is_basic_pointer, et);
1588  }
1589  else if(ENTITY_DEREFERENCING_P(f)) {
1590  expression e = EXPRESSION(CAR(args));
1591  free_basic(rb);
1592  rb = basic_of_expression(e);
1593  if(basic_pointer_p(rb)) {
1594  type pt = type_undefined;
1595 
1596  if(ultimate_p && !type_undefined_p(basic_pointer(rb)))
1598  else
1599  pt = copy_type(basic_pointer(rb));
1600 
1601  pips_assert("The pointed type is consistent", type_consistent_p(pt));
1602  if(type_undefined_p(pt)) {
1603  /* Too bad, this may happen in the parser */
1604  free_basic(rb);
1605  rb = basic_undefined;
1606  }
1607  else if(type_variable_p(pt) && !apply_p) {
1608  free_basic(rb);
1609  variable v = type_variable(pt);
1610  if(ENDP(variable_dimensions(v)))
1611  rb = copy_basic(variable_basic(v));
1612  else {
1613  /* consider int a[12][13] is of type int (*)[13]*/
1614  rb = make_basic_pointer(
1616  make_variable(
1620  )
1621  )
1622  );
1623  }
1624  }
1625  else if(type_functional_p(pt)) {
1626  if(apply_p) {
1627  free_basic(rb);
1629  if(type_variable_p(rt))
1631  else {
1632  /* Too bad for "void"...
1633  * SG: should not happen because dereferencing a void* is a mistake */
1634  pips_internal_error("input code seems to derference a void* pointer ?");
1635  }
1636  }
1637  else {
1638  return rb;
1639  }
1640  }
1641  else {
1642  pips_internal_error("unhandled case");
1643  }
1644  }
1645  else {
1646  type et = call_to_type(c);
1647  if(ultimate_p) et=ultimate_type(et);
1648  if( type_variable_p(et) )
1649  {
1650  variable v=type_variable(et);
1651  free_basic(rb);
1652  if(ENDP(variable_dimensions(v)))
1653  rb = copy_basic(variable_basic(v));
1654  else {
1655  /* consider int a[12][13] is of type int (*)[13]*/
1656  rb = make_basic_pointer(
1658  make_variable(
1662  )
1663  )
1664  );
1665  }
1666  }
1667  if( !type_variable_p(et) ) {
1668 
1669  /* This can also be a user error, but if the function is
1670  called from the parser, a CParserError() should be called:
1671  how to guess what to do? */
1672  pips_internal_error("Dereferencing of a non-pointer, non array expression"
1673  "Please use gcc to check that your source code is legal\n");
1674  }
1675  if(ultimate_p) free_type(et);
1676  }
1677  }
1678  else if(ENTITY_POINT_TO_P(f)) {
1679  //pips_internal_error("Point to case not implemented yet");
1680  //expression e1 = EXPRESSION(CAR(args));
1681  expression e2 = EXPRESSION(CAR(CDR(args)));
1682  free_basic(rb);
1683  pips_assert("Two arguments for ENTITY_POINT_TO", gen_length(args)==2);
1684  // FI: to avoid cycles betwen librairies ri-util and prettyprint
1685  /* ifdebug(8) { */
1686  /* pips_debug(8, "Point to case, e1 = "); */
1687  /* print_expression(e1); */
1688  /* pips_debug(8, " and e2 = "); */
1689  /* print_expression(e1); */
1690  /* pips_debug(8, "\n"); */
1691  /* } */
1692  rb = basic_of_expression(e2);
1693  }
1694  else if(ENTITY_BRACE_INTRINSIC_P(f)) {
1695  /* We should reconstruct a struct type or an array type... */
1696  rb = make_basic_overloaded();
1697  }
1698  else if(ENTITY_ASSIGN_P(f)) {
1699  /* returns the type of the left hand side */
1700  rb = basic_of_expression(EXPRESSION(CAR(args)));
1701  }
1702  else if(ENTITY_FIELD_P(f)) {
1703  free_basic(rb);
1704  rb = basic_of_expression(EXPRESSION(CAR(CDR(args))));
1705  }
1706  else if(ENTITY_COMMA_P(f)) {
1707  /* The value returned is the value of the last expression in the list. */
1708  free_basic(rb);
1710  }
1711  else if(ENTITY_CONDITIONAL_P(f)) {
1712  /* The value returned is the value of the first expression in
1713  the list after the condition. The second expression is
1714  assumed to have the same value because the code is assumed
1715  correct. */
1716  free_basic(rb);
1717  rb = basic_of_expression(EXPRESSION(CAR(CDR(args))));
1718  }
1719  else if(ENTITY_MINUS_C_P(f)) {
1720  /* This must be a pointer difference. Else, the parser
1721  would have used ENTITY_MINUS (see
1722  simplify_C_expression()). */
1723  free_basic(rb);
1725  }
1726  else {
1727  free_basic(rb);
1728  // FI: within declaration initializations, rb may be
1729  // undefined because the expressions uses a variable that
1730  // has not yet been typed by the parser. See C_syntax/simplify01.c
1731  rb = basic_of_expression(EXPRESSION(CAR(args)));
1732 
1733  FOREACH(EXPRESSION, arg, CDR(args)){
1734  basic b = basic_of_expression(arg);
1735  basic new_rb = basic_maximum(rb, b);
1736 
1737  free_basic(rb);
1738  free_basic(b);
1739  rb = new_rb;
1740  }
1741  /* logical variables can be used as integer arguments */
1742  if(!basic_undefined_p(rb) && basic_logical_p(rb))
1743  if(arithmetic_intrinsic_p(f)) {
1744  free_basic(rb);
1746  }
1747  }
1748 
1749  }
1750 
1751  /* pips_debug(7, "Intrinsic call to intrinsic \"%s\" with a posteriori result type \"%s\"\n", */
1752  /* module_local_name(f), */
1753  /* basic_to_string(rb)); */
1754 
1755  return rb;
1756 }
basic make_basic_overloaded(void)
Definition: ri.c:167
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
bool type_consistent_p(type p)
Definition: ri.c:2664
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define ENTITY_ASSIGN_P(e)
#define ENTITY_COMMA_P(e)
#define ENTITY_DEREFERENCING_P(e)
#define DEFAULT_INTEGER_TYPE_SIZE
#define ENTITY_POINT_TO_P(e)
#define ENTITY_BRACE_INTRINSIC_P(e)
C initialization expression.
#define ENTITY_CONDITIONAL_P(e)
#define ENTITY_FIELD_P(e)
C data structure and pointer management.
#define ENTITY_MINUS_C_P(e)
#define ENTITY_ADDRESS_OF_P(e)
bool arithmetic_intrinsic_p(entity e)
true if e is an arithmetic instrinsic
Definition: entity.c:1702
type call_to_type(call c)
Definition: type.c:2313
#define basic_undefined_p(x)
Definition: ri.h:557
#define variable_qualifiers(x)
Definition: ri.h:3124
#define call_arguments(x)
Definition: ri.h:711

References arithmetic_intrinsic_p(), basic_logical_p, basic_maximum(), basic_of_expression(), basic_overloaded_p, basic_pointer, basic_pointer_p, basic_undefined, basic_undefined_p, call_arguments, call_function, call_to_type(), CAR, CDR, copy_basic(), copy_type(), DEFAULT_INTEGER_TYPE_SIZE, 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_MINUS_C_P, ENTITY_POINT_TO_P, entity_type, EXPRESSION, f(), FOREACH, free_basic(), free_type(), functional_result, gen_full_copy_list(), gen_last(), gen_length(), is_basic_pointer, is_type_variable, make_basic(), make_basic_int(), make_basic_overloaded(), make_basic_pointer(), make_type(), make_type_variable(), make_variable(), NIL, pips_assert, pips_internal_error, some_basic_of_any_expression(), type_consistent_p(), type_functional, type_functional_p, type_undefined, type_undefined_p, type_variable, type_variable_p, type_void_p, ultimate_type(), variable_basic, variable_dimensions, and variable_qualifiers.

Referenced by basic_of_call().

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

◆ basic_of_reference()

basic basic_of_reference ( reference  r)

Retrieves the basic of a reference in a newly allocated basic object.

Parameters
rreference we want the basic of
Returns
allocated basic of the reference

Definition at line 1459 of file type.c.

1459  {
1460  return basic_of_any_reference(r,false,true);
1461 }
basic basic_of_any_reference(reference r, bool apply_p, bool ultimate_p)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1395

References basic_of_any_reference().

Referenced by build_new_ref(), distance_between_expression(), generate_prelude(), generate_scalar_variables(), generate_scalar_variables_from_list(), get_sizeofexpression_for_region(), get_type_max_width(), make_reduction_vector_entity(), make_substitution(), match_expression(), my_build_new_ref(), process_true_call_stat(), rename_statement_reductions(), and variables_width_filter().

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

◆ basic_supporting_entities()

list basic_supporting_entities ( list  sel,
set  vt,
basic  b 
)
Parameters
selel
vtt

Definition at line 4211 of file type.c.

4212 {
4213 
4214  ifdebug(8) {
4215  pips_debug(8, "Begin: ");
4216  print_entities(sel);
4217  fprintf(stderr, "\n\n");
4218  }
4219 
4220  if(basic_int_p(b) ||
4221  basic_float_p(b) ||
4222  basic_logical_p(b) ||
4223  basic_overloaded_p(b) ||
4224  basic_complex_p(b) ||
4225  basic_string_p(b))
4226  ;
4227  else if(basic_bit_p(b))
4228  sel = symbolic_supporting_entities(sel, vt, basic_bit(b));
4229  else if(basic_pointer_p(b))
4231  else if(basic_derived_p(b)) {
4232  //sel = CONS(ENTITY, basic_derived(b), sel);
4234  sel = gen_nconc(sel, CONS(ENTITY, basic_derived(b), NIL));
4235  }
4236  else if(basic_typedef_p(b)) {
4237  entity se = basic_typedef(b);
4238  //sel = CONS(ENTITY, se, sel);
4239  sel = recursive_type_supporting_entities(sel, vt, entity_type(se));
4240  sel = gen_nconc(sel, CONS(ENTITY, se, NIL));
4241  }
4242  else
4243  pips_internal_error("Unrecognized basic tag %d", basic_tag(b));
4244 
4245  ifdebug(8) {
4246  pips_debug(8, "End: ");
4247  print_entities(sel);
4248  fprintf(stderr, "\n\n");
4249  }
4250 
4251  return sel;
4252 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
void print_entities(list l)
Definition: entity.c:167
list symbolic_supporting_entities(list sel, set vt, symbolic s)
C version.
Definition: type.c:4206
list recursive_type_supporting_entities(list sel, set vt, type t)
Definition: type.c:4283
#define basic_typedef(x)
Definition: ri.h:643
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

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().

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

◆ basic_supporting_references()

list basic_supporting_references ( list  srl,
basic  b 
)

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4519 of file type.c.

4520 {
4521 
4522  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4523  /* ifdebug(9) { */
4524  /* pips_debug(8, "Begin: "); */
4525  /* print_references(srl); */
4526  /* fprintf(stderr, "\n"); */
4527  /* } */
4528 
4529  if(basic_int_p(b) ||
4530  basic_float_p(b) ||
4531  basic_logical_p(b) ||
4532  basic_overloaded_p(b) ||
4533  basic_complex_p(b) ||
4534  basic_string_p(b))
4535  ;
4536  else if(basic_bit_p(b))
4538  else if(basic_pointer_p(b))
4540  else if(basic_derived_p(b)) {
4541  //srl = CONS(ENTITY, basic_derived(b), srl);
4543  }
4544  else if(basic_typedef_p(b)) {
4545  entity se = basic_typedef(b);
4546  //srl = CONS(ENTITY, se, srl);
4548  }
4549  else
4550  pips_internal_error("Unrecognized basic tag %d", basic_tag(b));
4551 
4552  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4553  /* ifdebug(9) { */
4554  /* pips_debug(8, "End: "); */
4555  /* print_references(srl); */
4556  /* fprintf(stderr, "\n"); */
4557  /* } */
4558 
4559  return srl;
4560 }
static list recursive_type_supporting_references(list srl, type t)
Compute the list of references implied in the definition of a type.
Definition: type.c:4638
list symbolic_supporting_references(list srl, symbolic s)
Definition: type.c:4512

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, pips_internal_error, recursive_type_supporting_references(), and symbolic_supporting_references().

Referenced by variable_type_supporting_references().

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

◆ basic_supporting_types()

static list basic_supporting_types ( list  stl,
set  vt,
basic  b 
)
static

Definition at line 5071 of file type.c.

5072 {
5073 
5074  ifdebug(8) {
5075  pips_debug(8, "Begin: ");
5076  print_entities(stl);
5077  fprintf(stderr, "\n");
5078  }
5079 
5080  if(basic_int_p(b) ||
5081  basic_float_p(b) ||
5082  basic_logical_p(b) ||
5083  basic_overloaded_p(b) ||
5084  basic_complex_p(b) ||
5085  basic_string_p(b))
5086  ;
5087  else if(basic_bit_p(b))
5088  ;
5089  else if(basic_pointer_p(b))
5091  else if(basic_derived_p(b)) {
5092  entity de = basic_derived(b);
5093  type dt = entity_type(de);
5094  stl = CONS(ENTITY, de, stl);
5095  stl = recursive_type_supporting_types(stl, vt, dt);
5096  }
5097  else if(basic_typedef_p(b)) {
5098  entity se = basic_typedef(b);
5099  type st = entity_type(se);
5100  stl = CONS(ENTITY, se, stl);
5101  stl = recursive_type_supporting_entities(stl, vt, st);
5102  }
5103  else
5104  pips_internal_error("Unrecognized basic tag %d", basic_tag(b));
5105 
5106  ifdebug(8) {
5107  pips_debug(8, "End: ");
5108  print_entities(stl);
5109  fprintf(stderr, "\n");
5110  }
5111 
5112  return stl;
5113 }
static list recursive_type_supporting_types(list stl, set vt, type t)
Compute the list of types implied in the definition of a type.
Definition: type.c:5137

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().

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

◆ basic_to_generic_conversion()

entity basic_to_generic_conversion ( basic  b)

returns the corresponding generic conversion entity, if any.

otherwise returns entity_undefined.

what about INTEGER*{2,4,8} ?

Definition at line 2758 of file type.c.

2759 {
2760  entity result;
2761 
2762  switch (basic_tag(b))
2763  {
2764  case is_basic_int:
2765  /* what about INTEGER*{2,4,8} ?
2766  */
2768  break;
2769  case is_basic_float:
2770  {
2771  if (basic_float(b)==4)
2773  else if (basic_float(b)==8)
2775  else
2776  result = entity_undefined;
2777  break;
2778  }
2779  case is_basic_complex:
2780  {
2781  if (basic_complex(b)==8)
2783  else if (basic_complex(b)==16)
2785  else
2786  result = entity_undefined;
2787  break;
2788  }
2789  default:
2790  result = entity_undefined;
2791  }
2792 
2793  return result;
2794 }
#define DBLE_GENERIC_CONVERSION_NAME
#define DCMPLX_GENERIC_CONVERSION_NAME
#define CMPLX_GENERIC_CONVERSION_NAME
#define INT_GENERIC_CONVERSION_NAME
generic conversion names.
#define REAL_GENERIC_CONVERSION_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
#define entity_undefined
Definition: ri.h:2761
#define basic_float(x)
Definition: ri.h:619
#define basic_complex(x)
Definition: ri.h:628

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().

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

◆ basic_type_p()

bool basic_type_p ( type  t)

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 types Returns 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 2912 of file type.c.

2913 {
2914  if (type_variable_p(t))
2915  {
2917  return ((variable_dimensions(type_variable(t)) == NIL) &&
2918  (basic_int_p(b) || basic_float_p(b) || basic_logical_p(b)
2920  || basic_bit_p(b)));
2921  }
2922  return (type_void_p(t) || type_unknown_p(t)) ;
2923 }
#define type_unknown_p(x)
Definition: ri.h:2956

References 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().

+ Here is the caller graph for this function:

◆ basic_type_size()

int basic_type_size ( basic  b)

See also SizeOfElements()

pips_internal_error("undefined for type string");

Definition at line 1074 of file type.c.

1075 {
1076  int size = -1;
1077 
1078  switch(basic_tag(b)) {
1079  case is_basic_int: size = basic_int(b);
1080  break;
1081  case is_basic_float: size = basic_float(b);
1082  break;
1083  case is_basic_logical: size = basic_logical(b);
1084  break;
1085  case is_basic_overloaded:
1086  pips_internal_error("undefined for type overloaded");
1087  break;
1088  case is_basic_complex: size = basic_complex(b);
1089  break;
1090  case is_basic_string:
1091  /* pips_internal_error("undefined for type string"); */
1092  size = string_type_size(b);
1093  break;
1094  case is_basic_pointer:
1096  break;
1097  default: size = basic_int(b);
1098  pips_internal_error("ill. tag %d", basic_tag(b));
1099  break;
1100  }
1101 
1102  return size;
1103 }
#define DEFAULT_POINTER_TYPE_SIZE
int string_type_size(basic b)
Definition: type.c:1047
#define basic_int(x)
Definition: ri.h:616

References basic_complex, basic_float, basic_int, basic_logical, basic_tag, DEFAULT_POINTER_TYPE_SIZE, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, pips_internal_error, and string_type_size().

Referenced by change_basic_if_needed(), DeclareVariable(), get_c_full_name(), get_type_max_width(), loadstore_type_conversion_string(), MakeAtom(), MakeComplexConstant(), MakeComplexConstantExpression(), and match_expression().

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

◆ basic_ultimate()

basic basic_ultimate ( basic  b)

get the ultimate basic from a basic typedef

Definition at line 1806 of file type.c.

1807 {
1808  if(basic_typedef_p(b)) {
1810  pips_assert("typedef really has a variable type", type_variable_p(t) );
1811  b = variable_basic(type_variable(t));
1812  }
1813  return b;
1814 }

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().

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

◆ basic_union()

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

Parameters
exp1xp1
exp2xp2

Definition at line 1792 of file type.c.

1793 {
1794  basic b1 = basic_of_expression(exp1);
1795  basic b2 = basic_of_expression(exp2);
1796  basic b = basic_maximum(b1, b2);
1797 
1798  free_basic(b1);
1799  free_basic(b2);
1800  return b;
1801 }

References b1, b2, basic_maximum(), basic_of_expression(), and free_basic().

+ Here is the call graph for this function:

◆ bit_type_p()

bool bit_type_p ( type  t)

Definition at line 2843 of file type.c.

2844 {
2845  if (!type_undefined_p(t) && type_variable_p(t))
2846  {
2848  if (!basic_undefined_p(b) && basic_bit_p(b))
2849  return true;
2850  }
2851  return false;
2852 }

References basic_bit_p, basic_undefined_p, 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().

+ Here is the caller graph for this function:

◆ C_pointer_type_p()

bool C_pointer_type_p ( type  t)

Returns OK for "char[]" as well as for "char *".

And do not forget "string" for PIPS internal representation.

Does not take care of typedef. Use compute_basic_concrete_type() first is necessary.

Definition at line 3011 of file type.c.

3012 {
3013  bool pointer_p = false;
3014  if(type_variable_p(t)) {
3015  variable v = type_variable(t);
3016  list dl = variable_dimensions(v);
3017  basic b = variable_basic(v);
3018  pointer_p = (ENDP(dl) && basic_pointer_p(b))
3019  || (ENDP(dl) && basic_string_p(b))
3020  || ((int)gen_length(dl)==1 && unbounded_dimension_p(DIMENSION(CAR(dl))));
3021  }
3022  return pointer_p;
3023 }
bool unbounded_dimension_p(dimension dim)
bool unbounded_dimension_p(dim) input : a dimension of an array entity.
Definition: expression.c:1130

References basic_pointer_p, basic_string_p, CAR, DIMENSION, ENDP, gen_length(), type_variable, type_variable_p, unbounded_dimension_p(), variable_basic, and variable_dimensions.

Referenced by formal_source_to_sinks(), intrinsic_call_to_points_to(), list_assignment_to_points_to(), points_to_cell_types_compatibility(), points_to_reference_to_typed_index(), reduce_cell_to_pointer_type(), and source_to_sinks().

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

◆ C_type_to_pointed_type()

type C_type_to_pointed_type ( type  t)

returns a copy of t if t is not a pointer type, and the pointed type if t is a pointer type or.

Type definitions are replaced. If t is undefined, returns a type_undefined.

A new type is always allocated.

Definition at line 5288 of file type.c.

5289 {
5290  type upt = type_undefined;
5291 
5292  if(!type_undefined_p(t)) {
5293  type ut = ultimate_type(t);
5294  type pt = ut;
5295 
5296  if(pointer_type_p(ut))
5298  else if(array_type_p(ut)) {
5299  variable v = type_variable(t);
5300  list dl = variable_dimensions(v);
5301  basic b = variable_basic(v);
5302  if((int)gen_length(dl)==1 && unbounded_dimension_p(DIMENSION(CAR(dl)))) {
5304  }
5305  }
5306 
5307  if(!type_undefined_p(pt))
5308  upt = ultimate_type(pt);
5309  }
5310  return upt;
5311 }

References array_type_p(), basic_pointer, CAR, copy_basic(), copy_type(), DIMENSION, gen_length(), make_type_variable(), make_variable(), NIL, pointer_type_p(), type_undefined, type_undefined_p, type_variable, ultimate_type(), unbounded_dimension_p(), variable_basic, and variable_dimensions.

Referenced by create_stub_points_to(), and points_to_reference_to_typed_index().

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

◆ call_compatible_type()

type call_compatible_type ( type  t)

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 3791 of file type.c.

3792 {
3793  type compatible = t;
3794 
3795  pips_assert("t is a consistent type", type_consistent_p(t));
3796 
3797  if(!type_functional_p(t)) {
3798  if(type_variable_p(t)) {
3800 
3801  if(basic_pointer_p(b))
3802  compatible = call_compatible_type(basic_pointer(b));
3803  else if(basic_typedef_p(b)) {
3804  entity te = basic_typedef(b);
3805 
3806  compatible = call_compatible_type(entity_type(te));
3807  }
3808  else
3809  compatible = false;
3810  }
3811  else
3812  compatible = false;
3813  }
3814  pips_assert("compatible is a functional type", type_functional_p(compatible));
3815  pips_assert("compatible is a consistent type", type_consistent_p(compatible));
3816  return compatible;
3817 }
type call_compatible_type(type t)
returns the type necessary to generate or check a call to an object of type t.
Definition: type.c:3791

References basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, call_compatible_type(), entity_type, 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().

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

◆ call_compatible_type_p()

bool call_compatible_type_p ( type  t)

end of basic_concrete_types

Is an object of type t compatible with a call?

Definition at line 3764 of file type.c.

3765 {
3766  bool compatible_p = true;
3767 
3768  if(!type_functional_p(t)) {
3769  if(type_variable_p(t)) {
3771 
3772  if(basic_pointer_p(b))
3773  compatible_p = call_compatible_type_p(basic_pointer(b));
3774  else if(basic_typedef_p(b)) {
3775  entity te = basic_typedef(b);
3776 
3777  compatible_p = call_compatible_type_p(entity_type(te));
3778  }
3779  else
3780  compatible_p = false;
3781  }
3782  else
3783  compatible_p = false;
3784  }
3785  return compatible_p;
3786 }
bool call_compatible_type_p(type t)
end of basic_concrete_types
Definition: type.c:3764

References basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, call_compatible_type_p(), entity_type, type_functional_p, type_variable, type_variable_p, and variable_basic.

Referenced by call_compatible_type_p(), check_C_function_type(), and MakeFunctionExpression().

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

◆ call_to_functional_type()

type call_to_functional_type ( call  c,
bool  ultimate_p 
)

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

Parameters
ultimate_pltimate_p

Definition at line 3824 of file type.c.

3825 {
3826  entity f = call_function(c);
3827  type ft = entity_type(f);
3828  type rt = type_undefined;
3829 
3830  if(type_functional_p(ft))
3831  rt = entity_type(f);
3832  else if(type_variable_p(ft)) {
3833  basic ftb = variable_basic(type_variable(ft));
3834  if(basic_pointer_p(ftb)) {
3835  type pt = basic_pointer(ftb);
3836  rt = ultimate_p? ultimate_type(pt) : copy_type(pt);
3837  }
3838  else if(basic_typedef_p(ftb)) {
3839  entity te = basic_typedef(ftb);
3840  type ut = ultimate_type(entity_type(te));
3841 
3842  if(type_variable_p(ut)) {
3843  basic utb = variable_basic(type_variable(ut));
3844  if(basic_pointer_p(utb)) {
3845  type pt = basic_pointer(utb);
3846  rt = ultimate_p? ultimate_type(pt): copy_type(pt);
3847  }
3848  else
3849  /* assertion will fail anyway */
3850  free_type(ut);
3851  }
3852  else /* must be a functional type */
3853  rt = ut;
3854  }
3855  else {
3856  pips_internal_error("Basic for called function unknown");
3857  }
3858  }
3859  else
3860  pips_internal_error("Type for called function unknown");
3861 
3862  pips_assert("The typedef type is functional", type_functional_p(rt));
3863 
3864  return rt;
3865 }

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, type_functional_p, type_undefined, type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by MemberIdentifierToExpression(), and simplify_C_expression().

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

◆ call_to_type()

type call_to_type ( call  c)

b = make_basic(is_basic_overloaded, UU);

Never go there...

Definition at line 2313 of file type.c.

2314 {
2315  entity e = call_function(c);
2316  type t = type_undefined;
2317 
2318  switch (value_tag(entity_initial(e)))
2319  {
2320  case is_value_code:
2323  NIL, NIL));
2324  break;
2325  case is_value_intrinsic:
2326  t = intrinsic_call_to_type(c);
2327  break;
2328  case is_value_symbolic:
2329  /* b = make_basic(is_basic_overloaded, UU); */
2332  NIL, NIL));
2333  break;
2334  case is_value_constant:
2337  NIL, NIL));
2338  break;
2339  case is_value_unknown:
2340  pips_debug(1, "function %s has no initial value.\n"
2341  " Maybe it has not been parsed yet.\n",
2342  entity_name(e));
2345  NIL, NIL));
2346  break;
2347  default: pips_internal_error("unknown tag %d", t);
2348  /* Never go there... */
2349  }
2350 
2351  return t;
2352 }
type intrinsic_call_to_type(call c)
END_EOLE.
Definition: type.c:2080

References basic_of_constant(), basic_of_external(), call_function, copy_basic(), 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().

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

◆ char_star_constant_function_type_p()

bool char_star_constant_function_type_p ( type  t)

Beware of typedefs.

Beware of string_type_p()... Strictly speaking, string_type_p() should not be taken into acount.

Definition at line 5787 of file type.c.

5788 {
5789  bool char_star_p = false;
5790  if(type_functional_p(t)) {
5792  type rt = functional_result(f);
5793  char_star_p = char_star_type_p(rt) || string_type_p(rt);
5794  }
5795  return char_star_p;
5796 }
bool char_star_type_p(type t)
Beware of typedefs.
Definition: type.c:5774

References char_star_type_p(), f(), functional_result, string_type_p(), type_functional, and type_functional_p.

Referenced by check_type_of_points_to_cells(), expression_to_points_to_cells(), expression_to_points_to_sources(), new_recursive_filter_formal_context_according_to_actual_context(), offset_cell(), points_to_translation_mapping_is_typed_p(), and points_to_with_stripped_sink().

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

◆ char_star_type_p()

bool char_star_type_p ( type  t)

Beware of typedefs.

Definition at line 5774 of file type.c.

5775 {
5776  bool char_star_p = false;
5777  if(pointer_type_p(t)) {
5778  type pt = type_to_pointed_type(t);
5779  char_star_p = char_type_p(pt);
5780  }
5781  return char_star_p;
5782 }
bool char_type_p(type t)
return true whether ‘t’ is a char or an unsigned char
Definition: type.c:2877

References char_type_p(), pointer_type_p(), and type_to_pointed_type().

Referenced by char_star_constant_function_type_p(), declaration_statement_to_points_to(), expression_to_points_to_cells(), expression_to_points_to_sources(), and intrinsic_call_to_points_to().

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

◆ char_type_p()

bool char_type_p ( type  t)

return true whether ‘t’ is a char or an unsigned char

see words_basic()

Definition at line 2877 of file type.c.

2878 {
2879  bool is_char = false;
2880 
2881  if (!type_undefined_p(t) && type_variable_p(t)) {
2883  if (!basic_undefined_p(b) && basic_int_p(b)) {
2884  int i = basic_int(b);
2885  is_char = (i==1)||(i==11); /* see words_basic() */
2886  }
2887  }
2888  return is_char;
2889 }

References basic_int, basic_int_p, basic_undefined_p, type_undefined_p, type_variable, type_variable_p, and variable_basic.

Referenced by char_star_type_p(), check_type_of_points_to_cells(), points_to_translation_mapping_is_typed_p(), points_to_with_stripped_sink(), and SizeOfArray().

+ Here is the caller graph for this function:

◆ check_C_function_type()

bool check_C_function_type ( entity  f,
list  args 
)

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()".

Use parms to improve the type of f, probably declared f() with no type information.

Should be very similar to call_to_functional_type().

ifdebug(8) {

text txt = c_text_entity(get_current_module_entity(), f, 0, NIL);

print_text(stderr, txt);

}

Must be a typedef or a pointer to a function. No need to refine the type

ifdebug(8) {

text txt = c_text_entity(get_current_module_entity(), f, 0, NIL);

pips_debug(8, "Type not updated for function \"s"
", entity_user_name(f));

print_text(stderr, txt);

}

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.

Parameters
argsrgs

Definition at line 4716 of file type.c.

4717 {
4718  bool ok = true;
4719  type t = entity_type(f);
4720  type ct = call_compatible_type(t);
4722 
4723  pips_assert("f can be used to generate a call", call_compatible_type_p(t));
4724 
4725  if(ENDP(parms)) {
4726  if(ENDP(args))
4727  ;
4728  else {
4729  if(type_functional_p(t)) {
4730  /* Use parms to improve the type of f, probably declared f()
4731  with no type information. */
4732  /* Should be very similar to call_to_functional_type(). */
4733  list pl = NIL;
4734  MAP(EXPRESSION, e, {
4735  type et = expression_to_user_type(e);
4737  pl = gen_nconc(pl, CONS(PARAMETER, p, NIL));
4738  },
4739  args);
4741 
4745  }
4746 
4747  pips_user_warning("Type updated for function \"%s\"\n", entity_user_name(f));
4748  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4749  /* ifdebug(8) { */
4750  /* text txt = c_text_entity(get_current_module_entity(), f, 0, NIL); */
4751  /* print_text(stderr, txt); */
4752  /* } */
4753  }
4754  else {
4755  /* Must be a typedef or a pointer to a function. No need to refine the type*/
4756  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4757  /* ifdebug(8) { */
4758  /* text txt = c_text_entity(get_current_module_entity(), f, 0, NIL); */
4759  /* pips_debug(8, "Type not updated for function \"%s\"\n", entity_user_name(f)); */
4760  /* print_text(stderr, txt); */
4761  /* } */
4762  }
4763  }
4764  }
4765  else if(gen_length(args)!=gen_length(parms)) {
4766  /* Take care of the void case */
4767  if(gen_length(args)==0 && gen_length(parms)==1) {
4768  parameter p = PARAMETER(CAR(parms));
4769  type pt = parameter_type(p);
4770  ok = type_void_p(pt);
4771  }
4772  /* Take care of the varargs case*/
4773  else if(gen_length(parms) >= 2 && gen_length(args) > gen_length(parms)) {
4774  parameter lp = PARAMETER(CAR(gen_last(parms)));
4775  type pt = parameter_type(lp);
4776  ok = type_varargs_p(pt);
4777  }
4778  else
4779  ok = false;
4780  }
4781  else {
4782  /* Check type compatibility: find function in flint?
4783  type_equal_p() requires lots of extensions to handle C
4784  types. And you would probably need type conversion to concrete
4785  type.*/
4786  ;
4787  }
4788 
4789  return ok;
4790 }
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
dummy make_dummy_unknown(void)
Definition: ri.c:617
mode make_mode_value(void)
Definition: ri.c:1353
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define pips_user_warning
Definition: misc-local.h:146
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
type expression_to_user_type(expression e)
Preserve typedef'ed types when possible.
Definition: type.c:2645
#define parameter_type(x)
Definition: ri.h:1819
#define functional_parameters(x)
Definition: ri.h:1442
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define type_varargs_p(x)
Definition: ri.h:2953
static bool ok

References call_compatible_type(), call_compatible_type_p(), CAR, CONS, DEFAULT_INTEGER_TYPE_SIZE, ENDP, entity_type, entity_user_name(), EXPRESSION, expression_to_user_type(), f(), functional_parameters, functional_result, gen_last(), gen_length(), gen_nconc(), 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_user_warning, pl, type_functional, type_functional_p, type_unknown_p, type_varargs_p, and type_void_p.

Referenced by MakeFunctionExpression().

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

◆ compare_basic_p()

static bool compare_basic_p ( basic  b1,
basic  b2,
bool  same_p 
)
static

Used to implement the next two functions.

Take care of typedefs

Definition at line 933 of file type.c.

934 {
935  bool compare_p = false;
936 
937  /* Take care of typedefs */
938  if( basic_typedef_p(b1) )
939  {
941  if(type_variable_p(t1))
943  else // for instance, void
945  }
946 
947  if( basic_typedef_p(b2) )
948  {
950  if(type_variable_p(t2))
952  else // for instance, void
954  }
955 
957  if(same_p)
958  compare_p = basic_equal_p(b1,b2);
959  else
960  compare_p = (basic_tag(b1)==basic_tag(b2));
961  }
962  else
963  compare_p = false;
964 
965  return compare_p;
966 }

References b1, b2, basic_equal_p(), basic_tag, basic_typedef, basic_typedef_p, basic_undefined, basic_undefined_p, entity_type, type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by compatible_basic_p(), and same_basic_p().

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

◆ compatible_basic_p()

bool compatible_basic_p ( basic  b1,
basic  b2 
)

check if two basics are similar.

That is if they are equal modulo typedefs and modulo the precision. For instance, "int" and "unsigned int" and "long int" are all considered compatible.

Parameters
b11
b22

Definition at line 978 of file type.c.

979 {
980  return compare_basic_p(b1,b2, false);
981 }
static bool compare_basic_p(basic b1, basic b2, bool same_p)
Used to implement the next two functions.
Definition: type.c:933

References b1, b2, and compare_basic_p().

Referenced by c_user_function_call_to_transformer().

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

◆ compute_basic_concrete_type()

type compute_basic_concrete_type ( type  t)

computes a new type which is the basic concrete type of the input type (this new type is not stored in the entity_types_to_bctypes table).

Parameters
tis a type
Returns
: a new type in which typedefs have been expanded to reach a basic concrete type, except for struct, union, and enum because the inner types of the fields cannot be changed (they are entities).

pips_debug(8, "Begin with type \"s"
",

words_to_string(words_type(t, NIL, false)));

pips_debug(9, "of basic \"s"and number of dimensions d.
",

basic_to_string(bt),

(int) gen_length(lt));

pips_debug(8, "Ends with type \"s"
",

words_to_string(words_type(nt, NIL, false)));

ifdebug(9)

{

if(type_variable_p(nt))

{

variable nvt = type_variable(nt);

basic nbt = variable_basic(nvt);

list nlt = variable_dimensions(nvt);

pips_debug(9, "of basic \"s"and number of dimensions d.
",

basic_to_string(nbt),

(int) gen_length(nlt));

}

}

pips_assert("nt is not a typedef", type_variable_p(nt)? !basic_typedef_p(variable_basic(type_variable(nt))) : true);

Definition at line 3556 of file type.c.

3557 {
3558  type nt;
3559  debug_on("RI-UTIL_DEBUG_LEVEL");
3560 
3561  // FI: to avoid cycles betwen librairies ri-util and prettyprint
3562  /* pips_debug(8, "Begin with type \"%s\"\n", */
3563  /* words_to_string(words_type(t, NIL, false))); */
3564 
3565  switch (type_tag(t))
3566  {
3567  case is_type_variable:
3568  {
3569  variable vt = type_variable(t);
3570  basic bt = variable_basic(vt);
3571  list lt = variable_dimensions(vt);
3572 
3573  /* pips_debug(9, "of basic \"%s\"and number of dimensions %d.\n", */
3574  /* basic_to_string(bt), */
3575  /* (int) gen_length(lt)); */
3576 
3577  if(basic_typedef_p(bt))
3578  {
3579  entity e = basic_typedef(bt);
3581 
3582  pips_debug(9, "typedef : %s\n", type_to_string(st));
3583  if (type_variable_p(st))
3584  {
3585  nt = st;
3589  }
3590  else if (type_void_p(st))
3591  {
3592  if (ENDP(lt))
3593  nt = st;
3594  else
3595  {
3596  nt = copy_type(t);
3597  free_type(st);
3598  }
3599  }
3600  else if (type_struct_p(st) || type_union_p(st) || type_enum_p(st))
3601  {
3603  gen_full_copy_list(lt),
3605  free_type(st);
3606  }
3607  else
3608  {
3609  free_type(st);
3610  nt = copy_type(t);
3611  }
3612  }
3613  else if(basic_pointer_p(bt))
3614  {
3616 
3617  pips_debug(9, "pointer \n");
3618  nt = make_type_variable
3620  gen_full_copy_list(lt),
3622  }
3623  else
3624  {
3625  pips_debug(9, "other variable case \n");
3626  // Normalize the dimensions which may contain unevaluated
3627  // constant expressions
3628  // nt = copy_type(t);
3629  variable v = type_variable(t);
3630  list ql = variable_qualifiers(v);
3631  list nql = gen_full_copy_list(ql);
3632  list dl = variable_dimensions(v);
3634  basic b = variable_basic(v);
3635  basic nb = copy_basic(b);
3636  variable nv = make_variable(nb, ndl, nql);
3637  nt = make_type_variable(nv);
3638  }
3639  }
3640  break;
3641 
3642  default:
3643  nt = copy_type(t);
3644  }
3645 
3646  // FI: to avoid cycles betwen librairies ri-util and prettyprint
3647  /* pips_debug(8, "Ends with type \"%s\"\n", */
3648  /* words_to_string(words_type(nt, NIL, false))); */
3649  /* ifdebug(9) */
3650  /* { */
3651  /* if(type_variable_p(nt)) */
3652  /* { */
3653  /* variable nvt = type_variable(nt); */
3654  /* basic nbt = variable_basic(nvt); */
3655  /* list nlt = variable_dimensions(nvt); */
3656  /* pips_debug(9, "of basic \"%s\"and number of dimensions %d.\n", */
3657  /* basic_to_string(nbt), */
3658  /* (int) gen_length(nlt)); */
3659  /* } */
3660  /* } */
3661 
3662  /* pips_assert("nt is not a typedef",
3663  type_variable_p(nt)?
3664  !basic_typedef_p(variable_basic(type_variable(nt))) : true); */
3665  debug_off();
3666  return nt;
3667 }
basic make_basic_derived(entity _field_)
Definition: ri.c:182
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
list dimensions_to_normalized_dimensions(list dl)
evaluate constant expressions appearing in dimensions of list dl
Definition: type.c:3528
type compute_basic_concrete_type(type t)
computes a new type which is the basic concrete type of the input type (this new type is not stored i...
Definition: type.c:3556
#define type_enum_p(x)
Definition: ri.h:2968
#define type_union_p(x)
Definition: ri.h:2965

References basic_pointer, basic_pointer_p, basic_typedef, basic_typedef_p, compute_basic_concrete_type(), copy_basic(), copy_type(), debug_off, debug_on, dimensions_to_normalized_dimensions(), ENDP, entity_type, free_type(), gen_full_copy_list(), gen_nconc(), is_type_variable, make_basic_derived(), make_basic_pointer(), make_type_variable(), make_variable(), pips_debug, type_enum_p, type_struct_p, type_tag, type_to_string(), type_union_p, type_variable, type_variable_p, type_void_p, variable_basic, variable_dimensions, and variable_qualifiers.

Referenced by adapt_reference_to_type(), analyzed_type_p(), any_source_to_sinks(), any_user_call_site_to_transformer(), anywhere_source_to_sinks(), assignment_to_points_to(), c_return_to_transformer(), cast_to_points_to_sinks(), check_rhs_value_types(), check_type_of_points_to_cells(), compute_basic_concrete_type(), concrete_array_pointer_type_equal_p(), concrete_type_equal_p(), declaration_statement_to_points_to(), derived_formal_parameter_to_stub_points_to(), entity_basic_concrete_type(), entity_flow_or_context_sentitive_heap_location(), eval_linear_expression(), expression_to_concrete_type(), expression_to_points_to_cells(), expression_to_points_to_sources(), expression_to_transformer(), external_call_to_post_pv(), formal_source_to_sinks(), freed_list_to_points_to(), generic_function_to_return_value(), generic_substitute_formal_array_elements_in_transformer(), have_null_value_in_pointer_expression_p(), module_to_value_mappings(), offset_cell(), pointer_expression_to_transformer(), points_to_cell_to_concrete_type(), points_to_cell_types_compatibility(), points_to_expression_to_concrete_type(), points_to_expression_to_pointed_type(), points_to_function_projection(), points_to_reference_to_concrete_type(), points_to_source_to_translations(), points_to_translation_of_struct_formal_parameter(), process_casted_sinks(), reference_add_field_dimension(), sizeofexpression_to_points_to_sinks(), struct_initialization_to_points_to(), struct_reference_assignment_or_equality_to_transformer(), substitute_stubs_in_transformer(), types_compatible_for_effects_interprocedural_translation_p(), user_call_to_points_to_sinks(), and words_points_to_reference().

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

◆ concrete_array_pointer_type_equal_p()

bool concrete_array_pointer_type_equal_p ( type  t1,
type  t2 
)

Same as above, but resolve typedefs first.

Parameters
t11
t22

Definition at line 700 of file type.c.

701 {
704  bool equal_p = array_pointer_type_equal_p(ct1, ct2);
705  // Basic concrete types are memoized in a hash-table.
706  // They should not be freed (see corresponding functions)
707  // free_type(ct1), free_type(ct2);
708  return equal_p;
709 }

References array_pointer_type_equal_p(), and compute_basic_concrete_type().

Referenced by type_compatible_with_points_to_cell_p().

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

◆ concrete_type_equal_p()

bool concrete_type_equal_p ( type  t1,
type  t2 
)

Expand typedefs before the type comparison.

Parameters
t11
t22

Definition at line 571 of file type.c.

572 {
575  bool equal_p = generic_type_equal_p(ct1, ct2, false, true, hash_table_undefined);
576  free_type(ct1), free_type(ct2);
577  return equal_p;
578 }
static bool generic_type_equal_p(type t1, type t2, bool strict_p, bool qualifier_p, hash_table structural_table)
Warning: the lengths of string basics are not checked!!! string_type_size() could be used but it is p...
Definition: type.c:483

References compute_basic_concrete_type(), free_type(), generic_type_equal_p(), and hash_table_undefined.

+ Here is the call graph for this function:

◆ constant_expression_supporting_entities()

list constant_expression_supporting_entities ( list  sel,
set  vt,
expression  e 
)

C version.

Parameters
selel
vtt

Definition at line 4181 of file type.c.

4182 {
4183  return generic_constant_expression_supporting_entities(sel, vt, e, true);
4184 }
list generic_constant_expression_supporting_entities(list sel, set vt, expression e, bool language_c_p)
Definition: type.c:4058

References generic_constant_expression_supporting_entities().

Referenced by enum_supporting_entities(), and variable_type_supporting_entities().

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

◆ constant_expression_supporting_references()

list constant_expression_supporting_references ( list  srl,
expression  e 
)

Only applicable to C expressions.

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

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.

Forward the inner expression

do nothing for the time being...

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4451 of file type.c.

4452 {
4453  syntax s = expression_syntax(e);
4454 
4455  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4456  /* ifdebug(9) { */
4457  /* pips_debug(8, "Begin: "); */
4458  /* print_references(srl); */
4459  /* fprintf(stderr, "\n"); */
4460  /* } */
4461 
4462  if(syntax_call_p(s)) {
4463  call c = syntax_call(s);
4464  entity f = call_function(c);
4465 
4467  /* We need to know if we are dealing with C or Fortran code. */
4468  /* In C, f cannot be declared directly, we need its enum */
4469  /* But in Fortran, we are done */
4470  /* FI: suggested kludge: use a Fortran incompatible type for
4471  enum member. But currently they are four byte signed integer (c89)
4472  and this Fortran INTEGER type :-( */
4473 
4474  entity e_of_f = find_enum_of_member(f);
4475  //srl = CONS(ENTITY, e_of_f, srl);
4476  srl = enum_supporting_references(srl, e_of_f);
4477  }
4478 
4479  MAP(EXPRESSION, se, {
4481  }, call_arguments(c));
4482  }
4483  else if(syntax_reference_p(s)) {
4484  reference r = syntax_reference(s);
4485  list inds = reference_indices(r);
4486  /* Could be guarded so as not to be added twice. Guard might be
4487  useless with because types are visited only once. */
4488  srl = gen_nconc(srl, CONS(REFERENCE, r, NIL));
4489  MAP(EXPRESSION, se, {
4491  }, inds);
4492  }
4493  else if(syntax_cast_p(s)) {
4494  /* Forward the inner expression */
4497  } else {
4498  /* do nothing for the time being... */
4499  ;
4500  }
4501 
4502  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4503  /* ifdebug(9) { */
4504  /* pips_debug(8, "End: "); */
4505  /* print_references(srl); */
4506  /* fprintf(stderr, "\n"); */
4507  /* } */
4508 
4509  return srl;
4510 }
entity find_enum_of_member(entity m)
Definition: entity.c:2713
list constant_expression_supporting_references(list srl, expression e)
Only applicable to C expressions.
Definition: type.c:4451
list enum_supporting_references(list srl, entity e)
Definition: type.c:4415
bool symbolic_constant_entity_p(entity)
BEGIN_EOLE.
Definition: variable.c:83
#define syntax_reference_p(x)
Definition: ri.h:2728
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_call_p(x)
Definition: ri.h:2734
#define syntax_cast(x)
Definition: ri.h:2739
#define cast_expression(x)
Definition: ri.h:747
#define syntax_call(x)
Definition: ri.h:2736
#define syntax_cast_p(x)
Definition: ri.h:2737
#define expression_syntax(x)
Definition: ri.h:1247

References call_arguments, call_function, cast_expression, CONS, constant_expression_supporting_references(), enum_supporting_references(), EXPRESSION, expression_syntax, f(), find_enum_of_member(), gen_nconc(), MAP, NIL, REFERENCE, reference_indices, symbolic_constant_entity_p(), syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, syntax_reference, and syntax_reference_p.

Referenced by constant_expression_supporting_references(), enum_supporting_references(), symbolic_supporting_references(), and variable_type_supporting_references().

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

◆ declarable_type_p()

bool declarable_type_p ( type  t,
list  pdl 
)

Are all types necessary to define fully type "t" listed in list "pdl"?

This function is used by the prettyprinter to decide if a derived type can be fully defined or if its definition should wait.

Parameters
pdldl

Definition at line 4361 of file type.c.

4362 {
4363  list stl = type_supporting_entities(NIL, t);
4364  bool declarable_p = true;
4365 
4366  FOREACH(ENTITY, e, stl) {
4367  if(typedef_entity_p(e)) {
4368  if(!gen_in_list_p(e, pdl)) {
4369  declarable_p = false;
4370  break;
4371  }
4372  }
4373  }
4374  return declarable_p;
4375 }
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
bool typedef_entity_p(entity e)
Definition: entity.c:1902
list type_supporting_entities(list sel, type t)
Definition: type.c:4347

References ENTITY, FOREACH, gen_in_list_p(), NIL, type_supporting_entities(), and typedef_entity_p().

Referenced by c_text_related_entities(), and generic_c_words_simplified_entity().

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

◆ default_complex_type_p()

bool default_complex_type_p ( type  t)

Definition at line 3246 of file type.c.

3247 {
3248  bool default_complex_p = false;
3249  if(!type_undefined_p(t) && type_variable_p(t)) {
3250  variable v = type_variable(t);
3251  basic b = variable_basic(v);
3252  if(basic_complex_p(b)) {
3253  int s = basic_int(b);
3254 
3255  default_complex_p = ENDP(variable_dimensions(v))
3256  && ENDP(variable_qualifiers(v))
3257  && s == DEFAULT_COMPLEX_TYPE_SIZE;
3258  }
3259  }
3260  return default_complex_p;
3261 }
#define DEFAULT_COMPLEX_TYPE_SIZE

References basic_complex_p, basic_int, DEFAULT_COMPLEX_TYPE_SIZE, ENDP, type_undefined_p, type_variable, type_variable_p, variable_basic, variable_dimensions, and variable_qualifiers.

◆ dependence_of_dependent_basic()

static list dependence_of_dependent_basic ( basic  b)
static

Definition at line 5907 of file type.c.

5908 {
5909  list dep = NIL;
5910  if(basic_typedef_p(b)) {
5911  entity te = basic_typedef(b);
5912  type t = entity_type(te);
5914  }
5915  else if(basic_derived_p(b)) {
5916  entity de = basic_derived(b);
5917  type dt = entity_type(de);
5918  list fl = NIL; // field list
5919  if(type_struct_p(dt))
5920  fl = type_struct(dt);
5921  else if(type_union_p(dt))
5922  fl = type_union(dt);
5923  FOREACH(ENTITY, fe, fl) {
5924  type ft = entity_type(fe);
5925  dep = dependence_of_dependent_type(ft);
5926  }
5927  }
5928  return dep;
5929 }
list dependence_of_dependent_type(type t)
similar to dependent_type_p but return a list of reference on which the type depend.
Definition: type.c:5942
#define type_struct(x)
Definition: ri.h:2964
#define type_union(x)
Definition: ri.h:2967

References basic_derived, basic_derived_p, basic_typedef, basic_typedef_p, dependence_of_dependent_type(), ENTITY, entity_type, FOREACH, NIL, type_struct, type_struct_p, type_union, and type_union_p.

Referenced by dependence_of_dependent_type().

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

◆ dependence_of_dependent_type()

list dependence_of_dependent_type ( type  t)

similar to dependent_type_p but return a list of reference on which the type depend.

/param t type to analyze /return list of reference on which the type t depend so this list only contains elements as: i,x,n, a[0], a[1], ... and not n+m, 2*n, ... the reference present in this list as to be freed by the caller with gen_full_free_list for instance

Definition at line 5942 of file type.c.

5943 {
5944  list dep = NIL;
5945  if(type_variable_p(t)) {
5946  variable v = type_variable(t);
5947  list dl = variable_dimensions(v);
5948 
5949  FOREACH(DIMENSION, d, dl) {
5950  expression l = dimension_lower(d);
5951  expression u = dimension_upper(d);
5952  //The test is redundant with the gen_recurse
5953  //if(!extended_expression_constant_p(l))
5955 
5956  //The test is redundant with the gen_recurse
5957  //if(!extended_expression_constant_p(u))
5959  }
5960 
5961  basic b = variable_basic(v);
5963  dep = gen_append(dep, ldb);
5964  gen_free_list(ldb);
5965  ldb=NIL;
5966  }
5967 
5968  return dep;
5969 }
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
list gen_append(list l1, const list l2)
Definition: list.c:471
static list dependence_of_dependent_basic(basic b)
Definition: type.c:5907
static void reference_dependence_variable_check_and_add(reference ref, list *dependence_list)
Definition: type.c:5898
#define dimension_lower(x)
Definition: ri.h:980
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define dimension_upper(x)
Definition: ri.h:982

References dependence_of_dependent_basic(), DIMENSION, dimension_lower, dimension_upper, FOREACH, gen_append(), gen_context_recurse, gen_free_list(), gen_true2(), NIL, reference_dependence_variable_check_and_add(), reference_domain, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by dependence_of_dependent_basic().

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

◆ dependent_basic_p()

static bool dependent_basic_p ( basic  b)
static

Definition at line 5872 of file type.c.

5873 {
5874  bool dependent_p = false;
5875  if(basic_typedef_p(b)) {
5876  entity te = basic_typedef(b);
5877  type t = entity_type(te);
5878  dependent_p = dependent_type_p(t);
5879  }
5880  else if(basic_derived_p(b)) {
5881  entity de = basic_derived(b);
5882  type dt = entity_type(de);
5883  list fl = NIL; // field list
5884  if(type_struct_p(dt))
5885  fl = type_struct(dt);
5886  else if(type_union_p(dt))
5887  fl = type_union(dt);
5888  FOREACH(ENTITY, fe, fl) {
5889  type ft = entity_type(fe);
5890  dependent_p = dependent_type_p(ft);
5891  if(dependent_p)
5892  break;
5893  }
5894  }
5895  return dependent_p;
5896 }
bool dependent_type_p(type t)
A type is dependent in many ways according to definitions given in Wikipedia.
Definition: type.c:5849

References basic_derived, basic_derived_p, basic_typedef, basic_typedef_p, dependent_type_p(), ENTITY, entity_type, FOREACH, NIL, type_struct, type_struct_p, type_union, and type_union_p.

Referenced by dependent_type_p().

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

◆ dependent_type_p()

bool dependent_type_p ( type  t)

A type is dependent in many ways according to definitions given in Wikipedia.

Dependent types lead to many issues both theoretical and practical. The semantics of predicate type_equal_p() should be precised.

Here, for practical purposes, we need to know if the storage space required to store a value of a C type is constant and known at compile-time, or if it depends on the environment and the store and must be computed at run-time.

By this definition, functional types are always constant because functions are stored as pointer to functions in C. So in C as in Fortran, only varying dimensions can lead to dependent types. Such variables are called variable-length array (VLA). So this function might be called vla_type_p().

Some VLA are easy to implement and very convenient for the programmer. They have been included very early in Fortran extensions. Hence they have been handled in PIPS for a very long time and are allocated in the STACK_AREA, the DYNAMIC_AREA and Fortran commons being reserved for non variable-length variables.

They were introduced in C99 but relegated to conditional feature in C11 (I kind of remember, due to Microsoft lobbying). Because declarations can be placed anywhere in post C99 code, the implementation of VLA maybe costly. The dimensions must be evaluated and then alignment and packing are performed in situ by the gcc implementation, as well as stack management. For non-VLA variables, gcc seems to perform a pass similar to the flatten code pass or to the clone_statement() function and move all declarations at the begining of the current function (alpha-renaming). So the frame allocation is performed statically, apparently using more space than necessary because variables with disjoint scopes are allocated simultaneously. These implementation issues have been explored by Nelson Lossing.

This predicate is used by passes to check that declarations can be moved/rescheduled (flatten_code, loop_unroll, full_loop_unroll...).

Definition at line 5849 of file type.c.

5850 {
5851  bool dependent_p = false;
5852  if(type_variable_p(t)) {
5853  variable v = type_variable(t);
5854  list dl = variable_dimensions(v);
5855  FOREACH(DIMENSION, d, dl) {
5856  expression l = dimension_lower(d);
5857  expression u = dimension_upper(d);
5860  dependent_p = true;
5861  break;
5862  }
5863  }
5864  if(!dependent_p) {
5865  basic b = variable_basic(v);
5866  dependent_p = dependent_basic_p(b);
5867  }
5868  }
5869  return dependent_p;
5870 }
bool extended_expression_constant_p(expression exp)
Returns true if the value of the expression does not depend syntactically on the current store.
Definition: expression.c:2461
static bool dependent_basic_p(basic b)
Definition: type.c:5872

References dependent_basic_p(), DIMENSION, dimension_lower, dimension_upper, extended_expression_constant_p(), FOREACH, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by dependent_basic_p(), flatten_code(), and unroll().

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

◆ derived_type_fields()

list derived_type_fields ( type  t)
Parameters
tis the entity_type of a basic_derived
Returns
the list of fields of the input type

Definition at line 5354 of file type.c.

5355 {
5356  list l=NIL;
5357 
5358  switch (type_tag(t))
5359  {
5360  case is_type_struct:
5361  l = type_struct(t);
5362  break;
5363  case is_type_union:
5364  l = type_union(t);
5365  break;
5366  case is_type_enum:
5367  l = type_enum(t);
5368  break;
5369  default:
5370  pips_assert("input type is a struct union, or enum\n",
5371  type_struct_p(t) || type_union_p(t) || type_enum_p(t) );
5372  }
5373  return l;
5374 }
#define type_enum(x)
Definition: ri.h:2970
@ is_type_enum
Definition: ri.h:2907
@ is_type_union
Definition: ri.h:2906
@ is_type_struct
Definition: ri.h:2905

References is_type_enum, is_type_struct, is_type_union, NIL, pips_assert, type_enum, type_enum_p, type_struct, type_struct_p, type_tag, type_union, and type_union_p.

Referenced by derived_type_to_fields(), effect_indices_first_pointer_dimension_rank(), and generic_type_equal_p().

+ Here is the caller graph for this function:

◆ derived_type_p()

bool derived_type_p ( type  t)

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;

Note: arrays of struct are not considered derived types

Definition at line 3104 of file type.c.

3105 {
3107  && (variable_dimensions(type_variable(t)) == NIL));
3108 }

References basic_derived_p, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by any_user_call_site_to_transformer(), c_text_entities(), ensure_comment_consistency(), enum_type_p(), generic_c_words_simplified_entity(), struct_type_p(), and union_type_p().

+ Here is the caller graph for this function:

◆ derived_type_to_fields()

list derived_type_to_fields ( type  t)
Parameters
tis a type of kind "variable" with a basic of kind "derived"
Returns
the list of fields of the input type

Definition at line 5381 of file type.c.

5382 {
5383  list l = NIL;
5384  variable v = type_variable(t);
5385  basic b = variable_basic(v);
5386  if(basic_derived_p(b)) {
5387  entity est = basic_derived(b);
5388  type st = entity_type(est);
5389  l = derived_type_fields(st);
5390  }
5391  else
5392  pips_internal_error("Called with an improper argument.\n");
5393  return l;
5394 }
list derived_type_fields(type t)
Definition: type.c:5354

References basic_derived, basic_derived_p, derived_type_fields(), entity_type, NIL, pips_internal_error, type_variable, and variable_basic.

Referenced by any_source_to_sinks(), and struct_variable_to_fields().

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

◆ dimension_dup()

dimension dimension_dup ( dimension  d)

Definition at line 1159 of file type.c.

1160 {
1164 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
#define dimension_qualifiers(x)
Definition: ri.h:984

References copy_expression(), dimension_lower, dimension_qualifiers, dimension_upper, gen_full_copy_list(), and make_dimension().

Referenced by ldimensions_dup().

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

◆ dimension_equal_p()

bool dimension_equal_p ( dimension  d1,
dimension  d2 
)

same values

Parameters
d11
d22

Definition at line 747 of file type.c.

748 {
749  return /* same values */
752 }
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347

References dimension_lower, dimension_upper, and expression_equal_p().

Referenced by dimensions_equal_p(), and generic_variable_equal_p().

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

◆ dimensions_equal_p()

bool dimensions_equal_p ( list  dims1,
list  dims2 
)
Parameters
dims1ims1
dims2ims2

Definition at line 754 of file type.c.

754  {
755  return gen_equals(dims1,dims2,(gen_eq_func_t)dimension_equal_p);
756 }
bool gen_equals(const list l0, const list l1, gen_eq_func_t equals)
compares two lists using the functor given in parameters returns true if for all n,...
Definition: list.c:192
bool(* gen_eq_func_t)(const void *, const void *)
Definition: newgen_types.h:115
bool dimension_equal_p(dimension d1, dimension d2)
Definition: type.c:747

References dimension_equal_p(), and gen_equals().

Referenced by generic_variable_equal_p().

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

◆ dimensions_to_normalized_dimensions()

list dimensions_to_normalized_dimensions ( list  dl)

evaluate constant expressions appearing in dimensions of list dl

Related function: constant_reference_to_normalized_constant_reference()

Parameters
dll

Definition at line 3528 of file type.c.

3529 {
3530  list ndl = NIL;
3531  FOREACH(DIMENSION, d, dl) {
3532  expression l = dimension_lower(d);
3534  expression u = dimension_upper(d);
3536  list ql = dimension_qualifiers(d);
3537  list nql = gen_full_copy_list(ql);
3538  dimension nd = make_dimension(nl, nu, nql);
3539  ndl = CONS(DIMENSION, nd, ndl);
3540  }
3541  ndl = gen_nreverse(ndl);
3542  return ndl;
3543 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
expression normalize_integer_constant_expression(expression e)
Allocate a new expression equivalent to e, but constant expressions are evaluated.
Definition: eval.c:1112

References CONS, DIMENSION, dimension_lower, dimension_qualifiers, dimension_upper, FOREACH, gen_full_copy_list(), gen_nreverse(), make_dimension(), NIL, and normalize_integer_constant_expression().

Referenced by compute_basic_concrete_type().

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

◆ effect_basic_depth()

int effect_basic_depth ( basic  b)

Definition at line 4985 of file type.c.

4986 {
4987  int d = 0;
4988 
4989  switch(basic_tag(b)) {
4990  case is_basic_int:
4991  case is_basic_float:
4992  case is_basic_logical:
4993  case is_basic_overloaded:
4994  case is_basic_complex:
4995  case is_basic_string:
4996  case is_basic_bit:
4997  break;
4998  case is_basic_pointer:
4999  {
5000  d = effect_type_depth(basic_pointer(b))+1;
5001  break;
5002  }
5003  case is_basic_derived:
5004  {
5005  entity e = basic_derived(b);
5006  type t = entity_type(e);
5007  d = type_depth(t);
5008  break;
5009  }
5010  case is_basic_typedef:
5011  {
5012  entity e = basic_typedef(b);
5013  type t = entity_type(e);
5014 
5015  d = type_depth(t);
5016  break;
5017  }
5018  default:
5019  pips_internal_error("Unexpected basic tag %d", basic_tag(b));
5020  }
5021 
5022  return d;
5023 }
size_t type_depth(type t)
Number of steps to access the lowest leave of type t without dereferencing.
Definition: type.c:4880
int effect_type_depth(type t)
Number of steps to access the lowest leave of type t.
Definition: type.c:4948

References basic_derived, basic_pointer, basic_tag, basic_typedef, 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().

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

◆ effect_type_depth()

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)

This is equivalent to type_depth when property POINTS_TO_STRICT_POINTER_TYPES is set to false (FI).

Definition at line 4948 of file type.c.

4949 {
4950  int d = 0;
4951 
4952  if(type_variable_p(t)) {
4953  variable v = type_variable(t);
4954 
4956  }
4957  else if(type_void_p(t))
4958  d = 0;
4959  else if(type_varargs_p(t))
4960  d = 0;
4961  else if(type_struct_p(t)) {
4962  list fl = type_struct(t);
4963  d = 0;
4964  FOREACH(ENTITY, e, fl) {
4965  int i = type_depth(entity_type(e));
4966  d = d>i?d:i;
4967  }
4968  d++;
4969  }
4970  else if(type_union_p(t)) {
4971  list fl = type_union(t);
4972  d = 0;
4973  FOREACH(ENTITY, e, fl) {
4974  int i = type_depth(entity_type(e));
4975  d = d>i?d:i;
4976  }
4977  d++;
4978  }
4979  else if(type_enum_p(t))
4980  d = 0;
4981 
4982  return d;
4983 }
int effect_basic_depth(basic b)
Definition: type.c:4985

References effect_basic_depth(), ENTITY, entity_type, FOREACH, gen_length(), 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, variable_basic, and variable_dimensions.

Referenced by effect_basic_depth().

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

◆ entity_basic_concrete_type()

type entity_basic_concrete_type ( entity  e)

retrieves or computes and then returns the basic concrete type of an entity

Parameters
eis the input entity
Returns
the basic concrete type of e stored in the entity_types_to_bctypes table.

@beware don't free this type, it will be freed by pipsmake when resetting the table.

Definition at line 3677 of file type.c.

3678 {
3679  debug_on("RI-UTIL_DEBUG_LEVEL");
3680  pips_assert("types_to_bctypes must be defined", !hash_table_undefined_p(entity_types_to_bctypes));
3681  type t = entity_type(e);
3682  type bct = (type) hash_get(entity_types_to_bctypes, (void *) t);
3683 
3684  if (type_undefined_p(bct))
3685  {
3686  bct = compute_basic_concrete_type(t);
3688  }
3689  debug_off();
3690  return bct;
3691 }
struct _newgen_struct_type_ * type
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define hash_table_undefined_p(h)
Definition: newgen_hash.h:50
static hash_table entity_types_to_bctypes
Definition: type.c:3496

References compute_basic_concrete_type(), debug_off, debug_on, entity_type, entity_types_to_bctypes, hash_get(), hash_put(), hash_table_undefined_p, pips_assert, and type_undefined_p.

Referenced by abstract_locations_max(), add_inter_or_intraprocedural_field_entities(), add_intraprocedural_value_entities(), add_type_information(), analyzable_scalar_entity_p(), analyzed_array_p(), analyzed_basic_p(), analyzed_entity_p(), analyzed_struct_p(), analyzed_struct_type_p(), any_source_to_sinks(), any_user_call_site_to_transformer(), array_location_entity_of_module_p(), assign_rhs_to_reflhs_to_transformer(), basic_concrete_type_leads_to_pointer_p(), basic_concrete_types_compatible_for_effects_interprocedural_translation_p(), binary_intrinsic_call_to_points_to_sinks(), c_convex_effects_on_actual_parameter_forward_translation(), c_return_to_transformer(), cell_reference_to_type(), complete_points_to_reference_with_fixed_subscripts(), compute_points_to_binded_set(), compute_points_to_gen_set(), create_stub_entity(), declaration_statement_to_points_to(), declaration_to_post_pv(), dereferencing_subscript_to_points_to(), dereferencing_to_points_to(), dimensions_to_transformer(), effect_indices_first_pointer_dimension_rank(), effect_reference_first_pointer_dimension_rank(), entities_maymust_conflict_p(), entity_non_pointer_scalar_p(), expression_to_points_to(), FILE_star_effect_reference_p(), formal_source_to_sinks(), generic_function_to_return_value(), generic_make_entity_copy_with_new_name(), generic_points_to_cell_to_useful_pointer_cells(), generic_points_to_cells_translation(), generic_reference_to_transformer(), generic_substitute_formal_array_elements_in_transformer(), global_source_to_sinks(), memory_dereferencing_p(), module_initial_parameter_pv(), module_to_value_mappings(), new_recursive_filter_formal_context_according_to_actual_context(), offset_cell(), perform_array_element_substitutions_in_transformer(), pointer_reference_to_expression(), pointer_source_to_sinks(), points_to_array_reference_p(), points_to_array_reference_to_type(), points_to_cells_parameters(), points_to_function_projection(), points_to_set_block_projection(), points_to_translation_of_formal_parameters(), points_to_translation_of_struct_formal_parameter(), r_cell_reference_to_type(), recursive_cell_to_pointer_cells(), recursive_store_independent_points_to_reference_p(), reference_add_field_dimension(), reference_complete_with_zero_subscripts(), reference_condition_to_points_to(), reference_dereferencing_to_points_to(), reference_to_complexity(), reference_to_points_to(), reference_to_points_to_sinks(), reference_to_points_to_translations(), reference_to_type(), sequence_to_post_pv(), source_to_sinks(), split_initializations_in_statement(), store_independent_effect_p(), store_independent_points_to_reference_p(), struct_assignment_to_points_to(), struct_variable_to_fields(), substitute_struct_stub_in_transformer(), substitute_stubs_in_transformer(), substitute_stubs_in_transformer_with_translation_binding(), transformer_apply_field_assignments_or_equalities(), transformer_apply_unknown_field_assignments_or_equalities(), user_call_to_points_to(), user_call_to_points_to_sinks(), variable_to_abstract_location(), variable_to_pointer_locations(), and words_points_to_reference().

+ Here is the call graph for this function:

◆ entity_basic_concrete_types_init()

void entity_basic_concrete_types_init ( void  )

Definition at line 3507 of file type.c.

3508 {
3509  pips_assert("types_to_bctypes must be undefined", hash_table_undefined_p(entity_types_to_bctypes));
3511 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32
#define BCTYPES_TABLE_INIT_SIZE
basic_concrete_types
Definition: type.c:3495

References BCTYPES_TABLE_INIT_SIZE, entity_types_to_bctypes, hash_pointer, hash_table_make(), hash_table_undefined_p, and pips_assert.

Referenced by set_current_phase_context().

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

◆ entity_basic_concrete_types_reset()

void entity_basic_concrete_types_reset ( void  )

First, free all basic concrete types

Definition at line 3513 of file type.c.

3514 {
3515  /* First, free all basic concrete types */
3517  {
3518  free_type(t4);
3519  }
3522 }
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define HASH_FOREACH(key_type, k, value_type, v, ht)
Definition: newgen_hash.h:71

References entity_types_to_bctypes, free_type(), HASH_FOREACH, hash_table_free(), and hash_table_undefined.

Referenced by reset_current_phase_context().

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

◆ enum_supporting_entities()

list enum_supporting_entities ( list  sel,
set  vt,
entity  e 
)
Parameters
selel
vtt

Definition at line 4025 of file type.c.

4026 {
4027  type t = entity_type(e);
4028  list ml = type_enum(t);
4029  list cm = list_undefined;
4030 
4031  pips_assert("type is of enum kind", type_enum_p(t));
4032 
4033  ifdebug(8) {
4034  pips_debug(8, "Begin: ");
4035  print_entities(sel);
4036  fprintf(stderr, "\n\n");
4037  }
4038 
4039  for(cm = ml; !ENDP(cm); POP(cm)) {
4040  entity m = ENTITY(CAR(cm));
4041  value v = entity_initial(m);
4042  symbolic s = value_symbolic(v);
4043 
4044  pips_assert("m is an enum member", value_symbolic_p(v));
4045 
4047  }
4048 
4049  ifdebug(8) {
4050  pips_debug(8, "End: ");
4051  print_entities(sel);
4052  fprintf(stderr, "\n\n");
4053  }
4054 
4055  return sel;
4056 }
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
list constant_expression_supporting_entities(list sel, set vt, expression e)
C version.
Definition: type.c:4181
#define value_symbolic(x)
Definition: ri.h:3070
#define value_symbolic_p(x)
Definition: ri.h:3068
#define symbolic_expression(x)
Definition: ri.h:2597

References CAR, constant_expression_supporting_entities(), ENDP, ENTITY, entity_initial, entity_type, fprintf(), ifdebug, list_undefined, pips_assert, pips_debug, POP, print_entities(), symbolic_expression, type_enum, type_enum_p, value_symbolic, and value_symbolic_p.

Referenced by generic_constant_expression_supporting_entities().

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

◆ enum_supporting_references()

list enum_supporting_references ( list  srl,
entity  e 
)

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4415 of file type.c.

4416 {
4417  type t = entity_type(e);
4418  list ml = type_enum(t);
4419  list cm = list_undefined;
4420 
4421  pips_assert("type is of enum kind", type_enum_p(t));
4422 
4423  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4424  /* ifdebug(9) { */
4425  /* pips_debug(8, "Begin: "); */
4426  /* print_references(srl); */
4427  /* fprintf(stderr, "\n"); */
4428  /* } */
4429 
4430  for(cm = ml; !ENDP(cm); POP(cm)) {
4431  entity m = ENTITY(CAR(cm));
4432  value v = entity_initial(m);
4433  symbolic s = value_symbolic(v);
4434 
4435  pips_assert("m is an enum member", value_symbolic_p(v));
4436 
4438  }
4439 
4440  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4441  /* ifdebug(9) { */
4442  /* pips_debug(8, "End: "); */
4443  /* print_references(srl); */
4444  /* fprintf(stderr, "\n"); */
4445  /* } */
4446 
4447  return srl;
4448 }

References CAR, constant_expression_supporting_references(), ENDP, ENTITY, entity_initial, entity_type, list_undefined, pips_assert, POP, symbolic_expression, type_enum, type_enum_p, value_symbolic, and value_symbolic_p.

Referenced by constant_expression_supporting_references().

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

◆ enum_type_p()

bool enum_type_p ( type  t)

Returns true if t is of type derived and if the derived type is a enum.

Example : enum foo var;

FI: Could be unified with the prevous two functions, struct_type_p() and union_type_p()

Note: different from type_enum_p

Definition at line 3172 of file type.c.

3173 {
3174  bool enum_p = false;
3175  if(derived_type_p(t)) {
3177  entity dte = basic_derived(b);
3178  type dt = entity_type(dte);
3179  enum_p = type_enum_p(dt);
3180  }
3181  return enum_p;
3182 }
bool derived_type_p(type t)
Returns true if t is of type struct, union or enum.
Definition: type.c:3104

References basic_derived, derived_type_p(), entity_type, type_enum_p, type_variable, and variable_basic.

Referenced by rename_variable_type().

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

◆ expression_basic()

basic expression_basic ( expression  expr)

should be int

How to void a memory leak? Where can we find a basic int? A static variable?

Parameters
exprxpr

Definition at line 1115 of file type.c.

1116 {
1117  syntax the_syntax=expression_syntax(expr);
1118  basic b = basic_undefined;
1119 
1120  switch(syntax_tag(the_syntax))
1121  {
1122  case is_syntax_reference:
1124  break;
1125  case is_syntax_range:
1126  /* should be int */
1127  b = expression_basic(range_lower(syntax_range(the_syntax)));
1128  break;
1129  case is_syntax_call:
1130  /*
1131  * here is a little problem with pips... every intrinsics are
1132  * overloaded, what is not exactly what is desired...
1133  */
1134  return(entity_basic(call_function(syntax_call(the_syntax))));
1135  break;
1136  case is_syntax_cast:
1137  {
1138  cast c = syntax_cast(the_syntax);
1139  type t = cast_type(c);
1140  type ut = ultimate_type(t);
1141  b = variable_basic(type_variable(ut));
1142  pips_assert("Type is \"variable\"", type_variable_p(ut));
1143  break;
1144  }
1146  {
1147  /* How to void a memory leak? Where can we find a basic int? A static variable? */
1148  b = make_basic(is_basic_int, (void *) 4);
1149  break;
1150  }
1151  default:
1152  pips_internal_error("unexpected syntax tag");
1153  break;
1154  }
1155 
1156  return b;
1157 }
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
basic expression_basic(expression expr)
Definition: type.c:1115
#define syntax_tag(x)
Definition: ri.h:2727
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_cast
Definition: ri.h:2694
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
@ is_syntax_sizeofexpression
Definition: ri.h:2695
#define cast_type(x)
Definition: ri.h:745
#define range_lower(x)
Definition: ri.h:2288

References basic_undefined, 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(), suggest_basic_for_expression(), and words_nullary_op_c().

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

◆ expression_to_concrete_type()

type expression_to_concrete_type ( expression  e)

A new type is allocated.

Definition at line 3751 of file type.c.

3752 {
3753  type t = expression_to_type(e);
3755  return ct;
3756 }
type expression_to_type(expression exp)
For an array declared as int a[10][20], the type returned for a[i] is int [20].
Definition: type.c:2486

References compute_basic_concrete_type(), and expression_to_type().

Referenced by normalize_subscript_expression().

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

◆ expression_to_type()

type expression_to_type ( expression  exp)

For an array declared as int a[10][20], the type returned for a[i] is int [20].

gcc claims it is int (*)[10], that is a pointer to an array of 10 elements.

Parameters
expis an expression
Returns
a new allocated type which is the ntype of the expression in which typedef's are replaced by combination of basic types.

does not cover references to functions ...

Could be more elaborated with array types for array expressions

ifdebug(9){

pips_debug(6, "begins with expression :");

print_expression(exp);

fprintf(stderr, "\n");

}

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...

pips_debug(9, "returns with %s\n", words_to_string(words_type(t, NIL, false)));

Parameters
expxp

Definition at line 2486 of file type.c.

2487 {
2488  debug_on("RI-UTIL_DEBUG_LEVEL");
2489  /* does not cover references to functions ...*/
2490  /* Could be more elaborated with array types for array expressions */
2491  type t = type_undefined;
2492 
2493  syntax s_exp = expression_syntax(exp);
2494 
2495  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2496  /* ifdebug(9){ */
2497  /* pips_debug(6, "begins with expression :"); */
2498  /* print_expression(exp); */
2499  /* fprintf(stderr, "\n"); */
2500  /* } */
2501 
2502  switch(syntax_tag(s_exp))
2503  {
2504  case is_syntax_reference:
2505  {
2506  pips_debug(9, "reference case \n");
2507  t = reference_to_type(syntax_reference(s_exp));
2508  break;
2509  }
2510  case is_syntax_call:
2511  {
2512  pips_debug(9, "call case \n");
2513  t = call_to_type(syntax_call(s_exp));
2514  break;
2515  }
2516  case is_syntax_range:
2517  {
2518  pips_debug(9, "range case \n");
2519  /* Well, let's assume range are well formed... */
2521  break;
2522  }
2523  case is_syntax_cast:
2524  {
2525  pips_debug(9, "cast case \n");
2526  t = copy_type(cast_type(syntax_cast(s_exp)));
2527  if (!type_void_p(t) && type_tag(t) != is_type_variable)
2528  pips_internal_error("Bad reference type tag %d",type_tag(t));
2529  break;
2530  }
2532  {
2533  /*
2534  sizeofexpression se = syntax_sizeofexpression(s_exp);
2535  pips_debug(9, "size of case \n");
2536  if (sizeofexpression_type_p(se))
2537  {
2538  t = copy_type(sizeofexpression_type(se));
2539  if (type_tag(t) != is_type_variable)
2540  pips_internal_error("Bad reference type tag %d",type_tag(t));
2541  }
2542  else
2543  {
2544  t = expression_to_type(sizeofexpression_expression(se));
2545  }*/
2547  break;
2548  }
2549  case is_syntax_subscript:
2550  {
2551  /* current type */
2553  /* current basic */
2555  /* current dimensions */
2557  list l_inds = subscript_indices(syntax_subscript(s_exp));
2558 
2559  pips_debug(9, "subscript case \n");
2560 
2561  while (!ENDP(l_inds))
2562  {
2563  if(!ENDP(cd))
2564  {
2565  POP(cd);
2566  }
2567  else
2568  {
2569  pips_assert("reference has too many indices : pointer expected\n", basic_pointer_p(cb));
2570  ct = basic_pointer(cb);
2571  if( type_variable_p(ct) ) {
2572  cb = variable_basic(type_variable(ct));
2574  }
2575  else {
2576  abort();
2577  pips_internal_error("unhandled case");
2578  }
2579  }
2580  POP(l_inds);
2581  }
2582 
2583  /* Warning : qualifiers are set to NIL, because I do not see
2584  the need for something else for the moment. BC.
2585  */
2588  gen_full_copy_list(cd),
2589  NIL));
2590  break;
2591  }
2592  case is_syntax_application:
2593  {
2594  pips_debug(9, "application case \n");
2596  break;
2597  }
2598  case is_syntax_va_arg:
2599  {
2600  pips_debug(9, "va_arg case\n");
2601  list vararg_list = syntax_va_arg(s_exp);
2602  sizeofexpression soe = SIZEOFEXPRESSION(CAR(CDR(vararg_list)));
2603 
2604  t = copy_type(sizeofexpression_type(soe));
2605  break;
2606  }
2607 
2608  default:
2609  pips_internal_error("Bad syntax tag %d", syntax_tag(s_exp));
2610  /* Never go there... */
2611  }
2612 
2613  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2614  /* pips_debug(9, "returns with %s\n", words_to_string(words_type(t, NIL, false))); */
2615  debug_off();
2616  return t;
2617 }
#define abort()
Definition: misc-local.h:53
type reference_to_type(reference ref)
Definition: type.c:2354
#define SIZEOFEXPRESSION(x)
SIZEOFEXPRESSION.
Definition: ri.h:2364
#define sizeofexpression_type(x)
Definition: ri.h:2406
#define syntax_application(x)
Definition: ri.h:2748
#define syntax_va_arg(x)
Definition: ri.h:2751
@ is_syntax_application
Definition: ri.h:2697
@ is_syntax_va_arg
Definition: ri.h:2698
@ is_syntax_subscript
Definition: ri.h:2696
#define subscript_indices(x)
Definition: ri.h:2563
#define subscript_array(x)
Definition: ri.h:2561
#define application_function(x)
Definition: ri.h:508
#define syntax_subscript(x)
Definition: ri.h:2745

References abort, application_function, basic_pointer, basic_pointer_p, call_to_type(), CAR, cast_type, CDR, copy_basic(), copy_type(), debug_off, debug_on, DEFAULT_POINTER_TYPE_SIZE, ENDP, exp, expression_syntax, expression_to_type(), gen_full_copy_list(), 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, 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, and variable_dimensions.

Referenced by any_user_call_site_to_transformer(), application_to_points_to_sinks(), assignment_to_post_pv(), binary_arithmetic_operator_to_post_pv(), c_convex_effects_on_actual_parameter_forward_translation(), c_convex_effects_on_formal_parameter_backward_translation(), declaration_statement_to_points_to(), dereferencing_subscript_to_points_to(), do_linearize_array_manage_callers(), equal_condition_to_points_to(), eval_linear_expression(), EvalSizeofexpression(), expression_pointer_p(), expression_to_concrete_type(), expression_to_points_to_cells(), expression_to_points_to_sinks_with_offset(), expression_to_transformer(), expression_to_type(), expression_to_uncasted_type(), extended_expression_constant_p(), generic_abs_to_transformer(), generic_substitute_formal_array_elements_in_transformer(), integer_expression_and_precondition_to_integer_interval(), integer_expression_to_transformer(), intrinsic_call_to_points_to(), intrinsic_call_to_type(), malloc_arg_to_type(), MemberIdentifierToExpression(), non_equal_condition_to_points_to(), NormalizeCast(), null_equal_condition_to_points_to(), null_non_equal_condition_to_points_to(), order_condition_to_points_to(), pointer_expression_to_transformer(), points_to_expression_to_type(), points_to_reference_update_final_subscripts(), ppt_math(), rename_op(), struct_reference_assignment_or_equality_to_transformer(), transformer_add_condition_information_updown(), unary_arithmetic_operator_to_post_pv(), and update_operator_to_post_pv().

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

◆ expression_to_uncasted_type()

type expression_to_uncasted_type ( expression  exp)

If the expression is casted, return its type before cast.

ifdebug(6){

pips_debug(6, "begins with expression :");

print_expression(exp);

pips_debug(6, "\n");

}

Parameters
expxp

Definition at line 2620 of file type.c.

2621 {
2622  type t = type_undefined;
2623  syntax s_exp = expression_syntax(exp);
2624 
2625  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2626  /* ifdebug(6){ */
2627  /* pips_debug(6, "begins with expression :"); */
2628  /* print_expression(exp); */
2629  /* pips_debug(6, "\n"); */
2630  /* } */
2631 
2632  if(syntax_cast_p(s_exp)) {
2633  expression sub_exp = cast_expression(syntax_cast(s_exp));
2634 
2635  t = expression_to_uncasted_type(sub_exp);
2636  }
2637  else {
2638  t = expression_to_type(exp);
2639  }
2640 
2641  return t;
2642 }
type expression_to_uncasted_type(expression exp)
If the expression is casted, return its type before cast.
Definition: type.c:2620

References cast_expression, exp, expression_syntax, expression_to_type(), expression_to_uncasted_type(), syntax_cast, syntax_cast_p, and type_undefined.

Referenced by expression_to_uncasted_type().

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

◆ expression_to_user_type()

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 2645 of file type.c.

2646 {
2647  /* does not cover references to functions ...*/
2648  /* Could be more elaborated with array types for array expressions */
2649  type t = type_undefined;
2650  basic b = some_basic_of_any_expression(e, false, false);
2651  variable v = make_variable(b, NIL, NIL);
2652 
2653  t = make_type(is_type_variable, v);
2654 
2655  return t;
2656 }

References is_type_variable, make_type(), make_variable(), NIL, some_basic_of_any_expression(), and type_undefined.

Referenced by callnodeclfilter(), check_C_function_type(), and freia_create_helper_function().

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

◆ FILE_star_type_p()

bool FILE_star_type_p ( type  t)

Definition at line 3046 of file type.c.

3047 {
3048  bool res = false;
3049  if (type_variable_p(t))
3050  {
3052  if (basic_pointer_p(b))
3053  {
3054  t = basic_pointer(b);
3055  if (type_variable_p(t))
3056  {
3058  if (basic_derived_p(b))
3059  {
3060  entity te = basic_derived(b);
3061  if (strstr(entity_name(te), "_IO_FILE") != NULL)
3062  {
3063  res = true;
3064  }
3065  }
3066  }
3067  }
3068  }
3069  return res;
3070 }

References basic_derived, basic_derived_p, basic_pointer, basic_pointer_p, entity_name, type_variable, type_variable_p, and variable_basic.

◆ find_field_in_field_list()

entity find_field_in_field_list ( entity  f,
list  fl 
)

To deal with fields declared in different C files.

It is assumed that f and fl belong to the same derived type, be it a struct, a union or an enum.

Parameters
fll

Definition at line 5401 of file type.c.

5402 {
5403  entity nf = entity_undefined;
5404  if(entity_is_argument_p(f, fl))
5405  nf = f;
5406  else {
5407  string fn = (string) entity_user_name(f);
5408  FOREACH(ENTITY, of, fl) {
5409  string ofn = (string) entity_user_name(of);
5410  if(same_string_p(fn, ofn)) {
5411  nf = of;
5412  break;
5413  }
5414  }
5415  }
5416  return nf;
5417 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
#define same_string_p(s1, s2)
char * string
STRING.
Definition: newgen_types.h:39

References ENTITY, entity_is_argument_p(), entity_undefined, entity_user_name(), f(), FOREACH, and same_string_p.

Referenced by reference_add_field_dimension().

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

◆ find_ith_dimension()

dimension find_ith_dimension ( list  dims,
int  n 
)

This function returns the ith dimension of a list of dimensions.

Parameters
dimsims

Definition at line 5621 of file type.c.

5622 {
5623  int i;
5624  pips_assert("find_ith_dimension", n > 0);
5625  for(i=1; i<n && !ENDP(dims); i++, POP(dims))
5626  ;
5627  if(i==n && !ENDP(dims))
5628  return DIMENSION(CAR(dims));
5629  return dimension_undefined;
5630 }
#define dimension_undefined
Definition: ri.h:955

References CAR, DIMENSION, dimension_undefined, ENDP, pips_assert, and POP.

Referenced by array_size_stride(), assumed_size_array_p(), bottom_up_abc_base_reference_implied_do(), bottom_up_abc_reference(), pointer_type_array_p(), same_dimension_p(), size_of_actual_array(), size_of_dummy_array(), subscript_value(), subscript_value_stride(), top_down_abc_dimension(), and xml_Pattern_Paving().

+ Here is the caller graph for this function:

◆ FindIthDimension()

dimension FindIthDimension ( entity  e,
int  i 
)

Definition at line 1180 of file type.c.

1181 {
1182  cons * pc;
1183 
1184  if (!type_variable_p(entity_type(e)))
1185  pips_internal_error("not a variable");
1186 
1187  if (i <= 0)
1188  pips_internal_error("invalid dimension");
1189 
1191 
1192  while (pc != NULL && --i > 0)
1193  pc = CDR(pc);
1194 
1195  if (pc == NULL)
1196  pips_internal_error("not enough dimensions");
1197 
1198  return(DIMENSION(CAR(pc)));
1199 }

References CAR, CDR, DIMENSION, entity_type, 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().

+ Here is the caller graph for this function:

◆ fixed_length_array_type_p()

bool fixed_length_array_type_p ( type  t)

Definition at line 2987 of file type.c.

2988 {
2989  return array_type_p(t) && !variable_length_array_type_p(t);
2990 }
bool variable_length_array_type_p(type t)
Is this equivalent to dependent_type_p()?
Definition: type.c:2972

References array_type_p(), and variable_length_array_type_p().

Referenced by do_linearize_array_manage_callers().

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

◆ float_type_p()

bool float_type_p ( type  t)

Definition at line 3263 of file type.c.

3264 {
3265  bool float_p = false;
3266  if(!type_undefined_p(t) && type_variable_p(t)) {
3267  variable v = type_variable(t);
3268  basic b = variable_basic(v);
3269  if(basic_float_p(b)) {
3270  float_p = true;
3271  }
3272  }
3273  return float_p;
3274 }

References basic_float_p, type_undefined_p, type_variable, type_variable_p, and variable_basic.

Referenced by EvalConstant(), float_constant_p(), MakeParameter(), and simplify_float_constraint().

+ Here is the caller graph for this function:

◆ fortran_constant_expression_supporting_entities()

list fortran_constant_expression_supporting_entities ( list  sel,
expression  e 
)

Fortran version.

Parameters
selel

Definition at line 4187 of file type.c.

4188 {
4189  set vt = set_make(set_pointer);
4190 
4191  sel = generic_constant_expression_supporting_entities(sel, vt, e, false);
4192 
4193  set_free(vt);
4194 
4195  return sel;
4196 }
void set_free(set)
Definition: set.c:332
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59

References generic_constant_expression_supporting_entities(), set_free(), set_make(), and set_pointer.

Referenced by fortran_type_supporting_entities().

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

◆ fortran_type_supporting_entities()

list fortran_type_supporting_entities ( list  srl,
type  t 
)

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

In Fortran, dependencies are due to the dimension expressions.

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4593 of file type.c.

4594 {
4595  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4596  /* ifdebug(9) { */
4597  /* pips_debug(8, "Begin: "); */
4598  /* print_references(srl); */
4599  /* fprintf(stderr, "\n"); */
4600  /* } */
4601 
4602  if(type_functional_p(t))
4603  ;
4604  else if(type_variable_p(t)) {
4605  /* In Fortran, dependencies are due to the dimension expressions.*/
4606  variable v = type_variable(t);
4607  list dims = variable_dimensions(v);
4608 
4609  FOREACH(DIMENSION, d, dims) {
4610  expression l = dimension_lower(d);
4611  expression u = dimension_upper(d);
4614  }
4615  }
4616  else if(type_void_p(t))
4617  ;
4618  else
4619  pips_internal_error("Unexpected Fortran type with tag %d", type_tag(t));
4620 
4621  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4622  /* ifdebug(9) { */
4623  /* pips_debug(8, "End: "); */
4624  /* print_references(srl); */
4625  /* fprintf(stderr, "\n"); */
4626  /* } */
4627 
4628  return srl;
4629 }
list fortran_constant_expression_supporting_entities(list sel, expression e)
Fortran version.
Definition: type.c:4187

References DIMENSION, dimension_lower, dimension_upper, FOREACH, fortran_constant_expression_supporting_entities(), pips_internal_error, type_functional_p, type_tag, type_variable, type_variable_p, type_void_p, and variable_dimensions.

Referenced by check_fortran_declaration_dependencies().

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

◆ functional_equal_p()

bool functional_equal_p ( functional  f1,
functional  f2 
)
Parameters
f11
f22

Definition at line 1011 of file type.c.

1012 {
1013  return generic_functional_equal_p(f1, f2, true, true, false);
1014 }
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
bool generic_functional_equal_p(functional f1, functional f2, bool strict_p, bool qualifier_p, hash_table structural_table)
Definition: type.c:983

References f2(), and generic_functional_equal_p().

+ Here is the call graph for this function:

◆ functional_type_supporting_entities()

list functional_type_supporting_entities ( list  sel,
functional  f 
)
Parameters
selel

Definition at line 4014 of file type.c.

4015 {
4016  set vt = set_make(set_pointer);
4017 
4019 
4020  set_free(vt);
4021 
4022  return sel;
4023 }
list recursive_functional_type_supporting_entities(list sel, set vt, functional f)
Definition: type.c:3977

References f(), recursive_functional_type_supporting_entities(), set_free(), set_make(), and set_pointer.

Referenced by compilation_unit_text().

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

◆ functional_type_supporting_references()

list functional_type_supporting_references ( list  srl,
functional  f 
)

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4390 of file type.c.

4391 {
4392  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4393  /* ifdebug(9) { */
4394  /* pips_debug(8, "Begin: "); */
4395  /* print_references(srl); */
4396  /* fprintf(stderr, "\n"); */
4397  /* } */
4398 
4399  MAP(PARAMETER, p,
4402 
4404 
4405  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4406  /* ifdebug(9) { */
4407  /* pips_debug(8, "End: "); */
4408  /* print_references(srl); */
4409  /* fprintf(stderr, "\n"); */
4410  /* } */
4411 
4412  return srl;
4413 }

References f(), functional_parameters, functional_result, MAP, PARAMETER, parameter_type, and recursive_type_supporting_references().

Referenced by recursive_type_supporting_references().

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

◆ functional_type_supporting_types()

list functional_type_supporting_types ( functional  f)

FI: I'm not sure this function is of any use.

Definition at line 5059 of file type.c.

5060 {
5061  set vt = set_make(set_pointer);
5062  list stl = NIL;
5063 
5065 
5066  set_free(vt);
5067 
5068  return stl;
5069 }
static list recursive_functional_type_supporting_types(list stl, set vt, functional f)
Definition: type.c:5036

References f(), NIL, recursive_functional_type_supporting_types(), set_free(), set_make(), and set_pointer.

+ Here is the call graph for this function:

◆ generic_basic_depth()

static size_t generic_basic_depth ( basic  b,
set  vt 
)
static

Definition at line 4886 of file type.c.

4887 {
4888  int d = 0;
4889 
4890  switch(basic_tag(b)) {
4891  case is_basic_int:
4892  case is_basic_float:
4893  case is_basic_logical:
4894  case is_basic_overloaded:
4895  case is_basic_complex:
4896  case is_basic_string:
4897  case is_basic_bit:
4898  break;
4899  case is_basic_pointer: {
4900  if(!set_undefined_p(vt)) {
4901  type pt = basic_pointer(b);
4902  d = generic_type_depth(pt, vt)+1;
4903  // FI: Add an implicit array dimension ?
4904  // if(!get_bool_property("POINTS_TO_STRICT_POINTER_TYPES")) d++;
4905  }
4906  else
4907  d = 0;
4908 
4909  // FI: if it is needed to add a zero subscript, this feature
4910  // should be carefully documented. It generates results in between
4911  // type_depth() and maximal_type_depth(). It may be properly
4912  // handled by the caller. It is meaningless here and damaging when
4913  // points-to references must be kept store-independent.
4914 
4915  }
4916  break;
4917  case is_basic_derived:
4918  {
4919  entity e = basic_derived(b);
4920  type t = entity_type(e);
4921  d = generic_type_depth(t, vt);
4922  break;
4923  }
4924  case is_basic_typedef:
4925  {
4926  entity e = basic_typedef(b);
4927  type t = entity_type(e);
4928 
4929  d = generic_type_depth(t, vt);
4930  break;
4931  }
4932  default:
4933  pips_internal_error("Unexpected basic tag %d", basic_tag(b));
4934  }
4935 
4936  return d;
4937 }
#define set_undefined_p(s)
Definition: newgen_set.h:49
static size_t generic_type_depth(type t, set vt)
Definition: type.c:4794

References basic_derived, basic_pointer, basic_tag, basic_typedef, entity_type, generic_type_depth(), 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 set_undefined_p.

Referenced by generic_type_depth().

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

◆ generic_basic_equal_p()

bool generic_basic_equal_p ( basic  b1,
basic  b2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)

assertion: b1 and b2 are defined and have the same tag (see previous tests)

FI: there are two definition of equality, one more strict via the expression, and one more practical via the constant. But the constant is not always defined. And the Newgen declaration of symbolic looks wrong with "float:int"...

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!

just to avoid a warning

Parameters
b11
b22
strict_ptrict_p
qualifier_pualifier_p
structural_tabletructural_table

Definition at line 824 of file type.c.

825 {
826  if(b1 == b2)
827  return true;
828  else if (b1 == basic_undefined && b2 != basic_undefined)
829  return false;
830  else if (b1 != basic_undefined && b2 == basic_undefined)
831  return false;
832  else if (basic_tag(b1) != basic_tag(b2)) {
833  if(strict_p)
834  return false;
835  else
836  return same_basic_p(b1, b2);
837  }
838 
839  /* assertion: b1 and b2 are defined and have the same tag
840  (see previous tests) */
841 
842  switch(basic_tag(b1)) {
843  case is_basic_int:
844  return basic_int(b1) == basic_int(b2);
845  case is_basic_float:
846  return basic_float(b1) == basic_float(b2);
847  case is_basic_logical:
848  return basic_logical(b1) == basic_logical(b2);
849  case is_basic_overloaded:
850  return true;
851  case is_basic_complex:
852  return basic_complex(b1) == basic_complex(b2);
853  case is_basic_bit: {
854  symbolic s1 = basic_bit(b1);
855  symbolic s2 = basic_bit(b2);
856 
857  /* FI: there are two definition of equality, one more strict via
858  the expression, and one more practical via the constant. But
859  the constant is not always defined. And the Newgen declaration
860  of symbolic looks wrong with "float:int"... */
861 
864  return expression_equal_p(e1, e2);
865  }
866  case is_basic_pointer:
867  {
868  type t1 = basic_pointer(b1);
869  type t2 = basic_pointer(b2);
870  return generic_type_equal_p(t1, t2, strict_p, qualifier_p, structural_table);
871  //return (type_void_p(t1) && type_void_p(t2)) ||
872  // (type_variable_p(t1) && type_variable_p(t2) &&
873  // generic_basic_equal_p(variable_basic(type_variable(t1)),
874  // variable_basic(type_variable(t2)),
875  // strict_p, qualifier_p, structural_table));
876  }
877  case is_basic_derived:
878  {
879  entity e1 = basic_derived(b1);
880  entity e2 = basic_derived(b2);
881  bool equal_p = true;
882 
883  // FI: THIS IS MORE COMPLICATED THAN A POINTER COMPARISON...
884  // qualifier_p should be provided...
885  if(e1!=e2)
886  equal_p = generic_type_equal_p(entity_type(e1), entity_type(e2), strict_p, qualifier_p, structural_table);
887  return equal_p;
888  }
889  case is_basic_string:
890  /* Do we want string types to be equal only if lengths are equal?
891  * I do not think so
892  */
893  /*
894  pips_internal_error("string type comparison not implemented");
895  */
896  /* could be a star or an expression; a value_equal_p() is needed! */
897  return true;
898  case is_basic_typedef: {
899  // FI: just like fields, the same typedef can be defined in
900  // different files by different entities; it would be easier with
901  // concrete types
902 
903  // It is not clear how strict_p should be used...
904  entity nt1 = basic_typedef(b1);
905  entity nt2 = basic_typedef(b2);
906  if(same_entity_p(nt1, nt2))
907  return true;
908  else {
909  string nt1n = (string) entity_user_name(nt1);
910  string nt2n = (string) entity_user_name(nt2);
911  if(same_string_p(nt1n, nt2n)) {
912  type nt1t = entity_type(nt1);
913  type nt2t = entity_type(nt2);
914  return generic_type_equal_p(nt1t, nt2t, strict_p, qualifier_p, structural_table);
915  }
916  else
917  return false;
918  }
919  //return basic_typedef_p(b2)
920  // && same_entity_p(basic_typedef(b1),basic_typedef(b2));
921  }
922  default: pips_internal_error("unexpected tag %d", basic_tag(b1));
923  }
924  return false; /* just to avoid a warning */
925 }
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
bool same_basic_p(basic b1, basic b2)
check if two basics are similar.
Definition: type.c:969

References b1, b2, basic_bit, basic_complex, basic_derived, basic_float, basic_int, basic_logical, basic_pointer, basic_tag, basic_typedef, basic_undefined, entity_type, entity_user_name(), expression_equal_p(), generic_type_equal_p(), 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, s1, same_basic_p(), same_entity_p(), same_string_p, and symbolic_expression.

Referenced by basic_equal_p(), and generic_variable_equal_p().

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

◆ generic_constant_expression_supporting_entities()

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

Parameters
selel
vtt
language_c_panguage_c_p

Definition at line 4058 of file type.c.

4059 {
4060  syntax s = expression_syntax(e);
4061 
4062  ifdebug(8) {
4063  pips_debug(8, "Begin: ");
4064  print_entities(sel);
4065  fprintf(stderr, "\n\n");
4066  }
4067 
4068  if(syntax_call_p(s)) {
4069  call c = syntax_call(s);
4070  entity f = call_function(c);
4071 
4073  if(language_c_p) {
4074  /* In C, f cannot be declared directly, we need its enum */
4075  entity e_of_f = find_enum_of_member(f);
4076  //sel = CONS(ENTITY, e_of_f, sel);
4077  sel = enum_supporting_entities(sel, vt, e_of_f);
4078  sel = gen_nconc(sel, CONS(ENTITY, e_of_f, NIL));
4079  }
4080  else {
4081  /* In Fortran, symbolic constant are declared directly, but
4082  the may depend on other symbolic constants */
4083  value v = entity_initial(f);
4084  symbolic s = value_symbolic(v);
4085 
4086  //sel = CONS(ENTITY, f, sel);
4088  sel = gen_nconc(sel, CONS(ENTITY, f, NIL));
4089  }
4090  }
4091 
4092  FOREACH(EXPRESSION, se, call_arguments(c)) {
4094  }
4095  }
4096  else if(syntax_reference_p(s)) {
4097  reference r = syntax_reference(s);
4098  entity v = reference_variable(r);
4099  list inds = reference_indices(r);
4100  /* Could be guarded so as not to be added twice. Guard might be
4101  useless with because types are visited only once. */
4102  //sel = gen_nconc(sel, CONS(ENTITY, v, NIL));
4103  FOREACH(EXPRESSION, se, inds) {
4105  }
4106  sel = gen_nconc(sel, CONS(ENTITY, v, NIL));
4107  }
4108  else if(syntax_range_p(s)) {
4109  range r = syntax_range(s);
4110  expression l = range_lower(r);
4111  expression u = range_upper(r);
4112  expression i = range_increment(r);
4116  }
4117  else if(syntax_cast_p(s)) {
4118  cast c = syntax_cast(s);
4119  type t = cast_type(c);
4120  expression e = cast_expression(c);
4121  sel = recursive_type_supporting_entities(sel, vt, t);
4123  }
4124  else if(syntax_sizeofexpression_p(s)) {
4126  if(sizeofexpression_type_p(soe)) {
4127  type t = sizeofexpression_type(soe);
4128  sel = recursive_type_supporting_entities(sel, vt, t);
4129  }
4130  else {
4133  }
4134  }
4135  else if(syntax_subscript_p(s)) {
4136  subscript ss = syntax_subscript(s);
4137  expression a = subscript_array(ss);
4138  list inds = subscript_indices(ss);
4139  FOREACH(EXPRESSION, se, inds) {
4141  }
4143  }
4144  else if(syntax_application_p(s)) {
4147  list inds = application_arguments(as);
4148  FOREACH(EXPRESSION, se, inds) {
4150  }
4152  }
4153  else if(syntax_va_arg_p(s)) {
4154  list soel = syntax_va_arg(s);
4155  FOREACH(SIZEOFEXPRESSION, soe, soel) {
4156  if(sizeofexpression_type_p(soe)) {
4157  type t = sizeofexpression_type(soe);
4158  sel = recursive_type_supporting_entities(sel, vt, t);
4159  }
4160  else {
4163  }
4164  }
4165  }
4166  else {
4167  /* do nothing */
4168  ;
4169  }
4170 
4171  ifdebug(8) {
4172  pips_debug(8, "End: ");
4173  print_entities(sel);
4174  fprintf(stderr, "\n\n");
4175  }
4176 
4177  return sel;
4178 }
list enum_supporting_entities(list sel, set vt, entity e)
Definition: type.c:4025
list generic_symbolic_supporting_entities(list sel, set vt, symbolic s, bool language_c_p)
Definition: type.c:4198
#define range_upper(x)
Definition: ri.h:2290
#define sizeofexpression_expression(x)
Definition: ri.h:2409
#define syntax_va_arg_p(x)
Definition: ri.h:2749
#define syntax_sizeofexpression_p(x)
Definition: ri.h:2740
#define range_increment(x)
Definition: ri.h:2292
#define application_arguments(x)
Definition: ri.h:510
#define language_c_p(x)
Definition: ri.h:1594
#define syntax_sizeofexpression(x)
Definition: ri.h:2742
#define sizeofexpression_type_p(x)
Definition: ri.h:2404
#define syntax_application_p(x)
Definition: ri.h:2746
#define syntax_range_p(x)
Definition: ri.h:2731
#define syntax_subscript_p(x)
Definition: ri.h:2743

References application_arguments, application_function, call_arguments, call_function, cast_expression, cast_type, CONS, ENTITY, entity_initial, enum_supporting_entities(), EXPRESSION, expression_syntax, f(), find_enum_of_member(), FOREACH, fprintf(), gen_nconc(), generic_constant_expression_supporting_entities(), generic_symbolic_supporting_entities(), ifdebug, language_c_p, NIL, pips_debug, print_entities(), range_increment, range_lower, range_upper, recursive_type_supporting_entities(), reference_indices, reference_variable, SIZEOFEXPRESSION, sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, subscript_array, subscript_indices, symbolic_constant_entity_p(), syntax_application, syntax_application_p, syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, syntax_range, syntax_range_p, syntax_reference, syntax_reference_p, syntax_sizeofexpression, syntax_sizeofexpression_p, syntax_subscript, syntax_subscript_p, syntax_va_arg, syntax_va_arg_p, and value_symbolic.

Referenced by constant_expression_supporting_entities(), fortran_constant_expression_supporting_entities(), generic_constant_expression_supporting_entities(), and generic_symbolic_supporting_entities().

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

◆ generic_field_list_equal_p()

static bool generic_field_list_equal_p ( list  fl1,
list  fl2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)
static

This function is only used for structural type equality.

FI: we might want the fields to have the same user name.

Definition at line 419 of file type.c.

420 {
421  bool equal_p = gen_length(fl1)==gen_length(fl2);
422  if(equal_p) {
423  list cfl1 = fl1, cfl2 = fl2;
424  for(;equal_p && !ENDP(cfl1); POP(cfl1), POP(cfl2)) {
425  entity e1 = ENTITY(CAR(cfl1));
426  entity e2 = ENTITY(CAR(cfl2));
427  /* FI: we might want the fields to have the same user name. */
428  equal_p = generic_type_equal_p(entity_type(e1), entity_type(e2), strict_p, qualifier_p, structural_table);
429  }
430  }
431  return equal_p;
432 }

References CAR, ENDP, ENTITY, entity_type, gen_length(), generic_type_equal_p(), and POP.

Referenced by generic_type_equal_p().

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

◆ generic_field_list_names_equal_p()

static bool generic_field_list_names_equal_p ( list  fl1,
list  fl2 
)
static

In case you are not protected against recursivity, check field names only.

FI: we only use the field names.

Definition at line 435 of file type.c.

436 {
437  bool equal_p = gen_length(fl1)==gen_length(fl2);
438  if(equal_p) {
439  list cfl1 = fl1, cfl2 = fl2;
440  for(;equal_p && !ENDP(cfl1); POP(cfl1), POP(cfl2)) {
441  entity e1 = ENTITY(CAR(cfl1));
442  entity e2 = ENTITY(CAR(cfl2));
443  /* FI: we only use the field names. */
444  string n1 = (string) entity_user_name(e1);
445  string n2 = (string) entity_user_name(e2);
446  equal_p = strcmp(n1, n2)==0;
447  }
448  }
449  return equal_p;
450 }

References CAR, ENDP, ENTITY, entity_user_name(), gen_length(), and POP.

Referenced by generic_type_equal_p().

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

◆ generic_functional_equal_p()

bool generic_functional_equal_p ( functional  f1,
functional  f2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)
Parameters
f11
f22
strict_ptrict_p
qualifier_pualifier_p
structural_tabletructural_table

Definition at line 983 of file type.c.

985 {
986  if(f1 == f2)
987  return true;
988  else if (f1 == functional_undefined && f2 != functional_undefined)
989  return false;
990  else if (f1 != functional_undefined && f2 == functional_undefined)
991  return false;
992  else {
993  list lp1 = functional_parameters(f1);
995 
996  if(gen_length(lp1) != gen_length(lp2))
997  return false;
998 
999  for( ; !ENDP(lp1); POP(lp1), POP(lp2)) {
1000  parameter p1 = PARAMETER(CAR(lp1));
1001  parameter p2 = PARAMETER(CAR(lp2));
1002 
1003  if(!generic_parameter_equal_p(p1, p2, strict_p, qualifier_p, structural_table))
1004  return false;
1005  }
1006 
1007  return generic_type_equal_p(functional_result(f1), functional_result(f2), strict_p, qualifier_p, structural_table);
1008  }
1009 }
bool generic_parameter_equal_p(parameter p1, parameter p2, bool strict_p, bool qualifier_p, hash_table structural_table)
Definition: type.c:1016
#define functional_undefined
Definition: ri.h:1418

References CAR, ENDP, f2(), functional_parameters, functional_result, functional_undefined, gen_length(), generic_parameter_equal_p(), generic_type_equal_p(), PARAMETER, and POP.

Referenced by functional_equal_p(), and generic_type_equal_p().

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

◆ generic_parameter_equal_p()

bool generic_parameter_equal_p ( parameter  p1,
parameter  p2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)
Parameters
p11
p22
strict_ptrict_p
qualifier_pualifier_p
structural_tabletructural_table

Definition at line 1016 of file type.c.

1018 {
1019  if(p1 == p2)
1020  return true;
1021  else if (p1 == parameter_undefined && p2 != parameter_undefined)
1022  return false;
1023  else if (p1 != parameter_undefined && p2 == parameter_undefined)
1024  return false;
1025  else
1026  return generic_type_equal_p(parameter_type(p1), parameter_type(p2), strict_p, qualifier_p, structural_table)
1028 }
bool mode_equal_p(mode m1, mode m2)
Definition: type.c:1035
#define parameter_undefined
Definition: ri.h:1794
#define parameter_mode(x)
Definition: ri.h:1821

References generic_type_equal_p(), mode_equal_p(), parameter_mode, parameter_type, and parameter_undefined.

Referenced by generic_functional_equal_p(), and parameter_equal_p().

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

◆ generic_symbolic_supporting_entities()

list generic_symbolic_supporting_entities ( list  sel,
set  vt,
symbolic  s,
bool  language_c_p 
)
Parameters
selel
vtt
language_c_panguage_c_p

Definition at line 4198 of file type.c.

4199 {
4202  return sel;
4203 }

References generic_constant_expression_supporting_entities(), language_c_p, and symbolic_expression.

Referenced by generic_constant_expression_supporting_entities(), and symbolic_supporting_entities().

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

◆ generic_type_depth()

static size_t generic_type_depth ( type  t,
set  vt 
)
static

Definition at line 4794 of file type.c.

4795 {
4796  size_t d = 0;
4797  bool finished_p = false;
4798 
4799  if(!set_undefined_p(vt)) {
4800  if(set_belong_p(vt, t))
4801  finished_p = true;
4802  else
4803  set_add_element(vt, vt, t);
4804  }
4805 
4806  if(!finished_p) {
4807  if(type_variable_p(t)) {
4808  variable v = type_variable(t);
4809 
4811  }
4812  else if(type_void_p(t))
4813  d = 0;
4814  else if(type_varargs_p(t))
4815  d = 0;
4816  else if(type_struct_p(t)) {
4817  list fl = type_struct(t);
4818  d = 0;
4819  FOREACH(ENTITY, e, fl) {
4820  size_t i = generic_type_depth(entity_type(e), vt);
4821  d = d>i?d:i;
4822  }
4823  d++;
4824  }
4825  else if(type_union_p(t)) {
4826  list fl = type_union(t);
4827  d = 0;
4828  FOREACH(ENTITY, e, fl) {
4829  size_t i = generic_type_depth(entity_type(e), vt);
4830  d = d>i?d:i;
4831  }
4832  d++;
4833  }
4834  else if(type_enum_p(t))
4835  d = 0;
4836  }
4837 
4838  return d;
4839 }
bool set_belong_p(const set, const void *)
Definition: set.c:194
set set_add_element(set, const set, const void *)
Definition: set.c:152
static size_t generic_basic_depth(basic b, set vt)
Definition: type.c:4886

References ENTITY, entity_type, FOREACH, gen_length(), generic_basic_depth(), set_add_element(), set_belong_p(), set_undefined_p, type_enum_p, type_struct, type_struct_p, type_union, type_union_p, type_varargs_p, type_variable, type_variable_p, type_void_p, variable_basic, and variable_dimensions.

Referenced by generic_basic_depth(), maximal_type_depth(), and type_depth().

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

◆ generic_type_equal_p()

static bool generic_type_equal_p ( type  t1,
type  t2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)
static

Warning: the lengths of string basics are not checked!!! string_type_size() could be used but it is probably not very robust.

typedef int foo[n+n];

typedef int fii[2*n];

type_equal_p(foo, fii)==undefined, because it depends on their respective stores. FI: I do not know what's implemented, see variable_equal_p(). the unknown type is not handled in a satisfactory way: in some sense, it should be declared equal to any other type but the undefined type; currently unknown is equal to unknown, and different from other types.

undefined types could also be seen in a different way, as really undefined values; so if t1 or t2 is undefined, the procedure should abort; but type_undefined is considered equal to type_undefined.

Francois Irigoin, 10 March 1992 If strict_p, a typedef type is not equal to its definition (default value).

If qualifier_p, qualifiers must be equal (default value).

If structural_table is defined, the concrete types must be equal (to be refined? similar to strict_p? See also the equality of concrete types below)

This function should be static and used only indirectly via type_equal_p(), etc.

For a structural type equality, type pairs already visited are assumed equal. The walk can only prove they are not equal.

Fortunately, we do not have to remove the pairs when we go up in the recursion across types. The hash_table can be freed by the caller that has allocated it.

assertion: t1 and t2 are defined and have the same tag

just to avoid a warning

Definition at line 483 of file type.c.

484 {
485  bool tequal = false;
486 
487  if(t1 == t2)
488  return true;
489  else if (t1 == type_undefined && t2 != type_undefined)
490  return false;
491  else if (t1 != type_undefined && t2 == type_undefined)
492  return false;
493  else if (type_tag(t1) != type_tag(t2))
494  return false;
495 
496  /* For a structural type equality, type pairs already visited are
497  assumed equal. The walk can only prove they are not equal. */
498  if(!hash_table_undefined_p(structural_table)) {
499  type t12 = (type) hash_get(structural_table, (void *) t1);
500  if(t2==t12)
501  return true;
502  type t21 = (type) hash_get(structural_table, (void *) t2);
503  if(t1==t21)
504  return true;
505  hash_put(structural_table, t1, t2);
506  /* Fortunately, we do not have to remove the pairs when we go up
507  * in the recursion across types. The hash_table can be freed by
508  * the caller that has allocated it.
509  */
510  }
511 
512  /* assertion: t1 and t2 are defined and have the same tag */
513  switch(type_tag(t1)) {
514  case is_type_statement:
515  return true;
516  case is_type_area:
517  return area_equal_p(type_area(t1), type_area(t2));
518  case is_type_variable:
519  tequal = generic_variable_equal_p(type_variable(t1), type_variable(t2), strict_p, qualifier_p, structural_table);
520  return tequal;
521  case is_type_functional:
522  return generic_functional_equal_p(type_functional(t1), type_functional(t2), strict_p, qualifier_p, structural_table);
523  case is_type_unknown:
524  return true;
525  case is_type_void:
526  return true;
527  case is_type_struct: // FI: not OK if structual_table is not available
528  case is_type_union:
529  case is_type_enum: {
530  list fl1 = derived_type_fields(t1);
531  list fl2 = derived_type_fields(t2);
532  if(!hash_table_undefined_p(structural_table)) {
533  tequal = generic_field_list_equal_p(fl1, fl2, strict_p, qualifier_p, structural_table);
534  }
535  else {
536  tequal = generic_field_list_names_equal_p(fl1, fl2);
537  }
538  return tequal;
539  }
540  default:
541  pips_internal_error("unexpected tag %d.\n", type_tag(t1));
542  }
543 
544  return false; /* just to avoid a warning */
545 }
bool area_equal_p(area a1, area a2)
Definition: type.c:733
bool generic_variable_equal_p(variable v1, variable v2, bool strict_p, bool qualifier_p, hash_table structural_table)
Definition: type.c:762
static bool generic_field_list_equal_p(list fl1, list fl2, bool strict_p, bool qualifier_p, hash_table structural_table)
This function is only used for structural type equality.
Definition: type.c:419
static bool generic_field_list_names_equal_p(list fl1, list fl2)
In case you are not protected against recursivity, check field names only.
Definition: type.c:435
#define type_area(x)
Definition: ri.h:2946
@ is_type_statement
Definition: ri.h:2898
@ is_type_area
Definition: ri.h:2899
@ is_type_unknown
Definition: ri.h:2903

References area_equal_p(), derived_type_fields(), generic_field_list_equal_p(), generic_field_list_names_equal_p(), generic_functional_equal_p(), generic_variable_equal_p(), hash_get(), hash_put(), hash_table_undefined_p, is_type_area, is_type_enum, is_type_functional, is_type_statement, is_type_struct, is_type_union, is_type_unknown, is_type_variable, is_type_void, pips_internal_error, type_area, type_functional, type_tag, type_undefined, and type_variable.

Referenced by concrete_type_equal_p(), generic_basic_equal_p(), generic_field_list_equal_p(), generic_functional_equal_p(), generic_parameter_equal_p(), type_equal_p(), type_equal_up_to_qualifiers_p(), type_equal_up_to_typedefs_and_qualifiers_p(), type_structurally_equal_p(), and ultimate_type_equal_p().

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

◆ generic_variable_equal_p()

bool generic_variable_equal_p ( variable  v1,
variable  v2,
bool  strict_p,
bool  qualifier_p,
hash_table  structural_table 
)

must check basic, dimension and qualifiers

The decomposed condition is much easier to debug than the global predicate.

dimensions should be checked, but it's hard: the only Fortran requirement is that the space allocated in the callers is bigger than the space used in the callee; stars represent any strictly positive integer; we do not know if v1 is the caller type or the callee type; I do not know what should be done; FI

FI: I return false because the exact test should never be useful in the parser; 1 February 1994

FC: I need this in the prettyprinter...

Parameters
v11
v22
strict_ptrict_p
qualifier_pualifier_p
structural_tabletructural_table

Definition at line 762 of file type.c.

763 {
764  if(v1 == v2)
765  return true;
766  else if (v1 == variable_undefined && v2 != variable_undefined)
767  return false;
768  else if (v1 != variable_undefined && v2 == variable_undefined)
769  return false;
770  else {
771  /* must check basic, dimension and qualifiers
772  *
773  * The decomposed condition is much easier to debug than the
774  * global predicate.
775  */
776  bool equal_p = false;
777  bool beq_p = generic_basic_equal_p(variable_basic(v1), variable_basic(v2), strict_p, qualifier_p, structural_table);
778  if(beq_p) {
780  if(deq_p)
781  equal_p = (!qualifier_p || qualifiers_equal_p(variable_qualifiers(v1), variable_qualifiers(v2)));
782  }
783  return equal_p;
784  //generic_basic_equal_p(variable_basic(v1), variable_basic(v2), strict_p, qualifier_p, structural_table)
785  //&& dimensions_equal_p(variable_dimensions(v1), variable_dimensions(v2))
786  //&& (!qualifier_p || qualifiers_equal_p(variable_qualifiers(v1), variable_qualifiers(v2))) ;
787 
788  // FI: the next lines seem to be dead code
789  list ld1 = variable_dimensions(v1);
790  list ld2 = variable_dimensions(v2);
791 
792  if(ld1==NIL && ld2==NIL)
793  return true;
794  else
795  {
796  /* dimensions should be checked, but it's hard: the only
797  Fortran requirement is that the space allocated in
798  the callers is bigger than the space used in the
799  callee; stars represent any strictly positive integer;
800  we do not know if v1 is the caller type or the callee type;
801  I do not know what should be done; FI */
802  /* FI: I return false because the exact test should never be useful
803  in the parser; 1 February 1994 */
804  /* FC: I need this in the prettyprinter... */
805  int l1 = gen_length(ld1), l2 = gen_length(ld2);
806  if (l1!=l2)
807  return false;
808  for (; ld1; POP(ld1), POP(ld2))
809  {
810  dimension d1 = DIMENSION(CAR(ld1)), d2 = DIMENSION(CAR(ld2));
811  if (!dimension_equal_p(d1, d2))
812  return false;
813  }
814  }
815  }
816  return true;
817 }
bool qualifiers_equal_p(list dims1, list dims2)
Definition: type.c:758
bool dimensions_equal_p(list dims1, list dims2)
Definition: type.c:754
#define variable_undefined
Definition: ri.h:3095

References CAR, DIMENSION, dimension_equal_p(), dimensions_equal_p(), gen_length(), generic_basic_equal_p(), NIL, POP, qualifiers_equal_p(), variable_basic, variable_dimensions, variable_qualifiers, and variable_undefined.

Referenced by generic_type_equal_p(), and variable_equal_p().

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

◆ integer_type_p()

bool integer_type_p ( type  t)

Definition at line 3298 of file type.c.

3299 {
3300  bool int_p = false;
3301  if(!type_undefined_p(t) && type_variable_p(t)) {
3302  variable v = type_variable(t);
3303  basic b = variable_basic(v);
3304  int_p = basic_int_p(b);
3305  }
3306  return int_p;
3307 }

References basic_int_p, type_undefined_p, type_variable, type_variable_p, and variable_basic.

Referenced by declaration_statement_to_points_to(), eval_linear_expression(), and generic_abs_to_transformer().

+ Here is the caller graph for this function:

◆ intrinsic_call_to_type()

type intrinsic_call_to_type ( call  c)

END_EOLE.

Returns
the (newly allocated) type of the result given by call to an intrinsic function.

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

pips_debug(9, "Intrinsic call to intrinsic \"s" with a priori result type "s"
",

module_local_name(f),

words_to_string(words_type(rt, NIL, false)));

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

isn't expression_to_type expected to return a bct? well, there are cases (casts) which are not clear on this point... BC.

isn't it dangerous?, an ultimate_type can be an entity type!

ifdebug(9)

{

pips_debug(8, "Point to case, e1 = ");

print_expression(e1);

pips_debug(8, " and e2 = ");

print_expression(e2);

pips_debug(8, "\n");

}

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.

pips_user_warning("Non matching pointed types in pointer arithmetic expression %s - %s\n",

expression_to_string(exp1), expression_to_string(exp2));

current type of expression is type of first argument, except if it is an array, e.g. "fifi+3" after declaration "int fifi[3];"

we need to check the variable dimensions

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

current type is still valid

pips_debug(9, "Intrinsic call to intrinsic \"s" "

"with a posteriori result type \"s"
",

module_local_name(f),

words_to_string(words_type(t, NIL, false)));

Definition at line 2080 of file type.c.

2081 {
2082 
2083  entity f = call_function(c);
2084  list args = call_arguments(c);
2085  type t = type_undefined; /* the result */
2087 
2088  if(type_void_p(rt)) {
2089  t = copy_type(rt);
2090  }
2091  else if(type_variable_p(rt)) {
2093 
2094  // FI: to avoid cycles between librairies ri-util and prettyprint
2095  /* pips_debug(9, "Intrinsic call to intrinsic \"%s\" with a priori result type \"%s\"\n", */
2096  /* module_local_name(f), */
2097  /* words_to_string(words_type(rt, NIL, false))); */
2098 
2099  if(basic_overloaded_p(rb))
2100  {
2101 
2102  if (ENDP(args))
2103  {
2104  /* I don't know the type since there is no arguments !
2105  Bug encountered with a FMT=* in a PRINT.
2106  RK, 21/02/1994 : */
2107  /* leave it overloaded */
2108  t = copy_type(rt);
2109  }
2110  else if(ENTITY_ADDRESS_OF_P(f))
2111  {
2112  expression e = EXPRESSION(CAR(args));
2113  t = expression_to_type(e);
2116  NIL, NIL ));
2117 
2118  }
2119  else if(ENTITY_DEREFERENCING_P(f))
2120  {
2121  expression e = EXPRESSION(CAR(args));
2122  type ct = ultimate_type(expression_to_type(e)); /* isn't expression_to_type expected to return a bct?
2123  well, there are cases (casts) which are not clear on this point... BC. */
2124 
2125  if (type_variable_p(ct))
2126  {
2127  variable cv = type_variable(ct);
2128  basic cb = variable_basic(cv);
2129  list cd = variable_dimensions(cv);
2130  if( ENDP(cd)) {
2131  if(basic_pointer_p(cb))
2132  {
2134  pips_assert("The pointed type is consistent",
2135  type_consistent_p(t));
2136  free_type(ct); /* isn't it dangerous?, an ultimate_type can be an entity type! */
2137  }
2138  else if(basic_string_p(cb))
2139  {
2141  }
2142  else
2143  {
2144  pips_assert("Dereferencing of a non-pointer expression : it must be an array\n", !ENDP(cd));
2145  }
2146  }
2147  else {
2148  variable_dimensions(cv) = CDR(cd);
2149  cd->cdr = NIL;
2150  gen_full_free_list(cd);
2151  t = ct;
2152  }
2153  }
2154  else
2155  {
2156  pips_internal_error("dereferencing of a non-variable : not handled yet");
2157  }
2158  }
2159  else if(ENTITY_POINT_TO_P(f) || ENTITY_FIELD_P(f))
2160  {
2161  //expression e1 = EXPRESSION(CAR(args));
2162  expression e2 = EXPRESSION(CAR(CDR(args)));
2163 
2164  pips_assert("Two arguments for POINT_TO or FIELD \n",
2165  gen_length(args)==2);
2166 
2167  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2168  /* ifdebug(9) */
2169  /* { */
2170  /* pips_debug(8, "Point to case, e1 = "); */
2171  /* print_expression(e1); */
2172  /* pips_debug(8, " and e2 = "); */
2173  /* print_expression(e2); */
2174  /* pips_debug(8, "\n"); */
2175  /* } */
2176  t = expression_to_type(e2);
2177  }
2178  else if(ENTITY_BRACE_INTRINSIC_P(f))
2179  {
2180  /* We should reconstruct a struct type or an array type... */
2182  NIL,NIL));
2183  }
2184  else if(ENTITY_ASSIGN_P(f))
2185  {
2186  /* returns the type of the left hand side */
2187  t = expression_to_type(EXPRESSION(CAR(args)));
2188  }
2189  else if(ENTITY_COMMA_P(f))
2190  {
2191  /* The value returned is the value of the last expression in the list. */
2192 
2194  }
2195  else if( ENTITY_CONDITIONAL_P(f))
2196  {
2197  /* let us assume that the two last arguments have the same
2198  type : basic_maximum does not preserve types enough
2199  (see Effects/lhs01.c, expression *(i>2?&i:&j) ). BC.
2200  */
2201  t = expression_to_type(EXPRESSION(CAR(CDR(args))));
2202  }
2203  else
2204  {
2205  bool minus_c_pointer_arithmetic = false;
2206 
2207  // special case for minus operator when first argument is a pointer type
2208  if (ENTITY_MINUS_C_P(f) )
2209  {
2210  expression exp1 = EXPRESSION(CAR(args));
2211  expression exp2 = EXPRESSION(CAR(CDR(args)));
2212  type t1 = expression_to_type(exp1);
2213  type t2 = expression_to_type(exp2);
2214 
2215  if (pointer_type_p(t1))
2216  {
2217  if (pointer_type_p(t2))
2218  {
2219  type pt1 = pointed_type(t1);
2220  type pt2 = pointed_type(t2);
2221  if (!type_equal_p(pt1, pt2))
2222  {
2223  // user application should not pass compilation by a standard compiler
2224  // should we also trigger an error here?
2225  // FI: to avoid cycles between librairies ri-util and prettyprint
2226  /* pips_user_warning("Non matching pointed types in pointer arithmetic expression %s - %s\n", */
2227  /* expression_to_string(exp1), expression_to_string(exp2)); */
2228  pips_user_warning("Non matching pointed types in pointer arithmetic expressions.\n");
2229  }
2230  // result is of type ptrdiff_t (ISO/IEC 9899:TC3)
2232  NIL,NIL));
2233 
2234 
2235  }
2236  else
2237  {
2238  t = copy_type(t1);
2239  }
2240  minus_c_pointer_arithmetic = true;
2241  free_type(t1); free_type(t2);
2242  }
2243  }
2244 
2245  if (! minus_c_pointer_arithmetic )
2246  {
2247  /* current type of expression is type of first
2248  argument, except if it is an array, e.g. "fifi+3"
2249  after declaration "int fifi[3];" */
2250  type ct = expression_to_type(EXPRESSION(CAR(args)));
2251 
2252  if(array_type_p(ct)) {
2254  type nct = type_to_pointer_type(sct);
2255  free_type(ct);
2256  ct = nct;
2257  }
2258 
2259  FOREACH(EXPRESSION, arg, CDR(args)) {
2260  type nt = expression_to_type(arg);
2263 
2266 
2267  /* we need to check the variable dimensions */
2268  if (gen_length(nd) == gen_length(cd))
2269  {
2270  /* re-use an existing function. we do not take into
2271  account variable dimensions here. It may not be correct.
2272  but it's not worse than the previously existing version
2273  of expression_to_type
2274  */
2275  pips_debug(9,"same number of dimensions\n");
2276  basic b = basic_maximum(cb, nb);
2277  free_type(ct);
2278  free_type(nt);
2280  }
2281  else
2282  {
2283  pips_debug(9,"different number of dimensions\n");
2284  pips_assert("pointer arithmetic with array name, first element must be the address expression",
2285  gen_length(cd) > gen_length(nd));
2286  /* current type is still valid */
2287  free_type(nt);
2288  }
2289 
2290 
2291  }
2292  t = ct;
2293  }
2294  }
2295  }
2296  else {
2297  t = copy_type(rt);
2298  }
2299  }
2300  else
2301  pips_internal_error("Unexpected return type.");
2302 
2303  // FI: to avoid cycles between librairies ri-util and prettyprint
2304  /* pips_debug(9, "Intrinsic call to intrinsic \"%s\" " */
2305  /* "with a posteriori result type \"%s\"\n", */
2306  /* module_local_name(f), */
2307  /* words_to_string(words_type(t, NIL, false))); */
2308 
2309  return t;
2310 }
void gen_full_free_list(list l)
Definition: genClib.c:1023
#define DEFAULT_CHARACTER_TYPE_SIZE
Default type sizes.
type pointed_type(type t)
returns the type pointed by the input type if it is a pointer or an array of pointers
Definition: type.c:3035
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43

References array_type_p(), array_type_to_sub_array_type(), 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, DEFAULT_POINTER_TYPE_SIZE, 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_MINUS_C_P, ENTITY_POINT_TO_P, entity_type, EXPRESSION, expression_to_type(), f(), FOREACH, free_type(), functional_result, gen_full_copy_list(), gen_full_free_list(), gen_last(), gen_length(), is_basic_pointer, is_type_variable, make_basic(), make_basic_int(), make_basic_overloaded(), make_type(), make_type_variable(), make_variable(), NIL, pips_assert, pips_debug, pips_internal_error, pips_user_warning, pointed_type(), pointer_type_p(), type_consistent_p(), type_equal_p(), type_functional, type_to_pointer_type(), type_undefined, type_variable, type_variable_p, type_void_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by call_to_type().

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

◆ is_inferior_basic()

bool is_inferior_basic ( basic  b1,
basic  b2 
)

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, ...

  • overloaded is inferior to any basic.
  • logical is inferior to any other but overloaded.
  • string is inferior to any other but overloaded and logical. Used to decide that the sum of an int and a float is a floating-point addition (for ex.)
Parameters
b11
b22

Definition at line 2687 of file type.c.

2689 {
2690  if ( b1 == basic_undefined )
2691  pips_internal_error("first basic_undefined");
2692  else if ( b2 == basic_undefined )
2693  pips_internal_error("second basic_undefined");
2694 
2695  if (basic_overloaded_p(b1))
2696  return (true);
2697  else if (basic_overloaded_p(b2))
2698  return (false);
2699  else if (basic_logical_p(b1))
2700  return (true);
2701  else if (basic_logical_p(b2))
2702  return (false);
2703  else if (basic_string_p(b1))
2704  return (true);
2705  else if (basic_string_p(b2))
2706  return (false);
2707  else if (basic_int_p(b1)) {
2708  if (basic_int_p(b2))
2709  return (basic_int(b1) <= basic_int(b2));
2710  else
2711  return (true);
2712  }
2713  else if (basic_float_p(b1)) {
2714  if (basic_int_p(b2))
2715  return (false);
2716  else if (basic_float_p(b2))
2717  return (basic_float(b1) <= basic_float(b2));
2718  else
2719  return (true);
2720  }
2721  else if (basic_complex_p(b1)) {
2722  if (basic_int_p(b2) || basic_float_p(b2))
2723  return (false);
2724  else if (basic_complex_p(b2))
2725  return (basic_complex(b1) <= basic_complex(b2));
2726  else
2727  return (true);
2728  }
2729  else
2730  pips_internal_error("Case never occurs.");
2731  return (true);
2732 }

References b1, b2, 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, and pips_internal_error.

Referenced by arguments_to_complexity(), basic_union_arguments(), indices_to_complexity(), intrinsic_cost(), and typing_power_operator().

+ Here is the caller graph for this function:

◆ ldimensions_dup()

list ldimensions_dup ( list  l)

Definition at line 1166 of file type.c.

1167 {
1168  list result = NIL ;
1169 
1170  MAPL(cd,
1171  {
1172  result = CONS(DIMENSION, dimension_dup(DIMENSION(CAR(cd))),
1173  result);
1174  },
1175  l);
1176 
1177  return(gen_nreverse(result));
1178 }
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
dimension dimension_dup(dimension d)
Definition: type.c:1159

References CAR, CONS, DIMENSION, dimension_dup(), gen_nreverse(), MAPL, and NIL.

Referenced by type_variable_dup().

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

◆ logical_type_p()

bool logical_type_p ( type  t)

Definition at line 2865 of file type.c.

2866 {
2867  if (!type_undefined_p(t) && type_variable_p(t))
2868  {
2870  if (!basic_undefined_p(b) && basic_logical_p(b))
2871  return true;
2872  }
2873  return false;
2874 }

References basic_logical_p, basic_undefined_p, type_undefined_p, type_variable, type_variable_p, and variable_basic.

Referenced by logical_constant_p().

+ Here is the caller graph for this function:

◆ long_type_p()

bool long_type_p ( type  t)

Definition at line 2831 of file type.c.

2832 {
2833  if (type_variable_p(t))
2834  {
2836  if (basic_int_p(b))
2838  return true;
2839  }
2840  return false;
2841 }
#define DEFAULT_LONG_INTEGER_TYPE_SIZE

References basic_int, basic_int_p, DEFAULT_LONG_INTEGER_TYPE_SIZE, type_variable, type_variable_p, and variable_basic.

Referenced by make_standard_long_integer_type().

+ Here is the caller graph for this function:

◆ make_char_array_type()

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 5213 of file type.c.

5214 {
5215  /* Two options: a string of n characters or an array of n char,
5216  i.e. int. */
5217  constant c = make_constant_int(n);
5218  value val = make_value_constant(c);
5219  basic b = make_basic_string(val);
5220  variable var = make_variable(b, NIL, NIL);
5221  type t = make_type_variable(var);
5222 
5223  return t;
5224 }
value make_value_constant(constant _field_)
Definition: ri.c:2841
constant make_constant_int(intptr_t _field_)
Definition: ri.c:409
basic make_basic_string(value _field_)
Definition: ri.c:173

References make_basic_string(), make_constant_int(), make_type_variable(), make_value_constant(), make_variable(), and NIL.

Referenced by init_c_implicit_variables().

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

◆ make_scalar_char_pointer_type()

type make_scalar_char_pointer_type ( void  )

Allocate a char * pointer type.

Definition at line 5227 of file type.c.

5228 {
5230  basic b = make_basic_pointer(pt);
5231  variable v = make_variable(b, NIL, NIL);
5232  type t = make_type_variable(v);
5233  return t;
5234 }
type make_scalar_integer_type(_int n)
Definition: type.c:712

References DEFAULT_CHARACTER_TYPE_SIZE, make_basic_pointer(), make_scalar_integer_type(), make_type_variable(), make_variable(), and NIL.

Referenced by array_pointer_string_type_equal_p().

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

◆ make_scalar_complex_type()

type make_scalar_complex_type ( _int  n)

Definition at line 719 of file type.c.

720 {
723  return t;
724 }

References is_basic_complex, is_type_variable, make_basic(), make_type(), make_variable(), NIL, and UUINT.

+ Here is the call graph for this function:

◆ make_scalar_integer_type()

type make_scalar_integer_type ( _int  n)

Definition at line 712 of file type.c.

713 {
716  return t;
717 }

References is_basic_int, is_type_variable, make_basic(), make_type(), make_variable(), NIL, and UUINT.

Referenced by create_stub_points_to(), CreateAbstractStateVariable(), make_scalar_char_pointer_type(), UpdateEntity(), and UpdateType().

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

◆ make_scalar_overloaded_type()

type make_scalar_overloaded_type ( void  )

Definition at line 726 of file type.c.

727 {
730  return t;
731 }

References is_type_variable, make_basic_overloaded(), make_type(), make_variable(), and NIL.

Referenced by points_to_cells_minimal_upper_bound(), process_casted_sinks(), and process_casted_sources().

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

◆ make_standard_integer_type()

type make_standard_integer_type ( type  t,
int  size 
)

If it is int i:5, keep the bit basic type

Parameters
sizeize

Definition at line 3196 of file type.c.

3197 {
3198  if (t == type_undefined)
3199  {
3201  return make_type_variable(v);
3202  }
3203  else
3204  {
3205  if (signed_type_p(t) || unsigned_type_p(t))
3206  {
3208  int i = basic_int(b);
3209  variable v = make_variable(make_basic_int(10*(i/10)+size),NIL,NIL);
3210  pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+size);
3211  return make_type_variable(v);
3212  }
3213  else
3214  {
3215  if (bit_type_p(t))
3216  /* If it is int i:5, keep the bit basic type*/
3217  return t;
3218  else
3219  user_warning("Parse error", "Standard integer types\n");
3220  return type_undefined;
3221  }
3222  }
3223 }
#define user_warning(fn,...)
Definition: misc-local.h:262
bool signed_type_p(type t)
Definition: type.c:2800
bool unsigned_type_p(type t)
Predicates on types.
Definition: type.c:2821
bool bit_type_p(type t)
Definition: type.c:2843

References basic_int, bit_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, and variable_basic.

+ Here is the call graph for this function:

◆ make_standard_long_integer_type()

type make_standard_long_integer_type ( type  t)

long

long long

If it is long int i:5, keep the bit basic type

Definition at line 3309 of file type.c.

3310 {
3311  if (t == type_undefined)
3312  {
3314  return make_type_variable(v);
3315  }
3316  else
3317  {
3318  if (signed_type_p(t) || unsigned_type_p(t) || long_type_p(t))
3319  {
3321  int i = basic_int(b);
3322  variable v;
3323  if (i%10 == DEFAULT_INTEGER_TYPE_SIZE)
3324  {
3325  /* long */
3327  pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+DEFAULT_LONG_INTEGER_TYPE_SIZE);
3328  }
3329  else
3330  {
3331  /* long long */
3333  pips_debug(8,"Old basic size: %d, new size : %d\n",i,10*(i/10)+DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE);
3334  }
3335  return make_type_variable(v);
3336  }
3337  else
3338  {
3339  if (bit_type_p(t))
3340  /* If it is long int i:5, keep the bit basic type*/
3341  return t;
3342  else
3343  user_warning("Parse error", "Standard long integer types\n");
3344  return type_undefined;
3345  }
3346  }
3347 }
#define DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE
bool long_type_p(type t)
Definition: type.c:2831

References basic_int, bit_type_p(), DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LONG_INTEGER_TYPE_SIZE, DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE, 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, and variable_basic.

+ Here is the call graph for this function:

◆ make_unbounded_dimensions()

list make_unbounded_dimensions ( int  d)

Minimal information to build a d-dimensional array type.

Definition at line 5752 of file type.c.

5753 {
5754  list dl = NIL;
5755  int i;
5756  for(i=0; i<d;i++) {
5759  NIL);
5760  dl = CONS(DIMENSION, d, dl);
5761  }
5762  return dl;
5763 }
expression make_unbounded_expression()
Definition: expression.c:4339
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188

References CONS, DIMENSION, int_to_expression(), make_dimension(), make_unbounded_expression(), and NIL.

Referenced by create_stub_points_to().

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

◆ MakeAnyScalarParameter()

parameter MakeAnyScalarParameter ( tag  t,
_int  size 
)

For Fortran.

Parameters
sizeize

Definition at line 251 of file type.c.

252 {
253  return make_parameter(MakeTypeArray(make_basic(t, UUINT(size)), NIL),
256 }
mode make_mode_reference(void)
Definition: ri.c:1356
type MakeTypeArray(basic b, cons *ld)
functions on types
Definition: type.c:162

References make_basic(), make_dummy_unknown(), make_mode_reference(), make_parameter(), MakeTypeArray(), NIL, and UUINT.

Referenced by MakeComplexParameter(), MakeDoublecomplexParameter(), MakeDoubleprecisionParameter(), MakeIntegerParameter(), MakeLogicalParameter(), MakeLongDoublecomplexParameter(), MakeLongIntegerParameter(), MakeLongLongIntegerParameter(), MakeOverloadedParameter(), MakePointerParameter(), MakeQuadprecisionParameter(), MakeRealParameter(), and MakeUnsignedIntegerParameter().

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

◆ MakeAnyScalarResult()

type MakeAnyScalarResult ( tag  t,
_int  size 
)
Parameters
sizeize

Definition at line 337 of file type.c.

338 {
339  return MakeTypeArray(make_basic(t, UUINT(size)), NIL);
340 }

References make_basic(), MakeTypeArray(), NIL, and UUINT.

Referenced by MakeComplexResult(), MakeDoublecomplexResult(), MakeDoubleprecisionResult(), MakeIntegerResult(), MakeLogicalResult(), MakeLongDoublecomplexResult(), MakeLongIntegerResult(), MakeLongLongIntegerResult(), MakeOverloadedResult(), MakeQuadprecisionResult(), MakeRealResult(), and MakeUnsignedIntegerResult().

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

◆ MakeBasic()

basic MakeBasic ( int  the_tag)

END_EOLE.

Parameters
the_taghe_tag

Definition at line 128 of file type.c.

130 {
131  switch(the_tag)
132  {
133  case is_basic_int:
134  return(make_basic(is_basic_int, UUINT(4)));
135  break;
136  case is_basic_float:
137  return(make_basic(is_basic_float, UUINT(4)));
138  break;
139  case is_basic_logical:
140  return(make_basic(is_basic_logical, UUINT(4)));
141  break;
142  case is_basic_complex:
143  return(make_basic(is_basic_complex, UUINT(8)));
144  break;
145  case is_basic_overloaded:
147  break;
148  case is_basic_string:
150  break;
151  default:
152  pips_internal_error("unexpected basic tag: %d",
153  the_tag);
154  break;
155  }
156 
157  return(basic_undefined);
158 }
#define string_undefined
Definition: newgen_types.h:40

References basic_undefined, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_string, make_basic(), pips_internal_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(), mpi_initialize(), mpi_make_ctx(), and st_compute_ith_local_index().

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

◆ MakeBasicOverloaded()

basic MakeBasicOverloaded ( void  )

bool same_type_name_p(const type t0, const type t1) {

string s0 = string_of_type(t0), s1 =string_of_type(t1); bool same = same_string_p(s0,s1); free(s0); free(s1); return same; } generation of types

Definition at line 77 of file type.c.

78 {
80 }

References is_basic_overloaded, make_basic(), and NIL.

+ Here is the call graph for this function:

◆ MakeCharacterParameter()

parameter MakeCharacterParameter ( void  )

Definition at line 239 of file type.c.

240 {
245  NIL),
248 }
constant make_constant(enum constant_utype tag, void *val)
Definition: ri.c:406
mode make_mode(enum mode_utype tag, void *val)
Definition: ri.c:1350
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
@ is_mode_reference
Definition: ri.h:1676
@ is_constant_int
Definition: ri.h:817

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().

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

◆ MakeCharacterResult()

type MakeCharacterResult ( void  )

Definition at line 328 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().

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

◆ MakeComplexParameter()

parameter MakeComplexParameter ( void  )

Definition at line 224 of file type.c.

225 {
227 }
parameter MakeAnyScalarParameter(tag t, _int size)
For Fortran.
Definition: type.c:251

References DEFAULT_COMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarParameter().

Referenced by complex_to_complex_type(), and complex_to_real_type().

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

◆ MakeComplexResult()

type MakeComplexResult ( void  )

Definition at line 311 of file type.c.

312 {
314 }
type MakeAnyScalarResult(tag t, _int size)
Definition: type.c:337

References DEFAULT_COMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarResult().

Referenced by complex_to_complex_type(), and overloaded_to_complex_type().

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

◆ MakeDoublecomplexParameter()

parameter MakeDoublecomplexParameter ( void  )

Definition at line 229 of file type.c.

230 {
232 }
#define DEFAULT_DOUBLECOMPLEX_TYPE_SIZE

References DEFAULT_DOUBLECOMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarParameter().

Referenced by doublecomplex_to_double_type(), and doublecomplex_to_doublecomplex_type().

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

◆ MakeDoublecomplexResult()

type MakeDoublecomplexResult ( void  )

Definition at line 316 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().

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

◆ MakeDoubleprecisionParameter()

parameter MakeDoubleprecisionParameter ( void  )

◆ MakeDoubleprecisionResult()

type MakeDoubleprecisionResult ( void  )

◆ MakeIntegerParameter()

parameter MakeIntegerParameter ( void  )

Definition at line 184 of file type.c.

References DEFAULT_INTEGER_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().

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

◆ MakeIntegerResult()

◆ MakeLogicalParameter()

parameter MakeLogicalParameter ( void  )

Definition at line 219 of file type.c.

220 {
222 }
#define DEFAULT_LOGICAL_TYPE_SIZE

References DEFAULT_LOGICAL_TYPE_SIZE, is_basic_logical, and MakeAnyScalarParameter().

+ Here is the call graph for this function:

◆ MakeLogicalResult()

type MakeLogicalResult ( void  )

Definition at line 306 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().

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

◆ MakeLongDoublecomplexParameter()

parameter MakeLongDoublecomplexParameter ( void  )

MB.

Definition at line 234 of file type.c.

235 {
237 }
#define DEFAULT_LONGDOUBLECOMPLEX_TYPE_SIZE

References DEFAULT_LONGDOUBLECOMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarParameter().

Referenced by longdoublecomplex_to_longdouble_type(), and longdoublecomplex_to_longdoublecomplex_type().

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

◆ MakeLongDoublecomplexResult()

type MakeLongDoublecomplexResult ( void  )

MB.

Definition at line 322 of file type.c.

References DEFAULT_LONGDOUBLECOMPLEX_TYPE_SIZE, is_basic_complex, and MakeAnyScalarResult().

Referenced by longdoublecomplex_to_longdoublecomplex_type().

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

◆ MakeLongIntegerParameter()

parameter MakeLongIntegerParameter ( void  )

Definition at line 189 of file type.c.

References DEFAULT_LONG_INTEGER_TYPE_SIZE, is_basic_int, and MakeAnyScalarParameter().

Referenced by longinteger_to_overloaded_type().

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

◆ MakeLongIntegerResult()

type MakeLongIntegerResult ( void  )

MB.

Definition at line 281 of file type.c.

References DEFAULT_LONG_INTEGER_TYPE_SIZE, is_basic_int, and MakeAnyScalarResult().

Referenced by atomic_function_of_operation(), double_to_longinteger_type(), longdouble_to_longinteger_type(), longinteger_to_longinteger_type(), and real_to_longinteger_type().

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

◆ MakeLongLongIntegerParameter()

parameter MakeLongLongIntegerParameter ( void  )

MB.

Definition at line 199 of file type.c.

References DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE, is_basic_int, and MakeAnyScalarParameter().

Referenced by longlonginteger_to_overloaded_type().

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

◆ MakeLongLongIntegerResult()

type MakeLongLongIntegerResult ( void  )

MB.

Definition at line 286 of file type.c.

References DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE, is_basic_int, and MakeAnyScalarResult().

Referenced by double_to_longlonginteger_type(), longdouble_to_longlonginteger_type(), longlonginteger_to_longlonginteger_type(), and real_to_longlonginteger_type().

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

◆ MakeModeReference()

mode MakeModeReference ( void  )

Definition at line 82 of file type.c.

83 {
85 }

References is_mode_reference, make_mode(), and NIL.

Referenced by update_functional_type_with_actual_arguments(), and UpdateFunctionalType().

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

◆ MakeModeValue()

mode MakeModeValue ( void  )

Definition at line 87 of file type.c.

88 {
89  return(make_mode(is_mode_value, NIL));
90 }
@ is_mode_value
Definition: ri.h:1675

References is_mode_value, make_mode(), and NIL.

+ Here is the call graph for this function:

◆ MakeOverloadedParameter()

parameter MakeOverloadedParameter ( void  )

◆ MakeOverloadedResult()

type MakeOverloadedResult ( void  )

this function creates a default fortran operator result, i.e.

a zero dimension variable with an overloaded basic type.

Definition at line 261 of file type.c.

262 {
264 }

References is_basic_overloaded, and MakeAnyScalarResult().

Referenced by __attribute__(), default_intrinsic_type(), gfc2pips_code2instruction_(), integer_to_overloaded_type(), longinteger_to_overloaded_type(), longlonginteger_to_overloaded_type(), MakeRunTimeSupportFunction(), and pointer_to_overloaded_type().

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

◆ MakePointerParameter()

parameter MakePointerParameter ( void  )

Definition at line 173 of file type.c.

174 {
175  pips_internal_error("Wrong signature, wrong implementation.\n");
177 }

References DEFAULT_POINTER_TYPE_SIZE, is_basic_pointer, MakeAnyScalarParameter(), and pips_internal_error.

Referenced by pointer_to_overloaded_type().

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

◆ MakeQuadprecisionParameter()

parameter MakeQuadprecisionParameter ( void  )

MB.

Definition at line 214 of file type.c.

215 {
217 }
#define DEFAULT_QUADPRECISION_TYPE_SIZE

References DEFAULT_QUADPRECISION_TYPE_SIZE, is_basic_float, and MakeAnyScalarParameter().

Referenced by longdouble_to_integer_type(), longdouble_to_longdouble_type(), longdouble_to_longinteger_type(), and longdouble_to_longlonginteger_type().

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

◆ MakeQuadprecisionResult()

type MakeQuadprecisionResult ( void  )

MB.

Definition at line 301 of file type.c.

References DEFAULT_QUADPRECISION_TYPE_SIZE, is_basic_float, and MakeAnyScalarResult().

Referenced by longdouble_to_longdouble_type(), longdoublecomplex_to_longdouble_type(), and overloaded_to_longdouble_type().

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

◆ MakeRealParameter()

parameter MakeRealParameter ( void  )

Definition at line 204 of file type.c.

205 {
207 }
#define DEFAULT_REAL_TYPE_SIZE
The standard C integer types are represented as follow char = 1 short_int = 2 int = 4 long_int = 6 lo...

References DEFAULT_REAL_TYPE_SIZE, is_basic_float, and MakeAnyScalarParameter().

Referenced by real_to_double_type(), real_to_integer_type(), real_to_longinteger_type(), real_to_longlonginteger_type(), and real_to_real_type().

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

◆ MakeRealResult()

type MakeRealResult ( void  )

Definition at line 291 of file type.c.

References DEFAULT_REAL_TYPE_SIZE, is_basic_float, and MakeAnyScalarResult().

Referenced by atomic_function_of_operation(), complex_to_real_type(), integer_to_real_type(), overloaded_to_real_type(), and real_to_real_type().

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

◆ MakeTypeArray()

type MakeTypeArray ( basic  b,
cons ld 
)

functions on types

Parameters
ldd

Definition at line 162 of file type.c.

163 {
164  return(make_type(is_type_variable, make_variable(b, ld,NIL)));
165 }

References is_type_variable, make_type(), make_variable(), and NIL.

Referenced by CreateLogicalUnits(), MakeAnyScalarParameter(), MakeAnyScalarResult(), MakeCharacterParameter(), MakeCharacterResult(), and MakeVoidPointerResult().

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

◆ MakeTypeOverloaded()

type MakeTypeOverloaded ( void  )

Definition at line 107 of file type.c.

108 {
110 }
type MakeTypeVariable(basic b, cons *ld)
BEGIN_EOLE.
Definition: type.c:116

References make_basic_overloaded(), MakeTypeVariable(), and NIL.

Referenced by create_scalar_stub_sink_cell(), and type_to_array_type().

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

◆ MakeTypeStatement()

type MakeTypeStatement ( void  )

Definition at line 92 of file type.c.

93 {
95 }

References is_type_statement, make_type(), and NIL.

Referenced by bootstrap(), make_label(), MakeCLabel(), and MakeLabel().

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

◆ MakeTypeUnknown()

type MakeTypeUnknown ( void  )

Definition at line 97 of file type.c.

98 {
99  return(make_type(is_type_unknown, NIL));
100 }

References is_type_unknown, make_type(), and NIL.

Referenced by gfc2pips_symbol2type(), max_type(), and opgen_may_type().

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

◆ MakeTypeVariable()

◆ MakeTypeVoid()

type MakeTypeVoid ( void  )

Definition at line 102 of file type.c.

103 {
104  return(make_type(is_type_void, NIL));
105 }

References is_type_void, make_type(), and NIL.

Referenced by MakeCallInst().

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

◆ MakeUnsignedIntegerParameter()

parameter MakeUnsignedIntegerParameter ( void  )

Definition at line 194 of file type.c.

References DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_UNSIGNED_TYPE_SIZE, is_basic_int, and MakeAnyScalarParameter().

Referenced by unsigned_integer_to_void_pointer_type().

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

◆ MakeUnsignedIntegerResult()

type MakeUnsignedIntegerResult ( void  )

Definition at line 265 of file type.c.

References DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_UNSIGNED_TYPE_SIZE, is_basic_int, and MakeAnyScalarResult().

+ Here is the call graph for this function:

◆ MakeVoidPointerParameter()

parameter MakeVoidPointerParameter ( void  )

Definition at line 178 of file type.c.

179 {
182 }
type make_type_void(list _field_)
Definition: ri.c:2727

References make_dummy_unknown(), make_mode_value(), make_parameter(), make_type_void(), NIL, and type_to_pointer_type().

+ Here is the call graph for this function:

◆ MakeVoidPointerResult()

type MakeVoidPointerResult ( void  )

Definition at line 271 of file type.c.

272 {
274 }

References make_basic_pointer(), make_type_void(), MakeTypeArray(), and NIL.

Referenced by unsigned_integer_to_void_pointer_type().

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

◆ maximal_type_depth()

size_t maximal_type_depth ( type  t)

Number of steps to access the lowest leave of type t without a recursive test.

Number of dimensions for an array. One for a struct or an union field, plus its own dimension(s). Recursive data structures do not end up with MAX_INT as type depth. So

A pointer to a scalar may be a pointer to an array, unless property POINTS_TO_STRICT_POINTER_TYPES is set to true.

The name of the function should be non_recursive_maximal_type_depth(). It returns the maximum number of subscript expressions usable in a points-to cell reference.

Concrete types are not used. The depth of named types is supposedly calculated.

Definition at line 4856 of file type.c.

4857 {
4858  set vt = set_make(set_pointer);
4859  int depth = generic_type_depth(t, vt);
4860  set_free(vt);
4861  return depth;
4862 }
static int depth
la sequence de nids

References depth, generic_type_depth(), set_free(), set_make(), and set_pointer.

Referenced by xml_Type_Entity().

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

◆ mode_equal_p()

bool mode_equal_p ( mode  m1,
mode  m2 
)
Parameters
m11
m22

Definition at line 1035 of file type.c.

1036 {
1037  if(m1 == m2)
1038  return true;
1039  else if (m1 == mode_undefined && m2 != mode_undefined)
1040  return false;
1041  else if (m1 != mode_undefined && m2 == mode_undefined)
1042  return false;
1043  else
1044  return mode_tag(m1) == mode_tag(m2);
1045 }
#define mode_undefined
Definition: ri.h:1660
#define mode_tag(x)
Definition: ri.h:1693

References mode_tag, and mode_undefined.

Referenced by generic_parameter_equal_p().

+ Here is the caller graph for this function:

◆ number_of_fields()

int number_of_fields ( type  t)

Recursive number of fields in a data structure...

union and probably enum are not taken into account.

FI: I guess enum should be added

Definition at line 3893 of file type.c.

3894 {
3895  int n = 1;
3896  type ut = ultimate_type(t);
3897 
3898  if(type_variable_p(ut)) {
3900 
3901  if(basic_derived_p(ub)) {
3902  entity de = basic_derived(ub);
3903  type dt = entity_type(de);
3904  n = number_of_fields(dt);
3905  }
3906  }
3907  else if(type_struct_p(t)) {
3908  list el = type_struct(t);
3909  list ce = list_undefined;
3910 
3911  n = 0;
3912  for(ce = el; !ENDP(ce); POP(ce)) {
3913  entity fe = ENTITY(CAR(ce));
3914  type ft = entity_type(fe);
3915  n += number_of_fields(ft);
3916  }
3917  }
3918  else
3919  pips_internal_error("Illegal type argument");
3920 
3921  return n;
3922 }
int number_of_fields(type t)
Recursive number of fields in a data structure...
Definition: type.c:3893

References basic_derived, basic_derived_p, CAR, ENDP, ENTITY, entity_type, list_undefined, number_of_fields(), pips_internal_error, POP, type_struct, type_struct_p, type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by number_of_fields(), and number_of_items().

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

◆ number_of_items()

int number_of_items ( type  t)

Same as above, but arrays in struct are taken into account.

Definition at line 3925 of file type.c.

3926 {
3927  int n = 1;
3928  type ut = ultimate_type(t);
3929 
3930  if(type_variable_p(ut)) {
3931  variable uv = type_variable(ut);
3932  basic ub = variable_basic(uv);
3933  int ne;
3934  bool ok = NumberOfElements(ub, variable_dimensions(uv), &ne);
3935 
3936  if(basic_derived_p(ub)) {
3937  entity de = basic_derived(ub);
3938  type dt = entity_type(de);
3939  n = number_of_fields(dt);
3940  }
3941 
3942  if(ok)
3943  n = n*ne;
3944  else
3945  pips_internal_error("Unexpected use of this function");
3946  }
3947  else if(type_struct_p(t)) {
3948  list el = type_struct(t);
3949  list ce = list_undefined;
3950 
3951  n = 0;
3952  for(ce = el; !ENDP(ce); POP(ce)) {
3953  entity fe = ENTITY(CAR(ce));
3954  type ft = entity_type(fe);
3955  n += number_of_items(ft);
3956  }
3957  }
3958  else
3959  pips_internal_error("Illegal type argument");
3960 
3961  return n;
3962 }
int number_of_items(type t)
Same as above, but arrays in struct are taken into account.
Definition: type.c:3925
bool NumberOfElements(basic, list, int *)
Definition: size.c:403

References basic_derived, basic_derived_p, CAR, ENDP, ENTITY, entity_type, list_undefined, number_of_fields(), number_of_items(), NumberOfElements(), ok, pips_internal_error, POP, type_struct, type_struct_p, type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by number_of_items(), and SizeOfArray().

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

◆ overloaded_parameters_p()

bool overloaded_parameters_p ( list  lparams)
Parameters
lparamsparams

Definition at line 5236 of file type.c.

5237 {
5238  bool overloaded_p = true;
5239 
5240  FOREACH(PARAMETER, p, lparams) {
5241  type pt = parameter_type(p);
5242 
5243  if(!overloaded_type_p(pt)) {
5244  overloaded_p = false;
5245  break;
5246  }
5247  }
5248 
5249  return overloaded_p;
5250 }
list lparams
Array bounds.
Definition: reindexing.c:111
bool overloaded_type_p(type t)
Returns true if t is a variable type with a basic overloaded.
Definition: type.c:2666

References FOREACH, lparams, overloaded_type_p(), PARAMETER, and parameter_type.

Referenced by generic_c_words_simplified_entity().

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

◆ overloaded_type_p()

◆ parameter_equal_p()

bool parameter_equal_p ( parameter  p1,
parameter  p2 
)
Parameters
p11
p22

Definition at line 1030 of file type.c.

1031 {
1032  return generic_parameter_equal_p(p1, p2, true, true, false);
1033 }

References generic_parameter_equal_p().

+ Here is the call graph for this function:

◆ pointed_type()

type pointed_type ( type  t)

returns the type pointed by the input type if it is a pointer or an array of pointers

Definition at line 3035 of file type.c.

3036 {
3037  type res = type_undefined;
3038 
3041  return res;
3042 }

References basic_pointer, basic_pointer_p, type_undefined, type_variable, type_variable_p, and variable_basic.

Referenced by convert_pointer_to_array(), do_array_to_pointer_walk_call_and_patch(), do_linearize_prepatch_subscript(), effects_to_dma(), intrinsic_call_to_type(), and module_initial_parameter_pv().

+ Here is the caller graph for this function:

◆ pointer_type_p()

bool pointer_type_p ( type  t)

Check for scalar pointers.

Definition at line 2993 of file type.c.

2994 {
2995  bool pointer_p = false;
2996  if(type_variable_p(t)) {
2997  variable v = type_variable(t);
2998  basic b = variable_basic(v);
2999  if(basic_pointer_p(b))
3000  pointer_p = (variable_dimensions(type_variable(t)) == NIL);
3001 }
3002  return pointer_p;
3003 }

References basic_pointer_p, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by add_conflicts(), any_source_to_sinks(), anywhere_source_to_sinks(), array_pointer_type_equal_p(), assignment_to_points_to(), assignment_to_post_pv(), binary_arithmetic_operator_to_post_pv(), c_convex_effects_on_formal_parameter_backward_translation(), C_type_to_pointed_type(), call_to_points_to(), cast_to_points_to_sinks(), cell_must_point_to_nowhere_sink_in_set_p(), cell_points_to_non_null_sink_in_set_p(), cell_points_to_nowhere_sink_in_set_p(), cell_points_to_null_sink_in_set_p(), char_star_type_p(), check_rhs_value_types(), check_type_of_points_to_cells(), compute_points_to_binded_set(), declaration_statement_to_points_to(), dereferencing_to_points_to(), dereferencing_to_sinks(), do_array_to_pointer_type(), do_check_isolate_statement_preconditions_on_call(), do_gpu_qualify_pointers(), do_linearize_array_manage_callers(), do_linearize_prepatch_type(), effect_interference(), effect_scalar_p(), effect_to_store_independent(), entity_flow_or_context_sentitive_heap_location(), entity_scalar_p(), equal_condition_to_points_to(), expression_pointer_p(), expression_to_points_to(), expression_to_points_to_cells(), expression_to_points_to_sinks_with_offset(), expression_to_points_to_sources(), external_call_to_post_pv(), freed_list_to_points_to(), gen_may_constant_paths(), gen_must_constant_paths(), generic_c_words_simplified_entity(), generic_points_to_cell_to_useful_pointer_cells(), generic_stub_source_to_sinks(), intrinsic_call_condition_to_points_to(), intrinsic_call_to_points_to(), intrinsic_call_to_type(), memory_dereferencing_p(), new_recursive_filter_formal_context_according_to_actual_context(), non_equal_condition_to_points_to(), normalize_subscript_expression(), null_equal_condition_to_points_to(), null_non_equal_condition_to_points_to(), order_condition_to_points_to(), perform_array_element_substitutions_in_transformer(), points_to_cell_types_compatibility(), points_to_cells_parameters(), points_to_expression_to_pointed_type(), points_to_function_projection(), points_to_reference_update_final_subscripts(), points_to_set_block_projection(), points_to_translation_of_formal_parameters(), points_to_translation_of_struct_formal_parameter(), points_to_with_stripped_sink(), process_casted_sources(), recursive_cell_to_pointer_cells(), recursive_store_independent_points_to_reference_p(), reduce_cell_to_pointer_type(), reference_condition_to_points_to(), reference_dereferencing_to_points_to(), reference_to_points_to(), reference_to_points_to_sinks(), safe_intrinsic_to_post_pv(), set_entity_initial(), sizeofexpression_to_points_to_sinks(), store_independent_effect_p(), store_independent_reference_p(), struct_assignment_to_points_to(), struct_variable_to_pointer_locations(), struct_variable_to_pointer_subscripts(), subscript_to_points_to_sinks(), subscripted_reference_to_points_to(), TestCoupleOfReferences(), type_to_final_pointed_type(), type_to_pointed_type(), type_void_star_p(), unary_arithmetic_operator_to_post_pv(), update_operator_to_post_pv(), UpdateDerivedEntity(), UpdateEntity(), variable_initial_expression(), and variable_to_pointer_locations().

◆ private_ultimate_type()

static type private_ultimate_type ( type  t,
bool  arrays_only 
)
static

FI: there are different notions of "ultimate" types in C.

We may need to reduce a type to basic concrete types, removing all typedefs wherever they are. This is done by type_to_basic_concrete_type, see below.

We may also need to know if the type is compatible with a function call: we need to chase down the pointers as well as the typedefs. See call_compatible_type_p().

Finally, we may need to know how much memory should be allocated to hold an object of this type. This is what was needed first, hence the semantics of the function below.

Shoud this function be extended to return a type_undefined whe nthe argument is type_undefined or simply core dump to signal an issue as soon as possible? The second alternative is chosen. What type should be used to perform memory allocation? No allocation of a new type.

pips_debug(9, "and basic \"s"
", basic_to_string(bt));

without this test, we would erase the dimension ...

what should we do ? allocate a new type ... but this breaks the semantic of the function we still create a leak for this case, which does not appear to often a warning is printed out, so that we don't forget it

ifdebug(9) {

if(type_variable_p(nt)) {

variable nvt = type_variable(nt);

basic nbt = variable_basic(nvt);

pips_debug(9, "and basic \"s"
", basic_to_string(nbt));

}

}

Definition at line 3370 of file type.c.

3371 {
3372  type nt;
3373 
3374  // only under debug, because there is a big impact on performance
3375  ifdebug(1) pips_assert("type consistent",type_consistent_p(t));
3376 
3377  pips_debug(9, "Begins with type \"%s\"\n", type_to_string(t));
3378 
3379  if(type_variable_p(t)) {
3380  variable vt = type_variable(t);
3381  basic bt = variable_basic(vt);
3382 
3383  /* pips_debug(9, "and basic \"%s\"\n", basic_to_string(bt)); */
3384 
3385  if(basic_typedef_p(bt)) {
3386  entity e = basic_typedef(bt);
3387  type st = entity_type(e);
3388 
3389  if (!arrays_only
3391  // recursion
3392  nt = ultimate_type(st);
3393  else
3394  nt = t;
3395 
3396  // FC->SG the following stuff requires more comments to be understandable
3397  // FC->SG why this #if ???
3398 #if 1
3399  /* without this test, we would erase the dimension ... */
3400  if( !ENDP(variable_dimensions(vt) ) )
3401  {
3402  /* what should we do ? allocate a new type ...
3403  * but this breaks the semantic of the function
3404  * we still create a leak for this case, which does not appear to
3405  * often a warning is printed out, so that we don't forget it
3406  */
3407  // ??? FC->SG why this static structure?
3408  static size_t holder_iter = 0;
3409  // ??? FC->SG: why 8? why not 314159?
3410  //
3411  // this is creazy programming and a time bomb:-(
3412  //
3413  // it seems that the returned allocated type is stored there
3414  // so that it may be freed some time later, with the hope that by
3415  // the time it is freed it will not be in use anymore.
3416  //
3417  // I would prefer a memory leak in place of this kludge.
3418  // I would rather suggest to memoize the computed types
3419  // and not to do this kind of hidden garbage collector.
3420  static type holder[8] = {// SG: this should avoid the leak
3429  };
3430  nt=copy_type(nt);
3431  holder_iter = 7 & ( 1 + holder_iter ); // too much VHDL? :-(
3435  if (!type_undefined_p(holder[holder_iter]))
3436  free_type(holder[holder_iter]);
3437  holder[holder_iter]=nt;
3438  }
3439 #endif
3440  }
3441  else
3442  nt = t;
3443  }
3444  else
3445  nt = t;
3446 
3447  pips_debug(9, "Ends with type \"%s\"\n", type_to_string(nt));
3448  /* ifdebug(9) { */
3449  /* if(type_variable_p(nt)) { */
3450  /* variable nvt = type_variable(nt); */
3451  /* basic nbt = variable_basic(nvt); */
3452 
3453  /* pips_debug(9, "and basic \"%s\"\n", basic_to_string(nbt)); */
3454  /* } */
3455  /* } */
3456 
3457  if (!arrays_only)
3458  pips_assert("nt is not a typedef",
3460 
3461  // only under debug, because there is a big impact on performance
3462  ifdebug(1) pips_assert("type consistent",type_consistent_p(nt));
3463  return nt;
3464 }
if(!(yy_init))
Definition: genread_lex.c:1029
return(s1)

References basic_typedef, basic_typedef_p, copy_type(), ENDP, entity_type, free_type(), gen_full_copy_list(), gen_nconc(), ifdebug, pips_assert, pips_debug, type_consistent_p(), type_to_string(), type_undefined, type_undefined_p, type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by ultimate_array_type(), and ultimate_type().

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

◆ qualifier_equal_p()

bool qualifier_equal_p ( qualifier  q1,
qualifier  q2 
)
Parameters
q11
q22

Definition at line 5420 of file type.c.

5421 {
5422  bool equal_p = qualifier_tag(q1)==qualifier_tag(q2);
5423 
5424  return equal_p;
5425 }
#define qualifier_tag(x)
Definition: ri.h:2175

References qualifier_tag.

Referenced by insert_qualifier(), and qualifiers_equal_p().

+ Here is the caller graph for this function:

◆ qualifier_to_string()

string qualifier_to_string ( qualifier  q)

Definition at line 5427 of file type.c.

5428 {
5429  string s = string_undefined;
5430  switch (qualifier_tag(q)) {
5431  case is_qualifier_register:
5432  s = "register";
5433  break;
5434  case is_qualifier_const:
5435  s = "const";
5436  break;
5437  case is_qualifier_restrict:
5438  s = "restrict";
5439  break;
5440  case is_qualifier_volatile:
5441  s = "volatile";
5442  break;
5443  case is_qualifier_auto:
5444  s = "auto";
5445  break;
5446  default :
5447  pips_internal_error("unexpected tag %d", qualifier_tag(q));
5448  }
5449  return s;
5450 }
@ is_qualifier_volatile
Definition: ri.h:2129
@ is_qualifier_register
Definition: ri.h:2130
@ is_qualifier_restrict
Definition: ri.h:2128
@ is_qualifier_const
Definition: ri.h:2127
@ is_qualifier_auto
Definition: ri.h:2131

References is_qualifier_auto, is_qualifier_const, is_qualifier_register, is_qualifier_restrict, is_qualifier_volatile, pips_internal_error, qualifier_tag, and string_undefined.

Referenced by insert_qualifier().

+ Here is the caller graph for this function:

◆ qualifiers_const_p()

bool qualifiers_const_p ( list  ql)

Check that a qualifier list contains the const qualifier.

Parameters
qll

Definition at line 5453 of file type.c.

5454 {
5455  bool const_p = false;
5456  FOREACH(QUALIFIER, q, ql) {
5457  if(qualifier_const_p(q)) {
5458  const_p = true;
5459  break;
5460  }
5461  }
5462  return const_p;
5463 }
#define qualifier_const_p(x)
Definition: ri.h:2176
#define QUALIFIER(x)
QUALIFIER.
Definition: ri.h:2106

References FOREACH, QUALIFIER, and qualifier_const_p.

Referenced by generic_c_words_simplified_entity(), and type_with_const_qualifier_p().

+ Here is the caller graph for this function:

◆ qualifiers_equal_p()

bool qualifiers_equal_p ( list  dims1,
list  dims2 
)
Parameters
dims1ims1
dims2ims2

Definition at line 758 of file type.c.

758  {
759  return gen_equals(dims1,dims2,(gen_eq_func_t)qualifier_equal_p);
760 }
bool qualifier_equal_p(qualifier q1, qualifier q2)
Definition: type.c:5420

References gen_equals(), and qualifier_equal_p().

Referenced by add_declaration_to_declaration_statement_p(), and generic_variable_equal_p().

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

◆ qualifiers_restrict_p()

bool qualifiers_restrict_p ( list  ql)

Check that a qualifier list contains the restrict qualifier.

Parameters
qll

Definition at line 5466 of file type.c.

5467 {
5468  bool restrict_p = false;
5469  FOREACH(QUALIFIER, q, ql) {
5470  if(qualifier_restrict_p(q)) {
5471  restrict_p = true;
5472  break;
5473  }
5474  }
5475  return restrict_p;
5476 }
#define qualifier_restrict_p(x)
Definition: ri.h:2179

References FOREACH, QUALIFIER, and qualifier_restrict_p.

Referenced by generic_c_words_simplified_entity().

+ Here is the caller graph for this function:

◆ recursive_functional_type_supporting_entities()

list recursive_functional_type_supporting_entities ( list  sel,
set  vt,
functional  f 
)
Parameters
selel
vtt

Definition at line 3977 of file type.c.

3978 {
3979  ifdebug(8) {
3980  pips_debug(8, "Begin: ");
3981  print_entities(sel);
3982  fprintf(stderr, "\n\n");
3983  }
3984 
3987  {
3989  dummy d = parameter_dummy(p);
3990  if(dummy_identifier_p(d))
3992  }
3993 
3995  list tmp =NIL;
3996 
3997  FOREACH(ENTITY,e,sel)
3998  {
4000  tmp=CONS(ENTITY,e,tmp);
4001  }
4002  gen_free_list(sel);
4003  sel=gen_nreverse(tmp);
4004 
4005  ifdebug(8) {
4006  pips_debug(8, "End: ");
4007  print_entities(sel);
4008  fprintf(stderr, "\n\n");
4009  }
4010 
4011  return sel;
4012 }
struct paramStruct params
int dummy
A dummy file, to prevent empty libraries from breaking builds.
Definition: dummy.c:41
@ set_string
Definition: newgen_set.h:42
#define dummy_identifier(x)
Definition: ri.h:1033
#define parameter_dummy(x)
Definition: ri.h:1823
#define dummy_identifier_p(x)
Definition: ri.h:1031

References CONS, dummy_identifier, dummy_identifier_p, ENTITY, entity_user_name(), f(), FOREACH, fprintf(), functional_parameters, functional_result, gen_free_list(), gen_nreverse(), ifdebug, NIL, PARAMETER, parameter_dummy, parameter_type, params, pips_debug, print_entities(), recursive_type_supporting_entities(), set_add_element(), set_belong_p(), set_make(), and set_string.

Referenced by functional_type_supporting_entities(), and recursive_type_supporting_entities().

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

◆ recursive_functional_type_supporting_types()

static list recursive_functional_type_supporting_types ( list  stl,
set  vt,
functional  f 
)
static

Definition at line 5036 of file type.c.

5037 {
5038  ifdebug(8) {
5039  pips_debug(8, "Begin: ");
5040  print_entities(stl);
5041  fprintf(stderr, "\n");
5042  }
5043 
5046 
5048 
5049  ifdebug(8) {
5050  pips_debug(8, "End: ");
5051  print_entities(stl);
5052  fprintf(stderr, "\n");
5053  }
5054 
5055  return stl;
5056 }

References f(), FOREACH, fprintf(), functional_parameters, functional_result, ifdebug, PARAMETER, parameter_type, pips_debug, print_entities(), and recursive_type_supporting_types().

Referenced by functional_type_supporting_types(), and recursive_type_supporting_types().

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

◆ recursive_type_supporting_entities()

list recursive_type_supporting_entities ( list  sel,
set  vt,
type  t 
)

varargs do not depend on any other entities

This could be considered a pips_internal_error(), at least when the internal representation is built.

This is weird, but labels also are declared

Parameters
selel
vtt

Definition at line 4283 of file type.c.

4284 {
4285 
4286  ifdebug(8) {
4287  pips_debug(8, "Begin: ");
4288  print_entities(sel);
4289  fprintf(stderr, "\n\n");
4290  }
4291 
4292  if(!set_belong_p(vt, t)) {
4293  vt = set_add_element(vt, vt, t);
4294  if(type_functional_p(t))
4296  else if(type_variable_p(t))
4298  else if(type_varargs_p(t)) {
4299  /* varargs do not depend on any other entities */
4300  //pips_user_warning("varargs case not implemented yet\n"); /* do nothing? */
4301  type vart = type_varargs(t);
4302  sel = recursive_type_supporting_entities(sel, vt, vart);
4303  ;
4304  }
4305  else if(type_void_p(t))
4306  ;
4307  else if(type_struct_p(t)) {
4308  list sse = type_struct(t);
4309 
4310  FOREACH(ENTITY, se, sse) {
4311  sel = recursive_type_supporting_entities(sel, vt, entity_type(se));
4312  }
4313  }
4314  else if(type_union_p(t)) {
4315  list use = type_union(t);
4316 
4317  FOREACH(ENTITY, se, use) {
4318  sel = recursive_type_supporting_entities(sel, vt, entity_type(se));
4319  }
4320  }
4321  else if(type_enum_p(t)) {
4322  list ese = type_enum(t);
4323 
4324  FOREACH(ENTITY, se, ese) {
4325  sel = recursive_type_supporting_entities(sel, vt, entity_type(se));
4326  }
4327  }
4328  else if(type_unknown_p(t))
4329  /* This could be considered a pips_internal_error(), at least when
4330  the internal representation is built. */
4331  ;
4332  else if(type_statement_p(t))
4333  /* This is weird, but labels also are declared*/
4334  ;
4335  else
4336  pips_internal_error("Unexpected type with tag %d", type_tag(t));
4337  }
4338  ifdebug(8) {
4339  pips_debug(8, "End: ");
4340  print_entities(sel);
4341  fprintf(stderr, "\n\n");
4342  }
4343 
4344  return sel;
4345 }
list variable_type_supporting_entities(list sel, set vt, variable v)
Definition: type.c:4254
#define type_statement_p(x)
Definition: ri.h:2941
#define type_varargs(x)
Definition: ri.h:2955

References ENTITY, entity_type, FOREACH, fprintf(), ifdebug, pips_debug, pips_internal_error, print_entities(), recursive_functional_type_supporting_entities(), recursive_type_supporting_entities(), set_add_element(), set_belong_p(), type_enum, type_enum_p, type_functional, type_functional_p, type_statement_p, type_struct, type_struct_p, type_tag, type_union, type_union_p, type_unknown_p, type_varargs, type_varargs_p, type_variable, type_variable_p, type_void_p, and variable_type_supporting_entities().

Referenced by basic_supporting_entities(), basic_supporting_types(), generic_constant_expression_supporting_entities(), recursive_functional_type_supporting_entities(), recursive_type_supporting_entities(), and type_supporting_entities().

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

◆ recursive_type_supporting_references()

static list recursive_type_supporting_references ( list  srl,
type  t 
)
static

Compute the list of references implied in the definition of a type.

This is not Fortran compatible as enum members and symbolic constant appear the same but cannot be dealt with in the same way.

This list is empty for basic types such as int or char. But it increases rapidly with typedef, struct, union, bit and dimensions which can use enum elements in sizing expressions.

The supporting entities are gathered in an updated list, sel, supporting reference list.

gen_recurse() does not follow thru entities because they are tabulated and persistant.

What should be done with the tyoe unknown? Return a empty list or generate a pips_internal_error()?

Do not recurse if this type has already been visited.

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

No references are involved in C...

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Definition at line 4638 of file type.c.

4639 {
4640  /* Do not recurse if this type has already been visited. */
4641  if(!set_belong_p(supporting_types, t)) {
4643  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4644  /* ifdebug(9) { */
4645  /* pips_debug(8, "Begin: "); */
4646  /* print_references(srl); */
4647  /* fprintf(stderr, "\n"); */
4648  /* } */
4649 
4650  if(type_functional_p(t))
4652  else if(type_variable_p(t))
4654  else if(type_varargs_p(t)) {
4655  /* No references are involved in C... */
4656  //pips_user_warning("varargs case not implemented yet\n");
4657  type vt = type_varargs(t);
4658  srl = recursive_type_supporting_references(srl, vt);
4659  }
4660  else if(type_void_p(t))
4661  ;
4662  else if(type_struct_p(t)) {
4663  list sse = type_struct(t);
4664 
4665  MAP(ENTITY, se, {
4667  }, sse);
4668  }
4669  else if(type_union_p(t)) {
4670  list use = type_union(t);
4671 
4672  MAP(ENTITY, se, {
4674  }, use);
4675  }
4676  else if(type_enum_p(t)) {
4677  list ese = type_enum(t);
4678 
4679  MAP(ENTITY, se, {
4681  }, ese);
4682  }
4683  else if(type_unknown_p(t)) {
4684  pips_internal_error("unknown type left in a declaration");
4685  }
4686  else
4687  pips_internal_error("Unexpected type with tag %d", type_tag(t));
4688 
4689  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4690  /* ifdebug(9) { */
4691  /* pips_debug(8, "End: "); */
4692  /* print_references(srl); */
4693  /* fprintf(stderr, "\n"); */
4694  /* } */
4695  }
4696 
4697  return srl;
4698 }
static set supporting_types
Compute the list of entities implied in the definition of a type.
Definition: type.c:3975
list functional_type_supporting_references(list srl, functional f)
Definition: type.c:4390
list variable_type_supporting_references(list srl, variable v)
Definition: type.c:4562

References ENTITY, entity_type, functional_type_supporting_references(), MAP, pips_internal_error, set_add_element(), set_belong_p(), supporting_types, type_enum, type_enum_p, type_functional, type_functional_p, type_struct, type_struct_p, type_tag, type_union, type_union_p, type_unknown_p, type_varargs, type_varargs_p, type_variable, type_variable_p, type_void_p, and variable_type_supporting_references().

Referenced by basic_supporting_references(), functional_type_supporting_references(), and type_supporting_references().

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

◆ recursive_type_supporting_types()

static list recursive_type_supporting_types ( list  stl,
set  vt,
type  t 
)
static

Compute the list of types implied in the definition of a type.

This list is empty for basic types such as int or char. But it increases rapidly with typedef, struct and union. We assume that expressions in enum, bit and dimensions are not relevant.

The relationship between stl, the supporting type list, and the set vt, already visited types, herited from type_supporting_entities() is not clear. It might be better to simply return vt...

varargs case is self contained: no supporting type is required.

Hopefully, a dummy type declaration cannot be put among enum members declarations.

This could be considered a pips_internal_error(), at least when the internal representation is built.

This is weird, but labels also are declared

Definition at line 5137 of file type.c.

5138 {
5139 
5140  ifdebug(8) {
5141  pips_debug(8, "Begin: ");
5142  print_entities(stl);
5143  fprintf(stderr, "\n");
5144  }
5145 
5146  if(!set_belong_p(vt, t)) {
5147  vt = set_add_element(vt, vt, t);
5148  if(type_functional_p(t))
5150  else if(type_variable_p(t))
5151  stl = variable_type_supporting_types(stl, vt, type_variable(t));
5152  else if(type_varargs_p(t)) {
5153  /* varargs case is self contained: no supporting type is
5154  required. */
5155  //pips_user_warning("varargs case not implemented yet\n"); /* do nothing? */
5156  type vart = type_varargs(t);
5157  stl = recursive_type_supporting_types(stl, vt, vart);
5158  ;
5159  }
5160  else if(type_void_p(t))
5161  ;
5162  else if(type_struct_p(t)) {
5163  list sse = type_struct(t);
5164 
5165  FOREACH(ENTITY, se, sse) {
5166  stl = recursive_type_supporting_types(stl, vt, entity_type(se));
5167  }
5168  }
5169  else if(type_union_p(t)) {
5170  list use = type_union(t);
5171 
5172  FOREACH(ENTITY, se, use) {
5173  stl = recursive_type_supporting_types(stl, vt, entity_type(se));
5174  }
5175  }
5176  else if(type_enum_p(t))
5177  /* Hopefully, a dummy type declaration cannot be put among enum
5178  members declarations. */
5179  ;
5180  else if(type_unknown_p(t))
5181  /* This could be considered a pips_internal_error(), at least when
5182  the internal representation is built. */
5183  ;
5184  else if(type_statement_p(t))
5185  /* This is weird, but labels also are declared*/
5186  ;
5187  else
5188  pips_internal_error("Unexpected type with tag %d", type_tag(t));
5189  }
5190  ifdebug(8) {
5191  pips_debug(8, "End: ");
5192  print_entities(stl);
5193  fprintf(stderr, "\n");
5194  }
5195 
5196  return stl;
5197 }
static list variable_type_supporting_types(list stl, set vt, variable v)
Definition: type.c:5115

References ENTITY, entity_type, FOREACH, fprintf(), ifdebug, pips_debug, pips_internal_error, print_entities(), recursive_functional_type_supporting_types(), set_add_element(), set_belong_p(), type_enum_p, type_functional, type_functional_p, type_statement_p, type_struct, type_struct_p, type_tag, type_union, type_union_p, type_unknown_p, type_varargs, type_varargs_p, type_variable, type_variable_p, type_void_p, and variable_type_supporting_types().

Referenced by basic_supporting_types(), recursive_functional_type_supporting_types(), and type_supporting_types().

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

◆ reference_dependence_variable_check_and_add()

static void reference_dependence_variable_check_and_add ( reference  ref,
list dependence_list 
)
static

Add the dependence reference only if not already here:

Definition at line 5898 of file type.c.

5898  {
5899  entity var = reference_variable(ref);
5900  if (!const_variable_p(var)) {
5901  /* Add the dependence reference only if not already here: */
5903  *dependence_list = CONS(REFERENCE, copy_reference(ref), *dependence_list);
5904  }
5905 }
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define gen_chunk_undefined_p(c)
Definition: genC.h:75
void * gen_chunk_identity(gen_chunk x)
Definition: genClib.c:2812
void * gen_find(const void *item, const list seq, gen_filter2_func_t test, gen_extract_func_t extract)
Definition: list.c:398
bool(* gen_filter2_func_t)(const void *, const void *)
Definition: newgen_types.h:110
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
bool const_variable_p(entity)
Definition: variable.c:1687

References CONS, const_variable_p(), copy_reference(), gen_chunk_identity(), gen_chunk_undefined_p, gen_find(), ref, REFERENCE, reference_equal_p(), and reference_variable.

Referenced by dependence_of_dependent_type().

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

◆ reference_to_type()

type reference_to_type ( reference  ref)

pips_debug(9, "input entity type %s\n",

words_to_string(words_type(entity_type(reference_variable(ref)),

NIL, false)));

pips_debug(9, "reference case \n");

pips_debug(9, "exp_type %s\n", words_to_string(words_type(exp_type, NIL, false)));

current type

current basic

current dimensions

ifdebug(9) {

pips_debug(7, "new iteration : current type : %s\n",

words_to_string(words_type(ct, NIL, false)));

pips_debug(7, "current list of indices: \n");

print_expressions(l_inds);

}

Warning : qualifiers are set to NIL, because I do not see the need for something else for the moment. BC.

pips_debug(9, "t at the end of reference case %s\n", words_to_string(words_type(t, NIL, false)));

A reference to a function returns a pointer to a function of the very same time

pips_debug(9, "returns with %s\n", words_to_string(words_type(t, NIL, false)));

Parameters
refef

Definition at line 2354 of file type.c.

2355 {
2356  type t = type_undefined;
2357 
2358  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2359  /* pips_debug(9, "input entity type %s\n", */
2360  /* words_to_string(words_type(entity_type(reference_variable(ref)), */
2361  /* NIL, false))); */
2362 
2364 
2365  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2366  /* pips_debug(9, "reference case \n"); */
2367  /* pips_debug(9, "exp_type %s\n", words_to_string(words_type(exp_type, NIL, false))); */
2368 
2369  if(type_variable_p(exp_type))
2370  {
2371  type ct = exp_type; /* current type */
2372  basic cb = variable_basic(type_variable(exp_type)); /* current basic */
2373 
2374  list cd = variable_dimensions(type_variable(exp_type)); /* current dimensions */
2375  list l_inds = reference_indices(ref);
2376 
2377  pips_debug(9, "reference to a variable, "
2378  "we iterate over the indices if any \n");
2379 
2380  while (!ENDP(l_inds))
2381  {
2382  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2383  /* ifdebug(9) { */
2384  /* pips_debug(7, "new iteration : current type : %s\n", */
2385  /* words_to_string(words_type(ct, NIL, false))); */
2386  /* pips_debug(7, "current list of indices: \n"); */
2387  /* print_expressions(l_inds); */
2388  /* } */
2389  if(!ENDP(cd))
2390  {
2391  pips_debug(9, "poping one type dimension and one index\n");
2392  POP(cd);
2393  POP(l_inds);
2394  }
2395  else
2396  {
2397  pips_debug(9,"going through pointer dimension. \n");
2398  // FI: struct are only possible for constant memory path
2399  // the usual internal representation does not use fields
2400  // as indices
2401  pips_assert("reference has too many indices :"
2402  " pointer or struct expected\n",
2403  basic_pointer_p(cb) || basic_derived_p(cb));
2404  if(basic_pointer_p(cb)) {
2405  ct = basic_pointer(cb);
2406  cb = variable_basic(type_variable(ct));
2408  }
2409  else if(basic_derived_p(cb)) { // must be a struct, see assert
2410  entity de = basic_derived(cb);
2411  type st = entity_type(de);
2412  list fl = type_struct(st);
2413  // FI: I am not sure about the internal representation...
2414  // Do we find an integer or a field reference as
2415  // subscript expression?
2416  expression ind = EXPRESSION(CAR(l_inds));
2417  value ind_v = EvalExpression(ind);
2418  if(value_constant_p(ind_v)) {
2419  int n = constant_int(value_constant(ind_v));
2420  entity f = ENTITY(gen_nth(n, fl));
2421  type ft = entity_type(f);
2422  ct = ft;
2423  cb = variable_basic(type_variable(ct));
2425  }
2426  else { // FI: assume a reference to a field
2427  // pips_internal_error("Unexpected internal representation.\n");
2428  pips_assert("The subscript expression is a reference",
2429  expression_reference_p(ind));
2430  entity f =
2432  type ft = entity_type(f);
2433  ct = ft;
2434  cb = variable_basic(type_variable(ct));
2436  }
2437  }
2438  POP(l_inds);
2439  }
2440  }
2441 
2442  /* Warning : qualifiers are set to NIL, because I do not see
2443  * the need for something else for the moment. BC.
2444  */
2445  t = make_type_variable(
2447  gen_full_copy_list(cd),
2448  NIL));
2449  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2450  /* pips_debug(9, "t at the end of reference case %s\n", words_to_string(words_type(t, NIL, false))); */
2451  }
2452  else if(type_functional_p(exp_type))
2453  {
2454  pips_debug(9, "functional case \n");
2455  /* A reference to a function returns a pointer to a function
2456  of the very same time */
2459  (make_basic(is_basic_pointer, copy_type(exp_type)),
2460  NIL, NIL));
2461  }
2462  else
2463  {
2464  // The unknown type ends up here
2465  pips_internal_error("Bad reference type tag %d \"%s\" for reference to %s",
2466  type_tag(exp_type),
2467  type_to_string(exp_type),
2469  }
2470  // FI: to avoid cycles betwen librairies ri-util and prettyprint
2471  /* pips_debug(9, "returns with %s\n", words_to_string(words_type(t, NIL, false))); */
2472  return t;
2473 }
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
value EvalExpression(expression e)
Evaluate statically an expression.
Definition: eval.c:108
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
#define value_constant(x)
Definition: ri.h:3073
#define constant_int(x)
Definition: ri.h:850
#define value_constant_p(x)
Definition: ri.h:3071

References basic_derived, basic_derived_p, basic_pointer, basic_pointer_p, CAR, constant_int, copy_basic(), copy_type(), ENDP, ENTITY, entity_basic_concrete_type(), entity_name, entity_type, EvalExpression(), EXPRESSION, expression_reference_p(), expression_syntax, f(), gen_full_copy_list(), gen_nth(), is_basic_pointer, is_type_variable, make_basic(), make_type(), make_type_variable(), make_variable(), NIL, pips_assert, pips_debug, pips_internal_error, POP, ref, reference_indices, reference_variable, syntax_reference, type_functional_p, type_struct, type_tag, type_to_string(), type_undefined, type_variable, type_variable_p, value_constant, value_constant_p, variable_basic, and variable_dimensions.

Referenced by do_brace_expression_to_statements(), expression_to_type(), and substitute_stubs_in_transformer().

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

◆ safe_type_to_string()

string safe_type_to_string ( const type  t)

Definition at line 59 of file type.c.

60 {
61  if (type_undefined_p(t))
62  return "undefined type";
63  else
64  return type_to_string(t);
65 }

References type_to_string(), and type_undefined_p.

Referenced by points_to_with_stripped_sink(), and UpdateParenEntity().

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

◆ same_basic_p()

bool same_basic_p ( basic  b1,
basic  b2 
)

check if two basics are similar.

That is if they are equal modulo typedefs.

Parameters
b11
b22

Definition at line 969 of file type.c.

970 {
971  return compare_basic_p(b1,b2, true);
972 }

References b1, b2, and compare_basic_p().

Referenced by add_formal_to_actual_bindings(), and generic_basic_equal_p().

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

◆ same_type_p()

bool same_type_p ( type  t1,
type  t2 
)

Type equality and equivalence.

Issues mostly due to C:

  • typedefs: do you want a syntactic equality only?
  • qualifiers: should they be taken into account or not?
  • C defined type equivalence/compatibility: char * == char[], char[N][M]==char (*)[M]
  • functions and pointers to functions are equivalent
  • dependent types: how do you compare the dimension expressions?

Issues dur to PIPS internal representation:

  • newgen basic "string" is sometimes used instead of unsigned char[]

constant string like all constants are functions; for instance, a char * pointer can be assigned a functional void->string...

These issues lead to the concepts of "ultimate" type and of "basic concrete" type, and to the development of many different type "equality" functions. same_type_p(): similar to type_equals but bypasses typedefs

FI Warning: current version only compares ultimate_types but check the various typedef that follows.

typedef int foo;

type_equal_p(int, foo)==true, because foo is simply a renaming for int, but note that type_int_p(entity_type(foo)) returns false. Hence, type_int_p(t1) and type_equal_p(t1,t2) does not imply type_int_p(t2), which may lead to funny bugs.

typedef struct a { int x; int y; } a_t;

typedef struct b { int x; int y; } b_t;

type_equal_p(a_t, b_t)==false, because the underlying structures have different names and because the C type system does not use structural equivalence.

typedef struct { int x; int y; } c_t;

typedef struct { int x; int y; } d_t;

type_EQUAL_P(c_t, d_t)==FALSE because structures (or unions or enums) with implicit names receive each a unique name.

Parameters
t11
t22

Definition at line 409 of file type.c.

410 {
411  t1= ultimate_type(t1);
412  t2= ultimate_type(t2);
413  return type_equal_p(t1,t2);
414 }

References type_equal_p(), and ultimate_type().

+ Here is the call graph for this function:

◆ scalar_integer_type_p()

bool scalar_integer_type_p ( type  t)

The qualifiers do not matter && ENDP(variable_qualifiers(v))

unsigned are as OK as signed

Definition at line 3276 of file type.c.

3277 {
3278  bool long_p = false;
3279  if(!type_undefined_p(t) && type_variable_p(t)) {
3280  variable v = type_variable(t);
3281  basic b = variable_basic(v);
3282  if(basic_int_p(b)) {
3283 
3284  long_p = ENDP(variable_dimensions(v));
3285  /* The qualifiers do not matter
3286  && ENDP(variable_qualifiers(v))
3287  */
3288  /* unsigned are as OK as signed */ /*
3289  && (s == DEFAULT_INTEGER_TYPE_SIZE
3290  || s == DEFAULT_LONG_INTEGER_TYPE_SIZE
3291  || s == DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE);
3292  */
3293  }
3294  }
3295  return long_p;
3296 }

References basic_int_p, ENDP, type_undefined_p, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by check_rhs_value_types(), EvalConstant(), expression_to_points_to_sinks_with_offset(), for_to_do_loop_conversion(), loop_to_enter_transformer(), and MakeParameter().

+ Here is the caller graph for this function:

◆ scalar_type_p()

bool scalar_type_p ( type  t)

◆ signed_type_p()

bool signed_type_p ( type  t)

Definition at line 2800 of file type.c.

2801 {
2802  if (type_variable_p(t))
2803  {
2805  if (basic_int_p(b))
2806  if (basic_int(b)/10 == DEFAULT_SIGNED_TYPE_SIZE)
2807  return true;
2808  }
2809  return false;
2810 }
#define DEFAULT_SIGNED_TYPE_SIZE

References basic_int, basic_int_p, DEFAULT_SIGNED_TYPE_SIZE, type_variable, type_variable_p, and variable_basic.

Referenced by make_standard_integer_type(), and make_standard_long_integer_type().

+ Here is the caller graph for this function:

◆ simple_basic_dup()

basic simple_basic_dup ( basic  b)

basic_int, basic_float, basic_logical, basic_complex are all int's

so we duplicate them the same manner: with basic_int.

Definition at line 2735 of file type.c.

2736 {
2737  /* basic_int, basic_float, basic_logical, basic_complex are all int's */
2738  /* so we duplicate them the same manner: with basic_int. */
2739  if (basic_int_p(b) || basic_float_p(b) ||
2741  return(make_basic(basic_tag(b), UUINT(basic_int(b))));
2742  else if (basic_overloaded_p(b))
2743  return(make_basic(is_basic_overloaded, UU));
2744  else {
2745  user_warning("simple_basic_dup",
2746  "(tag %td) isn't that simple\n", basic_tag(b));
2747  if (basic_string_p(b))
2748  fprintf(stderr, "string: value tag = %d\n",
2749  value_tag(basic_string(b)));
2750  return make_basic(basic_tag(b), UUINT(basic_int(b)));
2751  }
2752 }
#define basic_string(x)
Definition: ri.h:631

References basic_complex_p, basic_float_p, basic_int, basic_int_p, basic_logical_p, basic_overloaded_p, basic_string, basic_string_p, basic_tag, fprintf(), is_basic_overloaded, make_basic(), user_warning, UU, UUINT, and value_tag.

Referenced by arguments_to_complexity(), indices_to_complexity(), intrinsic_cost(), and reference_to_complexity().

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

◆ some_basic_of_any_expression()

basic some_basic_of_any_expression ( expression  exp,
bool  apply_p,
bool  ultimate_p 
)

basic basic_of_any_expression(expression exp, bool apply_p): Makes a basic of the same basic as the expression "exp" if "apply_p" is FALSE.

If "apply_p" is true and if the expression returns a function, then return the resulting type of the function.

WARNING: a new basic object is allocated

PREFER (???) expression_basic

print_expression(exp);

pips_debug(6, "\n");

Well, let's assume range are well formed...

This happens with the assert macro... but could happen anywhere as in (void) printf(...);

FI: I cannot think of anything better...

SG: following code fragment seems wrong to me { sizeofexpression se = syntax_sizeofexpression(sy); if (sizeofexpression_type_p(se)) { type t = sizeofexpression_type(se); if (type_tag(t) != is_type_variable) pips_internal_error("Bad reference type tag %d",type_tag(t)); b = copy_basic(variable_basic(type_variable(t))); } else { b = some_basic_of_any_expression(sizeofexpression_expression(se), apply_p, ultimate_p); }

depending on the depth of the subscript, we should change the basic

the second argument is the type of the returned object

Never go there...

pips_debug(6, "returns with %s\n", basic_to_string(b));

Parameters
expxp
apply_ppply_p
ultimate_pltimate_p

Definition at line 1258 of file type.c.

1259 {
1261  basic b = basic_undefined;
1262 
1263  ifdebug(6){
1264  pips_debug(6, "begins with apply_p=%s and expression ", bool_to_string(apply_p));
1265  // FI: to avoid cycles betwen librairies ri-util and prettyprint
1266  /* print_expression(exp); */
1267  /* pips_debug(6, "\n"); */
1268  }
1269 
1270  switch(syntax_tag(sy)) {
1271  case is_syntax_reference:
1272  {
1273  b = basic_of_any_reference(syntax_reference(sy),apply_p,ultimate_p);
1274  break;
1275  }
1276  case is_syntax_call:
1277  b = basic_of_call(syntax_call(sy), apply_p, ultimate_p);
1278  break;
1279  case is_syntax_range:
1280  /* Well, let's assume range are well formed... */
1282  break;
1283  case is_syntax_cast:
1284  {
1285  type t = cast_type(syntax_cast(sy));
1286 
1287  if (type_tag(t) != is_type_variable) {
1288  if(type_void_p(t))
1289  /* This happens with the assert macro... but could happen
1290  anywhere as in (void) printf(...); */
1291  /* FI: I cannot think of anything better... */
1292  b = basic_undefined;
1293  else
1294  pips_internal_error("Bad reference type tag %d",type_tag(t));
1295  }
1296  else
1298  break;
1299  }
1301  /* SG: following code fragment seems wrong to me
1302  {
1303  sizeofexpression se = syntax_sizeofexpression(sy);
1304  if (sizeofexpression_type_p(se))
1305  {
1306  type t = sizeofexpression_type(se);
1307  if (type_tag(t) != is_type_variable)
1308  pips_internal_error("Bad reference type tag %d",type_tag(t));
1309  b = copy_basic(variable_basic(type_variable(t)));
1310  }
1311  else
1312  {
1313  b = some_basic_of_any_expression(sizeofexpression_expression(se), apply_p, ultimate_p);
1314  }
1315  */
1316 
1318  break;
1319 
1320  case is_syntax_subscript:
1321  {
1322  b = some_basic_of_any_expression(subscript_array(syntax_subscript(sy)), apply_p, ultimate_p);
1323  /* depending on the depth of the subscript, we should change the basic */
1325  break;
1326  }
1327  case is_syntax_application:
1328  {
1330  break;
1331  }
1332  case is_syntax_va_arg:
1333  {
1334  /* the second argument is the type of the returned object */
1336 
1337  if(sizeofexpression_type_p(sofe)) {
1339 
1340  if(type_variable_p(t))
1342  else
1343  pips_internal_error("Not implemented");
1344  }
1345  else {
1347  b = basic_of_any_expression(e, true);
1348  pips_internal_error("expression not expected here");
1349  }
1350  break;
1351  }
1352  default:
1353  pips_internal_error("Bad syntax tag %d", syntax_tag(sy));
1354  /* Never go there... */
1356  }
1357 
1358  /* pips_debug(6, "returns with %s\n", basic_to_string(b)); */
1359 
1360  return b;
1361 }
string bool_to_string(bool)
Definition: string.c:243
basic basic_of_call(call c, bool apply_p, bool ultimate_p)
basic basic_of_call(call c): returns the basic of the result given by the call "c".
Definition: type.c:1469

References application_function, basic_and_indices_to_basic(), basic_of_any_expression(), basic_of_any_reference(), basic_of_call(), basic_of_expression(), basic_undefined, bool_to_string(), CAR, cast_type, CDR, copy_basic(), DEFAULT_INTEGER_TYPE_SIZE, exp, expression_syntax, ifdebug, is_basic_overloaded, 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(), make_basic_int(), pips_debug, pips_internal_error, range_lower, SIZEOFEXPRESSION, sizeofexpression_expression, sizeofexpression_type, sizeofexpression_type_p, some_basic_of_any_expression(), subscript_array, subscript_indices, syntax_application, syntax_call, syntax_cast, syntax_range, syntax_reference, syntax_subscript, syntax_tag, syntax_va_arg, type_tag, type_variable, type_variable_p, type_void_p, ultimate_type(), UUINT, and variable_basic.

Referenced by basic_of_any_expression(), basic_of_intrinsic(), expression_to_user_type(), make_temporary_scalar_entity(), and some_basic_of_any_expression().

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

◆ standard_long_integer_type_p()

bool standard_long_integer_type_p ( type  t)

Used to encode the long keyword in the parser.

Used to detect long double type in parser

Definition at line 3227 of file type.c.

3228 {
3229  bool long_p = false;
3230  if(!type_undefined_p(t) && type_variable_p(t)) {
3231  variable v = type_variable(t);
3232  basic b = variable_basic(v);
3233  if(basic_int_p(b)) {
3234  int s = basic_int(b);
3235 
3236  long_p = ENDP(variable_dimensions(v))
3237  && ENDP(variable_qualifiers(v))
3238  && (s == DEFAULT_INTEGER_TYPE_SIZE
3241  }
3242  }
3243  return long_p;
3244 }

References basic_int, basic_int_p, DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LONG_INTEGER_TYPE_SIZE, DEFAULT_LONG_LONG_INTEGER_TYPE_SIZE, ENDP, type_undefined_p, type_variable, type_variable_p, variable_basic, variable_dimensions, and variable_qualifiers.

◆ string_type_p()

◆ string_type_size()

int string_type_size ( basic  b)

The size may be unknown as in CHARACTER*(*)

No way to check it really was a '*'?

Definition at line 1047 of file type.c.

1048 {
1049  int size = -1;
1050  value v = basic_string(b);
1052 
1053  switch(value_tag(v)) {
1054  case is_value_constant:
1055  c = value_constant(v);
1056  if(constant_int_p(c))
1057  size = constant_int(c);
1058  else
1059  pips_internal_error("Non-integer constant to size a string");
1060  break;
1061  case is_value_unknown:
1062  /* The size may be unknown as in CHARACTER*(*) */
1063  /* No way to check it really was a '*'? */
1064  size = -1;
1065  break;
1066  default:
1067  pips_internal_error("Non-constant value to size a string");
1068  }
1069 
1070  return size;
1071 }
#define constant_int_p(x)
Definition: ri.h:848
#define constant_undefined
Definition: ri.h:802

References basic_string, constant_int, constant_int_p, constant_undefined, is_value_constant, is_value_unknown, pips_internal_error, value_constant, and value_tag.

Referenced by basic_type_size(), constant_to_transformer(), SizeOfArray(), and string_expression_to_transformer().

+ Here is the caller graph for this function:

◆ struct_type_p()

bool struct_type_p ( type  t)

Returns true if t is of type derived and if the derived type is a struct.

Example : struct foo var;

Note: different trom type_struct_p

Definition at line 3121 of file type.c.

3122 {
3123  bool struct_p = false;
3124  if(derived_type_p(t)) {
3126  entity dte = basic_derived(b);
3127  type dt = entity_type(dte);
3128  struct_p = type_struct_p(dt);
3129  }
3130  return struct_p;
3131 }

References basic_derived, derived_type_p(), entity_type, type_struct_p, type_variable, and variable_basic.

Referenced by add_inter_or_intraprocedural_field_entities(), analyzed_array_p(), analyzed_array_type_p(), analyzed_entity_p(), analyzed_struct_p(), analyzed_struct_type_p(), any_source_to_sinks(), any_user_call_site_to_transformer(), anywhere_source_to_sinks(), assign_rhs_to_reflhs_to_transformer(), assignment_to_points_to(), c_return_to_transformer(), compute_points_to_binded_set(), declaration_statement_to_points_to(), dereferencing_to_points_to(), dereferencing_to_sinks(), freed_list_to_points_to(), generic_points_to_cell_to_useful_pointer_cells(), generic_stub_source_to_sinks(), generic_substitute_formal_array_elements_in_transformer(), intrinsic_call_to_points_to(), memory_dereferencing_p(), module_to_value_mappings(), new_recursive_filter_formal_context_according_to_actual_context(), offset_cell(), perform_array_element_substitutions_in_transformer(), points_to_cells_parameters(), points_to_function_projection(), points_to_set_block_projection(), points_to_translation_of_formal_parameters(), points_to_translation_of_struct_formal_parameter(), recursive_cell_to_pointer_cells(), recursive_store_independent_points_to_reference_p(), reference_add_field_dimension(), reference_to_points_to_sinks(), rename_variable_type(), split_initializations_in_statement(), strict_constant_path_p(), struct_assignment_to_points_to(), struct_variable_to_pointer_locations(), struct_variable_to_pointer_subscripts(), subscript_to_points_to_sinks(), transformer_apply_unknown_field_assignments_or_equalities(), and variable_to_pointer_locations().

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

◆ struct_type_to_fields()

◆ subscripted_field_list_to_type()

static type subscripted_field_list_to_type ( list  fl,
expression  se 
)
static

returns the type associated to se.

If se can be evaluated as n, returns the type of the nth field in the field list. If se is a reference to a field f in fl, returns the type of f.

if se is an not a statically evaluable integer expression and not a field reference, returns type_undefined.

If n is greater then the number of elements in fl, returns type_undefined.

If f is not in fl, returns type_undefined.

It might be easier for callers to raise a pips_internal_error() when the result is undefined...

Does not allocate a new type.

Must be a reference to a field

Must be an integer expression

Definition at line 5514 of file type.c.

5515 {
5516  type ft = type_undefined;
5517 
5518  if(expression_reference_p(se)) {
5519  /* Must be a reference to a field */
5521 
5522  if(gen_in_list_p(f, fl)) {
5523  ft = entity_type(f);
5524  }
5525  else {
5526  pips_internal_error("Field f is not in field list fl.");
5527  }
5528  }
5529  else {
5530  /* Must be an integer expression */
5531  intptr_t n = 0;
5532  bool ok = expression_integer_value(se, &n);
5533 
5534  if(ok) {
5535  entity f = ENTITY(CAR(gen_nthcdr(n-1, fl)));
5536  ft = entity_type(f);
5537  }
5538  else {
5539  pips_internal_error("Unusable subscript expression for a derived type.");
5540  }
5541  }
5542 
5543  if(type_undefined_p(ft))
5544  pips_internal_error("Ill. arguments");
5545 
5546  return ft;
5547 }
list gen_nthcdr(int n, const list lx)
caution: the first item is 0! was: return( (n<=0) ? l : gen_nthcdr( n-1, CDR( l ))) ; if n>gen_length...
Definition: list.c:700
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define intptr_t
Definition: stdint.in.h:294

References CAR, ENTITY, entity_type, expression_integer_value(), expression_reference(), expression_reference_p(), f(), gen_in_list_p(), gen_nthcdr(), intptr_t, ok, pips_internal_error, reference_variable, type_undefined, and type_undefined_p.

Referenced by subscripted_type_to_type().

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

◆ subscripted_type_to_type()

type subscripted_type_to_type ( type  t,
expression  se 
)

Returns the type of an object of type t subscripted by expression se.

For instance if t is a struct, the type returned is the type corresponding to the se field.

It is much more difficult for arrays...

Do we assume that t is a ultimate type?

A new type is allocated.

scalar case

enum cannot be subscripted

Other basics are incompatible with subscripts

array case

Parameters
see

Definition at line 5562 of file type.c.

5563 {
5564  type st = type_undefined;
5565 
5566  if(type_variable_p(t)) {
5567  variable v = type_variable(t);
5568  list dl = variable_dimensions(v);
5569 
5570  if(ENDP(dl)) {
5571  /* scalar case */
5572  basic b = variable_basic(v);
5573 
5574  if(basic_pointer_p(b)) {
5576  }
5577  else if(basic_derived_p(b)) {
5578  entity de = basic_derived(b);
5579  type det = entity_type(de);
5580  list fl = list_undefined;
5581 
5582  if(type_struct_p(det)) {
5583  fl = type_struct(det); // field list
5584  }
5585  else if(type_union_p(det)) {
5586  fl = type_union(det); // field list
5587  }
5588  else if(type_enum_p(det)) {
5589  /* enum cannot be subscripted */
5590  pips_internal_error("enum type cannot be subscripted.");
5591  }
5592  else {
5593  pips_internal_error("This type cannot be subscripted.");
5594  }
5596  }
5597  else {
5598  /* Other basics are incompatible with subscripts */
5599  pips_internal_error("This type cannot be subscripted");
5600  }
5601  }
5602  else {
5603  /* array case */
5604  type et = copy_type(t);
5605  variable etv = type_variable(et);
5606  // FI: skip the first dimension, which could be implemented more
5607  // efficiently by destroying only the first dimension
5608  list dl = variable_dimensions(etv);
5609  variable_dimensions(etv) =
5611  gen_full_free_list(dl);
5612  st = type_to_pointer_type(et);
5613  }
5614  }
5615  else {
5616  pips_internal_error("Type t is not a variable type.");
5617  }
5618  return st;
5619 }
static type subscripted_field_list_to_type(list fl, expression se)
returns the type associated to se.
Definition: type.c:5514

References basic_derived, basic_derived_p, basic_pointer_p, CDR, copy_type(), ENDP, entity_type, gen_full_copy_list(), gen_full_free_list(), list_undefined, pips_internal_error, subscripted_field_list_to_type(), type_enum_p, type_struct, type_struct_p, type_to_pointed_type(), type_to_pointer_type(), type_undefined, type_union, type_union_p, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by memory_dereferencing_p().

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

◆ symbolic_supporting_entities()

list symbolic_supporting_entities ( list  sel,
set  vt,
symbolic  s 
)

C version.

Parameters
selel
vtt

Definition at line 4206 of file type.c.

4207 {
4208  return generic_symbolic_supporting_entities(sel, vt, s, true);
4209 }

References generic_symbolic_supporting_entities().

Referenced by basic_supporting_entities().

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

◆ symbolic_supporting_references()

list symbolic_supporting_references ( list  srl,
symbolic  s 
)
Parameters
srlrl

Definition at line 4512 of file type.c.

4513 {
4516  return srl;
4517 }

References constant_expression_supporting_references(), and symbolic_expression.

Referenced by basic_supporting_references().

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

◆ type_depth()

size_t type_depth ( type  t)

Number of steps to access the lowest leave of type t without dereferencing.

Number of dimensions for an array. One for a struct or an union field, plus its own dimension(s). This does not take into account longer memory access paths due to pointers. Hence, recursive data structures do not end up with MAX_INT as type depth.

A pointer to a scalar may be a pointer to an array, unless property POINTS_TO_STRICT_POINTER_TYPES is set to true.

Concrete types are not used. The depth of named types is supposedly calculated.

This is the maximum number of subscripts used in a store independent reference, a.k.a. a constant memory access path, with a variable of type t.

Definition at line 4880 of file type.c.

4881 {
4883  return depth;
4884 }
#define set_undefined
Definition: newgen_set.h:48

References depth, generic_type_depth(), and set_undefined.

Referenced by c_convex_effects_on_formal_parameter_backward_translation(), cells_to_read_or_write_effects(), consistent_points_to_arc_p(), count_element_references_to_v_p(), effect_basic_depth(), effect_scalar_p(), effect_type_depth(), entity_atomic_reference_p(), and expression_to_points_to().

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

◆ type_equal_p()

bool type_equal_p ( type  t1,
type  t2 
)
Parameters
t11
t22

Definition at line 547 of file type.c.

548 {
549  return generic_type_equal_p(t1, t2, true, true, hash_table_undefined);
550 }

References generic_type_equal_p(), and hash_table_undefined.

Referenced by _expression_similar_p(), abstract_locations_max(), add_implicit_interprocedural_write_effects(), add_or_kill_equivalenced_variables(), any_user_call_site_to_transformer(), array_pointer_string_type_equal_p(), basic_maximum(), cast_equal_p(), DeclareVariable(), do_linearize_array_manage_callers(), entities_maymust_conflict_p(), entity_all_module_xxx_locations_typed(), entity_all_xxx_locations_typed(), entity_flow_or_context_sentitive_heap_location(), integer_expression_to_transformer(), intrinsic_call_to_type(), make_local_value_entity(), max_type(), multiple_pointer_assignment_to_post_pv(), new_recursive_filter_formal_context_according_to_actual_context(), NormalizeCast(), opkill_may_constant_path(), opkill_may_type(), opkill_must_constant_path(), outliner_file(), pointer_expression_to_transformer(), points_to_source_to_translations(), points_to_translation_of_formal_parameters(), precondition_intra_to_inter(), recursive_filter_formal_context_according_to_actual_context(), references_may_conflict_p(), retype_formal_parameters(), same_analyzable_type_scalar_entity_list_p(), same_type_p(), sizeofexpression_equal_p(), struct_reference_assignment_or_equality_to_transformer(), substitute_stubs_in_transformer_with_translation_binding(), translate_global_value(), type_compatible_super_cell(), TypeFunctionalEntity(), update_functional_type_with_actual_arguments(), UpdateType(), and variable_references_may_conflict_p().

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

◆ type_equal_up_to_qualifiers_p()

bool type_equal_up_to_qualifiers_p ( type  t1,
type  t2 
)
Parameters
t11
t22

Definition at line 552 of file type.c.

553 {
554  return generic_type_equal_p(t1, t2, true, false, hash_table_undefined);
555 }

References generic_type_equal_p(), and hash_table_undefined.

Referenced by array_pointer_type_equal_p().

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

◆ type_equal_up_to_typedefs_and_qualifiers_p()

bool type_equal_up_to_typedefs_and_qualifiers_p ( type  t1,
type  t2 
)
Parameters
t11
t22

Definition at line 557 of file type.c.

558 {
559  // FI: the last false is weird...
560  return generic_type_equal_p(t1, t2, false, false, hash_table_undefined);
561 }

References generic_type_equal_p(), and hash_table_undefined.

Referenced by points_to_cell_types_compatibility().

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

◆ type_fields()

list type_fields ( type  t)

Definition at line 3073 of file type.c.

3074 {
3075  list l_res = NIL;
3076 
3077  switch (type_tag(t))
3078  {
3079  case is_type_struct:
3080  l_res = type_struct(t);
3081  break;
3082  case is_type_union:
3083  l_res = type_union(t);
3084  break;
3085  case is_type_enum:
3086  l_res = type_enum(t);
3087  break;
3088  default:
3089  pips_internal_error("type_fields improperly called");
3090  }
3091  return l_res;
3092 
3093 }

References is_type_enum, is_type_struct, is_type_union, NIL, pips_internal_error, type_enum, type_struct, type_tag, and type_union.

Referenced by basic_concrete_type_leads_to_pointer_p(), and basic_concrete_types_compatible_for_effects_interprocedural_translation_p().

+ Here is the caller graph for this function:

◆ type_fundamental_basic_p()

bool type_fundamental_basic_p ( type  t)

Definition at line 2930 of file type.c.

2931 {
2932  if (type_variable_p(t))
2933  {
2935  return (basic_int_p(b) || basic_float_p(b) || basic_logical_p(b)
2937  || basic_bit_p(b));
2938  }
2939  return (type_void_p(t) || type_unknown_p(t)) ;
2940 }

References basic_bit_p, basic_complex_p, basic_float_p, basic_int_p, basic_logical_p, basic_overloaded_p, basic_string_p, type_unknown_p, type_variable, type_variable_p, type_void_p, and variable_basic.

Referenced by assignment_to_post_pv(), declaration_to_post_pv(), and sequence_to_post_pv().

+ Here is the caller graph for this function:

◆ type_pointer_on_struct_variable_p()

bool type_pointer_on_struct_variable_p ( type  t)

Definition at line 2960 of file type.c.

2961 {
2962  t = ultimate_type(t);
2964  {
2966  return type_struct_variable_p(pt);
2967  }
2968  return false;
2969 }
bool type_struct_variable_p(type t)
Definition: type.c:3867

References basic_pointer, basic_pointer_p, type_struct_variable_p(), type_variable, ultimate_type(), and variable_basic.

Referenced by do_check_isolate_statement_preconditions_on_call(), and do_split_structure().

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

◆ type_struct_variable_p()

bool type_struct_variable_p ( type  t)

Definition at line 3867 of file type.c.

3868 {
3869  t = ultimate_type(t);
3870  if(type_variable_p(t))
3873  else
3874  return false;
3875 }
bool entity_struct_p(entity e)
Is entity e the entity corresponding to a struct declaration?
Definition: entity.c:1002

References basic_derived, basic_derived_p, entity_struct_p(), type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by do_brace_expression_to_statements(), do_split_structure(), get_sizeofexpression_for_region(), make_fields_assignment_instruction(), semantics_usable_points_to_reference_p(), substitute_struct_stub_in_transformer(), substitute_stubs_in_transformer(), type_pointer_on_struct_variable_p(), and variable_references_may_conflict_p().

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

◆ type_structurally_equal_p()

bool type_structurally_equal_p ( type  t1,
type  t2 
)

Type t1 and t2 are equal if their basic concrete components are equal.

1-D arrays and pointers are compatible if build on the same type.

Qualifiers are ignored.

Parameters
t11
t22

Definition at line 586 of file type.c.

587 {
588  hash_table structural_table = hash_table_make(hash_pointer, 0);
589  bool equal_p = generic_type_equal_p(t1, t2, false, false, structural_table);
590  hash_table_free(structural_table);
591  return equal_p;
592 }

References generic_type_equal_p(), hash_pointer, hash_table_free(), and hash_table_make().

Referenced by check_type_of_points_to_cells(), declaration_statement_to_points_to(), filter_formal_context_according_to_actual_context(), new_filter_formal_context_according_to_actual_context(), reference_to_points_to_sinks(), and same_field_entity_p().

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

◆ type_supporting_entities()

list type_supporting_entities ( list  sel,
type  t 
)

keep track of already visited types

Parameters
selel

Definition at line 4347 of file type.c.

4348 {
4349  /* keep track of already visited types */
4350  set vt = set_make(set_pointer);
4351  sel = recursive_type_supporting_entities(sel, vt, t);
4352  set_free(vt);
4353  return sel;
4354 }

References recursive_type_supporting_entities(), set_free(), set_make(), and set_pointer.

Referenced by AddEntityToModuleCompilationUnit(), declarable_type_p(), ensure_comment_consistency(), entity_used_in_declarations_p(), and stub_text().

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

◆ type_supporting_references()

list type_supporting_references ( list  srl,
type  t 
)

To avoid multiple recursion through the same type

Parameters
srlrl

Definition at line 4700 of file type.c.

4701 {
4702  /* To avoid multiple recursion through the same type */
4706  return srl;
4707 }

References recursive_type_supporting_references(), set_free(), set_make(), set_pointer, and supporting_types.

Referenced by declaration_supporting_references().

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

◆ type_supporting_types()

list type_supporting_types ( type  t)

Return the list of types used to define type t.

The goal is to find out if a dummy data structure (struct, union or enum) is used within another one and hence does not need to be printed out by the prettyprinter.

keep track of already visited types

Definition at line 5203 of file type.c.

5204 {
5205  /* keep track of already visited types */
5206  set vt = set_make(set_pointer);
5207  list stl = NIL;
5208  stl = recursive_type_supporting_types(stl, vt, t);
5209  set_free(vt);
5210  return stl;
5211 }

References NIL, recursive_type_supporting_types(), set_free(), set_make(), and set_pointer.

Referenced by outliner_independent_recursively(), and type_used_in_type_declarations_p().

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

◆ type_to_array_type()

type type_to_array_type ( type  t)

convert a type "t" into a newly allocated array type "at" whose elements are of type "t", unless "t" is void.

Then an array of overloaded elements is generated. The new dimension is unbounded.

This useful when dealing with pointers that are not precisely typed. In C you have often to assume they point towards an array since pointer arithmetic is OK by default.

The behavior of this function is not well defined when typedef are used... t should be a concrete type.

You cannot added a second unbounded dimension in C...

So you should change the element type...

But this is not compatible with points-to references. We can add 0 subscripts as much as we want for unbounded dimensions, but we cannot change *p into p[0]... This is linked to effects-util and points-to analysis, and should probably not be here in library ri-util

Definition at line 5653 of file type.c.

5654 {
5655  type at = type_undefined;
5656 
5657  if(type_void_p(t)) {
5658  at = MakeTypeOverloaded();
5659  }
5660  else
5661  at = copy_type(t);
5662 
5663  variable vt = type_variable(at);
5664 
5665  /* You cannot added a second unbounded dimension in C... */
5666  /* So you should change the element type... */
5667  /* But this is not compatible with points-to references. We can
5668  add 0 subscripts as much as we want for unbounded dimensions,
5669  but we cannot change *p into p[0]... This is linked to
5670  effects-util and points-to analysis, and should probably not be
5671  here in library ri-util */
5672 
5673  //list ld = variable_dimensions(vt);
5674  //dimension fd = DIMENSION(CAR(ld));
5675  //if(false && unbounded_dimension_p(fd)) {
5676  //type et = array_type_to_element_type(at);
5677  // type net = type_to_pointer_type(et);
5678  //free_basic(variable_basic(vt));
5679  //variable_basic(vt) = make_basic_pointer(et);
5680  //}
5681  //else {
5684  NIL);
5685  // Add the new dimension as first dimension... be cause an
5686  // unbounded dimension must be the first dimension.
5688  // }
5689 
5690  return at;
5691 }
type MakeTypeOverloaded()
Definition: type.c:107

References CONS, copy_type(), DIMENSION, int_to_expression(), make_dimension(), make_unbounded_expression(), MakeTypeOverloaded(), NIL, type_undefined, type_variable, type_void_p, and variable_dimensions.

Referenced by create_advanced_stub_points_to(), create_stub_points_to(), and global_source_to_sinks().

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

◆ type_to_final_pointed_type()

type type_to_final_pointed_type ( type  t)

returns t if t is not a pointer type, and the first indirectly pointed type that is not a pointer if t is a pointer type.

Type definitions are replaced.

Definition at line 5336 of file type.c.

5337 {
5338  type ut = type_undefined;
5339 
5340  if(!type_undefined_p(t)) {
5341  ut = ultimate_type(t);
5342 
5343  while(!type_undefined_p(ut) && pointer_type_p(ut)) {
5344  ut = type_to_pointed_type(ut);
5345  }
5346  }
5347  return ut;
5348 }

References pointer_type_p(), type_to_pointed_type(), type_undefined, type_undefined_p, and ultimate_type().

Referenced by filtered_declaration_list().

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

◆ type_to_pointed_type()

type type_to_pointed_type ( type  t)

returns t if t is not a pointer type, and the pointed type if t is a pointer type.

Type definitions are replaced. If t is undefined, returns a type_undefined.

Definition at line 5265 of file type.c.

5266 {
5267  type upt = type_undefined;
5268 
5269  if(!type_undefined_p(t)) {
5270  type ut = ultimate_type(t);
5271  type pt = ut;
5272 
5273  if(pointer_type_p(ut))
5275 
5276  if(!type_undefined_p(pt))
5277  upt = ultimate_type(pt);
5278  }
5279  return upt;
5280 }

References basic_pointer, pointer_type_p(), type_undefined, type_undefined_p, type_variable, ultimate_type(), and variable_basic.

Referenced by anywhere_source_to_sinks(), array_pointer_type_equal_p(), call_to_points_to(), cell_to_nowhere_sink(), char_star_type_p(), check_rhs_value_types(), check_type_of_points_to_cells(), create_stub_points_to(), dereferencing_subscript_to_points_to(), derived_formal_parameter_to_stub_points_to(), entity_flow_or_context_sentitive_heap_location(), expression_to_points_to_cells(), expression_to_points_to_sources(), formal_source_to_sinks(), freed_list_to_points_to(), generic_stub_source_to_sinks(), global_source_to_sinks(), MakeIoFileArray(), normalize_subscript_expression(), offset_cell(), perform_array_element_substitutions_in_transformer(), pointer_formal_parameter_to_stub_points_to(), points_to_cell_types_compatibility(), points_to_expression_to_pointed_type(), points_to_translation_mapping_is_typed_p(), points_to_with_stripped_sink(), process_casted_sinks(), sizeofexpression_to_points_to_sinks(), source_to_sinks(), struct_assignment_to_points_to(), struct_initialization_to_points_to(), subscripted_type_to_type(), type_to_final_pointed_type(), type_void_star_p(), typedef_formal_parameter_to_stub_points_to(), and user_call_to_points_to_sinks().

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

◆ type_to_pointer_type()

type type_to_pointer_type ( type  t)

allocate a new type "pt" which includes directly "t".

Definition at line 5253 of file type.c.

5254 {
5256 
5257  pips_assert("pt is consistent", type_consistent_p(pt));
5258 
5259  return pt;
5260 }

References make_basic_pointer(), make_type_variable(), make_variable(), NIL, pips_assert, and type_consistent_p().

Referenced by array_type_to_pointer_type(), entity_null_locations(), intrinsic_call_to_type(), MakeVoidPointerParameter(), r_cell_reference_to_type(), subscripted_type_to_type(), and void_to_void_to_int_pointer_type().

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

◆ type_to_returned_type()

type type_to_returned_type ( type  t)

returns t if t is not a functoional type, and the returned type if t is a functional type.

Type definitions are replaced. If t is undefined, returns a type_undefined.

Definition at line 5316 of file type.c.

5317 {
5318  type urt = type_undefined;
5319 
5320  if(!type_undefined_p(t)) {
5321  type ut = ultimate_type(t);
5322  type rt = ut;
5323 
5324  if(type_functional_p(ut))
5326 
5327  if(!type_undefined_p(rt))
5328  urt = ultimate_type(rt);
5329  }
5330  return urt;
5331 }

References functional_result, type_functional, type_functional_p, type_undefined, type_undefined_p, and ultimate_type().

Referenced by call_to_points_to_sinks().

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

◆ type_to_string()

◆ type_union_variable_p()

bool type_union_variable_p ( type  t)

Definition at line 3877 of file type.c.

3878 {
3879  t = ultimate_type(t);
3880  if(type_variable_p(t))
3883  else
3884  return false;
3885 }
bool entity_union_p(entity e)
Is entity e an entity representing the union declaration?
Definition: entity.c:1038

References basic_derived, basic_derived_p, entity_union_p(), type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by variable_references_may_conflict_p().

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

◆ type_void_star_p()

bool type_void_star_p ( type  t)

Definition at line 5765 of file type.c.

5766 {
5767  bool void_star_p = false;
5768  if(pointer_type_p(t))
5769  void_star_p = type_void_p(type_to_pointed_type(t));
5770  return void_star_p;
5771 }

References pointer_type_p(), type_to_pointed_type(), and type_void_p.

Referenced by check_rhs_value_types(), and declaration_statement_to_points_to().

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

◆ type_with_const_qualifier_p()

bool type_with_const_qualifier_p ( type  t)

Is there a const qualifier associated to type t.

FI: this should be extended in case const can be carried by a typedef, but this first version should be enough for Molka.

Definition at line 5483 of file type.c.

5484 {
5485  bool qualifier_p = false;
5486 
5487  if(type_variable_p(t)) {
5488  variable v = type_variable(t);
5489  list ql = variable_qualifiers(v);
5490  qualifier_p = qualifiers_const_p(ql);
5491  }
5492 
5493  return qualifier_p;
5494 }
bool qualifiers_const_p(list ql)
Check that a qualifier list contains the const qualifier.
Definition: type.c:5453

References qualifiers_const_p(), type_variable, type_variable_p, and variable_qualifiers.

Referenced by safe_assigned_expression_to_transformer().

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

◆ typedef_type_p()

bool typedef_type_p ( type  t)

Returns true if t is a typedefED type.

Example : Myint i;

Definition at line 3189 of file type.c.

3190 {
3192  && (variable_dimensions(type_variable(t)) == NIL));
3193 }

References basic_typedef_p, NIL, type_variable, type_variable_p, variable_basic, and variable_dimensions.

Referenced by generic_c_words_simplified_entity(), and rename_variable_type().

+ Here is the caller graph for this function:

◆ ultimate_array_type()

type ultimate_array_type ( type  t)

Definition at line 3471 of file type.c.

3472 {
3473  return private_ultimate_type(t, true);
3474 }
static type private_ultimate_type(type t, bool arrays_only)
FI: there are different notions of "ultimate" types in C.
Definition: type.c:3370

References private_ultimate_type().

Referenced by effects_to_dma().

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

◆ ultimate_type()

type ultimate_type ( type  t)

Definition at line 3466 of file type.c.

3467 {
3468  return private_ultimate_type(t, false);
3469 }

References private_ultimate_type().

Referenced by add_any_variable_to_area(), add_conflicts(), add_implicit_interprocedural_write_effects(), add_index_bound_conditions(), add_reference_information(), any_expression_to_transformer(), any_scalar_assign_to_transformer_list(), any_scalar_assign_to_transformer_without_effect(), any_user_call_site_to_transformer(), anywhere_source_to_sinks(), array_bounded_p(), basic_and_indices_to_basic(), basic_of_any_reference(), basic_of_external(), basic_of_intrinsic(), basic_ultimate(), c_convex_effects_on_actual_parameter_forward_translation(), C_loop_range(), c_reference(), c_text_entities(), C_type_to_pointed_type(), call_to_functional_type(), call_to_post_pv(), call_to_transformer(), can_terapixify_expression_p(), CCompilationUnitMemoryAllocations(), check_declaration_uniqueness_p(), compare_basic_p(), count_element_references_to_v_p(), CreateReturnEntity(), declarations_to_dimensions(), derived_formal_parameter_to_stub_points_to(), do_array_to_pointer_walk_call_and_patch(), do_check_isolate_statement_preconditions_on_call(), do_group_constants_terapix(), do_group_count_elements_reduce(), do_linearize_array_reference(), do_linearize_prepatch_subscript(), do_linearize_prepatch_type(), do_linearize_type(), do_loop_unroll_with_prologue(), do_split_structure(), effect_interference(), effect_to_store_independent(), entity_array_p(), entity_atomic_reference_p(), entity_enum_variable_p(), entity_integer_scalar_p(), entity_memory_size(), entity_pointer_p(), entity_scalar_p(), entity_variable_length_array_p(), expression_basic(), expression_pointer_p(), extended_expression_constant_p(), fix_loop_index_sign(), for_to_do_loop_conversion(), freia_data2d_field(), freia_image_variable_p(), generic_stub_source_to_sinks(), get_symbol_table(), initialization_list_to_statements(), integer_scalar_entity_p(), intrinsic_call_to_type(), loadstore_type_conversion_string(), make_new_scalar_variable_with_prefix(), MakeFunctionExpression(), MemberIdentifierToExpression(), memory_dereferencing_p(), normalize_microcode(), number_of_fields(), number_of_items(), number_of_usable_functional_parameters(), parameter_passing_mode_p(), partial_eval_reference(), positive_expression_p(), private_ultimate_type(), reference_add_field_dimension(), reference_offset(), reference_to_points_to_sinks(), same_type_p(), set_entity_initial(), simplify_C_expression(), SizeOfArray(), some_basic_of_any_expression(), statement_insertion_fix_access_in_callers(), store_independent_reference_p(), struct_variable_to_pointer_locations(), struct_variable_to_pointer_subscripts(), TestCoupleOfReferences(), transformer_add_condition_information_updown(), type_dereferencement_depth(), type_pointer_on_struct_variable_p(), type_struct_variable_p(), type_to_final_pointed_type(), type_to_pointed_type(), type_to_returned_type(), type_union_variable_p(), type_void_or_void_pointer_p(), ultimate_type_equal_p(), UpdateEntity(), UpdateEntity2(), user_call_to_points_to_sinks(), value_passing_summary_transformer(), variable_initial_expression(), variable_to_dimensions(), variables_width_filter(), void_function_p(), and xml_print_parameter().

+ Here is the call graph for this function:

◆ ultimate_type_equal_p()

bool ultimate_type_equal_p ( type  t1,
type  t2 
)
Parameters
t11
t22

Definition at line 563 of file type.c.

564 {
565  type ut1 = ultimate_type(t1);
566  type ut2 = ultimate_type(t2);
567  return generic_type_equal_p(ut1, ut2, false, true, hash_table_undefined);
568 }

References generic_type_equal_p(), hash_table_undefined, and ultimate_type().

+ Here is the call graph for this function:

◆ union_type_p()

bool union_type_p ( type  t)

Returns true if t is of type derived and if the derived type is a union.

Example : union foo var;

Note: different trom type_union_p

Definition at line 3151 of file type.c.

3152 {
3153  bool union_p = false;
3154  if(derived_type_p(t)) {
3156  entity dte = basic_derived(b);
3157  type dt = entity_type(dte);
3158  union_p = type_union_p(dt);
3159  }
3160  return union_p;
3161 }

References basic_derived, derived_type_p(), entity_type, type_union_p, type_variable, and variable_basic.

Referenced by rename_variable_type().

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

◆ unsigned_basic_p()

bool unsigned_basic_p ( basic  b)

Definition at line 2812 of file type.c.

2812  {
2813  if (basic_int_p(b))
2815  return true;
2816  return false;
2817 }

References basic_int, basic_int_p, and DEFAULT_UNSIGNED_TYPE_SIZE.

Referenced by unsigned_type_p().

+ Here is the caller graph for this function:

◆ unsigned_type_p()

bool unsigned_type_p ( type  t)

Predicates on types.

Definition at line 2821 of file type.c.

2822 {
2823  if (type_variable_p(t))
2824  {
2826  return unsigned_basic_p(b);
2827  }
2828  return false;
2829 }
bool unsigned_basic_p(basic b)
Definition: type.c:2812

References type_variable, type_variable_p, unsigned_basic_p(), and variable_basic.

Referenced by add_type_information(), C_loop_range(), fix_loop_index_sign(), make_standard_integer_type(), make_standard_long_integer_type(), and positive_expression_p().

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

◆ variable_dimension_number()

int variable_dimension_number ( variable  v)

Definition at line 5632 of file type.c.

5633 {
5634  int d = 0;
5635 
5637  d++;
5638 
5639  return d;
5640 }

References DIMENSION, FOREACH, and variable_dimensions.

Referenced by create_scalar_stub_sink_cell(), pointer_reference_to_expression(), reference_dereferencing_to_points_to(), and reference_to_points_to_sinks().

+ Here is the caller graph for this function:

◆ variable_equal_p()

bool variable_equal_p ( variable  v1,
variable  v2 
)
Parameters
v11
v22

Definition at line 819 of file type.c.

820 {
821  return generic_variable_equal_p(v1, v2, true, true, hash_table_undefined);
822 }

References generic_variable_equal_p(), and hash_table_undefined.

Referenced by register_scalar_communications().

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

◆ variable_length_array_type_p()

bool variable_length_array_type_p ( type  t)

Is this equivalent to dependent_type_p()?

Definition at line 2972 of file type.c.

2973 {
2974  bool return_val = false;
2975  if(array_type_p(t)) {
2979  return_val=true;
2980  break;
2981  }
2982  }
2983  }
2984  return return_val;
2985 }

References array_type_p(), dimension_lower, dimension_upper, extended_expression_constant_p(), FOREACH, type_variable, and variable_dimensions.

Referenced by entity_variable_length_array_p(), extended_expression_constant_p(), and fixed_length_array_type_p().

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

◆ variable_type_supporting_entities()

list variable_type_supporting_entities ( list  sel,
set  vt,
variable  v 
)
Parameters
selel
vtt

Definition at line 4254 of file type.c.

4255 {
4256  basic b = variable_basic(v);
4257  list dims = variable_dimensions(v);
4258 
4259  ifdebug(8) {
4260  pips_debug(8, "Begin: ");
4261  print_entities(sel);
4262  fprintf(stderr, "\n");
4263  }
4264 
4265  FOREACH(DIMENSION, d, dims) {
4266  expression l = dimension_lower(d);
4267  expression u = dimension_upper(d);
4268  sel = constant_expression_supporting_entities(sel, vt, l);
4269  sel = constant_expression_supporting_entities(sel, vt, u);
4270  }
4271 
4272  sel = basic_supporting_entities(sel, vt, b);
4273 
4274  ifdebug(8) {
4275  pips_debug(8, "End: ");
4276  print_entities(sel);
4277  fprintf(stderr, "\n\n");
4278  }
4279 
4280  return sel;
4281 }
list basic_supporting_entities(list sel, set vt, basic b)
Definition: type.c:4211

References basic_supporting_entities(), constant_expression_supporting_entities(), DIMENSION, dimension_lower, dimension_upper, FOREACH, fprintf(), ifdebug, pips_debug, print_entities(), variable_basic, and variable_dimensions.

Referenced by recursive_type_supporting_entities().

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

◆ variable_type_supporting_references()

list variable_type_supporting_references ( list  srl,
variable  v 
)

ifdebug(9) {

pips_debug(8, "Begin: ");

print_references(srl);

fprintf(stderr, "\n");

}

ifdebug(9) {

pips_debug(8, "End: ");

print_references(srl);

fprintf(stderr, "\n");

}

Parameters
srlrl

Definition at line 4562 of file type.c.

4563 {
4564  basic b = variable_basic(v);
4565  list dims = variable_dimensions(v);
4566 
4567  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4568  /* ifdebug(9) { */
4569  /* pips_debug(8, "Begin: "); */
4570  /* print_references(srl); */
4571  /* fprintf(stderr, "\n"); */
4572  /* } */
4573 
4574  MAP(DIMENSION, d, {
4575  expression l = dimension_lower(d);
4576  expression u = dimension_upper(d);
4579  }, dims);
4580 
4581  srl = basic_supporting_references(srl, b);
4582 
4583  // FI: to avoid cycles betwen librairies ri-util and prettyprint
4584  /* ifdebug(9) { */
4585  /* pips_debug(8, "End: "); */
4586  /* print_references(srl); */
4587  /* fprintf(stderr, "\n"); */
4588  /* } */
4589 
4590  return srl;
4591 }
list basic_supporting_references(list srl, basic b)
Definition: type.c:4519

References basic_supporting_references(), constant_expression_supporting_references(), DIMENSION, dimension_lower, dimension_upper, MAP, variable_basic, and variable_dimensions.

Referenced by recursive_type_supporting_references().

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

◆ variable_type_supporting_types()

static list variable_type_supporting_types ( list  stl,
set  vt,
variable  v 
)
static

The dimensions cannot contain a type declaration

Definition at line 5115 of file type.c.

5116 {
5117  /* The dimensions cannot contain a type declaration */
5118  basic b = variable_basic(v);
5119 
5120  ifdebug(8) {
5121  pips_debug(8, "Begin: ");
5122  print_entities(stl);
5123  fprintf(stderr, "\n");
5124  }
5125 
5126  stl = basic_supporting_types(stl, vt, b);
5127 
5128  ifdebug(8) {
5129  pips_debug(8, "End: ");
5130  print_entities(stl);
5131  fprintf(stderr, "\n");
5132  }
5133 
5134  return stl;
5135 }
static list basic_supporting_types(list stl, set vt, basic b)
Definition: type.c:5071

References basic_supporting_types(), fprintf(), ifdebug, pips_debug, print_entities(), and variable_basic.

Referenced by recursive_type_supporting_types().

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

Variable Documentation

◆ entity_types_to_bctypes

◆ supporting_types

set supporting_types = set_undefined
static

Compute the list of entities implied in the definition of a type.

This list is empty for basic types such as int or char. But it increases rapidly with typedef, struct, union, bit and dimensions which can use enum elements in sizing expressions.

The supporting entities are gathered in an updated list, sel, supporting entity list. If entity a depends on entity b, b must appear first in the list. Each entity should appear only once but first we keep all occurences to make sure the partial order between.entities is respected.

Definition at line 3975 of file type.c.

Referenced by recursive_type_supporting_references(), and type_supporting_references().