libFirm
|
Datastructure to hold type information. More...
Modules | |
Reverse Type Edges | |
Trouts list all uses of types and entities. | |
Type Opcodes | |
This module specifies the kinds of types available in firm. | |
Class | |
If the type opcode is set to type_class the type represents class types. | |
Struct | |
A struct type represents aggregate types that consist of a list of fields. | |
Union | |
The union type represents union types. | |
Method | |
A method type represents a method, function or procedure type. | |
Array | |
The array type represents rectangular multi dimensional arrays. | |
Enumeration | |
Enumeration types need not necessarily be represented explicitly by Firm types, as the frontend can lower them to integer constants as well. | |
Pointer | |
Pointer types: | |
Primitive | |
Primitive types are types that represent atomic data values that map directly to modes. | |
None | |
This type is an auxiliary type dedicated to support type analyses. | |
Code | |
Unknown | |
This type is an auxiliary type dedicated to support type analyses. | |
Compound | |
Frame | |
Traversing |
Macros | |
#define | is_SuperClass_of(high, low) is_SubClass_of(low, high) |
Returns true if high is superclass of low. | |
#define | is_SuperClass_ptr_of(low, high) is_SubClass_ptr_of(high, low) |
Superclass check for pointers to classes. |
Typedefs | |
typedef struct ir_type | ir_type |
Type. | |
typedef ident * | mangle_inherited_name_func (const ir_entity *ent, const ir_type *clss) |
Type of argument functions for inheritance resolver. |
Enumerations | |
enum | inh_transitive_closure_state { inh_transitive_closure_none, inh_transitive_closure_valid, inh_transitive_closure_invalid, inh_transitive_closure_max } |
The state of the transitive closure. More... | |
enum | ir_class_cast_state { ir_class_casts_any = 0, ir_class_casts_transitive = 1, ir_class_casts_normalized = 2, ir_class_casts_state_max } |
The state of Cast operations that cast class types or pointers to class types. More... | |
enum | ir_type_state { layout_undefined, layout_fixed } |
The state of the type layout. More... |
Functions | |
int | is_SubClass_of (ir_type *low, ir_type *high) |
Returns true if low is subclass of high. | |
int | is_SubClass_ptr_of (ir_type *low, ir_type *high) |
Subclass check for pointers to classes. | |
int | is_overwritten_by (ir_entity *high, ir_entity *low) |
Returns true if high is (transitive) overwritten by low. | |
ir_entity * | resolve_ent_polymorphy (ir_type *dynamic_class, ir_entity *static_ent) |
Resolve polymorphism in the inheritance relation. | |
ident * | default_mangle_inherited_name (const ir_entity *ent, const ir_type *clss) |
Default name mangling for inherited entities. | |
void | resolve_inheritance (mangle_inherited_name_func *mfunc) |
Resolve implicit inheritance. | |
void | set_irp_inh_transitive_closure_state (inh_transitive_closure_state s) |
Sets the transitive closure of sub/superclass state for the whole program. | |
void | invalidate_irp_inh_transitive_closure_state (void) |
Sets the transitive closure of sub/superclass state for the whole program to inh_transitive_closure_invalid. | |
inh_transitive_closure_state | get_irp_inh_transitive_closure_state (void) |
Returns the transitive closure of sub/superclass state for the whole program. | |
void | compute_inh_transitive_closure (void) |
Compute transitive closure of the subclass/superclass and overwrites/overwrittenby relation. | |
void | free_inh_transitive_closure (void) |
Free memory occupied by the transitive closure information. | |
ir_type * | get_class_trans_subtype_first (const ir_type *tp) |
Start iteration over all transitive subtypes of tp . | |
ir_type * | get_class_trans_subtype_next (const ir_type *tp) |
Returns next type in a subtype iteration started by get_class_trans_subtype_first() | |
int | is_class_trans_subtype (const ir_type *tp, const ir_type *subtp) |
Check if subtp is a subtype of tp . | |
ir_type * | get_class_trans_supertype_first (const ir_type *tp) |
Start iteration over all transitive supertypes of tp . | |
ir_type * | get_class_trans_supertype_next (const ir_type *tp) |
Returns next type in a supertype iteration started by get_class_trans_supertype_first() | |
ir_entity * | get_entity_trans_overwrittenby_first (const ir_entity *ent) |
Start iteration over all entities that transitive overwrite entity ent . | |
ir_entity * | get_entity_trans_overwrittenby_next (const ir_entity *ent) |
Returns next entity in a overwrittenby iteration started by get_entity_trans_overwrittenby_first() | |
ir_entity * | get_entity_trans_overwrites_first (const ir_entity *ent) |
Start iteration over all transitive overwritten entities, overwritten by entity ent . | |
ir_entity * | get_entity_trans_overwrites_next (const ir_entity *ent) |
Returns next entity in a overwrites iteration started by get_entity_trans_overwrites_first() | |
void | set_irg_class_cast_state (ir_graph *irg, ir_class_cast_state state) |
Sets class cast state for graph irg to state . | |
ir_class_cast_state | get_irg_class_cast_state (const ir_graph *irg) |
Returns class cast state for graph irg . | |
void | set_irp_class_cast_state (ir_class_cast_state state) |
Sets class cast state for the whole program to state . | |
ir_class_cast_state | get_irp_class_cast_state (void) |
Returns class cast state for the whole program. | |
int | check_type (const ir_type *tp) |
Checks a type. | |
int | tr_verify (void) |
Walks the type information and performs a set of sanity checks. | |
void | free_type (ir_type *tp) |
Frees the memory used by the type. | |
const tp_op * | get_type_tpop (const ir_type *tp) |
Returns type opcode of type tp . | |
ident * | get_type_tpop_nameid (const ir_type *tp) |
Returns name identifier of type opcode of type tp . | |
const char * | get_type_tpop_name (const ir_type *tp) |
Returns name of type opcode of type tp . | |
tp_opcode | get_type_tpop_code (const ir_type *tp) |
Returns opcode of type opcode of type tp . | |
void | ir_print_type (char *buffer, size_t buffer_size, const ir_type *tp) |
construct a string representing the type. | |
const char * | get_type_state_name (ir_type_state s) |
Returns a human readable string for the enum entry. | |
ir_type_state | get_type_state (const ir_type *tp) |
Returns the type layout state of a type. | |
void | set_type_state (ir_type *tp, ir_type_state state) |
Sets the type layout state of a type. | |
ir_mode * | get_type_mode (const ir_type *tp) |
Returns the mode of a type. | |
void | set_type_mode (ir_type *tp, ir_mode *m) |
Sets the mode of a type. | |
unsigned | get_type_size_bytes (const ir_type *tp) |
Returns the size of a type in bytes. | |
void | set_type_size_bytes (ir_type *tp, unsigned size) |
Sets the size of a type in bytes. | |
unsigned | get_type_alignment_bytes (ir_type *tp) |
Returns the alignment of a type in bytes. | |
void | set_type_alignment_bytes (ir_type *tp, unsigned align) |
Sets the alignment of a type in bytes. | |
ir_visited_t | get_type_visited (const ir_type *tp) |
Returns the visited counter of a type. | |
void | set_type_visited (ir_type *tp, ir_visited_t num) |
Sets the visited counter of a type to num. | |
void | mark_type_visited (ir_type *tp) |
Sets visited field in type to type_visited. | |
int | type_visited (const ir_type *tp) |
Returns non-zero if the type is already visited. | |
int | type_not_visited (const ir_type *tp) |
Returns non-zero if the type is not yet visited. | |
void * | get_type_link (const ir_type *tp) |
Returns the associated link field of a type. | |
void | set_type_link (ir_type *tp, void *l) |
Sets the associated link field of a type. | |
void | inc_master_type_visited (void) |
Increments type visited reference counter by one. | |
void | set_master_type_visited (ir_visited_t val) |
Sets type visited reference counter. | |
ir_visited_t | get_master_type_visited (void) |
Returns type visited reference counter. | |
void | set_type_dbg_info (ir_type *tp, type_dbg_info *db) |
Sets the debug information of a type. | |
type_dbg_info * | get_type_dbg_info (const ir_type *tp) |
Returns the debug information of a type. | |
int | is_type (const void *thing) |
Checks whether a pointer points to a type. | |
long | get_type_nr (const ir_type *tp) |
Outputs a unique number for this type if libfirm is compiled for debugging, (configure with –enable-debug) else returns the address of the type cast to long. | |
int | equal_type (ir_type *typ1, ir_type *typ2) |
Checks whether two types are structurally equal. | |
int | smaller_type (ir_type *st, ir_type *lt) |
Checks whether two types are structural comparable. | |
int | is_atomic_type (const ir_type *tp) |
Checks whether a type is atomic. |
Datastructure to hold type information.
This module supplies a datastructure to represent all types known in the compiled program. This includes types specified in the program as well as types defined by the language. In the view of the intermediate representation there is no difference between these types. Finally it specifies some auxiliary types.
There exist several kinds of types, arranged by the structure of the type. A type is described by a set of attributes. Some of these attributes are common to all types, others depend on the kind of the type.
Types are different from the modes defined in irmode: Types are on the level of the programming language, modes at the level of the target processor.
#define is_SuperClass_of | ( | high, | |
low | |||
) | is_SubClass_of(low, high) |
Returns true if high is superclass of low.
Low is a subclass of high if low == high or if low is a subclass of a subclass of high. I.e, we search in all subtypes of high for low. @@ this can be implemented more efficient if we know the set of all subclasses of high.
#define is_SuperClass_ptr_of | ( | low, | |
high | |||
) | is_SubClass_ptr_of(high, low) |
Type.
Definition at line 84 of file firm_types.h.
enum ir_class_cast_state |
The state of Cast operations that cast class types or pointers to class types.
The state expresses, how far Cast operations conform with the class hierarchy.
class A {} class B1 extends A {} class B2 extends A {} class C extends B1 {} normalized: Cast operations conform with the inheritance relation. I.e., the type of the operand of a Cast is either a super= or a sub- type of the type casted to. Example: (A)((B2) (new C())). transitive: Cast operations conform with the transitive inheritance relation. Example: (A)(new C()). any: Cast operations do not conform with the transitive inheritance relation. Example: (B2)(new B1())
Flags for class cast state.
The state in irp is always smaller or equal to the state of any irg.
We rely on the ordering of the enum.
enum ir_type_state |
The state of the type layout.
int check_type | ( | const ir_type * | tp | ) |
Checks a type.
void compute_inh_transitive_closure | ( | void | ) |
Compute transitive closure of the subclass/superclass and overwrites/overwrittenby relation.
This function walks over the ir (O(#types+#entities)) to compute the transitive closure.
Default name mangling for inherited entities.
Returns an ident that consists of the name of type followed by an underscore and the name (not ld_name) of the entity.
Checks whether two types are structurally equal.
typ1 | the first type |
typ2 | the second type |
Types are equal if :
void free_inh_transitive_closure | ( | void | ) |
Free memory occupied by the transitive closure information.
void free_type | ( | ir_type * | tp | ) |
Frees the memory used by the type.
Removes the type from the type list and frees all entities belonging to the type.
Start iteration over all transitive subtypes of tp
.
Returns next type in a subtype iteration started by get_class_trans_subtype_first()
Start iteration over all transitive supertypes of tp
.
Returns next type in a supertype iteration started by get_class_trans_supertype_first()
Start iteration over all transitive overwritten entities, overwritten by entity ent
.
Returns next entity in a overwrites iteration started by get_entity_trans_overwrites_first()
Start iteration over all entities that transitive overwrite entity ent
.
Returns next entity in a overwrittenby iteration started by get_entity_trans_overwrittenby_first()
ir_class_cast_state get_irg_class_cast_state | ( | const ir_graph * | irg | ) |
Returns class cast state for graph irg
.
ir_class_cast_state get_irp_class_cast_state | ( | void | ) |
Returns class cast state for the whole program.
inh_transitive_closure_state get_irp_inh_transitive_closure_state | ( | void | ) |
Returns the transitive closure of sub/superclass state for the whole program.
ir_visited_t get_master_type_visited | ( | void | ) |
Returns type visited reference counter.
unsigned get_type_alignment_bytes | ( | ir_type * | tp | ) |
Returns the alignment of a type in bytes.
type_dbg_info* get_type_dbg_info | ( | const ir_type * | tp | ) |
Returns the debug information of a type.
tp | The type. |
void* get_type_link | ( | const ir_type * | tp | ) |
Returns the associated link field of a type.
Returns the mode of a type.
Returns NULL for all non atomic types.
long get_type_nr | ( | const ir_type * | tp | ) |
Outputs a unique number for this type if libfirm is compiled for debugging, (configure with –enable-debug) else returns the address of the type cast to long.
unsigned get_type_size_bytes | ( | const ir_type * | tp | ) |
Returns the size of a type in bytes.
ir_type_state get_type_state | ( | const ir_type * | tp | ) |
Returns the type layout state of a type.
const char* get_type_state_name | ( | ir_type_state | s | ) |
Returns a human readable string for the enum entry.
const char* get_type_tpop_name | ( | const ir_type * | tp | ) |
Returns name of type opcode of type tp
.
Returns name identifier of type opcode of type tp
.
ir_visited_t get_type_visited | ( | const ir_type * | tp | ) |
Returns the visited counter of a type.
void inc_master_type_visited | ( | void | ) |
Increments type visited reference counter by one.
void invalidate_irp_inh_transitive_closure_state | ( | void | ) |
Sets the transitive closure of sub/superclass state for the whole program to inh_transitive_closure_invalid.
void ir_print_type | ( | char * | buffer, |
size_t | buffer_size, | ||
const ir_type * | tp | ||
) |
construct a string representing the type.
This uses the info retrieved by the type_dbg_info if available. Otherwise it tries to create an approximate textual representation of the type. Keep in mind that this representation is not unique for each type, might abstract away some details. The main intention of this is creating human redable strings giving an idea of the type.
int is_atomic_type | ( | const ir_type * | tp | ) |
Checks whether a type is atomic.
tp | any type |
Check if subtp
is a subtype of tp
.
This function checks the full transitive closure of the subtype relation and not just direct subtyping.
Returns true if high is (transitive) overwritten by low.
Returns false if high == low.
Returns true if low is subclass of high.
Low is a subclass of high if low == high or if low is a subclass of a subclass of high. I.e, we search in all subtypes of high for low. @@ this can be implemented more efficient if we know the set of all subclasses of high.
Subclass check for pointers to classes.
Dereferences at both types the same amount of pointer types (as many as possible). If the remaining types are both class types and subclasses, returns true, else false. Can also be called with two class types.
int is_type | ( | const void * | thing | ) |
Checks whether a pointer points to a type.
thing | an arbitrary pointer |
void mark_type_visited | ( | ir_type * | tp | ) |
Sets visited field in type to type_visited.
Resolve polymorphism in the inheritance relation.
Returns the dynamically referenced entity if the static entity and the dynamic type are given. Searches downwards in overwritten tree.
void resolve_inheritance | ( | mangle_inherited_name_func * | mfunc | ) |
Resolve implicit inheritance.
Resolves the implicit inheritance supplied by firm. Firm defines, that each entity that is not overwritten in a subclass is inherited to this subclass without change implicitly. This function generates entities that explicitly represent this inheritance. It generates for each entity overwriting entities in all subclasses of the owner of the entity, if the entity is not overwritten in that subclass.
The name of the new entity is generated with the function passed. If the function is NULL, the default_mangle_inherited_name() is used.
void set_irg_class_cast_state | ( | ir_graph * | irg, |
ir_class_cast_state | state | ||
) |
Sets class cast state for graph irg
to state
.
void set_irp_class_cast_state | ( | ir_class_cast_state | state | ) |
Sets class cast state for the whole program to state
.
void set_irp_inh_transitive_closure_state | ( | inh_transitive_closure_state | s | ) |
Sets the transitive closure of sub/superclass state for the whole program.
void set_master_type_visited | ( | ir_visited_t | val | ) |
Sets type visited reference counter.
void set_type_alignment_bytes | ( | ir_type * | tp, |
unsigned | align | ||
) |
Sets the alignment of a type in bytes.
If the alignment of a type is not set, it is calculated here according to the following rules: -#.) if a type has a mode, the alignment is the mode size. -#.) compound types have the alignment of their biggest member. -#.) array types have the alignment of their element type. -#.) method types return 0 here. -#.) all other types return 1 here (i.e. aligned at byte).
void set_type_dbg_info | ( | ir_type * | tp, |
type_dbg_info * | db | ||
) |
Sets the debug information of a type.
tp | The type. |
db | The debug info. |
void set_type_link | ( | ir_type * | tp, |
void * | l | ||
) |
Sets the associated link field of a type.
Sets the mode of a type.
Only has an effect on primitive, enumeration and pointer types.
void set_type_size_bytes | ( | ir_type * | tp, |
unsigned | size | ||
) |
Sets the size of a type in bytes.
For primitive, enumeration, pointer and method types the size is always fixed. This call is legal but has no effect.
void set_type_state | ( | ir_type * | tp, |
ir_type_state | state | ||
) |
Sets the type layout state of a type.
For primitives, pointer and method types the layout is always fixed. This call is legal but has no effect.
void set_type_visited | ( | ir_type * | tp, |
ir_visited_t | num | ||
) |
Sets the visited counter of a type to num.
Checks whether two types are structural comparable.
st | pointer type |
lt | pointer type |
int tr_verify | ( | void | ) |
Walks the type information and performs a set of sanity checks.
Currently, the following checks are executed:
int type_not_visited | ( | const ir_type * | tp | ) |
Returns non-zero if the type is not yet visited.
int type_visited | ( | const ir_type * | tp | ) |
Returns non-zero if the type is already visited.