-/** This enumeration flags the peculiarity of entities and types. */
-typedef enum {
- peculiarity_description, /**< Represents only a description. The entity/type is never
- allocated, no code/data exists for this entity/type.
- @@@ eventually rename to descriptive (adjective as the others!)*/
- peculiarity_inherited, /**< Describes explicitly that other entities are
- inherited to the owner of this entity.
- Overwrites must refer to at least one other
- entity. If this is a method entity there exists
- no irg for this entity, only for one of the
- overwritten ones.
- Only for entity. */
- peculiarity_existent /**< The entity/type (can) exist.
- @@@ eventually rename to 'real' i.e., 'echt'
- This serves better as opposition to description _and_ inherited.*/
-} ir_peculiarity;
+/**
+ * linkage specifies how the linker treats symbols
+ */
+typedef enum ir_linkage {
+ 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,
+ /**
+ * 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 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 << 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 << 3,
+ /**
+ * Some entity uses are potentially hidden from the compiler.
+ * (For example because they happen in an asm("") statement. This flag
+ * should be set for __attribute__((used)) in C code).
+ * Setting this flag prohibits that the compiler making assumptions about
+ * read/write behaviour to global variables or changing calling conventions
+ * from cdecl to fastcall.
+ */
+ IR_LINKAGE_HIDDEN_USER = 1 << 4
+} ir_linkage;
+ENUM_BITSET(ir_linkage)
+
+/**
+ * Return the visibility class of an entity
+ */
+FIRM_API ir_visibility get_entity_visibility(const ir_entity *entity);
+
+/**
+ * Set visibility class of an entity
+ */
+FIRM_API 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_visibility(entity) != ir_visibility_local ||
+ * (get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER)
+ */
+FIRM_API int entity_is_externally_visible(const ir_entity *entity);
+
+/**
+ * Return 1 if the entity has a definition (initializer) in the current
+ * compilation unit
+ */
+FIRM_API int entity_has_definition(const ir_entity *entity);