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

a bunch of comments

a flag to see the state of the interprocedural view

[r3038]
parent 478dcb4a
* print routines for all enums!
Add flag whether mode is associative, float modes are not!!
* 25.2.04 Goetz
......
......@@ -46,7 +46,8 @@ CLASSFILES = $(MEMBERS:.m=.class)
CPPFLAGS += -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/common \
-I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/tr \
-I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/debug \
-I$(top_srcdir)/ir/ana -I$(top_srcdir)/ir/st
-I$(top_srcdir)/ir/ana -I$(top_stcdir)/ir/opt \
-I$(top_srcdir)/ir/st
LDFLAGS += -I$(topdir)
......
......@@ -246,9 +246,12 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) {
fuer die es keine Implementierung gibt. */
if (get_entity_peculiarity(ent) == peculiarity_description) {
/* @@@ GL Methode um Fehler anzuzeigen aufrufen! */
printf("WARNING: Calling method description %s in method %s which has "
"no implementation!\n", get_entity_name(ent),
get_entity_name(get_irg_ent(current_ir_graph)));
printf("WARNING: Calling method description %s\n in method %s\n of class %s\n which has "
"no implementation!\n", get_entity_name(ent),
get_entity_name(get_irg_ent(current_ir_graph)),
get_type_name(get_entity_owner(get_irg_ent(current_ir_graph))));
printf("This happens when compiling a Java Interface that's never really used, i.e., "
"no class implementing the interface is ever used.\n");
} else {
exchange(node, new_Bad());
}
......@@ -679,6 +682,7 @@ static entity ** get_free_methods(void) {
int i;
entity ** arr = NEW_ARR_F(entity *, 0);
entity * ent;
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
entity * ent = get_irg_ent(irg);
......@@ -686,13 +690,16 @@ static entity ** get_free_methods(void) {
if (get_entity_visibility(ent) != visibility_local) {
eset_insert(set, ent);
}
/* Finde alle Methoden die in dieser Methode extern sichtbar werden,
z.B. da die Adresse einer Methode abgespeichert wird. */
irg_walk_graph(irg, NULL, (irg_walk_func *) free_ana_walker, set);
}
/* Hauptprogramm ist auch frei, auch wenn es nicht "external
/* Hauptprogramm ist auch dann frei, wenn es nicht "external
* visible" ist. */
if(get_irp_main_irg()) {
if (get_irp_main_irg()) {
eset_insert(set, get_irg_ent(get_irp_main_irg()));
}
/* Wandle Menge in Feld um. Effizienter. */
for (ent = eset_first(set); ent; ent = eset_next(set)) {
ARR_APP1(entity *, arr, ent);
}
......
......@@ -196,9 +196,8 @@ void compute_doms(ir_graph *irg) {
if (current_ir_graph->outs_state != outs_consistent)
compute_outs(current_ir_graph);
/**
this with a standard walker as passing the parent to the sons isn't
simple. **/
/* this with a standard walker as passing the parent to the sons isn't
simple. */
used = 0;
inc_irg_block_visited(current_ir_graph);
init_tmp_dom_info(get_irg_start_block(current_ir_graph), NULL, tdi_list, &used);
......
......@@ -409,6 +409,9 @@ void compute_ip_outs(void) {
int n_out_edges;
ir_node **out_edges;
assert(get_irp_ip_view_state() == ip_view_valid &&
"Cannot construct outs for invalid ip view.");
if (irp->outs_state != no_outs) free_ip_outs();
global_count = n_out_edges = count_ip_outs();
......
......@@ -21,12 +21,29 @@
#include "array.h"
#include "irprog.h"
#include "irnode_t.h"
#include "irprog_t.h"
#include "ircons.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irflag_t.h"
/* Return the current state of the interprocedural view. */
ip_view_state get_irp_ip_view_state(void) {
return irp->ip_view;
}
/* Set the current state of the interprocedural view. */
static void set_irp_ip_view(ip_view_state state) {
irp->ip_view = state;
}
/* Set the state of the interprocedural view to invalid. */
void set_irp_ip_view_invalid(void) {
set_irp_ip_view(ip_view_invalid);
}
/* # define CATE_jni */
/* Datenstruktur fr jede Methode */
......@@ -765,6 +782,10 @@ static void construct_call(ir_node * call) {
void cg_construct(int arr_len, entity ** free_methods_arr) {
int i;
if (get_irp_ip_view_state() == ip_view_valid) return;
if (get_irp_ip_view_state() == ip_view_invalid) cg_destruct();
set_irp_ip_view(ip_view_valid);
collect_phicallproj();
/* count callers */
......@@ -832,13 +853,16 @@ static void destruct_walker(ir_node * node, void * env) {
void cg_destruct(void) {
int i;
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
irg_walk_graph(irg, destruct_walker, clear_link, NULL);
set_irg_frame(irg, skip_nop(get_irg_frame(irg)));
set_irg_globals(irg, skip_nop(get_irg_globals(irg)));
set_irg_callee_info_state(irg, irg_callee_info_none);
set_irg_end_reg(irg, get_irg_end(irg));
set_irg_end_except(irg, get_irg_end(irg));
if (get_irp_ip_view_state() != ip_view_no) {
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
irg_walk_graph(irg, destruct_walker, clear_link, NULL);
set_irg_frame(irg, skip_nop(get_irg_frame(irg)));
set_irg_globals(irg, skip_nop(get_irg_globals(irg)));
set_irg_callee_info_state(irg, irg_callee_info_none);
set_irg_end_reg(irg, get_irg_end(irg));
set_irg_end_except(irg, get_irg_end(irg));
}
set_irp_ip_view(ip_view_no);
}
}
......@@ -18,14 +18,38 @@
#include "entity.h"
/* Aufbau der interprozeduralen Darstellung. In den Call-Operationen
* muessen alle potentiellen callees gespeichert sein. */
/** The state of the interprocedural view.
*
* This value indicates the state of the interprocedural view.
*/
typedef enum {
ip_view_no, /**< The interprocedural view is not constructed. There are no
view specific nodes (EndReg, Filter....) in any graph. */
ip_view_valid, /**< The interprocedural view is valid. */
ip_view_invalid /**< The interprocedural view is invalid. Specific nodes are
all still in the representation, but the graph is no more complete. */
} ip_view_state;
/** Return the current state of the interprocedural view. */
ip_view_state get_irp_ip_view_state(void);
/** Set the state of the interprocedural view to invalid. */
void set_irp_ip_view_invalid(void);
/** Construction of the interprocedural view.
*
* Construction of the interprocedural view. A prior analyses must have set
* all possible callees in the corresponding fiels of Call nodes. Sets
* ip_view_valid in irp.
*
* @arg free_methods_arr: An array of all free methods, i.e., methods that
* are external visible. These methods get an 'Unknown'
* caller.
* @arg arr_len The number of free methods. */
void cg_construct(int arr_len, entity *free_methods_arr[]);
/* Abbau der interprozeduralen (Sichten-) Darstellung, in eine
* gewoehnliche intraprozedurale Darstellung */
/** Deconstruction of the interprocedural view. Reduces memory consumption of
the ir. Sets ip_view_no in irp. */
void cg_destruct(void);
......
......@@ -1519,6 +1519,13 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode);
static ir_node *
phi_merge (ir_node *block, int pos, ir_mode *mode, ir_node **nin, int ins);
/* Construct a new frag_array for node n.
Copy the content from the current graph_arr of the corresponding block:
this is the current state.
Set ProjM(n) as current memory state.
Further the last entry in frag_arr of current block points to n. This
constructs a chain block->last_frag_op-> ... first_frag_op of all frag ops in the block.
*/
static INLINE ir_node ** new_frag_arr (ir_node *n)
{
ir_node **arr;
......@@ -2262,7 +2269,7 @@ new_d_FuncCall (dbg_info* db, ir_node *callee, int arity, ir_node **in,
/* (Uses also constructors of ?? interface, except new_Block. */
/* ********************************************************************* */
/** Block construction **/
/* * Block construction **/
/* immature Block without predecessors */
ir_node *new_d_immBlock (dbg_info* db) {
ir_node *res;
......
This diff is collapsed.
......@@ -30,11 +30,17 @@
current_ir_graph is set properly. */
void exchange (ir_node *old, ir_node *nw);
/** Turns a node into a "useless" Tuple. The Tuple node just forms a tuple
from several inputs. The predecessors of the tuple have to be
set by hand. The block predecessor automatically remains the same.
This is useful if a node returning a tuple is removed, but the Projs
extracting values from the tuple are not available. */
/** Turns a node into a "useless" Tuple.
*
* Turns a node into a "useless" Tuple. The Tuple node just forms a tuple
* from several inputs. The predecessors of the tuple have to be
* set by hand. The block predecessor automatically remains the same.
* This is useful if a node returning a tuple is removed, but the Projs
* extracting values from the tuple are not available.
*
* @param node The node to be turned into a tuple.
* @param arity The number of values formed into a Tuple.
*/
void turn_into_tuple (ir_node *node, int arity);
/** Walks over the passed ir graph and collects all Phi nodes as a
......
......@@ -514,7 +514,7 @@ static void relink_bad_block_predecessors(ir_node *n, void *env) {
} /* Block is not relinked */
}
/**
/*
* Relinks Bad predecesors from Bocks and Phis called by walker
* remove_bad_predecesors(). If n is a Block, call
* relink_bad_block_redecessors(). If n is a Phinode, call also the relinking
......
......@@ -85,13 +85,13 @@ new_ir_graph (entity *ent, int n_loc)
#if PRECISE_EXC_CONTEXT
res->n_loc = n_loc + 1 + 1; /* number of local variables that are never
dereferenced in this graph plus one for
the store plus one for links to fragile
operations. n_loc is not the number of
parameters to the procedure! */
the store plus one for links to fragile
operations. n_loc is not the number of
parameters to the procedure! */
#else
res->n_loc = n_loc + 1; /* number of local variables that are never
dereferenced in this graph plus one for
the store. This is not the number of parameters
the store. This is not the number of parameters
to the procedure! */
#endif
......
......@@ -197,13 +197,19 @@ new_ir_node (dbg_info *db,
*
*/
/* This works for all except Block. To express the difference to
* access routines that work for all nodes we use infix "nodes". */
/** This works for all except Block. To express the difference to
* access routines that work for all nodes we use infix "nodes" and do not
* name this function get_irn_block. */
#define get_nodes_block get_nodes_Block
ir_node *get_nodes_Block (ir_node *node);
#define set_nodes_block set_nodes_Block
void set_nodes_Block (ir_node *node, ir_node *block);
/**
* @function get_irn_block
* @see get_nodes_block
*/
/**
* Projection numbers for result of Start node: use for Proj nodes!
*/
......@@ -857,7 +863,7 @@ ir_node *get_fragile_op_mem(ir_node *node);
/** Output information about a node */
#define DDMN(X) printf("%s(l.%i) %s%s: %ld (%p)\n", __MYFUNC__, __LINE__, get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), (void *)(X))
/** Output information about a node and its block */
#define DDMNB(X) printf("%s%s: %ld (in block %ld)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), get_irn_node_nr(get_nodes_Block(X)))
#define DDMNB(X) printf("%s%s: %ld (in block %ld)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), get_irn_node_nr(get_nodes_block(X)))
/** Output information about a type */
#define DDMT(X) printf("%s(l.%i) %s %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_type_tpop_name(X), get_type_name(X), get_type_nr(X), (void *)(X))
/** Output information about an entity */
......
......@@ -172,21 +172,21 @@ typedef union {
type *f; /**< For Free. */
cast_attr cast; /**< For Cast. */
int phi0_pos; /**< For Phi. Used to remember the value defined by
this Phi node. Needed when the Phi is completed
to call get_r_internal_value to find the
predecessors. If this attribute is set, the Phi
node takes the role of the obsolete Phi0 node,
therefore the name. */
this Phi node. Needed when the Phi is completed
to call get_r_internal_value to find the
predecessors. If this attribute is set, the Phi
node takes the role of the obsolete Phi0 node,
therefore the name. */
int *phi_backedge; /**< For Phi after construction.
Field n set to true if pred n is backedge.
@todo Ev. replace by bitfield! */
Field n set to true if pred n is backedge.
@todo Ev. replace by bitfield! */
long proj; /**< For Proj: contains the result position to project */
confirm_attr confirm_cmp; /**< For Confirm: compare operation */
filter_attr filter; /**< For Filter */
end_attr end; /**< For EndReg, EndExcept */
#if PRECISE_EXC_CONTEXT
struct ir_node **frag_arr; /**< For Phi node construction in case of exceptions
for nodes Store, Load, Div, Mod, Quot, DivMod. */
for nodes Store, Load, Div, Mod, Quot, DivMod. */
#endif
} attr;
......@@ -202,8 +202,8 @@ struct ir_node {
struct ir_node **in; /**< array with predecessors / operands */
void *link; /**< to attach additional information to the node, e.g.
used while construction to link Phi0 nodes and
during optimization to link to nodes that
shall replace a node. */
during optimization to link to nodes that
shall replace a node. */
/* ------- Fields for optimizations / analysis information ------- */
struct ir_node **out; /**< array of out edges */
struct dbg_info* dbi; /**< A pointer to information for debug support. */
......
......@@ -19,12 +19,17 @@
*
* This file defines a construct that keeps all information about a
* program:
* - A reference point to the method to be executed on program start.
* - A list of all procedures.
* - A list of all types.
* - A global type that can be thought of as a god-class containing all
* global variables and procedures. This is not the base class of
* - A global type that contais all global variables and procedures that do
* not belong to a class. This type represents the data segment of the
* program. It is not the base class of
* all classes in a class hierarchy (as, e.g., "object" in java).
* - (An obstack containing global things, e.g., the above mentioned lists.)
* - A degenerated graph that contains constant expressions.
* - interprocedural outs state.
* - a flag indicating validity of the interprocedural representation.
* - the output file name
*/
# ifndef _IRPROG_H_
......@@ -33,6 +38,7 @@
# include "irnode.h"
# include "type.h"
/**
* Datastructure that holds central information about a program
*
......@@ -128,7 +134,6 @@ const char *get_irp_prog_name (void);
/**
* Returns an irgraph that only contains constant
*
* expressions for constant entities.
* Do not use any access function for this graph, do not generate code
* for this graph. This graph contains only one block. The constant
......@@ -138,8 +143,10 @@ const char *get_irp_prog_name (void);
ir_graph *get_const_code_irg(void);
irg_outs_state get_irp_ip_outs_state(void);
void set_irp_ip_outs_inconsistent(void);
void set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node** get_irp_ip_outedges(void);
void set_irp_ip_outs_inconsistent(void);
/* @@@ Must this be global visible? */
void set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node** get_irp_ip_outedges(void);
#endif /* ifndef _IRPROG_H_ */
......@@ -23,6 +23,7 @@
#include "irprog.h"
#include "irgraph.h"
#include "ircgcons.h"
#include "firm_common_t.h"
......@@ -43,6 +44,7 @@ struct ir_prog {
irg_outs_state outs_state; /**< Out edges. */
ir_node **ip_outedges; /**< Huge Array that contains all out edges
in interprocedural view. */
ip_view_state ip_view; /**< State of interprocedural view. */
ident *name;
/*struct obstack *obst; * @@@ Should we place all types and
entities on an obstack, too? */
......
......@@ -414,7 +414,8 @@ void remove_class_supertype(type *clss, type *supertype);
/** This enumeration flags the peculiarity of entities and types. */
typedef enum peculiarity {
peculiarity_description, /**< Represents only a description. The entity/type is never
allocated, no code/data exists for this entity/type. */
allocated, no code/data exists for this entity/type.
@@@ eventually rename to descriptive (adjectiv 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
......@@ -422,7 +423,9 @@ typedef enum peculiarity {
no irg for this entity, only for one of the
overwritten ones.
Only for entity. */
peculiarity_existent /**< The entity/type (can) exist. */
peculiarity_existent /**< The entity/type (can) exist.
@@@ eventually rename to 'real' i.e., 'echt'
This serves better as opposition to description _and_ inherited.*/
} peculiarity;
char *get_peculiarity_string(peculiarity p);
......
......@@ -24,9 +24,9 @@
*
* VAR_A is some extern variable.
*
* main(int a) { /* pos 0 *
* int b = 1; /* pos 1 *
* int h; /* pos 2 *
* main(int a) { // pos 0
* int b = 1; // pos 1
* int h; // pos 2
*
* while (0 == 0) loop {
* h = a;
......
......@@ -23,9 +23,9 @@
* This file constructs the ir for the following pseudo-program:
*
* main() {
* int a = 0; /* pos 0 *
* int b = 1; /* pos 1 *
* int h; /* pos 2 *
* int a = 0; // pos 0
* int b = 1; // pos 1
* int h; // pos 2
*
* if (0 == 0)
* { a = 2; }
......
......@@ -4,18 +4,20 @@ layoutalgorithm: mindepth
manhattan_edges: yes
port_sharing: no
orientation: bottom_to_top
classname 1: "Data"
classname 2: "Block"
classname 13:"Control Flow"
classname 14:"Memory"
classname 15:"Dominators"
classname 3: "Entity type"
classname 4: "Entity owner"
classname 5: "Method Param"
classname 6: "Method Res"
classname 7: "Super"
classname 8: "Union"
classname 9: "Points-to"
classname 1: "intrablock Data"
classname 16: "interblock Data"
classname 2: "Block"
classname 13: "Control Flow"
classname 14: "intrablock Memory"
classname 17: "interblock Memory"
classname 15: "Dominators"
classname 3: "Entity type"
classname 4: "Entity owner"
classname 5: "Method Param"
classname 6: "Method Res"
classname 7: "Super"
classname 8: "Union"
classname 9: "Points-to"
classname 10: "Array Element Type"
classname 11: "Overwrites"
classname 12: "Member"
......
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