Commit 01586f22 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Remove the functions for 'atomic entities'.

* 'get_atomic_ent_value()' is a wrapper, which tries to unify the different kind of initalizers by wastefully creating nodes on demand.
  It had only a single user, which tried to use it for method entities, which does not work anymore (see 3rd bullet point).
* 'set_atomic_ent_value()' is a thin and unnecessary wrapper to set a const node initializer.
* 'is_atomic_entity()' classifies entities having (among primitive and pointer types) method type as having an atomic initializer.
  They do not for a long time (was an address of itself).
  Except for the two functions above, this function is unused.
* 'Atomic' is a misnomer and should rather be 'scalar'.
parent 26876c68
......@@ -485,12 +485,6 @@ FIRM_API size_t get_entity_parameter_number(const ir_entity *entity);
*/
FIRM_API void set_entity_parameter_number(ir_entity *entity, size_t n);
/** Returns initial value of entity with atomic type @p ent. */
FIRM_API ir_node *get_atomic_ent_value(const ir_entity *ent);
/** Sets initial value of entity with atomic type @p ent to node @p val.
* @note @p val must be a node in the const_code graph */
FIRM_API void set_atomic_ent_value(ir_entity *ent, ir_node *val);
/** @defgroup ir_initializer Entity Initializers
* @{
*/
......@@ -588,12 +582,6 @@ FIRM_API void set_entity_overwrittenby(ir_entity *ent, size_t pos,
FIRM_API void remove_entity_overwrittenby(ir_entity *ent,
ir_entity *overwrites);
/** Returns true if the type of the entity is a primitive, pointer
* or method type.
*
* @note This is a different classification than from is_primitive_type().
*/
FIRM_API int is_atomic_entity(const ir_entity *ent);
/** Returns true if the type of the entity is a class, structure,
array or union type. */
FIRM_API int is_compound_entity(const ir_entity *ent);
......
......@@ -167,15 +167,12 @@ static void sel_methods_walker(ir_node *node, void *env)
ir_entity *const entity = get_Member_entity(node);
if (!is_method_entity(entity))
return;
/* we may have a vtable entry and need this redirection to get the actually
* called method */
ir_entity *const called = get_Address_entity(get_atomic_ent_value(entity));
if (!pset_find_ptr(entities, called)) {
if (!pset_find_ptr(entities, entity)) {
/* Entity not yet handled. Find all (internal or external)
* implemented methods that overwrites this entity.
* This set is stored in the entity link. */
set_entity_link(called, get_impl_methods(called));
pset_insert_ptr(entities, called);
set_entity_link(entity, get_impl_methods(entity));
pset_insert_ptr(entities, entity);
}
}
......
......@@ -45,9 +45,9 @@ static ir_entity *create_ent(ir_entity **const dst, int value, const char *name)
= new_global_entity(glob, id, type, ir_visibility_local,
IR_LINKAGE_CONSTANT | IR_LINKAGE_NO_IDENTITY);
ir_graph *const cnst_irg = get_const_code_irg();
ir_node *const cnst = new_r_Const_long(cnst_irg, mode, value);
set_atomic_ent_value(ent, cnst);
ir_tarval *const cnst = new_tarval_from_long(value, mode);
ir_initializer_t *const init = create_initializer_tarval(cnst);
set_entity_initializer(ent, init);
*dst = ent;
}
return *dst;
......
......@@ -136,11 +136,12 @@ static void add_constructor(ir_entity *method)
ir_type *const constructors = get_segment_type(IR_SEGMENT_CONSTRUCTORS);
ident *const ide = id_unique("constructor_ptr");
ir_entity *const ptr = new_global_entity(constructors, ide, ptr_type, ir_visibility_private, IR_LINKAGE_CONSTANT | IR_LINKAGE_HIDDEN_USER);
ir_graph *const irg = get_const_code_irg();
ir_node *const val = new_r_Address(irg, method);
set_entity_ld_ident(ptr, NEW_IDENT(""));
set_atomic_ent_value(ptr, val);
ir_graph *const irg = get_const_code_irg();
ir_node *const val = new_r_Address(irg, method);
ir_initializer_t *const init = create_initializer_const(val);
set_entity_initializer(ptr, init);
}
/**
......
......@@ -16,8 +16,6 @@
#include "util.h"
#include "irhooks.h"
#include "irprog_t.h"
#include "ircons_t.h"
#include "tv_t.h"
#include "irdump.h"
#include "irgraph_t.h"
#include "callgraph.h"
......@@ -419,43 +417,6 @@ void (set_entity_usage)(ir_entity *ent, ir_entity_usage flags)
_set_entity_usage(ent, flags);
}
ir_node *get_atomic_ent_value(const ir_entity *entity)
{
assert(is_atomic_entity(entity));
ir_initializer_t *initializer = get_entity_initializer(entity);
if (initializer == NULL) {
ir_type *type = get_entity_type(entity);
return new_r_Unknown(get_const_code_irg(), get_type_mode(type));
}
switch (get_initializer_kind(initializer)) {
case IR_INITIALIZER_NULL: {
ir_type *type = get_entity_type(entity);
ir_mode *mode = get_type_mode(type);
return new_r_Const_null(get_const_code_irg(), mode);
}
case IR_INITIALIZER_TARVAL: {
ir_tarval *tv = get_initializer_tarval_value(initializer);
return new_r_Const(get_const_code_irg(), tv);
}
case IR_INITIALIZER_CONST:
return get_initializer_const_value(initializer);
case IR_INITIALIZER_COMPOUND:
panic("compound initializer in atomic entity not allowed (%+F)", entity);
}
panic("invalid initializer kind (%+F)", entity);
}
void set_atomic_ent_value(ir_entity *entity, ir_node *val)
{
assert(is_atomic_entity(entity));
assert(is_Dummy(val) || get_irn_mode(val) == get_type_mode(entity->type));
ir_initializer_t *initializer = create_initializer_const(val);
set_entity_initializer(entity, initializer);
}
const char *get_initializer_kind_name(ir_initializer_kind_t ini)
{
#define X(a) case a: return #a
......@@ -781,14 +742,6 @@ int is_unknown_entity(const ir_entity *entity)
return entity->kind == IR_ENTITY_UNKNOWN;
}
int is_atomic_entity(const ir_entity *ent)
{
ir_type const *const type = get_entity_type(ent);
tp_opcode const opcode = get_type_opcode(type);
return opcode == tpo_primitive || opcode == tpo_pointer
|| opcode == tpo_method;
}
int is_compound_entity(const ir_entity *ent)
{
ir_type const *const type = get_entity_type(ent);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment