libFirm
Loading...
Searching...
No Matches
typerep.h
1/*
2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
4 */
5
10#ifndef FIRM_TYPEREP_H
11#define FIRM_TYPEREP_H
12
13#include <stddef.h>
14#include "firm_types.h"
15
16#include "begin.h"
17
115
173ENUM_BITSET(ir_linkage)
174
175
179
183FIRM_API void set_entity_visibility(ir_entity *entity, ir_visibility visibility);
184
193FIRM_API int entity_is_externally_visible(const ir_entity *entity);
194
200FIRM_API int entity_has_definition(const ir_entity *entity);
201
210FIRM_API ir_entity *new_entity(ir_type *owner, ident *name, ir_type *tp);
211
215FIRM_API ir_entity *new_global_entity(ir_type *segment, ident *ld_name,
216 ir_type *type, ir_visibility visibility,
217 ir_linkage linkage);
218
224FIRM_API ir_entity *new_parameter_entity(ir_type *owner, size_t pos,
225 ir_type *type);
226
242FIRM_API ir_entity *new_alias_entity(ir_type *owner, ident *name,
243 ir_entity *alias, ir_type *type,
244 ir_visibility visibility);
245
249FIRM_API void set_entity_alias(ir_entity *alias, ir_entity *aliased);
250
254FIRM_API ir_entity *get_entity_alias(const ir_entity *alias);
255
261FIRM_API int check_entity(const ir_entity *ent);
262
269FIRM_API ir_entity *clone_entity(ir_entity const *old, ident *name,
270 ir_type *owner);
271
278FIRM_API void free_entity(ir_entity *ent);
279
281FIRM_API const char *get_entity_name(const ir_entity *ent);
282
284FIRM_API ident *get_entity_ident(const ir_entity *ent);
285
287FIRM_API void set_entity_ident(ir_entity *ent, ident *id);
288
295FIRM_API ident *get_entity_ld_ident(const ir_entity *ent);
296
298FIRM_API void set_entity_ld_ident(ir_entity *ent, ident *ld_ident);
299
301FIRM_API const char *get_entity_ld_name(const ir_entity *ent);
302
304FIRM_API int entity_has_ld_ident(const ir_entity *entity);
305
307FIRM_API ir_type *get_entity_owner(const ir_entity *ent);
308
314FIRM_API void set_entity_owner(ir_entity *ent, ir_type *owner);
315
317FIRM_API ir_type *get_entity_type(const ir_entity *ent);
318
320FIRM_API void set_entity_type(ir_entity *ent, ir_type *tp);
321
324
326FIRM_API void set_entity_linkage(ir_entity *entity, ir_linkage linkage);
328FIRM_API void add_entity_linkage(ir_entity *entity, ir_linkage linkage);
330FIRM_API void remove_entity_linkage(ir_entity *entity, ir_linkage linkage);
331
336FIRM_API ir_volatility get_entity_volatility(const ir_entity *ent);
337
342FIRM_API void set_entity_volatility(ir_entity *ent, ir_volatility vol);
343
345FIRM_API const char *get_volatility_name(ir_volatility var);
346
348FIRM_API unsigned get_entity_alignment(const ir_entity *entity);
349
354FIRM_API void set_entity_alignment(ir_entity *entity, unsigned alignment);
355
360FIRM_API ir_align get_entity_aligned(const ir_entity *ent);
361
366FIRM_API void set_entity_aligned(ir_entity *ent, ir_align a);
367
369FIRM_API const char *get_align_name(ir_align a);
370
376FIRM_API int get_entity_offset(const ir_entity *entity);
377
379FIRM_API void set_entity_offset(ir_entity *entity, int offset);
380
382FIRM_API unsigned get_entity_bitfield_offset(const ir_entity *entity);
383
385FIRM_API void set_entity_bitfield_offset(ir_entity *entity, unsigned offset);
386
388FIRM_API void set_entity_bitfield_size(ir_entity *entity, unsigned size);
389
391FIRM_API unsigned get_entity_bitfield_size(const ir_entity *entity);
392
394FIRM_API void *get_entity_link(const ir_entity *ent);
395
397FIRM_API void set_entity_link(ir_entity *ent, void *l);
398
405FIRM_API ir_graph *get_entity_irg(const ir_entity *ent);
406
414
416#define IR_VTABLE_NUM_NOT_SET ((unsigned)(-1))
417
419FIRM_API unsigned get_entity_vtable_number(const ir_entity *ent);
420
422FIRM_API void set_entity_vtable_number(ir_entity *ent, unsigned vtable_number);
423
425FIRM_API void set_entity_label(ir_entity *ent, ir_label_t label);
427FIRM_API ir_label_t get_entity_label(const ir_entity *ent);
428
444
447
450
457
464FIRM_API void set_entity_dbg_info(ir_entity *ent, dbg_info *db);
465
473#define IR_VA_START_PARAMETER_NUMBER ((size_t)-1)
474
479FIRM_API int is_parameter_entity(const ir_entity *entity);
480
484FIRM_API size_t get_entity_parameter_number(const ir_entity *entity);
485
489FIRM_API void set_entity_parameter_number(ir_entity *entity, size_t n);
490
506
509
512
517
523
526
529
532
535
537FIRM_API size_t get_initializer_compound_n_entries(const ir_initializer_t *initializer);
538
541 size_t index,
542 ir_initializer_t *value);
543
546 const ir_initializer_t *initializer, size_t index);
547
551FIRM_API void set_entity_initializer(ir_entity *entity, ir_initializer_t *initializer);
552
555
557FIRM_API void add_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
560FIRM_API size_t get_entity_n_overwrites(const ir_entity *ent);
563FIRM_API size_t get_entity_overwrites_index(const ir_entity *ent,
564 ir_entity *overwritten);
566FIRM_API ir_entity *get_entity_overwrites(const ir_entity *ent, size_t pos);
568FIRM_API void set_entity_overwrites(ir_entity *ent, size_t pos,
569 ir_entity *overwritten);
571FIRM_API void remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten);
572
574FIRM_API size_t get_entity_n_overwrittenby(const ir_entity *ent);
577FIRM_API size_t get_entity_overwrittenby_index(const ir_entity *ent,
578 ir_entity *overwrites);
580FIRM_API ir_entity *get_entity_overwrittenby(const ir_entity *ent, size_t pos);
582FIRM_API void set_entity_overwrittenby(ir_entity *ent, size_t pos,
583 ir_entity *overwrites);
586 ir_entity *overwrites);
587
590FIRM_API int is_compound_entity(const ir_entity *ent);
592FIRM_API int is_method_entity(const ir_entity *ent);
594FIRM_API int is_alias_entity(const ir_entity *ent);
595
597FIRM_API long get_entity_nr(const ir_entity *ent);
598
601FIRM_API ir_visited_t get_entity_visited(const ir_entity *ent);
602
605FIRM_API void set_entity_visited(ir_entity *ent, ir_visited_t num);
606
609FIRM_API void mark_entity_visited(ir_entity *ent);
610
613FIRM_API int entity_visited(const ir_entity *ent);
614
617FIRM_API int entity_not_visited(const ir_entity *ent);
618
623FIRM_API int entity_has_additional_properties(const ir_entity *entity);
624
633
637
641
657
660FIRM_API int is_unknown_entity(const ir_entity *entity);
661
665typedef enum ptr_access_kind {
666 ptr_access_none = 0,
667 ptr_access_read = 1,
668 ptr_access_write = 2,
669 ptr_access_rw = ptr_access_read|ptr_access_write,
670 ptr_access_store = 4,
671 ptr_access_all = ptr_access_rw|ptr_access_store
672} ptr_access_kind;
673ENUM_BITSET(ptr_access_kind)
674
675
716
720FIRM_API const char *get_type_opcode_name(tp_opcode opcode);
721
728FIRM_API int is_SubClass_of(const ir_type *low, const ir_type *high);
729
737FIRM_API int is_SubClass_ptr_of(ir_type *low, ir_type *high);
738
745#define is_SuperClass_of(high, low) is_SubClass_of(low, high)
746
752#define is_SuperClass_ptr_of(low, high) is_SubClass_ptr_of(high, low)
753
757FIRM_API int is_overwritten_by(ir_entity *high, ir_entity *low);
758
764FIRM_API ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class,
765 ir_entity* static_ent);
766
767/* ----------------------------------------------------------------------- */
768/* The transitive closure of the subclass/superclass and */
769/* overwrites/overwrittenby relation. */
770/* */
771/* A walk over the ir (O(#types+#entities)) computes the transitive */
772/* closure. Adding a new type/entity or changing the basic relations in */
773/* some other way invalidates the transitive closure, i.e., it is not */
774/* updated by the basic functions. */
775/* */
776/* The transitive edges are held in a set, not in an array as the */
777/* underlying relation. */
778/* */
779/* Do the sets contain the node itself? I assume NOT! */
780/* ----------------------------------------------------------------------- */
781
791
801
808
810FIRM_API void free_inh_transitive_closure(void);
811
824FIRM_API int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp);
825
833
841
850
851
857FIRM_API int check_type(const ir_type *tp);
858
864FIRM_API int tr_verify(void);
865
872FIRM_API void free_type(ir_type *tp);
873
875FIRM_API tp_opcode get_type_opcode(const ir_type *type);
876
886FIRM_API void ir_print_type(char *buffer, size_t buffer_size,
887 const ir_type *tp);
888
904
906FIRM_API const char *get_type_state_name(ir_type_state s);
907
910
916FIRM_API void set_type_state(ir_type *tp, ir_type_state state);
917
922FIRM_API ir_mode *get_type_mode(const ir_type *tp);
923
925FIRM_API unsigned get_type_size(const ir_type *tp);
926
932FIRM_API void set_type_size(ir_type *tp, unsigned size);
933
935FIRM_API unsigned get_type_alignment(const ir_type *tp);
936
938FIRM_API void set_type_alignment(ir_type *tp, unsigned align);
939
942FIRM_API ir_visited_t get_type_visited(const ir_type *tp);
945FIRM_API void set_type_visited(ir_type *tp, ir_visited_t num);
948FIRM_API void mark_type_visited(ir_type *tp);
951FIRM_API int type_visited(const ir_type *tp);
952
954FIRM_API void *get_type_link(const ir_type *tp);
956FIRM_API void set_type_link(ir_type *tp, void *l);
957
960FIRM_API void inc_master_type_visited(void);
963FIRM_API void set_master_type_visited(ir_visited_t val);
966FIRM_API ir_visited_t get_master_type_visited(void);
967
975
982
988FIRM_API long get_type_nr(const ir_type *tp);
989
1017
1019FIRM_API size_t get_class_n_members(const ir_type *clss);
1020
1022FIRM_API ir_entity *get_class_member(const ir_type *clss, size_t pos);
1023
1028#define INVALID_MEMBER_INDEX ((size_t)-1)
1029
1031FIRM_API size_t get_class_member_index(ir_type const *clss,
1032 ir_entity const *mem);
1033
1038FIRM_API void add_class_subtype(ir_type *clss, ir_type *subtype);
1039
1041FIRM_API size_t get_class_n_subtypes(const ir_type *clss);
1042
1044FIRM_API ir_type *get_class_subtype(const ir_type *clss, size_t pos);
1045
1050FIRM_API size_t get_class_subtype_index(const ir_type *clss,
1051 const ir_type *subclass);
1052
1057FIRM_API void set_class_subtype(ir_type *clss, ir_type *subtype, size_t pos);
1058
1060FIRM_API void remove_class_subtype(ir_type *clss, ir_type *subtype);
1061
1066FIRM_API void add_class_supertype(ir_type *clss, ir_type *supertype);
1067
1069FIRM_API size_t get_class_n_supertypes(const ir_type *clss);
1070
1075FIRM_API size_t get_class_supertype_index(const ir_type *clss,
1076 const ir_type *super_clss);
1077
1079FIRM_API ir_type *get_class_supertype(const ir_type *clss, size_t pos);
1080
1085FIRM_API void set_class_supertype(ir_type *clss, ir_type *supertype, size_t pos);
1086
1088FIRM_API void remove_class_supertype(ir_type *clss, ir_type *supertype);
1089
1091FIRM_API int is_Class_type(const ir_type *clss);
1092
1111
1113FIRM_API size_t get_struct_n_members(const ir_type *strct);
1114
1116FIRM_API ir_entity *get_struct_member(const ir_type *strct, size_t pos);
1117
1119FIRM_API size_t get_struct_member_index(ir_type const *strct,
1120 ir_entity const *member);
1121
1123FIRM_API int is_Struct_type(const ir_type *strct);
1124
1141
1143FIRM_API size_t get_union_n_members(const ir_type *uni);
1144
1146FIRM_API ir_entity *get_union_member(const ir_type *uni, size_t pos);
1147
1149FIRM_API size_t get_union_member_index(ir_type const *uni,
1150 ir_entity const *member);
1151
1153FIRM_API int is_Union_type(const ir_type *uni);
1154
1200FIRM_API ir_type *new_type_method(size_t n_param, size_t n_res, int is_variadic, unsigned cc_mask, mtp_additional_properties property_mask);
1201
1203FIRM_API size_t get_method_n_params(const ir_type *method);
1204
1206FIRM_API ir_type *get_method_param_type(const ir_type *method, size_t pos);
1210FIRM_API void set_method_param_type(ir_type *method, size_t pos, ir_type *tp);
1212FIRM_API size_t get_method_n_ress(const ir_type *method);
1214FIRM_API ir_type *get_method_res_type(const ir_type *method, size_t pos);
1216FIRM_API void set_method_res_type(ir_type *method, size_t pos, ir_type *tp);
1217
1219FIRM_API int is_method_variadic(ir_type const *method);
1220
1223
1228typedef enum {
1229 cc_reg_param = 0x01000000,
1231 cc_last_on_top = 0x02000000,
1236 cc_callee_clear_stk = 0x04000000,
1238 cc_this_call = 0x08000000,
1240 cc_compound_ret = 0x10000000,
1241 cc_frame_on_caller_stk = 0x20000000,
1243 cc_fpreg_param = 0x40000000,
1245
1247#define cc_bits (0xFF000000)
1248
1250#define cc_cdecl_set (0)
1252#define cc_stdcall_set cc_callee_clear_stk
1254#define cc_fastcall_set (cc_reg_param|cc_callee_clear_stk)
1255
1259#define IS_CDECL(cc_mask) (((cc_mask) & cc_bits) == cc_cdecl_set)
1260
1264#define IS_STDCALL(cc_mask) (((cc_mask) & cc_bits) == cc_stdcall_set)
1265
1269#define IS_FASTCALL(cc_mask) (((cc_mask) & cc_bits) == cc_fastcall_set)
1270
1274#define SET_CDECL(cc_mask) (((cc_mask) & ~cc_bits) | cc_cdecl_set)
1275
1279#define SET_STDCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_stdcall_set)
1280
1284#define SET_FASTCALL(cc_mask) (((cc_mask) & ~cc_bits) | cc_fastcall_set)
1285
1287FIRM_API unsigned get_method_calling_convention(const ir_type *method);
1288
1290FIRM_API unsigned get_method_n_regparams(ir_type *method);
1291
1293FIRM_API int is_Method_type(const ir_type *method);
1294
1312FIRM_API ir_type *new_type_array(ir_type *element_type, unsigned n_elements);
1313
1315FIRM_API unsigned get_array_size(const ir_type *array);
1316
1319
1321FIRM_API int is_Array_type(const ir_type *array);
1322
1334FIRM_API ir_type *new_type_pointer(ir_type *points_to);
1335
1337FIRM_API void set_pointer_points_to_type(ir_type *pointer, ir_type *tp);
1338
1341
1343FIRM_API int is_Pointer_type(const ir_type *pointer);
1344
1357
1359FIRM_API int is_Primitive_type(const ir_type *primitive);
1360
1367FIRM_API ir_type *get_code_type(void);
1371FIRM_API int is_code_type(const ir_type *tp);
1395FIRM_API int is_unknown_type(const ir_type *type);
1403FIRM_API int is_atomic_type(const ir_type *tp);
1404
1421FIRM_API ident *get_compound_ident(const ir_type *tp);
1422
1424FIRM_API const char *get_compound_name(const ir_type *tp);
1425
1437FIRM_API size_t get_compound_n_members(const ir_type *tp);
1438
1447FIRM_API ir_entity *get_compound_member(const ir_type *tp, size_t pos);
1448
1450FIRM_API size_t get_compound_member_index(ir_type const *tp,
1451 ir_entity const *member);
1452
1454FIRM_API void remove_compound_member(ir_type *compound, ir_entity *entity);
1455
1462
1470FIRM_API int is_compound_type(const ir_type *tp);
1471
1483FIRM_API ir_type *new_type_frame(void);
1484
1488FIRM_API int is_frame_type(const ir_type *tp);
1489
1496
1506FIRM_API int is_segment_type(const ir_type *tp);
1507
1520typedef int (compare_types_func_t)(const void *tp1, const void *tp2);
1521
1528typedef void type_walk_func(ir_type *type, ir_entity *entity, void *env);
1529
1535typedef void class_walk_func(ir_type *clss, void *env);
1536
1541FIRM_API void type_walk(type_walk_func *pre, type_walk_func *post, void *env);
1542
1548FIRM_API void type_walk_irg(ir_graph *irg, type_walk_func *pre,
1549 type_walk_func *post, void *env);
1550
1561 void *env);
1562
1577 void *env);
1578
1587 void *env);
1588
1595typedef void entity_walk_func(ir_entity *ent, void *env);
1596
1605 void *env);
1606
1611#include "end.h"
1612
1613#endif
struct type_dbg_info type_dbg_info
Source Type Reference.
Definition firm_types.h:43
struct dbg_info dbg_info
Source Reference.
Definition firm_types.h:40
const char ident
Identifier.
Definition firm_types.h:50
struct ir_graph ir_graph
Procedure Graph.
Definition firm_types.h:74
struct ir_mode ir_mode
SSA Value mode.
Definition firm_types.h:59
struct ir_node ir_node
Procedure Graph Node.
Definition firm_types.h:53
struct ir_tarval ir_tarval
Target Machine Value.
Definition firm_types.h:68
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.
void set_entity_dbg_info(ir_entity *ent, dbg_info *db)
Sets the debug information of an entity.
ir_linkage get_entity_linkage(const ir_entity *entity)
Returns the linkage of an 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
ident * get_entity_ld_ident(const ir_entity *ent)
Returns the mangled name of the entity.
void set_entity_linkage(ir_entity *entity, ir_linkage linkage)
Sets the linkage flags of entity entity to linkage.
unsigned get_entity_alignment(const ir_entity *entity)
Returns alignment of entity in bytes.
void set_entity_ld_ident(ir_entity *ent, ident *ld_ident)
Sets the mangled name of the entity.
void free_entity(ir_entity *ent)
Frees the entity.
ir_visited_t get_entity_visited(const ir_entity *ent)
Returns the entities visited counter.
ir_entity * new_parameter_entity(ir_type *owner, size_t pos, ir_type *type)
Creates a new entity corresponding to a function parameter.
ir_entity * get_entity_overwrites(const ir_entity *ent, size_t pos)
Returns entry pos in list of entities overwriting entity ent.
void set_entity_usage(ir_entity *ent, ir_entity_usage flag)
Sets/resets the state of the address taken flag of an entity.
const char * get_align_name(ir_align a)
Returns the name of the alignment.
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 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 a...
size_t get_entity_n_overwrittenby(const ir_entity *ent)
Returns number of entities overwritten by ent.
void set_entity_volatility(ir_entity *ent, ir_volatility vol)
Sets the volatility of an entity.
ir_volatility get_entity_volatility(const ir_entity *ent)
Returns the volatility of an entity.
ir_visibility
Visibility classes for entities.
Definition typerep.h:79
size_t get_entity_overwrites_index(const ir_entity *ent, ir_entity *overwritten)
Returns index of overwritten in list of entities overwriting entity ent.
void set_entity_alias(ir_entity *alias, ir_entity *aliased)
Sets the aliased entity of an alias entity.
int is_method_entity(const ir_entity *ent)
Returns true if the entity is a method entity.
void set_entity_overwrittenby(ir_entity *ent, size_t pos, ir_entity *overwrites)
Sets entry pos in list of entities overwritten by entity ent.
void mark_entity_visited(ir_entity *ent)
Marks entity as visited.
ir_entity * get_unknown_entity(void)
Returns the unknown entity .
struct ir_entity ir_entity
Entity.
Definition firm_types.h:83
const char * get_entity_name(const ir_entity *ent)
Returns the name of an entity.
void set_entity_vtable_number(ir_entity *ent, unsigned vtable_number)
Sets the entity vtable number.
int entity_has_definition(const ir_entity *entity)
Returns 1 if the entity has a definition (initializer) in the current compilation unit.
int entity_visited(const ir_entity *ent)
Returns true if this entity was visited.
void remove_entity_linkage(ir_entity *entity, ir_linkage linkage)
Remove linkage flags linkage from entity entity.
ir_graph * get_entity_linktime_irg(const ir_entity *ent)
Return the method graph the method entity points to after linking.
void set_entity_type(ir_entity *ent, ir_type *tp)
Sets the type of an entity.
const char * get_volatility_name(ir_volatility var)
Returns the name of the volatility.
void set_entity_bitfield_size(ir_entity *entity, unsigned size)
Sets the size in bits for a bitfield.
ir_entity * get_entity_alias(const ir_entity *alias)
Returns the entity aliased by an alias entity.
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.
void set_entity_owner(ir_entity *ent, ir_type *owner)
Sets the owner field in entity to owner.
unsigned get_entity_vtable_number(const ir_entity *ent)
Returns the entity vtable number.
void add_entity_overwrites(ir_entity *ent, ir_entity *overwritten)
Adds entity ent to the list of entities that overwrite overwritten.
ident * get_entity_ident(const ir_entity *ent)
Returns the ident of an entity.
unsigned get_entity_bitfield_size(const ir_entity *entity)
Returns the size in bits for a bitfield, 0 if entity is not a bitfield.
unsigned get_entity_bitfield_offset(const ir_entity *entity)
For bitfields, returns the offset in bits to the bitfield base.
ir_initializer_t * get_entity_initializer(const ir_entity *entity)
Returns the initializer of an entity.
ir_visibility get_entity_visibility(const ir_entity *entity)
Returns the visibility class of an entity.
mtp_additional_properties get_entity_additional_properties(const ir_entity *ent)
Returns the mask of the additional entity properties.
void set_entity_initializer(ir_entity *entity, ir_initializer_t *initializer)
Sets the initializer of an entity.
void set_entity_bitfield_offset(ir_entity *entity, unsigned offset)
Sets the offset in bits to the base for a bitfield.
void set_entity_link(ir_entity *ent, void *l)
Stores new intermediate information.
int check_entity(const ir_entity *ent)
Check an entity.
void set_entity_overwrites(ir_entity *ent, size_t pos, ir_entity *overwritten)
Sets entry pos in list of entities overwriting entity ent.
ir_graph * get_entity_irg(const ir_entity *ent)
Return the method graph of a method entity.
ir_type * get_entity_owner(const ir_entity *ent)
Returns the owner of the entity.
void * get_entity_link(const ir_entity *ent)
Returns the stored intermediate information.
ir_entity_usage
Bitfield type indicating the way an entity is used.
Definition typerep.h:432
size_t get_entity_n_overwrites(const ir_entity *ent)
Returns the number of entities in the list of entities that overwrite entity ent.
int is_alias_entity(const ir_entity *ent)
Returns true if the entity is an alias entity.
int entity_has_ld_ident(const ir_entity *entity)
returns 1 if the entity has an ld_ident set explicitely
ir_type * get_entity_type(const ir_entity *ent)
Returns the type of an entity.
ir_entity * clone_entity(ir_entity const *old, ident *name, ir_type *owner)
Create a new entity with attributes copied from an existing entity.
void set_entity_visited(ir_entity *ent, ir_visited_t num)
Sets the entities visited counter.
int is_unknown_entity(const ir_entity *entity)
Tests whether entity entity is (the) unknown entity.
void set_entity_ident(ir_entity *ent, ident *id)
Sets the ident of the entity.
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.
size_t get_entity_parameter_number(const ir_entity *entity)
Returns the parameter number of the parameter which entity represents.
ir_entity * get_entity_overwrittenby(const ir_entity *ent, size_t pos)
Return entry pos in list of entities overwritten by entity ent.
void set_entity_alignment(ir_entity *entity, unsigned alignment)
Allows you to override the type alignment for an entity.
void set_entity_label(ir_entity *ent, ir_label_t label)
Sets label number of an entity with code type.
const char * get_entity_ld_name(const ir_entity *ent)
Returns the mangled name of the entity as a string.
void remove_entity_overwrittenby(ir_entity *ent, ir_entity *overwrites)
Removes entry overwrites in list of entities overwritten by ent.
void set_entity_offset(ir_entity *entity, int offset)
Sets the offset of an entity (in a compound) in bytes.
int entity_not_visited(const ir_entity *ent)
Returns true if this entity was not visited.
void set_entity_additional_properties(ir_entity *ent, mtp_additional_properties prop)
Sets the mask of the additional graph properties.
ir_linkage
linkage specifies how the linker treats symbols
Definition typerep.h:119
ir_entity * new_entity(ir_type *owner, ident *name, ir_type *tp)
Creates a new entity.
int get_entity_offset(const ir_entity *entity)
Returns the offset of an entity (in a compound) in bytes.
dbg_info * get_entity_dbg_info(const ir_entity *ent)
Returns the debug information of an entity.
ir_align get_entity_aligned(const ir_entity *ent)
Returns indication whether entity is aligned in memory.
int entity_has_additional_properties(const ir_entity *entity)
Return true if this entity can be queried for additional properties.
void add_entity_additional_properties(ir_entity *ent, mtp_additional_properties flag)
Sets additional graph properties.
long get_entity_nr(const ir_entity *ent)
Outputs a unique number for this entity.
void set_entity_parameter_number(ir_entity *entity, size_t n)
Sets the parameter number of the parameter which entity represents.
void set_entity_visibility(ir_entity *entity, ir_visibility visibility)
Sets visibility class of an entity.
void set_entity_aligned(ir_entity *ent, ir_align a)
Sets indication whether entity is aligned in memory.
ir_entity_usage get_entity_usage(const ir_entity *ent)
Returns the entity usage.
void add_entity_linkage(ir_entity *entity, ir_linkage linkage)
Adds linkage flags linkage to entity entity.
ir_label_t get_entity_label(const ir_entity *ent)
Returns label number of an entity with code type.
void remove_entity_overwrites(ir_entity *ent, ir_entity *overwritten)
Remove overwritten from list of entities overwriting entity ent.
@ ir_visibility_external_protected
The entity is visible across compilation units and modules and cannot be overridden by other modules.
Definition typerep.h:98
@ ir_visibility_external
The entity is visible across compilation units.
Definition typerep.h:87
@ ir_visibility_external_private
The entity is visible across compilation units, but not across modules.
Definition typerep.h:92
@ ir_visibility_private
This has the same semantic as visibility_local.
Definition typerep.h:113
@ ir_visibility_local
The entity is local to the compilation unit.
Definition typerep.h:105
@ ir_usage_address_taken
The address of this entity was taken.
Definition typerep.h:434
@ ir_usage_reinterpret_cast
The entity was read but with a wrong mode (an implicit reinterpret cast)
Definition typerep.h:437
@ ir_usage_write
The entity was written to.
Definition typerep.h:435
@ ir_usage_unknown
Unknown access.
Definition typerep.h:440
@ ir_usage_read
The entity was read.
Definition typerep.h:436
@ ir_usage_none
This entity is unused.
Definition typerep.h:433
@ IR_LINKAGE_NO_CODEGEN
Do not generate code even if the entity has a graph or initialization data attached.
Definition typerep.h:165
@ IR_LINKAGE_WEAK
The entity is a weak symbol.
Definition typerep.h:134
@ IR_LINKAGE_DEFAULT
Definition typerep.h:120
@ IR_LINKAGE_GARBAGE_COLLECT
The entity may be removed when it isn't referenced anywhere in the compilation unit even if it is exp...
Definition typerep.h:140
@ IR_LINKAGE_MERGE
The linker will try to merge entities with same name from different compilation units.
Definition typerep.h:147
@ IR_LINKAGE_HIDDEN_USER
Some entity uses are potentially hidden from the compiler.
Definition typerep.h:156
@ IR_LINKAGE_NO_IDENTITY
The entity does not need to have an address that is different from other entities.
Definition typerep.h:171
@ IR_LINKAGE_CONSTANT
A symbol whose definition won't change in a program.
Definition typerep.h:127
ir_initializer_t * create_initializer_const(ir_node *value)
Creates an initializer containing a reference to a node on the const-code irg.
ir_initializer_t * create_initializer_tarval(ir_tarval *tv)
Creates an initializer containing a single tarval value.
ir_initializer_t * create_initializer_compound(size_t n_entries)
Creates a compound initializer which holds n_entries entries.
ir_node * get_initializer_const_value(const ir_initializer_t *initializer)
Returns the value contained in a const initializer.
ir_initializer_t * get_initializer_null(void)
Returns the null initializer (there is only one instance of it in a program )
ir_initializer_kind_t get_initializer_kind(const ir_initializer_t *initializer)
Returns the kind of an initializer.
const char * get_initializer_kind_name(ir_initializer_kind_t ini)
Returns the name of the initializer kind.
union ir_initializer_t ir_initializer_t
Initializer (for entities)
Definition firm_types.h:89
size_t get_initializer_compound_n_entries(const ir_initializer_t *initializer)
Returns the number of entries in a compound initializer.
ir_initializer_t * get_initializer_compound_value(const ir_initializer_t *initializer, size_t index)
Returns the value with index index of a compound initializer.
void set_initializer_compound_value(ir_initializer_t *initializer, size_t index, ir_initializer_t *value)
Sets entry with index index to the initializer value.
ir_tarval * get_initializer_tarval_value(const ir_initializer_t *initialzier)
Returns the value contained in a tarval initializer.
ir_initializer_kind_t
the kind (type) of an initializer
Definition typerep.h:496
@ IR_INITIALIZER_TARVAL
initializer containing a tarval
Definition typerep.h:500
@ IR_INITIALIZER_COMPOUND
list of initializers used to initialize a compound or array type
Definition typerep.h:504
@ IR_INITIALIZER_NULL
initializes type with default values (usually 0)
Definition typerep.h:502
@ IR_INITIALIZER_CONST
initializer containing an ir_node from the const-code irg
Definition typerep.h:498
int is_overwritten_by(ir_entity *high, ir_entity *low)
Returns true if high is (transitively) overwritten by low.
tp_opcode get_type_opcode(const ir_type *type)
Returns opcode of type type.
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()
const char * get_type_opcode_name(tp_opcode opcode)
Returns the name of the type opcode opcode.
ir_entity * resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent)
Resolve polymorphism in the inheritance relation.
void set_irp_inh_transitive_closure_state(inh_transitive_closure_state s)
Sets the transitive closure of sub/superclass state for the whole program.
unsigned get_type_size(const ir_type *tp)
Returns the size of a type in bytes.
void set_type_visited(ir_type *tp, ir_visited_t num)
Sets the visited counter of a type to num.
void compute_inh_transitive_closure(void)
Compute transitive closure of the subclass/superclass and overwrites/overwrittenby relation.
int is_SubClass_ptr_of(ir_type *low, ir_type *high)
Subclass check for pointers to classes.
int type_visited(const ir_type *tp)
Returns non-zero if the type is already visited.
void set_type_alignment(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.
int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp)
Check if subtp is a subtype of tp.
void set_type_size(ir_type *tp, unsigned size)
Sets the size of a type in bytes.
void set_type_link(ir_type *tp, void *l)
Sets the associated link field of a type.
void ir_print_type(char *buffer, size_t buffer_size, const ir_type *tp)
construct a string representing the type.
int is_atomic_type(const ir_type *tp)
Checks whether a type is atomic.
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()
struct ir_type ir_type
Type.
Definition firm_types.h:71
tp_opcode
An enum for the type kinds.
Definition typerep.h:702
void set_type_state(ir_type *tp, ir_type_state state)
Sets the type layout state of a type.
int tr_verify(void)
Walks the type information and performs a set of sanity checks.
ir_type * get_class_trans_supertype_first(const ir_type *tp)
Start iteration over all transitive supertypes of tp.
void free_inh_transitive_closure(void)
Free memory occupied by the transitive closure information.
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()
unsigned get_type_alignment(const ir_type *tp)
Returns the alignment of a type in bytes.
void inc_master_type_visited(void)
Increments type visited reference counter by one.
int check_type(const ir_type *tp)
Checks a type for memory corruption, dangling pointers and consistency.
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.
void invalidate_irp_inh_transitive_closure_state(void)
Sets the transitive closure of sub/superclass state for the whole program to inh_transitive_closure_i...
long get_type_nr(const ir_type *tp)
Outputs a unique number for this type if libfirm is compiled for debugging, (configure with –enable-d...
void set_type_dbg_info(ir_type *tp, type_dbg_info *db)
Sets the debug information of a type.
ir_entity * get_entity_trans_overwrittenby_first(const ir_entity *ent)
Start iteration over all entities that transitive overwrite entity ent.
void set_master_type_visited(ir_visited_t val)
Sets type visited reference counter.
ir_type_state get_type_state(const ir_type *tp)
Returns the type layout state of a type.
int is_SubClass_of(const ir_type *low, const ir_type *high)
Returns true if low is subclass of high.
ir_mode * get_type_mode(const ir_type *tp)
Returns the mode of a type.
ir_visited_t get_master_type_visited(void)
Returns type visited reference counter.
const char * get_type_state_name(ir_type_state s)
Returns a human readable string for the enum entry.
void free_type(ir_type *tp)
Frees the memory used by the type.
inh_transitive_closure_state
The state of the transitive closure.
Definition typerep.h:785
void mark_type_visited(ir_type *tp)
Sets visited field in type to type_visited.
type_dbg_info * get_type_dbg_info(const ir_type *tp)
Returns the debug information of a type.
ir_type * get_class_trans_subtype_first(const ir_type *tp)
Start iteration over all transitive subtypes of tp.
void * get_type_link(const ir_type *tp)
Returns the associated link field of a type.
inh_transitive_closure_state get_irp_inh_transitive_closure_state(void)
Returns the transitive closure of sub/superclass state for the whole program.
ir_type_state
The state of the type layout.
Definition typerep.h:890
@ tpo_pointer
A pointer type.
Definition typerep.h:710
@ tpo_uninitialized
Definition typerep.h:703
@ tpo_last
Definition typerep.h:714
@ tpo_array
An array type.
Definition typerep.h:709
@ tpo_code
a piece of code (a basic block)
Definition typerep.h:712
@ tpo_primitive
A primitive type.
Definition typerep.h:711
@ tpo_method
A method type.
Definition typerep.h:708
@ tpo_class
A class type.
Definition typerep.h:706
@ tpo_union
A union type.
Definition typerep.h:705
@ tpo_segment
A segment type.
Definition typerep.h:707
@ tpo_struct
A struct type.
Definition typerep.h:704
@ tpo_unknown
Special code for the Unknown type.
Definition typerep.h:713
@ inh_transitive_closure_none
Closure is not computed, can not be accessed.
Definition typerep.h:786
@ inh_transitive_closure_max
Invalid value.
Definition typerep.h:789
@ inh_transitive_closure_invalid
Closure invalid, but can be accessed.
Definition typerep.h:788
@ inh_transitive_closure_valid
Closure computed and valid.
Definition typerep.h:787
@ layout_undefined
The layout of this type is not defined.
Definition typerep.h:891
@ layout_fixed
The layout is fixed, all component/member entities have an offset assigned.
Definition typerep.h:897
size_t get_class_n_supertypes(const ir_type *clss)
Returns the number of supertypes.
ir_type * get_class_subtype(const ir_type *clss, size_t pos)
Returns the subtype at position pos, 0 <= pos < n_subtype.
size_t get_class_n_members(const ir_type *clss)
Returns the number of members of this class.
void add_class_subtype(ir_type *clss, ir_type *subtype)
Adds subtype as subtype to clss.
void add_class_supertype(ir_type *clss, ir_type *supertype)
Adds supertype as supertype to class.
int is_Class_type(const ir_type *clss)
Returns true if a type is a class type.
size_t get_class_member_index(ir_type const *clss, ir_entity const *mem)
Returns index of mem in clss, INVALID_MEMBER_INDEX if not contained.
void set_class_supertype(ir_type *clss, ir_type *supertype, size_t pos)
Sets the supertype at position pos, 0 <= pos < n_supertype.
size_t get_class_supertype_index(const ir_type *clss, const ir_type *super_clss)
Returns the index to access superclass as supertype of class.
ir_type * get_class_supertype(const ir_type *clss, size_t pos)
Returns the supertype at position pos, 0 <= pos < n_supertype.
ir_entity * get_class_member(const ir_type *clss, size_t pos)
Returns the member at position pos, 0 <= pos < n_member.
size_t get_class_subtype_index(const ir_type *clss, const ir_type *subclass)
Returns the index to access subclass as subtype of class.
void set_class_subtype(ir_type *clss, ir_type *subtype, size_t pos)
Sets the subtype at position pos, 0 <= pos < n_subtype.
void remove_class_supertype(ir_type *clss, ir_type *supertype)
Finds supertype in the list of supertypes and removes it.
size_t get_class_n_subtypes(const ir_type *clss)
Returns the number of subtypes.
ir_type * new_type_class(ident *name)
Creates a new class type.
void remove_class_subtype(ir_type *clss, ir_type *subtype)
Finds subtype in the list of subtypes and removes it
size_t get_struct_member_index(ir_type const *strct, ir_entity const *member)
Returns index of member in strct, -1 if not contained.
size_t get_struct_n_members(const ir_type *strct)
Returns the number of members of this struct.
ir_entity * get_struct_member(const ir_type *strct, size_t pos)
Returns the member at position pos, pos < n_member.
int is_Struct_type(const ir_type *strct)
Returns true if a type is a struct type.
ir_type * new_type_struct(ident *name)
Creates a new type struct.
size_t get_union_n_members(const ir_type *uni)
Returns the number of unioned types of this union.
size_t get_union_member_index(ir_type const *uni, ir_entity const *member)
Returns index of member in uni, -1 if not contained.
ir_entity * get_union_member(const ir_type *uni, size_t pos)
Returns the entity at position pos of a union.
ir_type * new_type_union(ident *name)
Creates a new type union.
int is_Union_type(const ir_type *uni)
Returns true if a type is a union type.
size_t get_method_n_params(const ir_type *method)
Returns the number of parameters of this method.
ir_type * get_method_res_type(const ir_type *method, size_t pos)
Returns the return type of a method type at position pos.
int is_method_variadic(ir_type const *method)
Returns the variadicity of a method.
calling_convention
Calling conventions: lower 24 bits are the number of register parameters, upper 8 encode the calling ...
Definition typerep.h:1228
mtp_additional_properties
Additional method type properties: Tell about special properties of a method type.
Definition firm_types.h:224
void set_method_res_type(ir_type *method, size_t pos, ir_type *tp)
Sets the type of the result at position pos of a method.
size_t get_method_n_ress(const ir_type *method)
Returns the number of results of a method type.
ir_type * new_type_method(size_t n_param, size_t n_res, int is_variadic, unsigned cc_mask, mtp_additional_properties property_mask)
Create a new method type.
unsigned get_method_n_regparams(ir_type *method)
Returns the number of registers parameters, 0 means default.
int is_Method_type(const ir_type *method)
Returns true if a type is a method type.
void set_method_param_type(ir_type *method, size_t pos, ir_type *tp)
Sets the type of the parameter at position pos of a method.
mtp_additional_properties get_method_additional_properties(const ir_type *method)
Returns the mask of the additional graph properties.
ir_type * get_method_param_type(const ir_type *method, size_t pos)
Returns the type of the parameter at position pos of a method.
unsigned get_method_calling_convention(const ir_type *method)
Returns the calling convention of an entities graph.
@ cc_this_call
The first parameter is a this pointer and is transmitted in a special way.
Definition typerep.h:1238
@ cc_compound_ret
The method returns a compound type.
Definition typerep.h:1240
@ cc_reg_param
Transmit parameters in registers, else the stack is used.
Definition typerep.h:1229
@ cc_last_on_top
The last non-register parameter is transmitted on top of the stack.
Definition typerep.h:1231
@ cc_fpreg_param
Transmit floating point parameters in registers, else the stack is used.
Definition typerep.h:1243
@ cc_frame_on_caller_stk
The method did not allocate an own stack frame, instead the caller must reserve size on its own stack...
Definition typerep.h:1241
@ cc_callee_clear_stk
The callee clears the stack.
Definition typerep.h:1236
unsigned get_array_size(const ir_type *array)
Returns the size (number of elements) of an array.
ir_type * new_type_array(ir_type *element_type, unsigned n_elements)
Create a new array type with n_elements of type element_type.
ir_type * get_array_element_type(const ir_type *array)
Returns the array element type.
int is_Array_type(const ir_type *array)
Returns true if a type is an array type.
ir_type * get_pointer_points_to_type(const ir_type *pointer)
Returns the type to which a pointer points to.
int is_Pointer_type(const ir_type *pointer)
Returns true if a type is a pointer type.
ir_type * new_type_pointer(ir_type *points_to)
Creates a new type pointer.
void set_pointer_points_to_type(ir_type *pointer, ir_type *tp)
Sets the type to which a pointer points to.
int is_Primitive_type(const ir_type *primitive)
Returns true if a type is a primitive type.
ir_type * new_type_primitive(ir_mode *mode)
Creates a new primitive type.
int is_code_type(const ir_type *tp)
Checks whether a type is a code type.
ir_type * get_code_type(void)
Returns the code type.
ir_type * get_unknown_type(void)
Returns the unknown type.
int is_unknown_type(const ir_type *type)
Checks whether type type is the unknown type.
size_t get_compound_n_members(const ir_type *tp)
Returns the number of elements in a Firm compound type.
void default_layout_compound_type(ir_type *tp)
Layout members of a compound type in the default way (as determined by the target ABI).
int is_compound_type(const ir_type *tp)
Checks whether a type is a compound type.
ident * get_compound_ident(const ir_type *tp)
Returns the identifier of a compound type.
ir_entity * get_compound_member(const ir_type *tp, size_t pos)
Returns the member of a Firm compound type at position pos.
void remove_compound_member(ir_type *compound, ir_entity *entity)
Remove a member from a compound type.
size_t get_compound_member_index(ir_type const *tp, ir_entity const *member)
Returns index of member in tp, -1 if not contained.
const char * get_compound_name(const ir_type *tp)
Returns compound identifier as c-string.
ir_type * clone_frame_type(ir_type *type)
Makes a clone of a frame type.
ir_type * new_type_frame(void)
Makes a new frame type.
int is_frame_type(const ir_type *tp)
Checks, whether a type is a frame type.
int is_segment_type(const ir_type *tp)
Checks, whether a type is a frame type.
void class_walk_func(ir_type *clss, void *env)
The class walk function.
Definition typerep.h:1535
void class_walk_super2sub(class_walk_func *pre, class_walk_func *post, void *env)
Same as type_walk_super2sub, but visits only class types.
void walk_types_entities(ir_type *tp, entity_walk_func *doit, void *env)
Walks over all entities in the type.
void type_walk_func(ir_type *type, ir_entity *entity, void *env)
Type of argument functions for type walkers.
Definition typerep.h:1528
void type_walk_super(type_walk_func *pre, type_walk_func *post, void *env)
Walker for class types in inheritance order.
int compare_types_func_t(const void *tp1, const void *tp2)
Type for a function that compares two types.
Definition typerep.h:1520
void type_walk(type_walk_func *pre, type_walk_func *post, void *env)
Touches every type and entity in unspecified order.
void type_walk_super2sub(type_walk_func *pre, type_walk_func *post, void *env)
Touches every class in specified order:
void entity_walk_func(ir_entity *ent, void *env)
the entity walk function.
Definition typerep.h:1595
void type_walk_irg(ir_graph *irg, type_walk_func *pre, type_walk_func *post, void *env)
Walks over all type information reachable from an ir graph.