Commit e4f3c2cf authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

removed warnings

new access routined

[r676]
parent f184596a
......@@ -10,13 +10,14 @@ srcdir = @srcdir@
topdir = ../..
subdir := ir/tr
INSTALL_HEADERS = entity.h mangle.h tpop.h type.h typewalk.h type_or_entity.h typegmod.h
INSTALL_HEADERS = entity.h mangle.h tpop.h type.h typewalk.h type_or_entity.h \
typegmod.h trvrfy.h
SOURCES = $(INSTALL_HEADERS)
SOURCES += Makefile.in \
entity.c entity_t.h mangle.c tpop.c tpop_t.h type.c type_t.h \
typewalk.c typegmod.c typegmod_t.h
typewalk.c typegmod.c typegmod_t.h trvrfy.h trvrfy.c
include $(topdir)/MakeRules
......
......@@ -121,6 +121,7 @@ copy_entity_own (entity *old, type *new_owner) {
new = (entity *) malloc (sizeof (entity));
memcpy (new, old, sizeof (entity));
new->owner = new_owner;
/*
if ((get_type_tpop(get_entity_owner(old)) == type_class) &&
(get_type_tpop(new_owner) == type_class)) {
new->overwrites = DUP_ARR_F(entity *, old->overwrites);
......@@ -130,6 +131,11 @@ copy_entity_own (entity *old, type *new_owner) {
new->overwrites = NEW_ARR_F(entity *, 1);
new->overwrittenby = NEW_ARR_F(entity *, 1);
}
*/
if (is_class_type(new_owner)) {
new->overwrites = NEW_ARR_F(entity *, 1);
new->overwrittenby = NEW_ARR_F(entity *, 1);
}
insert_entity_in_owner (new);
......@@ -461,6 +467,16 @@ get_entity_n_overwrites (entity *ent) {
return (ARR_LEN (ent->overwrites))-1;
}
int
get_entity_overwrites_index(entity *ent, entity *overwritten) {
int i;
assert(ent && is_class_type(get_entity_owner(ent)));
for (i = 0; i < get_entity_n_overwrites(ent); i++)
if (get_entity_overwrites(ent, i) == overwritten)
return i;
return -1;
}
INLINE entity *
get_entity_overwrites (entity *ent, int pos) {
assert(ent);
......@@ -477,6 +493,19 @@ set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
ent->overwrites[pos+1] = overwritten;
}
void
remove_entity_overwrites(entity *ent, entity *overwritten) {
int i;
assert(ent && is_class_type(get_entity_owner(ent)));
for (i = 1; i < (ARR_LEN (ent->overwrites)); i++)
if (ent->overwrites[i] == overwritten) {
for(; i < (ARR_LEN (ent->overwrites))-1; i++)
ent->overwrites[i] = ent->overwrites[i+1];
ARR_SETLEN(entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
break;
}
}
INLINE void
add_entity_overwrittenby (entity *ent, entity *overwrites) {
assert(ent);
......@@ -491,6 +520,16 @@ get_entity_n_overwrittenby (entity *ent) {
return (ARR_LEN (ent->overwrittenby))-1;
}
int
get_entity_overwrittenby_index(entity *ent, entity *overwrites) {
int i;
assert(ent && is_class_type(get_entity_owner(ent)));
for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
if (get_entity_overwrittenby(ent, i) == overwrites)
return i;
return -1;
}
INLINE entity *
get_entity_overwrittenby (entity *ent, int pos) {
assert(ent);
......@@ -507,6 +546,18 @@ set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
ent->overwrittenby[pos+1] = overwrites;
}
void remove_entity_overwrittenby(entity *ent, entity *overwrites) {
int i;
assert(ent && is_class_type(get_entity_owner(ent)));
for (i = 1; i < (ARR_LEN (ent->overwrittenby)); i++)
if (ent->overwrittenby[i] == overwrites) {
for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
ent->overwrittenby[i] = ent->overwrittenby[i+1];
ARR_SETLEN(entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
break;
}
}
/* A link to store intermediate information */
void *
get_entity_link(entity *ent) {
......@@ -539,6 +590,14 @@ set_entity_irg(entity *ent, ir_graph *irg) {
ent->irg = irg;
}
int is_entity (void *thing) {
assert(thing);
if (get_kind(thing) == k_entity)
return 1;
else
return 0;
}
int is_atomic_entity(entity *ent) {
type* t = get_entity_type(ent);
return (is_primitive_type(t) || is_pointer_type(t) ||
......@@ -571,3 +630,11 @@ void mark_entity_visited(entity *ent) {
assert (ent);
ent->visit = type_visited;
}
INLINE bool entity_visited(entity *ent) {
return get_entity_visited(ent) >= type_visited;
}
INLINE bool entity_not_visited(entity *ent) {
return get_entity_visited(ent) < type_visited;
}
......@@ -125,7 +125,8 @@ entity *new_entity (type *owner, ident *name, type *tp);
entity *new_d_entity (type *owner, ident *name, type *tp, dbg_info *db);
/* Copies the entity if the new_owner is different from the
owner of the old entity. Else returns the old entity.
Automatically inserts the new entity as a member of owner. */
Automatically inserts the new entity as a member of owner.
Resets the overwrites/overwritten_by fields. */
entity *copy_entity_own (entity *old, type *new_owner);
/* Copies the entity if the new_name is different from the
name of the old entity. Else returns the old entity.
......@@ -202,10 +203,10 @@ typedef enum {
ent_variability get_entity_variability (entity *ent);
void set_entity_variability (entity *ent, ent_variability var);
/* This enumeration flags the volatility of entities. */
/** This enumeration flags the volatility of entities. */
typedef enum {
non_volatile, /* The entity is not volatile */
is_volatile /* The entity is volatile */
non_volatile, /**< The entity is not volatile */
is_volatile /**< The entity is volatile */
} ent_volatility;
ent_volatility get_entity_volatility (entity *ent);
......@@ -270,13 +271,27 @@ void set_array_entity_values(entity *ent, tarval **values, int num_vals);
both relations, they only differ in the order of arguments. */
void add_entity_overwrites (entity *ent, entity *overwritten);
int get_entity_n_overwrites (entity *ent);
int get_entity_overwrites_index(entity *ent, entity *overwritten);
entity *get_entity_overwrites (entity *ent, int pos);
void set_entity_overwrites (entity *ent, int pos, entity *overwritten);
void remove_entity_overwrites(entity *ent, entity *overwritten);
void add_entity_overwrittenby (entity *ent, entity *overwrites);
int get_entity_n_overwrittenby (entity *ent);
int get_entity_overwrittenby_index(entity *ent, entity *overwrites);
entity *get_entity_overwrittenby (entity *ent, int pos);
void set_entity_overwrittenby (entity *ent, int pos, entity *overwrites);
void remove_entity_overwrittenby(entity *ent, entity *overwrites);
/**
* Checks whether a pointer points to an entity.
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is an entity, else false
*/
int is_entity (void *thing);
/* Returns true if the type of the entity is a primitive, pointer
enumeration or method type. */
......@@ -297,6 +312,9 @@ unsigned long get_entity_visited(entity *ent);
void set_entity_visited(entity *ent, unsigned long num);
/* Sets visited field in entity to entity_visited. */
void mark_entity_visited(entity *ent);
bool entity_visited(entity *ent);
bool entity_not_visited(entity *ent);
......
......@@ -204,7 +204,6 @@ set_type_state(type *tp, type_state state) {
assert(get_entity_offset(get_class_member(tp, i)) > -1);
assert(is_method_type(get_entity_type(get_class_member(tp, i))) ||
(get_entity_allocation(get_class_member(tp, i)) == automatic_allocated));
/* @@@ lowerfirm geht nicht durch */
}
} break;
case tpo_struct:
......@@ -250,6 +249,16 @@ void mark_type_visited(type *tp) {
assert(tp->visit < type_visited);
tp->visit = type_visited;
}
/* @@@ name clash with master flag
bool type_visited(type *tp) {
assert(tp && tp->kind == k_type);
return tp->visit >= type_visited;
}*/
bool type_not_visited(type *tp) {
assert(tp && tp->kind == k_type);
return tp->visit < type_visited;
}
int is_type (void *thing) {
assert(thing);
......@@ -369,7 +378,6 @@ bool equal_type(type *typ1, type *typ2) {
}
} break;
case tpo_array: {
type *set, *let; /* small/large elt. type */
if (get_array_n_dimensions(typ1) != get_array_n_dimensions(typ2))
return false;
if (!equal_type(get_array_element_type(typ1), get_array_element_type(typ2)))
......@@ -545,6 +553,14 @@ int get_class_n_members (type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.members))-1;
}
int get_class_member_index(type *clss, entity *mem) {
int i;
assert(clss && (clss->type_op == type_class));
for (i = 0; i < get_class_n_members(clss); i++)
if (get_class_member(clss, i) == mem)
return i;
return -1;
}
entity *get_class_member (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_members(clss));
......@@ -629,6 +645,15 @@ int get_class_n_supertypes (type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.supertypes))-1;
}
int get_class_supertype_index(type *clss, type *super_clss) {
int i;
assert(clss && (clss->type_op == type_class));
assert(super_clss && (super_clss->type_op == type_class));
for (i = 0; i < get_class_n_supertypes(clss); i++)
if (get_class_supertype(clss, i) == super_clss)
return i;
return -1;
}
type *get_class_supertype (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
assert(pos >= 0 && pos < get_class_n_supertypes(clss));
......
......@@ -146,6 +146,8 @@ unsigned long get_type_visited(type *tp);
void set_type_visited(type *tp, unsigned long num);
/* Sets visited field in type to type_visited. */
void mark_type_visited(type *tp);
/* @@@ name clash!! bool type_visited(type *tp); */
bool type_not_visited(type *tp);
void* get_type_link(type *tp);
void set_type_link(type *tp, void *l);
......@@ -168,8 +170,11 @@ void inc_master_type_visited();
/**
*
* Checks whether a pointer points to a type.
* @param thing - a pointer
* @return true if the thing is a type, else false
*
* @param thing an arbitrary pointer
*
* @return
* true if the thing is a type, else false
*
*/
int is_type (void *thing);
......@@ -284,6 +289,8 @@ void add_class_member (type *clss, entity *member);
int get_class_n_members (type *clss);
/* Returns the member at position pos, 0 <= pos < n_member */
entity *get_class_member (type *clss, int pos);
/** Returns index of mem in clss, -1 if not contained. */
int get_class_member_index(type *clss, entity *mem);
/* Overwrites the member at position pos, 0 <= pos < n_member with
the passed entity. */
void set_class_member (type *clss, entity *member, int pos);
......@@ -320,6 +327,7 @@ void remove_class_subtype(type *clss, type *subtype);
void add_class_supertype (type *clss, type *supertype);
/* Returns the number of supertypes */
int get_class_n_supertypes (type *clss);
int get_class_supertype_index(type *clss, type *super_clss);
/* Gets the supertype at position pos, 0 <= pos < n_supertype. */
type *get_class_supertype (type *clss, int pos);
/* Sets the supertype at postition pos, 0 <= pos < n_subtype. Does not
......
......@@ -22,6 +22,7 @@
typedef void (type_walk_func)(type_or_ent *, void *);
typedef void (class_walk_func)(type *, void *);
/**
Touches every type and entity in unspecified order. If new
......@@ -66,8 +67,8 @@ void type_walk_super(type_walk_func *pre,
Does not visit global type, frame types.
*/
/* @@@ ?? something is wrong with this. */
void class_walk_super2sub(type_walk_func *pre,
type_walk_func *post,
void class_walk_super2sub(class_walk_func *pre,
class_walk_func *post,
void *env);
......
./array-heap_example; ./empty; ./irr_cf_example; ./array-stack_example; ./global_var_example; ./irr_loop_example; ./call_str_example; ./if_else_example; ./memory_example; ./cond_example; ./if_example; ./oo_program_example; ./const_eval_example; ./if_while_example; ./three_cfpred_example; ./dead_block_example; ./inheritance_example; ./while_example; ./endless_loop; ./global_cse; ./oo_inline_example;
Creating an IR graph: ARRAY-HEAP_EXAMPLE...
Optimizing ...
Dumping the graph and a type graph.
use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: EMPTY...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: IRR_CF...
Optimizing ...
Dumping the graph and a control flow graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: ARRAY-STACK_EXAMPLE...
Optimizing ...
Dumping the graph and a type graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: GLOBAL_VAR ...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: IRR_LOOP...
Optimizing ...
Dumping the graph and a control flow graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: CALL_STR_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
creating an IR graph: IF_ELSE_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: MEMORY_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: COND_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: IF_EXAMPLE...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: OO_PROGRAM_EXAMPLE...
Creating IR graph for set_a:
Creating IR graph for c:
Optimizing ...
Dumping graphs of all procedures and a type graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: CONST_EVAL_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: IF_WHILE_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it with out-edges.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: ...
Optimizing ...
Dumping the graph and a control flow graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: DEAD_BLOCK...
Optimizing ...
Dumping the graph and a control flow graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
Creating type information...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: WHILE_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: ENDLESS_LOOP_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
Use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: GLOBAL_CSE_EXAMPLE...
Optimizing ...
Done building the graph. Dumping it.
use xvcg to view this graph:
/ben/goetz/bin/xvcg GRAPHNAME
Creating an IR graph: OO_INLINE_EXAMPLE...
Creating IR graph for set_a:
Creating IR graph for c:
Inlining set_a ...
INLINEing c ...
Optimizing ...
Dumping graphs of all procedures and a type graph.
Use xvcg to view these graphs:
/ben/goetz/bin/xvcg GRAPHNAME
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