libFirm
|
An entity is the representation of program known objects in Firm. More...
Modules | |
Entity Initializers | |
Macros | |
#define | IR_VTABLE_NUM_NOT_SET ((unsigned)(-1)) |
A reserved value for "not yet set". More... | |
#define | IR_VA_START_PARAMETER_NUMBER ((size_t)-1) |
Sepcial parameter number which can be used for parameter entities to indicate the first non-declared parameter in a procedure with variable arguments. More... | |
Typedefs | |
typedef struct ir_entity | ir_entity |
Entity. More... | |
Enumerations | |
enum | ir_visibility { ir_visibility_external, ir_visibility_external_private, ir_visibility_external_protected, ir_visibility_local, ir_visibility_private } |
Visibility classed for entities. More... | |
enum | ir_linkage { IR_LINKAGE_DEFAULT = 0, IR_LINKAGE_CONSTANT = 1 << 0, IR_LINKAGE_WEAK = 1 << 1, IR_LINKAGE_GARBAGE_COLLECT = 1 << 2, IR_LINKAGE_MERGE = 1 << 3, IR_LINKAGE_HIDDEN_USER = 1 << 4, IR_LINKAGE_NO_CODEGEN = 1 << 5, IR_LINKAGE_NO_IDENTITY = 1 << 6 } |
linkage specifies how the linker treats symbols More... | |
enum | ir_entity_usage { ir_usage_none = 0, ir_usage_address_taken = 1 << 0, ir_usage_write = 1 << 1, ir_usage_read = 1 << 2, ir_usage_reinterpret_cast = 1 << 3, ir_usage_unknown } |
Bitfield type indicating the way an entity is used. More... | |
Functions | |
ir_visibility | get_entity_visibility (const ir_entity *entity) |
Returns the visibility class of an entity. More... | |
void | set_entity_visibility (ir_entity *entity, ir_visibility visibility) |
Sets visibility class of an entity. More... | |
int | entity_is_externally_visible (const ir_entity *entity) |
Returns 1 if the entity is visible outside the current compilation unit or to unknown callers (like asm statements). More... | |
int | entity_has_definition (const ir_entity *entity) |
Returns 1 if the entity has a definition (initializer) in the current compilation unit. More... | |
ir_entity * | new_entity (ir_type *owner, ident *name, ir_type *tp) |
Creates a new entity. More... | |
ir_entity * | new_global_entity (ir_type *segment, ident *ld_name, ir_type *type, ir_visibility visibility, ir_linkage linkage) |
Creates a new global entity. More... | |
ir_entity * | new_parameter_entity (ir_type *owner, size_t pos, ir_type *type) |
Creates a new entity corresponding to a function parameter. More... | |
ir_entity * | new_alias_entity (ir_type *owner, ident *name, ir_entity *alias, ir_type *type, ir_visibility visibility) |
Creates a new entity aliasing another entity. More... | |
void | set_entity_alias (ir_entity *alias, ir_entity *aliased) |
Sets the entity an alias entity aliases. More... | |
ir_entity * | get_entity_alias (const ir_entity *alias) |
Returns the entity aliased by an alias entity. More... | |
int | check_entity (const ir_entity *ent) |
Check an entity. More... | |
ir_entity * | clone_entity (ir_entity const *old, ident *name, ir_type *owner) |
Create a new entity with attributes copied from an existing entity. More... | |
void | free_entity (ir_entity *ent) |
Frees the entity. More... | |
const char * | get_entity_name (const ir_entity *ent) |
Returns the name of an entity. More... | |
ident * | get_entity_ident (const ir_entity *ent) |
Returns the ident of an entity. More... | |
void | set_entity_ident (ir_entity *ent, ident *id) |
Sets the ident of the entity. More... | |
ident * | get_entity_ld_ident (const ir_entity *ent) |
Returns the mangled name of the entity. More... | |
void | set_entity_ld_ident (ir_entity *ent, ident *ld_ident) |
Sets the mangled name of the entity. More... | |
const char * | get_entity_ld_name (const ir_entity *ent) |
Returns the mangled name of the entity as a string. More... | |
int | entity_has_ld_ident (const ir_entity *entity) |
returns 1 if the entity has an ld_ident set explicitely More... | |
ir_type * | get_entity_owner (const ir_entity *ent) |
Returns the owner of the entity. More... | |
void | set_entity_owner (ir_entity *ent, ir_type *owner) |
Sets the owner field in entity to owner. More... | |
ir_type * | get_entity_type (const ir_entity *ent) |
Returns the type of an entity. More... | |
void | set_entity_type (ir_entity *ent, ir_type *tp) |
Sets the type of an entity. More... | |
ir_linkage | get_entity_linkage (const ir_entity *entity) |
Returns the linkage of an entity. More... | |
void | set_entity_linkage (ir_entity *entity, ir_linkage linkage) |
Sets the linkage flags of entity entity to linkage . More... | |
void | add_entity_linkage (ir_entity *entity, ir_linkage linkage) |
Adds linkage flags linkage to entity entity . More... | |
void | remove_entity_linkage (ir_entity *entity, ir_linkage linkage) |
Remove linkage flags linkage from entity entity . More... | |
ir_volatility | get_entity_volatility (const ir_entity *ent) |
Returns the volatility of an entity. More... | |
void | set_entity_volatility (ir_entity *ent, ir_volatility vol) |
Sets the volatility of an entity. More... | |
const char * | get_volatility_name (ir_volatility var) |
Returns the name of the volatility. More... | |
unsigned | get_entity_alignment (const ir_entity *entity) |
Returns alignment of entity in bytes. More... | |
void | set_entity_alignment (ir_entity *entity, unsigned alignment) |
Allows you to override the type alignment for an entity. More... | |
ir_align | get_entity_aligned (const ir_entity *ent) |
Returns indication whether entity is aligned in memory. More... | |
void | set_entity_aligned (ir_entity *ent, ir_align a) |
Sets indication whether entity is aligned in memory. More... | |
const char * | get_align_name (ir_align a) |
Returns the name of the alignment. More... | |
int | get_entity_offset (const ir_entity *entity) |
Returns the offset of an entity (in a compound) in bytes. More... | |
void | set_entity_offset (ir_entity *entity, int offset) |
Sets the offset of an entity (in a compound) in bytes. More... | |
unsigned | get_entity_bitfield_offset (const ir_entity *entity) |
For bitfields, returns the offset in bits to the bitfield base. More... | |
void | set_entity_bitfield_offset (ir_entity *entity, unsigned offset) |
Sets the offset in bits to the base for a bitfield. More... | |
void | set_entity_bitfield_size (ir_entity *entity, unsigned size) |
Sets the size in bits for a bitfield. More... | |
unsigned | get_entity_bitfield_size (const ir_entity *entity) |
Returns the size in bits for a bitfield, 0 if entity is not a bitfield. More... | |
void * | get_entity_link (const ir_entity *ent) |
Returns the stored intermediate information. More... | |
void | set_entity_link (ir_entity *ent, void *l) |
Stores new intermediate information. More... | |
ir_graph * | get_entity_irg (const ir_entity *ent) |
Return the method graph of a method entity. More... | |
ir_graph * | get_entity_linktime_irg (const ir_entity *ent) |
Return the method graph the method entity points to after linking. More... | |
unsigned | get_entity_vtable_number (const ir_entity *ent) |
Returns the entity vtable number. More... | |
void | set_entity_vtable_number (ir_entity *ent, unsigned vtable_number) |
Sets the entity vtable number. More... | |
void | set_entity_label (ir_entity *ent, ir_label_t label) |
Sets label number of an entity with code type. More... | |
ir_label_t | get_entity_label (const ir_entity *ent) |
Returns label number of an entity with code type. More... | |
ir_entity_usage | get_entity_usage (const ir_entity *ent) |
Returns the entity usage. More... | |
void | set_entity_usage (ir_entity *ent, ir_entity_usage flag) |
Sets/resets the state of the address taken flag of an entity. More... | |
dbg_info * | get_entity_dbg_info (const ir_entity *ent) |
Returns the debug information of an entity. More... | |
void | set_entity_dbg_info (ir_entity *ent, dbg_info *db) |
Sets the debug information of an entity. More... | |
int | is_parameter_entity (const ir_entity *entity) |
returns true if a given entity is a parameter_entity representing the address of a function parameter More... | |
size_t | get_entity_parameter_number (const ir_entity *entity) |
returns number of parameter a parameter entitiy represents More... | |
void | set_entity_parameter_number (ir_entity *entity, size_t n) |
set number of parameter an entity represents More... | |
void | set_entity_initializer (ir_entity *entity, ir_initializer_t *initializer) |
Sets the new style initializers of an entity. More... | |
ir_initializer_t * | get_entity_initializer (const ir_entity *entity) |
Returns the new style initializers of an entity. More... | |
void | add_entity_overwrites (ir_entity *ent, ir_entity *overwritten) |
Adds entity ent to the list of entities that overwrite overwritten . More... | |
size_t | get_entity_n_overwrites (const ir_entity *ent) |
Returns the number of entities in the list of entities that overwrite entity ent . More... | |
size_t | get_entity_overwrites_index (const ir_entity *ent, ir_entity *overwritten) |
Returns index of overwritten in list of entities overwriting entity ent . More... | |
ir_entity * | get_entity_overwrites (const ir_entity *ent, size_t pos) |
Returns entry pos in list of entities overwriting entity ent . More... | |
void | set_entity_overwrites (ir_entity *ent, size_t pos, ir_entity *overwritten) |
Sets entry pos in list of entities overwriting entity ent . More... | |
void | remove_entity_overwrites (ir_entity *ent, ir_entity *overwritten) |
Remove overwritten from list of entities overwriting entity ent . More... | |
size_t | get_entity_n_overwrittenby (const ir_entity *ent) |
Returns number of entities overwritten by ent . More... | |
size_t | get_entity_overwrittenby_index (const ir_entity *ent, ir_entity *overwrites) |
Returns index of overwrites in list of entities overwritten by entity ent . More... | |
ir_entity * | get_entity_overwrittenby (const ir_entity *ent, size_t pos) |
Return entry pos in list of entities overwritten by entity ent . More... | |
void | set_entity_overwrittenby (ir_entity *ent, size_t pos, ir_entity *overwrites) |
Sets entry pos in list of entities overwritten by entity ent . More... | |
void | remove_entity_overwrittenby (ir_entity *ent, ir_entity *overwrites) |
Removes entry overwrites in list of entities overwritten by ent . More... | |
int | is_compound_entity (const ir_entity *ent) |
Returns true if the type of the entity is a class, structure, array or union type. More... | |
int | is_method_entity (const ir_entity *ent) |
Returns true if the entity is a method entity. More... | |
int | is_alias_entity (const ir_entity *ent) |
Returns true if the entity is an alias entity. More... | |
long | get_entity_nr (const ir_entity *ent) |
Outputs a unique number for this entity if libfirm is compiled for debugging, (configure with –enable-debug) else returns the address of the type cast to long. More... | |
ir_visited_t | get_entity_visited (const ir_entity *ent) |
Returns the entities visited counter. More... | |
void | set_entity_visited (ir_entity *ent, ir_visited_t num) |
Sets the entities visited counter. More... | |
void | mark_entity_visited (ir_entity *ent) |
Marks entity as visited. More... | |
int | entity_visited (const ir_entity *ent) |
Returns true if this entity was visited. More... | |
int | entity_not_visited (const ir_entity *ent) |
Returns true if this entity was not visited. More... | |
int | entity_has_additional_properties (const ir_entity *entity) |
Return true if this entity can be queried for additional properties. More... | |
mtp_additional_properties | get_entity_additional_properties (const ir_entity *ent) |
Returns the mask of the additional entity properties. More... | |
void | set_entity_additional_properties (ir_entity *ent, mtp_additional_properties prop) |
Sets the mask of the additional graph properties. More... | |
void | add_entity_additional_properties (ir_entity *ent, mtp_additional_properties flag) |
Sets additional graph properties. More... | |
ir_entity * | get_unknown_entity (void) |
Returns the unknown entity . More... | |
int | is_unknown_entity (const ir_entity *entity) |
Tests whether entity entity is (the) unknown entity. More... | |
An entity is the representation of program known objects in Firm.
The primary concept of entities is to represent members of complex types, i.e., fields and methods of classes. As not all programming language model all variables and methods as members of some class, the concept of entities is extended to cover also local and global variables, and arbitrary procedures.
An entity always specifies the type of the object it represents and the type of the object it is a part of, the owner of the entity. Originally this is the type of the class of which the entity is a member. The owner of local variables is the procedure they are defined in. The owner of global variables and procedures visible in the whole program is a universally defined class type "GlobalType". The owner of procedures defined in the scope of an other procedure is the enclosing procedure.
The type ir_entity is an abstract data type to represent program entities. If contains the following attributes:
These fields can only be accessed via access functions.
Overwrites is a field that specifies that an access to the overwritten entity in the supertype must use this entity. It's a list as with multiple inheritance several entities can be overwritten. This field is mostly useful for method entities. If a Sel node selects an entity that is overwritten by other entities it must return a pointer to the entity of the dynamic type of the pointer that is passed to it. Lowering of the Sel node must assure this. Overwrittenby is the inverse of overwrites. Both add routines add both relations, they only differ in the order of arguments.
#define IR_VA_START_PARAMETER_NUMBER ((size_t)-1) |
Sepcial parameter number which can be used for parameter entities to indicate the first non-declared parameter in a procedure with variable arguments.
We assumes that all additional parameters for variable parameters are on the stack. Starting from this address you can walk the stack to find all other parameters.
#define IR_VTABLE_NUM_NOT_SET ((unsigned)(-1)) |
Entity.
Definition at line 83 of file firm_types.h.
enum ir_entity_usage |
Bitfield type indicating the way an entity is used.
enum ir_linkage |
linkage specifies how the linker treats symbols
enum ir_visibility |
Visibility classed for entities.
void add_entity_additional_properties | ( | ir_entity * | ent, |
mtp_additional_properties | flag | ||
) |
Sets additional graph properties.
void add_entity_linkage | ( | ir_entity * | entity, |
ir_linkage | linkage | ||
) |
Adds linkage flags linkage
to entity entity
.
Adds entity ent
to the list of entities that overwrite overwritten
.
int check_entity | ( | const ir_entity * | ent | ) |
Check an entity.
Create a new entity with attributes copied from an existing entity.
Does not copy the overwrites/overwritte_by, visited an dusage fields, sets a new name and inserts the entity into owner
.
int entity_has_additional_properties | ( | const ir_entity * | entity | ) |
Return true if this entity can be queried for additional properties.
This is possible for method and alias entities.
int entity_has_definition | ( | const ir_entity * | entity | ) |
Returns 1 if the entity has a definition (initializer) in the current compilation unit.
Note that this function returns false if IR_LINKAGE_NO_CODEGEN is set even if a graph is present.
int entity_has_ld_ident | ( | const ir_entity * | entity | ) |
returns 1 if the entity has an ld_ident set explicitely
int entity_is_externally_visible | ( | const ir_entity * | entity | ) |
Returns 1 if the entity is visible outside the current compilation unit or to unknown callers (like asm statements).
(The entity might still be accessible indirectly through pointers) This is a convenience function and does the same as get_entity_visibility(entity) != ir_visibility_local || (get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)
int entity_not_visited | ( | const ir_entity * | ent | ) |
Returns true if this entity was not visited.
int entity_visited | ( | const ir_entity * | ent | ) |
Returns true if this entity was visited.
void free_entity | ( | ir_entity * | ent | ) |
Frees the entity.
The owner will still contain the pointer to this entity, as well as all other references!
const char* get_align_name | ( | ir_align | a | ) |
Returns the name of the alignment.
mtp_additional_properties get_entity_additional_properties | ( | const ir_entity * | ent | ) |
Returns the mask of the additional entity properties.
The properties are automatically inherited from the irg if available or from the method type if they were not set using set_entity_additional_properties() or set_entity_additional_property().
Returns the entity aliased by an alias entity.
ir_align get_entity_aligned | ( | const ir_entity * | ent | ) |
Returns indication whether entity is aligned in memory.
unsigned get_entity_alignment | ( | const ir_entity * | entity | ) |
Returns alignment of entity in bytes.
unsigned get_entity_bitfield_offset | ( | const ir_entity * | entity | ) |
For bitfields, returns the offset in bits to the bitfield base.
unsigned get_entity_bitfield_size | ( | const ir_entity * | entity | ) |
Returns the size in bits for a bitfield, 0 if entity is not a bitfield.
Returns the debug information of an entity.
ent | The entity. |
ir_initializer_t* get_entity_initializer | ( | const ir_entity * | entity | ) |
Returns the new style initializers of an entity.
Return the method graph of a method entity.
ir_label_t get_entity_label | ( | const ir_entity * | ent | ) |
Returns label number of an entity with code type.
Returns the mangled name of the entity.
If the mangled name is set it returns the existing name. Else it generates a name with mangle_entity() and remembers this new name internally.
const char* get_entity_ld_name | ( | const ir_entity * | ent | ) |
Returns the mangled name of the entity as a string.
void* get_entity_link | ( | const ir_entity * | ent | ) |
Returns the stored intermediate information.
ir_linkage get_entity_linkage | ( | const ir_entity * | entity | ) |
Returns the linkage of an entity.
Return the method graph the method entity points to after linking.
This is different to get_entity_irg() in case of weak symbols where this function returns NULL because the code may be replaced by a non-weak symbol after linking.
size_t get_entity_n_overwrites | ( | const ir_entity * | ent | ) |
Returns the number of entities in the list of entities that overwrite entity ent
.
size_t get_entity_n_overwrittenby | ( | const ir_entity * | ent | ) |
Returns number of entities overwritten by ent
.
const char* get_entity_name | ( | const ir_entity * | ent | ) |
Returns the name of an entity.
long get_entity_nr | ( | const ir_entity * | ent | ) |
Outputs a unique number for this entity if libfirm is compiled for debugging, (configure with –enable-debug) else returns the address of the type cast to long.
int get_entity_offset | ( | const ir_entity * | entity | ) |
Returns the offset of an entity (in a compound) in bytes.
Only set if layout = fixed.
Returns entry pos
in list of entities overwriting entity ent
.
Returns index of overwritten
in list of entities overwriting entity ent
.
Return entry pos
in list of entities overwritten by entity ent
.
Returns index of overwrites
in list of entities overwritten by entity ent
.
size_t get_entity_parameter_number | ( | const ir_entity * | entity | ) |
returns number of parameter a parameter entitiy represents
ir_entity_usage get_entity_usage | ( | const ir_entity * | ent | ) |
Returns the entity usage.
ir_visibility get_entity_visibility | ( | const ir_entity * | entity | ) |
Returns the visibility class of an entity.
ir_visited_t get_entity_visited | ( | const ir_entity * | ent | ) |
Returns the entities visited counter.
ir_volatility get_entity_volatility | ( | const ir_entity * | ent | ) |
Returns the volatility of an entity.
unsigned get_entity_vtable_number | ( | const ir_entity * | ent | ) |
Returns the entity vtable number.
ir_entity* get_unknown_entity | ( | void | ) |
Returns the unknown entity .
const char* get_volatility_name | ( | ir_volatility | var | ) |
Returns the name of the volatility.
int is_alias_entity | ( | const ir_entity * | ent | ) |
Returns true if the entity is an alias entity.
int is_compound_entity | ( | const ir_entity * | ent | ) |
Returns true if the type of the entity is a class, structure, array or union type.
int is_method_entity | ( | const ir_entity * | ent | ) |
Returns true if the entity is a method entity.
int is_parameter_entity | ( | const ir_entity * | entity | ) |
returns true if a given entity is a parameter_entity representing the address of a function parameter
int is_unknown_entity | ( | const ir_entity * | entity | ) |
Tests whether entity entity
is (the) unknown entity.
void mark_entity_visited | ( | ir_entity * | ent | ) |
Marks entity as visited.
ir_entity* new_alias_entity | ( | ir_type * | owner, |
ident * | name, | ||
ir_entity * | alias, | ||
ir_type * | type, | ||
ir_visibility | visibility | ||
) |
Creates a new entity aliasing another entity.
An aliasing entity is a logically separate entity with its own name, but instead of having a definition the linker will merge the name with the definition of the aliased entity. In gcc this feature is known as attribute((alias())).
owner | owning type (must be a global segment) |
name | name of the entity |
alias | entity that is aliased |
type | type of the aliased entity, should but need not be the same type as the one of the aliased entity |
visibility | visibility of the entity |
Creates a new entity.
Automatically inserts the entity as a member of owner. Entity is automatic_allocated and uninitialized except if the type is type_method, then it is static_allocated and constant. Visibility is local, offset -1, and it is not volatile.
ir_entity* new_global_entity | ( | ir_type * | segment, |
ident * | ld_name, | ||
ir_type * | type, | ||
ir_visibility | visibility, | ||
ir_linkage | linkage | ||
) |
Creates a new global entity.
Creates a new entity corresponding to a function parameter.
This must be created on an irgs frame_type
void remove_entity_linkage | ( | ir_entity * | entity, |
ir_linkage | linkage | ||
) |
Remove linkage flags linkage
from entity entity
.
Remove overwritten
from list of entities overwriting entity ent
.
Removes entry overwrites
in list of entities overwritten by ent
.
void set_entity_additional_properties | ( | ir_entity * | ent, |
mtp_additional_properties | prop | ||
) |
Sets the mask of the additional graph properties.
Sets the entity an alias entity aliases.
void set_entity_aligned | ( | ir_entity * | ent, |
ir_align | a | ||
) |
Sets indication whether entity is aligned in memory.
void set_entity_alignment | ( | ir_entity * | entity, |
unsigned | alignment | ||
) |
Allows you to override the type alignment for an entity.
entity | the entity |
alignment | alignment in bytes |
void set_entity_bitfield_offset | ( | ir_entity * | entity, |
unsigned | offset | ||
) |
Sets the offset in bits to the base for a bitfield.
void set_entity_bitfield_size | ( | ir_entity * | entity, |
unsigned | size | ||
) |
Sets the size in bits for a bitfield.
0 means not a bitfield.
Sets the debug information of an entity.
ent | The entity. |
db | The debug info. |
void set_entity_initializer | ( | ir_entity * | entity, |
ir_initializer_t * | initializer | ||
) |
Sets the new style initializers of an entity.
void set_entity_label | ( | ir_entity * | ent, |
ir_label_t | label | ||
) |
Sets label number of an entity with code type.
void set_entity_link | ( | ir_entity * | ent, |
void * | l | ||
) |
Stores new intermediate information.
void set_entity_linkage | ( | ir_entity * | entity, |
ir_linkage | linkage | ||
) |
Sets the linkage flags of entity entity
to linkage
.
void set_entity_offset | ( | ir_entity * | entity, |
int | offset | ||
) |
Sets the offset of an entity (in a compound) in bytes.
Sets entry pos
in list of entities overwriting entity ent
.
Sets entry pos
in list of entities overwritten by entity ent
.
Sets the owner field in entity to owner.
Automatically removes entity from old owner type and adds it to the new one.
void set_entity_parameter_number | ( | ir_entity * | entity, |
size_t | n | ||
) |
set number of parameter an entity represents
void set_entity_usage | ( | ir_entity * | ent, |
ir_entity_usage | flag | ||
) |
Sets/resets the state of the address taken flag of an entity.
void set_entity_visibility | ( | ir_entity * | entity, |
ir_visibility | visibility | ||
) |
Sets visibility class of an entity.
void set_entity_visited | ( | ir_entity * | ent, |
ir_visited_t | num | ||
) |
Sets the entities visited counter.
void set_entity_volatility | ( | ir_entity * | ent, |
ir_volatility | vol | ||
) |
Sets the volatility of an entity.
void set_entity_vtable_number | ( | ir_entity * | ent, |
unsigned | vtable_number | ||
) |
Sets the entity vtable number.