#include "irgraph_t.h"
#include "callgraph.h"
#include "error.h"
-#include "compound_path.h"
/** The name of the unknown entity. */
#define UNKNOWN_ENTITY_NAME "unknown_entity"
res->aligned = align_is_aligned;
res->usage = ir_usage_unknown;
res->compiler_gen = 0;
- res->visibility = ir_visibility_default;
+ res->visibility = ir_visibility_external;
res->offset = -1;
res->offset_bit_remainder = 0;
res->alignment = 0;
if (is_Method_type(type)) {
ir_graph *irg = get_const_code_irg();
symconst_symbol sym;
- ir_mode *mode = is_Method_type(type) ? mode_P_code : mode_P_data;
res = intern_new_entity(owner, IR_ENTITY_METHOD, name, type, db);
sym.entity_p = res;
- set_atomic_ent_value(res, new_r_SymConst(irg, mode, sym, symconst_addr_ent));
- res->linkage = IR_LINKAGE_CONSTANT;
- res->attr.mtd_attr.irg_add_properties = mtp_property_inherited;
- res->attr.mtd_attr.vtable_number = IR_VTABLE_NUM_NOT_SET;
- res->attr.mtd_attr.param_access = NULL;
- res->attr.mtd_attr.param_weight = NULL;
- res->attr.mtd_attr.irg = NULL;
+ set_atomic_ent_value(res, new_r_SymConst(irg, mode_P_code, sym, symconst_addr_ent));
+ res->linkage = IR_LINKAGE_CONSTANT;
+ res->attr.mtd_attr.properties = get_method_additional_properties(type);
+ res->attr.mtd_attr.vtable_number = IR_VTABLE_NUM_NOT_SET;
+ res->attr.mtd_attr.param_access = NULL;
+ res->attr.mtd_attr.param_weight = NULL;
+ res->attr.mtd_attr.irg = NULL;
} else if (owner != NULL
&& (is_compound_type(owner) && !(owner->flags & tf_segment))) {
res = intern_new_entity(owner, IR_ENTITY_COMPOUND_MEMBER, name, type, db);
- res->attr.cmpd_attr.values = NULL;
- res->attr.cmpd_attr.val_paths = NULL;
} else {
res = intern_new_entity(owner, IR_ENTITY_NORMAL, name, type, db);
}
if (ent->initializer != NULL) {
/* TODO: free initializers */
- } else if (entity_has_compound_ent_values(ent)) {
- /* can't free compound graph path as it might be used
- * multiple times */
- ent->attr.cmpd_attr.val_paths = NULL;
}
- if (ent->entity_kind == IR_ENTITY_COMPOUND_MEMBER) {
- ent->attr.cmpd_attr.values = NULL;
- } else if (ent->entity_kind == IR_ENTITY_METHOD) {
+ if (ent->entity_kind == IR_ENTITY_METHOD) {
if (ent->attr.mtd_attr.param_access) {
DEL_ARR_F(ent->attr.mtd_attr.param_access);
ent->attr.mtd_attr.param_access = NULL;
*newe = *old;
if (old->initializer != NULL) {
/* FIXME: the initializers are NOT copied */
- } else if (entity_has_compound_ent_values(old)) {
- newe->attr.cmpd_attr.values = NULL;
- newe->attr.cmpd_attr.val_paths = NULL;
- if (old->attr.cmpd_attr.values)
- newe->attr.cmpd_attr.values = DUP_ARR_F(ir_node *, old->attr.cmpd_attr.values);
-
- /* FIXME: the compound graph paths are NOT copied */
- if (old->attr.cmpd_attr.val_paths)
- newe->attr.cmpd_attr.val_paths = DUP_ARR_F(compound_graph_path *, old->attr.cmpd_attr.val_paths);
} else if (is_method_entity(old)) {
/* do NOT copy them, reanalyze. This might be the best solution */
newe->attr.mtd_attr.param_access = NULL;
return ent->attr.code_attr.label;
}
-static void verify_visibility(const ir_entity *entity)
-{
- if (get_entity_visibility(entity) == ir_visibility_external
- && !is_method_entity(entity)) {
- assert(!entity_has_definition(entity));
- }
-}
-
void set_entity_visibility(ir_entity *entity, ir_visibility visibility)
{
entity->visibility = visibility;
- verify_visibility(entity);
}
ir_visibility get_entity_visibility(const ir_entity *entity)
panic("compound initializer in atomic entity not allowed (%+F)", entity);
}
- panic("invalid initializer kind in get_atomic_ent_value(%+F)", entity);
+ panic("invalid initializer kind (%+F)", entity);
}
void set_atomic_ent_value(ir_entity *entity, ir_node *val)
nn = new_rd_Conv(dbg, block,
copy_const_value(dbg, get_Conv_op(n), block), m);
break;
+ case iro_Minus:
+ nn = new_rd_Minus(dbg, block,
+ copy_const_value(dbg, get_Minus_op(n), block), m);
+ break;
+ case iro_Not:
+ nn = new_rd_Not(dbg, block,
+ copy_const_value(dbg, get_Not_op(n), block), m);
+ break;
case iro_Unknown:
nn = new_r_Unknown(irg, m); break;
default:
- panic("opcode invalid or not implemented");
+ panic("opcode invalid or not implemented %+F", n);
}
return nn;
}
mtp_additional_properties get_entity_additional_properties(const ir_entity *ent)
{
- ir_graph *irg;
-
assert(is_method_entity(ent));
-
- /* first check, if the graph has additional properties */
- irg = get_entity_irg(ent);
-
- if (irg)
- return get_irg_additional_properties(irg);
-
- if (ent->attr.mtd_attr.irg_add_properties & mtp_property_inherited)
- return get_method_additional_properties(get_entity_type(ent));
-
- return ent->attr.mtd_attr.irg_add_properties;
+ return ent->attr.mtd_attr.properties;
}
void set_entity_additional_properties(ir_entity *ent, mtp_additional_properties property_mask)
{
- ir_graph *irg;
-
assert(is_method_entity(ent));
+ /* you mustn't set less properties than the entities type */
+ assert((get_method_additional_properties(get_entity_type(ent)) & ~property_mask) == 0);
- /* first check, if the graph exists */
- irg = get_entity_irg(ent);
- if (irg)
- set_irg_additional_properties(irg, property_mask);
- else {
- /* do not allow to set the mtp_property_inherited flag or
- * the automatic inheritance of flags will not work */
- ent->attr.mtd_attr.irg_add_properties = property_mask & ~mtp_property_inherited;
- }
+ /* do not allow to set the mtp_property_inherited flag or
+ * the automatic inheritance of flags will not work */
+ ent->attr.mtd_attr.properties = property_mask;
}
void add_entity_additional_properties(ir_entity *ent, mtp_additional_properties properties)
{
- ir_graph *irg;
-
assert(is_method_entity(ent));
- /* first check, if the graph exists */
- irg = get_entity_irg(ent);
- if (irg)
- add_irg_additional_properties(irg, properties);
- else {
- mtp_additional_properties mask = ent->attr.mtd_attr.irg_add_properties;
-
- if (mask & mtp_property_inherited)
- mask = get_method_additional_properties(get_entity_type(ent));
-
- /* do not allow to set the mtp_property_inherited flag or
- * the automatic inheritance of flags will not work */
- ent->attr.mtd_attr.irg_add_properties = mask | (properties & ~mtp_property_inherited);
- }
+ /* do not allow to set the mtp_property_inherited flag or
+ * the automatic inheritance of flags will not work */
+ ent->attr.mtd_attr.properties |= properties;
}
ir_type *(get_entity_repr_class)(const ir_entity *ent)
int entity_has_definition(const ir_entity *entity)
{
- return entity->initializer != NULL
- || get_entity_irg(entity) != NULL
- || entity_has_compound_ent_values(entity);
+ if (is_method_entity(entity)) {
+ return get_entity_irg(entity) != NULL
+ && (get_entity_linkage(entity) & IR_LINKAGE_NO_CODEGEN) == 0;
+ } else {
+ return entity->initializer != NULL;
+ }
}
void ir_init_entity(ir_prog *irp)