Commit 7ed5a91f authored by Matthias Braun's avatar Matthias Braun
Browse files

remove unused/outdated OO features from core libfirm

Note that for OO code you should use liboo which provides the same
features!
parent 9644dc79
......@@ -695,39 +695,6 @@ FIRM_API ir_entity *get_unknown_entity(void);
* @returns 1 if it is the unknown entity, 0 otherwise */
FIRM_API int is_unknown_entity(const ir_entity *entity);
/** @deprecated */
typedef enum {
allocation_automatic,
allocation_parameter,
allocation_dynamic,
allocation_static
} ir_allocation;
/** @deprecated */
FIRM_API ir_allocation get_entity_allocation(const ir_entity *ent);
/** @deprecated */
FIRM_API void set_entity_allocation(ir_entity *ent, ir_allocation al);
/** @deprecated */
typedef enum {
peculiarity_existent,
peculiarity_description,
peculiarity_inherited
} ir_peculiarity;
/** @deprecated */
FIRM_API ir_peculiarity get_entity_peculiarity(const ir_entity *ent);
/** @deprecated */
FIRM_API void set_entity_peculiarity(ir_entity *ent, ir_peculiarity pec);
/** @deprecated */
FIRM_API int is_entity_final(const ir_entity *ent);
/** @deprecated */
FIRM_API void set_entity_final(ir_entity *ent, int final);
/** @deprecated */
FIRM_API ir_peculiarity get_class_peculiarity(const ir_type *clss);
/** @deprecated */
FIRM_API void set_class_peculiarity(ir_type *clss, ir_peculiarity pec);
/** @} */
/** Encodes how a pointer parameter is accessed. */
......@@ -868,40 +835,6 @@ FIRM_API int is_overwritten_by(ir_entity *high, ir_entity *low);
FIRM_API ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class,
ir_entity* static_ent);
/** Default name mangling for inherited entities.
*
* Returns an ident that consists of the name of type followed by an
* underscore and the name (not ld_name) of the entity. */
FIRM_API ident *default_mangle_inherited_name(const ir_entity *ent,
const ir_type *clss);
/** Type of argument functions for inheritance resolver.
*
* @param ent The entity in the super type that will be overwritten
* by the newly generated entity, for which this name is
* used.
* @param clss The class type in which the new entity will be placed.
*/
typedef ident *mangle_inherited_name_func(const ir_entity *ent,
const ir_type *clss);
/** Resolve implicit inheritance.
*
* Resolves the implicit inheritance supplied by firm. Firm defines,
* that each entity that is not overwritten in a subclass is
* inherited to this subclass without change implicitly. This
* function generates entities that explicitly represent this
* inheritance. It generates for each entity overwriting entities in
* all subclasses of the owner of the entity, if the entity is not
* overwritten in that subclass.
*
* The name of the new entity is generated with the function passed.
* If the function is NULL, the default_mangle_inherited_name() is
* used.
*/
FIRM_API void resolve_inheritance(mangle_inherited_name_func *mfunc);
/* ----------------------------------------------------------------------- */
/* The transitive closure of the subclass/superclass and */
/* overwrites/overwrittenby relation. */
......@@ -1191,9 +1124,6 @@ FIRM_API int is_segment_type(const ir_type *tp);
*
* - supertypes: A list of direct superclasses.
*
* - vtable_size: The size of this class virtual function table.
* Default: 0
*
* - final: A final class is always a leaf in the class hierarchy. Final
* classes cannot be super classes of other ones. As this information
* can only be computed in whole world compilations, we allow to
......@@ -1236,10 +1166,6 @@ FIRM_API ir_entity *get_class_member(const ir_type *clss, size_t pos);
/** Returns index of mem in clss, INVALID_MEMBER_INDEX if not contained. */
FIRM_API size_t get_class_member_index(const ir_type *clss, ir_entity *mem);
/** Finds the member with name 'name'. If several members with the same
* name returns one of them. Returns NULL if no member found. */
FIRM_API ir_entity *get_class_member_by_name(ir_type *clss, ident *name);
/** Adds subtype as subtype to clss.
*
* Checks whether clss is a supertype of subtype. If not
......@@ -1296,30 +1222,6 @@ FIRM_API void set_class_supertype(ir_type *clss, ir_type *supertype, size_t pos)
/** Finds supertype in the list of supertypes and removes it */
FIRM_API void remove_class_supertype(ir_type *clss, ir_type *supertype);
/** Returns the size of the virtual function table. */
FIRM_API unsigned get_class_vtable_size(const ir_type *clss);
/** Sets a new size of the virtual function table. */
FIRM_API void set_class_vtable_size(ir_type *clss, unsigned size);
/** Returns non-zero if a class is final. */
FIRM_API int is_class_final(const ir_type *clss);
/** Sets the class final flag. */
FIRM_API void set_class_final(ir_type *clss, int flag);
/** Returns non-zero if a class is an interface */
FIRM_API int is_class_interface(const ir_type *clss);
/** Sets the class interface flag. */
FIRM_API void set_class_interface(ir_type *clss, int flag);
/** Returns non-zero if a class is an abstract class. */
FIRM_API int is_class_abstract(const ir_type *clss);
/** Sets the class abstract flag. */
FIRM_API void set_class_abstract(ir_type *clss, int flag);
/** Returns true if a type is a class type. */
FIRM_API int is_Class_type(const ir_type *clss);
......@@ -2069,14 +1971,6 @@ typedef void entity_walk_func(ir_entity *ent, void *env);
FIRM_API void walk_types_entities(ir_type *tp, entity_walk_func *doit,
void *env);
/**
* If we have the closed world assumption, we can calculate the
* finalization of classes and entities by inspecting the class hierarchy.
* After this is done, all classes and entities that are not overridden
* anymore have the final property set.
*/
FIRM_API void types_calc_finalization(void);
/** @deprecated */
FIRM_API ir_visibility get_type_visibility(const ir_type *tp);
/** @deprecated */
......
......@@ -344,8 +344,6 @@ static be_main_env_t *be_init_env(be_main_env_t *const env,
env->cup_name = compilation_unit_name;
env->arch_env = isa_if->begin_codegeneration();
set_class_final(env->pic_trampolines_type, 1);
memset(asm_constraint_flags, 0, sizeof(asm_constraint_flags));
return env;
......
......@@ -661,15 +661,6 @@ void dump_type_to_file(FILE *const F, const ir_type *const tp)
ir_fprintf(F, "\n %+F", stp);
}
}
fprintf(F, "\n flags: ");
if (is_class_final(tp))
fprintf(F, "final, ");
if (is_class_interface(tp))
fprintf(F, "interface, ");
if (is_class_abstract(tp))
fprintf(F, "abstract, ");
fprintf(F, "\n");
}
break;
......
......@@ -577,8 +577,7 @@ static void write_type_primitive(write_env_t *env, ir_type *tp)
static void write_type_compound(write_env_t *env, ir_type *tp)
{
if (is_Class_type(tp)) {
if (get_class_n_subtypes(tp) > 0 || get_class_n_supertypes(tp) > 0
|| get_class_vtable_size(tp) > 0) {
if (get_class_n_subtypes(tp) > 0 || get_class_n_supertypes(tp) > 0) {
/* sub/superclass export not implemented yet, it's unclear whether
* class types will stay in libfirm anyway */
panic("can't export class types yet");
......
......@@ -66,10 +66,6 @@ static void complete_ir_prog(ir_prog *irp, const char *module_name)
irp->segment_types[IR_SEGMENT_CONSTRUCTORS] = new_type_segment(IDENT("Constructors"), tf_constructors);
irp->segment_types[IR_SEGMENT_DESTRUCTORS] = new_type_segment(IDENT("Destructors"), tf_destructors);
/* The global type is a class, but we cannot derive from it, so set
the final property to assist optimizations that checks for it. */
set_class_final(irp->segment_types[IR_SEGMENT_GLOBAL], 1);
irp->const_code_irg = new_const_code_irg();
irp->globals_entity_usage_state = ir_entity_usage_not_computed;
#undef IDENT
......
......@@ -768,7 +768,6 @@ ir_graph *(get_entity_linktime_irg)(const ir_entity *ent)
void set_entity_irg(ir_entity *ent, ir_graph *irg)
{
assert(is_method_entity(ent));
assert(get_entity_peculiarity(ent) == peculiarity_existent);
ent->attr.mtd_attr.irg = irg;
}
......@@ -945,33 +944,3 @@ void ir_finish_entity(ir_prog *irp)
{
free_entity(irp->unknown_entity);
}
ir_allocation get_entity_allocation(const ir_entity *entity)
{
return (ir_allocation)entity->allocation;
}
void set_entity_allocation(ir_entity *entity, ir_allocation allocation)
{
entity->allocation = allocation;
}
ir_peculiarity get_entity_peculiarity(const ir_entity *entity)
{
return (ir_peculiarity)entity->peculiarity;
}
void set_entity_peculiarity(ir_entity *entity, ir_peculiarity peculiarity)
{
entity->peculiarity = peculiarity;
}
void set_entity_final(ir_entity *entity, int final)
{
entity->final = final;
}
int is_entity_final(const ir_entity *entity)
{
return entity->final;
}
......@@ -17,63 +17,6 @@
#include "irgwalk.h"
#include "irflag.h"
/* ----------------------------------------------------------------------- */
/* Resolve implicit inheritance. */
/* ----------------------------------------------------------------------- */
ident *default_mangle_inherited_name(const ir_entity *super, const ir_type *clss)
{
return id_mangle_u(new_id_from_str("inh"), id_mangle_u(get_class_ident(clss), get_entity_ident(super)));
}
/** Replicates all entities in all super classes that are not overwritten
by an entity of this class. */
static void copy_entities_from_superclass(ir_type *clss, void *env)
{
mangle_inherited_name_func *mfunc = *(mangle_inherited_name_func **)env;
for (size_t i = 0; i < get_class_n_supertypes(clss); i++) {
ir_type *super = get_class_supertype(clss, i);
for (size_t j = 0; j < get_class_n_members(super); j++) {
ir_entity *inhent = get_class_member(super, j);
/* check whether inhent is already overwritten */
bool overwritten = false;
for (size_t k = 0; (k < get_class_n_members(clss)) && (overwritten == 0); k++) {
ir_entity *thisent = get_class_member(clss, k);
for (size_t l = 0; l < get_entity_n_overwrites(thisent); l++) {
if (inhent == get_entity_overwrites(thisent, l)) {
/* overwritten - do not copy */
overwritten = true;
break;
}
}
}
/* Inherit entity */
if (!overwritten) {
ir_entity *thisent = copy_entity_own(inhent, clss);
add_entity_overwrites(thisent, inhent);
if (get_entity_peculiarity(inhent) == peculiarity_existent)
set_entity_peculiarity(thisent, peculiarity_inherited);
set_entity_ld_ident(thisent, mfunc(inhent, clss));
if (get_entity_linkage(inhent) & IR_LINKAGE_CONSTANT) {
assert(is_atomic_entity(inhent) && /* @@@ */
"Inheritance of constant, compound entities not implemented");
add_entity_linkage(thisent, IR_LINKAGE_CONSTANT);
set_atomic_ent_value(thisent, get_atomic_ent_value(inhent));
}
}
}
}
}
void resolve_inheritance(mangle_inherited_name_func *mfunc)
{
if (!mfunc)
mfunc = default_mangle_inherited_name;
class_walk_super2sub(copy_entities_from_superclass, NULL, (void *)&mfunc);
}
/* ----------------------------------------------------------------------- */
/* The transitive closure of the subclass/superclass and */
/* overwrites/overwrittenby relation. */
......
......@@ -318,13 +318,6 @@ int check_entity(const ir_entity *entity)
fine = false;
}
}
if (get_entity_peculiarity(entity) == peculiarity_existent) {
ir_entity *impl = get_Address_entity(get_atomic_ent_value(entity));
if (impl == NULL) {
report_error("inherited method entity %+F must have constant pointing to existent entity.", entity);
fine = false;
}
}
break;
case IR_ENTITY_PARAMETER:
if (!is_frame_type(owner)) {
......
......@@ -436,13 +436,9 @@ ir_type *new_type_class(ident *name)
{
ir_type *res = new_type(type_class, NULL);
res->name = name;
res->attr.cla.subtypes = NEW_ARR_F (ir_type *, 0);
res->attr.cla.supertypes = NEW_ARR_F (ir_type *, 0);
res->attr.cla.peculiarity = peculiarity_existent;
res->attr.cla.vtable_size = 0;
res->attr.cla.clss_flags = cf_none;
res->attr.cla.dfn = 0;
compound_init(res);
res->attr.cla.subtypes = NEW_ARR_F(ir_type*, 0);
res->attr.cla.supertypes = NEW_ARR_F(ir_type*, 0);
hook_new_type(res);
return res;
}
......@@ -616,69 +612,6 @@ void remove_class_supertype(ir_type *clss, ir_type *supertype)
}
}
ir_peculiarity get_class_peculiarity(const ir_type *clss)
{
assert(is_Class_type(clss));
return clss->attr.cla.peculiarity;
}
void set_class_peculiarity(ir_type *clss, ir_peculiarity pec)
{
assert(is_Class_type(clss));
assert(pec != peculiarity_inherited); /* There is no inheritance of types in libFirm. */
clss->attr.cla.peculiarity = pec;
}
unsigned (get_class_vtable_size)(const ir_type *clss)
{
return _get_class_vtable_size(clss);
}
void (set_class_vtable_size)(ir_type *clss, unsigned size)
{
_set_class_vtable_size(clss, size);
}
int (is_class_final)(const ir_type *clss)
{
return _is_class_final(clss);
}
void (set_class_final)(ir_type *clss, int flag)
{
_set_class_final(clss, flag);
}
int (is_class_interface)(const ir_type *clss)
{
return _is_class_interface(clss);
}
void (set_class_interface)(ir_type *clss, int flag)
{
_set_class_interface(clss, flag);
}
int (is_class_abstract)(const ir_type *clss)
{
return _is_class_abstract(clss);
}
void (set_class_abstract)(ir_type *clss, int final)
{
_set_class_abstract(clss, final);
}
void set_class_dfn(ir_type *clss, int dfn)
{
clss->attr.cla.dfn = dfn;
}
int get_class_dfn(const ir_type *clss)
{
return (clss->attr.cla.dfn);
}
int (is_Class_type)(const ir_type *clss)
{
return _is_class_type(clss);
......@@ -1013,7 +946,6 @@ ir_type *new_type_segment(ident *const name, type_flags const flags)
{
ir_type *const seg = new_type_class(name);
seg->flags |= tf_segment | flags;
set_class_final(seg, true);
return seg;
}
......@@ -1412,7 +1344,6 @@ ir_type *new_type_frame(void)
{
ir_type *res = new_type_class(new_id_from_str("<frame_type>"));
res->flags |= tf_frame_type;
set_class_final(res, 1);
return res;
}
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Calculate finalization of classes and entities by
* inspecting the class hierarchy.
* @author Michael Beck
*/
#include "typerep.h"
#include "irprog_t.h"
#include "irflag_t.h"
#include "entity_t.h"
#include "debug.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg;)
static void do_finalization(ir_type *const cls, ir_entity *const ent, void *const env)
{
ir_type *glob_tp = (ir_type*)env;
if (cls) {
if (!is_Class_type(cls))
return;
if (is_class_final(cls))
return;
if (get_class_n_subtypes(cls) == 0) {
/* Note that we set the final property even for the
frame/global types this way. Should not made any problems. */
set_class_final(cls, 1);
DB((dbg, LEVEL_1, " made final Class %s\n",
get_class_name(cls)));
}
} else {
if (is_entity_final(ent))
return;
ir_type *owner = get_entity_owner(ent);
/* beware of array entities */
if (! is_Class_type(owner) || owner == glob_tp)
return;
if (is_class_final(owner)) {
assert(get_entity_n_overwrittenby(ent) == 0);
set_entity_final(ent, 1);
DB((dbg, LEVEL_1, " made final %s::%s\n",
get_compound_name(owner), get_entity_name(ent)));
} else if (get_entity_n_overwrittenby(ent) == 0) {
set_entity_final(ent, 1);
DB((dbg, LEVEL_1, " made final %s::%s\n",
get_compound_name(owner), get_entity_name(ent)));
}
}
}
void types_calc_finalization(void)
{
if (! get_opt_closed_world())
return;
FIRM_DBG_REGISTER(dbg, "firm.tr.finalization");
/* types must be visited before their entities */
type_walk(do_finalization, NULL, get_glob_type());
}
......@@ -41,14 +41,6 @@
#define is_Class_type(clss) _is_class_type(clss)
#define get_class_n_members(clss) _get_class_n_members(clss)
#define get_class_member(clss, pos) _get_class_member(clss, pos)
#define get_class_vtable_size(clss) _get_class_vtable_size(clss)
#define set_class_vtable_size(clss, size) _set_class_vtable_size(clss, size)
#define is_class_final(clss) _is_class_final(clss)
#define set_class_final(clss, flag) _set_class_final(clss, flag)
#define is_class_interface(clss) _is_class_interface(clss)
#define set_class_interface(clss, flag) _set_class_interface(clss, flag)
#define is_class_abstract(clss) _is_class_abstract(clss)
#define set_class_abstract(clss, flag) _set_class_abstract(clss, flag)
#define is_Struct_type(strct) _is_struct_type(strct)
#define is_Method_type(method) _is_method_type(method)
#define is_Union_type(uni) _is_union_type(uni)
......@@ -69,23 +61,11 @@ typedef struct {
ir_entity **members;
} compound_attr;
/** Class flags. */
enum class_flags {
cf_none = 0, /**< No flags. */
cf_final_class = 1, /**< Set if a class is an final class */
cf_interface_class = 2, /**< Set if a class is an "interface" */
cf_absctract_class = 4, /**< Set if a class is "abstract" */
};
/** Class type attributes. */
typedef struct {
compound_attr base;
ir_type **subtypes; /**< Array containing the direct subtypes. */
ir_type **supertypes; /**< Array containing the direct supertypes */
ir_peculiarity peculiarity; /**< The peculiarity of this class. */
int dfn; /**< A number that can be used for 'instanceof' operator. */
unsigned vtable_size; /**< The size of the vtable for this class. */
unsigned clss_flags; /**< Additional class flags. */
compound_attr base;
ir_type **subtypes; /**< Array containing the direct subtypes. */
ir_type **supertypes; /**< Array containing the direct supertypes */
} cls_attr;
/** Method type attributes. */
......@@ -376,63 +356,6 @@ static inline ir_entity *_get_class_member(const ir_type *clss, size_t pos)
return clss->attr.ca.members[pos];
}
static inline unsigned _get_class_vtable_size(const ir_type *clss)
{
assert(clss->type_op == type_class);
return clss->attr.cla.vtable_size;
}
static inline void _set_class_vtable_size(ir_type *clss, unsigned vtable_size)
{
assert(clss->type_op == type_class);
clss->attr.cla.vtable_size = vtable_size;
}
static inline int _is_class_final(const ir_type *clss)
{
assert(clss->type_op == type_class);
return clss->attr.cla.clss_flags & cf_final_class;
}
static inline void _set_class_final(ir_type *clss, int final)
{
assert(clss->type_op == type_class);
if (final)
clss->attr.cla.clss_flags |= cf_final_class;
else
clss->attr.cla.clss_flags &= ~cf_final_class;
}
static inline int _is_class_interface(const ir_type *clss)
{
assert(clss->type_op == type_class);
return clss->attr.cla.clss_flags & cf_interface_class;
}
static inline void _set_class_interface(ir_type *clss, int final)
{
assert(clss->type_op == type_class);
if (final)
clss->attr.cla.clss_flags |= cf_interface_class;
else
clss->attr.cla.clss_flags &= ~cf_interface_class;
}
static inline int _is_class_abstract(const ir_type *clss)
{
assert(clss->type_op == type_class);
return clss->attr.cla.clss_flags & cf_absctract_class;
}
static inline void _set_class_abstract(ir_type *clss, int final)
{
assert(clss->type_op == type_class);
if (final)
clss->attr.cla.clss_flags |= cf_absctract_class;
else
clss->attr.cla.clss_flags &= ~cf_absctract_class;
}
static inline int _is_struct_type(const ir_type *strct)
{
return (strct->type_op == type_struct);
......
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