* @see ir_type, ir_entity
*/
+/**
+ * Visibility classed for entities.
+ */
+typedef enum {
+ /**
+ * The entity is visible outside the compilation unit, but it is defined
+ * here.
+ */
+ ir_visibility_default,
+ /**
+ * The entity is local to the compilation unit.
+ * A local entity is not visible in other compilation units.
+ * Note that the entity might still be accessed indirectly from other units
+ * through pointers.
+ */
+ ir_visibility_local,
+ /**
+ * The entity is defined outside the compilation unit but potentially used
+ * here.
+ */
+ ir_visibility_external,
+ /**
+ * This has the same semantic as visibility_local. Additionally the symbol is
+ * completely hidden from the linker (it only appears in the assembly).
+ * While visibility_local is probably still visible to debuggers,
+ * visibility_private symbols aren't and probably won't appear in the object
+ * files
+ */
+ ir_visibility_private
+} ir_visibility;
+
/**
* linkage specifies how the linker treats symbols
*/
typedef enum {
- IR_LINKAGE_DEFAULT = 0,
+ IR_LINKAGE_DEFAULT = 0,
/**
* A symbol whose definition won't change in a program.
* Optimisation might replace loads from this entity with constants.
* Also most linkers put such data in a constant segment which is shared
* between multiple running instances of the same application.
*/
- IR_LINKAGE_CONSTANT = 1 << 0,
+ IR_LINKAGE_CONSTANT = 1 << 0,
/**
* The entity is a weak symbol.
* A weak symbol is overridden by a non-weak symbol if one exists.
* Most linkers only support the IR_LINKAGE_WEAK in combination with
* IR_LINKAGE_MERGE.
*/
- IR_LINKAGE_WEAK = 1 << 1,
- /**
- * The entity is local to the compilation unit.
- * A local entity will not be exported by the linker and is not visible
- * in other compilation units. Note that the entity might still be accessed
- * indirectly from other units through pointers.
- */
- IR_LINKAGE_LOCAL = 1 << 2,
- /**
- * The entity is defined in another compilation.
- */
- IR_LINKAGE_EXTERN = 1 << 3,
+ IR_LINKAGE_WEAK = 1 << 1,
/**
* The entity may be removed when it isn't referenced anywhere in the
* compilation unit even if it is exported (non-local).
* Typically used for C++ instantiated template code (,,COMDAT'' section).
*/
- IR_LINKAGE_GARBAGE_COLLECT = 1 << 5,
+ IR_LINKAGE_GARBAGE_COLLECT = 1 << 2,
/**
* The linker will try to merge entities with same name from different
* compilation units. This is the usual behaviour for global variables
* without explicit initialisation in C (``COMMON'' symbols). It's also
* typically used in C++ for instantiated template code (,,COMDAT'' section)
*/
- IR_LINKAGE_MERGE = 1 << 6,
+ IR_LINKAGE_MERGE = 1 << 3,
/**
* Some entity uses are potentially hidden from the compiler.
* (For example because they happen in an asm("") statement. This flag
* read/write behaviour to global variables or changing calling conventions
* from cdecl to fastcall.
*/
- IR_LINKAGE_HIDDEN_USER = 1 << 7,
+ IR_LINKAGE_HIDDEN_USER = 1 << 4
} ir_linkage;
/**
- * The following are some common combinations of linkage types seen in the
- * C/C++ languages
+ * Return the visibility class of an entity
*/
-enum ir_common_linkages {
- /** C "common" symbol */
- IR_LINKAGE_COMMON = IR_LINKAGE_MERGE,
- /** C "weak" symbol */
- IR_LINKAGE_WEAKSYM = IR_LINKAGE_WEAK | IR_LINKAGE_MERGE,
- /** C++ comdat code */
- IR_LINKAGE_COMDAT = IR_LINKAGE_GARBAGE_COLLECT | IR_LINKAGE_GARBAGE_COLLECT
-};
+ir_visibility get_entity_visibility(const ir_entity *entity);
/**
- * Return 1 if the entity is visible outside the current compilation unit.
+ * Set visibility class of an entity
+ */
+void set_entity_visibility(ir_entity *entity, ir_visibility visibility);
+
+/**
+ * Return 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_linkage(entity) & IR_LINKAGE_LOCAL) == 0
+ * get_entity_visibility(entity) != ir_visibility_local ||
+ * (get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)
*/
int entity_is_externally_visible(const ir_entity *entity);
*/
int entity_has_definition(const ir_entity *entity);
-/**
- * Return 1 if the entity is/will be defined in the current compilation unit.
- * This is a convenience function for
- * (get_entity_linkage(entity) & IR_LINKAGE_EXTERN) == 0.
- *
- * In contrast to entity_has_definition(entity) you have no guarantee here that
- * the entity actually has a firm initializer.
- */
-int entity_is_defined_here(const ir_entity *entity);
-
-/**
- * Return 1 if the entity is constant. Constant means the entities value
- * won't change at all when the program is running.
- */
-int entity_is_constant(const ir_entity *entity);
-
/**
* Creates a new entity.
*
unsigned get_entity_alignment(const ir_entity *entity);
/** Allows you to override the type alignment for an entity.
+ * @param entity the entity
* @param alignment alignment in bytes
*/
void set_entity_alignment(ir_entity *entity, unsigned alignment);
/** Sets/resets the compiler generated flag. */
void set_entity_compiler_generated(ir_entity *ent, int flag);
-/** Checks if an entity is marked by the backend. */
-int is_entity_backend_marked(const ir_entity *ent);
-
-/** Sets/resets the backend marker flag. */
-void set_entity_backend_marked(ir_entity *ent, int flag);
-
/**
* Bitfield type indicating the way an entity is used.
*/
/** Create a new method type.
*
- * @param name the name (ident) of this type
* @param n_param the number of parameters
* @param n_res the number of results
*
/** Create a new method type with debug information.
*
- * @param name the name (ident) of this type
* @param n_param the number of parameters
* @param n_res the number of results
* @param db user defined debug information
*/
void types_calc_finalization(void);
-/**
- * @deprecated
- */
-typedef enum {
- visibility_local,
- visibility_external_visible,
- visibility_external_allocated
-} ir_visibility;
-
/** @deprecated */
ir_visibility get_type_visibility(const ir_type *tp);
/** @deprecated */