Commit c80c368f authored by Michael Beck's avatar Michael Beck
Browse files

removed gloval intraprocedural_view variable and replaced by get_*() set_*() functions

[r4267]
parent a8906329
......@@ -178,7 +178,7 @@ static int graph_cmp(const void *elt, const void *key) {
void compute_callgraph(void) {
int i, n_irgs = get_irp_n_irgs();
assert(interprocedural_view == 0); /* Else walking will not reach the Call nodes. */
assert(! get_interprocedural_view()); /* Else walking will not reach the Call nodes. */
/* initialize */
free_callgraph();
......@@ -588,8 +588,8 @@ is_endless_head (ir_graph *n, ir_graph *root)
static bool
is_ip_head (ir_graph *n, ir_graph *pred)
{
int iv_rem = interprocedural_view;
interprocedural_view = 1;
int iv_rem = get_interprocedural_view();
set_interprocedural_view(true);
ir_node *sblock = get_irg_start_block(n);
int i, arity = get_Block_n_cfgpreds(sblock);
int is_be = 0;
......@@ -611,7 +611,7 @@ is_ip_head (ir_graph *n, ir_graph *pred)
}
}
interprocedural_view = iv_rem;
set_interprocedural_view(iv_rem);
return is_be;
}
......
......@@ -11,6 +11,7 @@
*/
#include "irnode_t.h"
#include "irgraph_t.h"
#include "array.h"
#include "irbackedge_t.h"
......@@ -30,7 +31,7 @@ static INLINE int *mere_get_backarray(ir_node *n) {
switch (get_irn_opcode(n)) {
case iro_Block:
if (!get_Block_matured(n)) return NULL;
if (interprocedural_view && n->attr.block.in_cg) {
if (get_interprocedural_view() && n->attr.block.in_cg) {
assert(n->attr.block.cg_backedge && "backedge array not allocated!");
return n->attr.block.cg_backedge;
} else {
......@@ -43,7 +44,7 @@ static INLINE int *mere_get_backarray(ir_node *n) {
return n->attr.phi_backedge;
break;
case iro_Filter:
if (interprocedural_view) {
if (get_interprocedural_view()) {
assert(n->attr.filter.backedge && "backedge array not allocated!");
return n->attr.filter.backedge;
}
......@@ -89,9 +90,9 @@ INLINE void fix_backedges(struct obstack *obst, ir_node *n) {
if (ARR_LEN(arr) != ARR_LEN(get_irn_in(n))-1) {
arr = new_backedge_arr(obst, ARR_LEN(get_irn_in(n))-1);
if (opc == iro_Phi) n->attr.phi_backedge = arr;
if ((opc == iro_Block) && !interprocedural_view)
if ((opc == iro_Block) && !get_interprocedural_view())
n->attr.block.backedge = arr;
if ((opc == iro_Block) && interprocedural_view)
if ((opc == iro_Block) && get_interprocedural_view())
n->attr.block.cg_backedge = arr;
if (opc == iro_Filter) n->attr.filter.backedge = arr;
return;
......@@ -140,21 +141,21 @@ bool has_backedges (ir_node *n) {
/** Sets all backedge information to zero. */
void clear_backedges (ir_node *n) {
int i, arity;
int rem = interprocedural_view;
int rem = get_interprocedural_view();
int *ba;
interprocedural_view = 0;
set_interprocedural_view(false);
ba = get_backarray (n);
if (ba) {
arity = get_irn_arity(n);
for (i = 0; i < arity; i++)
ba[i] = 0;
}
interprocedural_view = 1;
set_interprocedural_view(true);
ba = get_backarray (n);
if (ba) {
arity = get_irn_arity(n);
for (i = 0; i < arity; i++)
ba[i] = 0;
}
interprocedural_view = rem;
set_interprocedural_view(rem);
}
......@@ -578,7 +578,7 @@ int construct_cf_backedges(ir_graph *irg) {
ir_node *end = get_irg_end(irg);
int i;
assert(!interprocedural_view &&
assert(!get_interprocedural_view() &&
"use construct_ip_backedges");
max_loop_depth = 0;
......@@ -611,7 +611,7 @@ int construct_cf_backedges(ir_graph *irg) {
int construct_ip_cf_backedges (void) {
ir_graph *rem = current_ir_graph;
int rem_ipv = interprocedural_view;
int rem_ipv = get_interprocedural_view();
int i;
assert(get_irp_ip_view_state() == ip_view_valid);
......@@ -622,7 +622,7 @@ int construct_ip_cf_backedges (void) {
current_loop = NULL;
new_loop(); /* sets current_loop */
interprocedural_view = 1;
set_interprocedural_view(true);
inc_max_irg_visited();
for (i = 0; i < get_irp_n_irgs(); i++)
......@@ -677,19 +677,19 @@ int construct_ip_cf_backedges (void) {
assert(get_irg_loop(outermost_ir_graph)->kind == k_ir_loop);
current_ir_graph = rem;
interprocedural_view = rem_ipv;
set_interprocedural_view(rem_ipv);
return max_loop_depth;
}
static void reset_backedges(ir_node *n) {
assert(is_Block(n));
int rem = interprocedural_view;
interprocedural_view = 1;
int rem = get_interprocedural_view();
set_interprocedural_view(true);
clear_backedges(n);
interprocedural_view = 0;
set_interprocedural_view(false);
clear_backedges(n);
interprocedural_view = rem;
set_interprocedural_view(rem);
}
static void loop_reset_backedges(ir_loop *l) {
......@@ -715,10 +715,10 @@ void free_cfloop_information(ir_graph *irg) {
void free_all_cfloop_information (void) {
int i;
int rem = interprocedural_view;
interprocedural_view = 1; /* To visit all filter nodes */
int rem = get_interprocedural_view();
set_interprocedural_view(true); /* To visit all filter nodes */
for (i = 0; i < get_irp_n_irgs(); i++) {
free_cfloop_information(get_irp_irg(i));
}
interprocedural_view = rem;
set_interprocedural_view(rem);
}
......@@ -579,7 +579,7 @@ static bool is_outermost_Start(ir_node *n) {
Besides current_ir_graph is not set properly. */
if ((get_irn_op(n) == op_Block) &&
(n == get_irg_start_block(current_ir_graph))) {
if ((!interprocedural_view) ||
if ((!get_interprocedural_view()) ||
(current_ir_graph == outermost_ir_graph))
return true;
}
......@@ -602,7 +602,7 @@ get_start_index(ir_node *n) {
test showed the loop tree is deeper. */
if (get_irn_op(n) == op_Phi ||
get_irn_op(n) == op_Block ||
(get_irn_op(n) == op_Filter && interprocedural_view) ||
(get_irn_op(n) == op_Filter && get_interprocedural_view()) ||
(get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats &&
get_irn_pinned(n) == op_pin_state_floats))
// Here we could test for backedge at -1 which is illegal
......@@ -650,7 +650,7 @@ INLINE static bool is_possible_loop_head(ir_node *n) {
ir_op *op = get_irn_op(n);
return ((op == op_Block) ||
(op == op_Phi) ||
((op == op_Filter) && interprocedural_view));
((op == op_Filter) && get_interprocedural_view()));
}
/* Returns true if n is a loop header, i.e., it is a Block, Phi
......@@ -1137,7 +1137,7 @@ int construct_backedges(ir_graph *irg) {
ir_graph *rem = current_ir_graph;
ir_loop *head_rem;
assert(!interprocedural_view &&
assert(!get_interprocedural_view() &&
"not implemented, use construct_ip_backedges");
max_loop_depth = 0;
......@@ -1175,7 +1175,7 @@ int construct_backedges(ir_graph *irg) {
int construct_ip_backedges (void) {
ir_graph *rem = current_ir_graph;
int rem_ipv = interprocedural_view;
int rem_ipv = get_interprocedural_view();
int i;
max_loop_depth = 0;
......@@ -1187,7 +1187,7 @@ int construct_ip_backedges (void) {
current_loop = NULL;
new_loop(); /* sets current_loop */
interprocedural_view = 1;
set_interprocedural_view(true);
inc_max_irg_visited();
for (i = 0; i < get_irp_n_irgs(); i++)
......@@ -1239,13 +1239,13 @@ int construct_ip_backedges (void) {
assert(get_irg_loop(outermost_ir_graph)->kind == k_ir_loop);
current_ir_graph = rem;
interprocedural_view = rem_ipv;
set_interprocedural_view(rem_ipv);
return max_loop_depth;
}
void my_construct_ip_backedges (void) {
ir_graph *rem = current_ir_graph;
int rem_ipv = interprocedural_view;
int rem_ipv = get_interprocedural_view();
int i;
assert(get_irp_ip_view_state() == ip_view_valid);
......@@ -1256,7 +1256,7 @@ void my_construct_ip_backedges (void) {
current_loop = NULL;
new_loop(); /* sets current_loop */
interprocedural_view = 1;
set_interprocedural_view(true);
inc_max_irg_visited();
for (i = 0; i < get_irp_n_irgs(); i++)
......@@ -1308,17 +1308,18 @@ void my_construct_ip_backedges (void) {
assert(get_irg_loop(outermost_ir_graph)->kind == k_ir_loop);
current_ir_graph = rem;
interprocedural_view = rem_ipv;
set_interprocedural_view(rem_ipv);
}
static void reset_backedges(ir_node *n) {
if (is_possible_loop_head(n)) {
int rem = interprocedural_view;
interprocedural_view = 1;
int rem = get_interprocedural_view();
set_interprocedural_view(true);
clear_backedges(n);
interprocedural_view = 0;
set_interprocedural_view(true);
clear_backedges(n);
interprocedural_view = rem;
set_interprocedural_view(rem);
}
}
......@@ -1358,12 +1359,12 @@ void free_loop_information(ir_graph *irg) {
void free_all_loop_information (void) {
int i;
int rem = interprocedural_view;
interprocedural_view = 1; /* To visit all filter nodes */
int rem = get_interprocedural_view();
set_interprocedural_view(true); /* To visit all filter nodes */
for (i = 0; i < get_irp_n_irgs(); i++) {
free_loop_information(get_irp_irg(i));
}
interprocedural_view = rem;
set_interprocedural_view(rem);
}
......
......@@ -23,6 +23,7 @@
#include "irnode_t.h"
#include "irprog_t.h"
#include "irgraph_t.h"
#include "eset.h"
#include "irgwalk.h"
......@@ -227,9 +228,9 @@ static int rta_fill_incremental (void)
int i;
int n_runs = 0;
int rerun = TRUE;
int old_ip_view = interprocedural_view;
int old_ip_view = get_interprocedural_view();
interprocedural_view = 0; /* save this for later */
set_interprocedural_view(false); /* save this for later */
/* init_tables has added main_irg to _live_graphs */
......@@ -279,7 +280,7 @@ static int rta_fill_incremental (void)
n_runs ++;
}
interprocedural_view = old_ip_view; /* cover up our traces */
set_interprocedural_view(old_ip_view); /* cover up our traces */
return (n_runs);
}
......@@ -520,6 +521,9 @@ void rta_report (void)
/*
* $Log$
* Revision 1.28 2004/11/03 14:47:18 beck
* removed gloval intraprocedural_view variable and replaced by get_*() set_*() functions
*
* Revision 1.27 2004/10/21 07:23:34 goetz
* comments
*
......
......@@ -330,7 +330,7 @@ static void collect_node(ir_node * node, void *env) {
* graphs not visited.
* Free the list with DEL_ARR_F. */
static ir_node ** construct_block_lists(ir_graph *irg) {
int i, rem_view = interprocedural_view;
int i, rem_view = get_interprocedural_view();
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
......@@ -340,12 +340,12 @@ static ir_node ** construct_block_lists(ir_graph *irg) {
irg_walk_graph(current_ir_graph, clear_link, collect_node, current_ir_graph);
/* Collect also EndReg and EndExcept. We do not want to change the walker. */
interprocedural_view = 0;
set_interprocedural_view(false);
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph)-1);
irg_walk(get_irg_end_reg(current_ir_graph), clear_link, collect_node, current_ir_graph);
set_irg_visited(current_ir_graph, get_irg_visited(current_ir_graph)-1);
irg_walk(get_irg_end_except(current_ir_graph), clear_link, collect_node, current_ir_graph);
interprocedural_view = rem_view;
set_interprocedural_view(rem_view);
current_ir_graph = rem;
return ird_get_irg_link(irg);
......@@ -479,8 +479,10 @@ dump_node_opcode(FILE *F, ir_node *n)
} break;
case iro_Filter: {
if (!interprocedural_view) fprintf(F, "Proj'");
else goto default_case;
if (!get_interprocedural_view())
fprintf(F, "Proj'");
else
goto default_case;
} break;
case iro_Proj: {
......@@ -501,7 +503,7 @@ dump_node_opcode(FILE *F, ir_node *n)
case iro_End:
case iro_EndExcept:
case iro_EndReg: {
if (interprocedural_view) {
if (get_interprocedural_view()) {
fprintf(F, "%s %s", get_irn_opname(n), get_ent_dump_name(get_irg_entity(get_irn_irg(n))));
break;
} else
......@@ -581,7 +583,7 @@ dump_node_nodeattr(FILE *F, ir_node *n)
switch (get_irn_opcode(n)) {
case iro_Start:
if (false && interprocedural_view) {
if (false && get_interprocedural_view()) {
fprintf (F, "%s", get_ent_dump_name(get_irg_entity(current_ir_graph)));
}
break;
......@@ -686,7 +688,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n)
fprintf(F, "arity: %d", get_irn_arity(n));
if ((get_irn_op(n) == op_Block) ||
(get_irn_op(n) == op_Phi) ||
((get_irn_op(n) == op_Filter) && interprocedural_view)) {
((get_irn_op(n) == op_Filter) && get_interprocedural_view())) {
fprintf(F, " backedges:");
comma = ' ';
for (i = 0; i < get_irn_arity(n); i++)
......@@ -710,7 +712,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n)
fprintf(F, "start of method of type %s \n", get_type_name_ex(tp, &bad));
for (i = 0; i < get_method_n_params(tp); ++i)
fprintf(F, " param %d type: %s \n", i, get_type_name_ex(get_method_param_type(tp, i), &bad));
if ((get_irp_ip_view_state() == ip_view_valid) && !interprocedural_view) {
if ((get_irp_ip_view_state() == ip_view_valid) && !get_interprocedural_view()) {
ir_node *sbl = get_nodes_block(n);
int i, n_cfgpreds = get_Block_cg_n_cfgpreds(sbl);
fprintf(F, "graph has %d interprocedural predecessors:\n", n_cfgpreds);
......@@ -773,13 +775,13 @@ static INLINE int dump_node_info(FILE *F, ir_node *n)
}
} break;
case iro_Return: {
if (!interprocedural_view) {
if (!get_interprocedural_view()) {
type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
fprintf(F, "return in method of type %s \n", get_type_name_ex(tp, &bad));
for (i = 0; i < get_method_n_ress(tp); ++i)
fprintf(F, " res %d type: %s \n", i, get_type_name_ex(get_method_res_type(tp, i), &bad));
fprintf(F, " res %d type: %s \n", i, get_type_name_ex(get_method_res_type(tp, i), &bad));
}
} break;
} break;
case iro_Const: {
type *tp = get_Const_type(n);
assert(tp != none_type);
......@@ -805,7 +807,7 @@ static INLINE int dump_node_info(FILE *F, ir_node *n)
} break;
case iro_Filter: {
int i;
if (interprocedural_view) {
if (get_interprocedural_view()) {
fprintf(F, "intra predecessor nodes:\n");
for (i = 0; i < get_irn_intra_arity(n); i++) {
ir_node *pred = get_irn_intra_n(n, i);
......@@ -1091,7 +1093,7 @@ dump_ir_data_edges(FILE *F, ir_node *n) {
ir_node * pred = get_irn_n(n, i);
assert(pred);
if ((interprocedural_view && get_irn_visited(pred) < visited))
if ((get_interprocedural_view() && get_irn_visited(pred) < visited))
continue; /* pred not dumped */
if (dump_backedge_information_flag && is_backedge(n, i))
......@@ -1889,8 +1891,8 @@ dump_ir_graph (ir_graph *irg, const char *suffix )
if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0) return;
current_ir_graph = irg;
if (interprocedural_view) suffix1 = "-pure-ip";
else suffix1 = "-pure";
if (get_interprocedural_view()) suffix1 = "-pure-ip";
else suffix1 = "-pure";
f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
......@@ -1919,8 +1921,8 @@ dump_ir_block_graph (ir_graph *irg, const char *suffix)
if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0)
return;
if (interprocedural_view) suffix1 = "-ip";
else suffix1 = "";
if (get_interprocedural_view()) suffix1 = "-ip";
else suffix1 = "";
f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
......@@ -1952,8 +1954,8 @@ dump_ir_graph_w_types (ir_graph *irg, const char *suffix)
current_ir_graph = irg;
if (interprocedural_view) suffix1 = "-pure-wtypes-ip";
else suffix1 = "-pure-wtypes";
if (get_interprocedural_view()) suffix1 = "-pure-wtypes-ip";
else suffix1 = "-pure-wtypes";
f = vcg_open(irg,suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
......@@ -1981,8 +1983,8 @@ dump_ir_block_graph_w_types (ir_graph *irg, const char *suffix)
if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0)
return;
if (interprocedural_view) suffix1 = "-wtypes-ip";
else suffix1 = "-wtypes";
if (get_interprocedural_view()) suffix1 = "-wtypes-ip";
else suffix1 = "-wtypes";
f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
......@@ -2087,7 +2089,7 @@ dump_cfg (ir_graph *irg, const char *suffix)
FILE *f;
ir_graph *rem = current_ir_graph;
int ddif = dump_dominator_information_flag;
int ipv = interprocedural_view;
int ipv = get_interprocedural_view();
/* if a filter is set, dump only the irg's that match the filter */
if (strncmp(get_entity_name(get_irg_entity(irg)), dump_file_filter, strlen(dump_file_filter)) != 0)
......@@ -2098,9 +2100,9 @@ dump_cfg (ir_graph *irg, const char *suffix)
f = vcg_open(irg, suffix, "-cfg");
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
if (interprocedural_view) {
if (ipv) {
printf("Warning: dumping cfg not in interprocedural view!\n");
interprocedural_view = 0;
set_interprocedural_view(false);
}
if (get_irg_dom_state(irg) != dom_consistent)
......@@ -2111,7 +2113,7 @@ dump_cfg (ir_graph *irg, const char *suffix)
dump_node(f, get_irg_bad(irg));
dump_dominator_information_flag = ddif;
interprocedural_view = ipv;
set_interprocedural_view(ipv);
vcg_close(f);
current_ir_graph = rem;
}
......@@ -2194,8 +2196,8 @@ void dump_callgraph(const char *suffix) {
void dump_all_cg_block_graph(const char *suffix) {
FILE *f;
int i;
int rem_view = interprocedural_view;
interprocedural_view = 1;
int rem_view = get_interprocedural_view();
set_interprocedural_view(true);
f = vcg_open_name("All_graphs", suffix);
dump_vcg_header(f, "All_graphs", NULL);
......@@ -2215,7 +2217,7 @@ void dump_all_cg_block_graph(const char *suffix) {
}
vcg_close(f);
interprocedural_view = rem_view;
set_interprocedural_view(rem_view);
}
/***********************************************************************/
......
......@@ -483,7 +483,7 @@ copy_graph_env (int copy_node_nr) {
void
dead_node_elimination(ir_graph *irg) {
ir_graph *rem;
int rem_ipview = interprocedural_view;
int rem_ipview = get_interprocedural_view();
struct obstack *graveyard_obst = NULL;
struct obstack *rebirth_obst = NULL;
......@@ -493,7 +493,7 @@ dead_node_elimination(ir_graph *irg) {
/* Remember external state of current_ir_graph. */
rem = current_ir_graph;
current_ir_graph = irg;
interprocedural_view = 0;
set_interprocedural_view(false);
/* Handle graph state */
assert(get_irg_phase_state(current_ir_graph) != phase_building);
......@@ -529,7 +529,7 @@ dead_node_elimination(ir_graph *irg) {
stat_dead_node_elim_stop(irg);
current_ir_graph = rem;
interprocedural_view = rem_ipview;
set_interprocedural_view(rem_ipview);
}
/**
......
......@@ -19,6 +19,7 @@
# include "ircons.h"
# include "irgraph_t.h"
# include "irprog_t.h"
# include "irnode_t.h"
# include "iropt_t.h"
# include "irflag_t.h"
# include "array.h"
......@@ -36,12 +37,24 @@ INLINE void set_current_ir_graph(ir_graph *graph) {
}
bool interprocedural_view = false;
INLINE bool get_interprocedural_view(void) {
return interprocedural_view;
int __interprocedural_view = false;
int (get_interprocedural_view)(void) {
return __get_interprocedural_view();
}
INLINE void set_interprocedural_view(bool state) {
interprocedural_view = state;
void (set_interprocedural_view)(int state) {
__interprocedural_view = state;
/* set function vectors for faster access */
if (state) {
__get_irn_arity = __get_irn_inter_arity;
__get_irn_n = __get_irn_inter_n;
}
else {
__get_irn_arity = __get_irn_intra_arity;
__get_irn_n = __get_irn_intra_n;
}
}
static ident* frame_type_suffix = NULL;
......
......@@ -88,9 +88,8 @@ void set_current_ir_graph(ir_graph *graph);
/** This flag indicate the current view. The behaviour of some methods
* (get_irn_*, set_irn_*) is influenced by this flag. */
extern bool interprocedural_view;
bool get_interprocedural_view(void);
void set_interprocedural_view(bool state);
int get_interprocedural_view(void);
void set_interprocedural_view(int state);
/** Create a new ir graph to built ir for a procedure.
*
......
......@@ -143,6 +143,13 @@ int node_is_in_irgs_storage(ir_graph *irg, ir_node *n);
/* inline functions for graphs */
/*-------------------------------------------------------------------*/
extern int __interprocedural_view;
static INLINE int
__get_interprocedural_view(void) {
return __interprocedural_view;
}
static INLINE int
__is_ir_graph(void *thing) {
return (get_kind(thing) == k_ir_graph);
......@@ -435,6 +442,7 @@ __inc_irg_block_visited(ir_graph *irg)
++irg->block_visited;
}
#define get_interprocedural_view() __get_interprocedural_view()
#define is_ir_graph(thing) __is_ir_graph(thing)
#define get_irg_start_block(irg) __get_irg_start_block(irg)
#define set_irg_start_block(irg, node) __set_irg_start_block(irg, node)
......
......@@ -208,16 +208,16 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env)
{
assert(node && node->kind==k_ir_node);
if (interprocedural_view) {
if (get_interprocedural_view()) {
eset * irg_set = eset_create();
int visited;
ir_graph * irg;
assert(get_irp_ip_view_state() == ip_view_valid);
interprocedural_view = false;
set_interprocedural_view(false);
eset_insert(irg_set, current_ir_graph);
irg_walk(node, (irg_walk_func *) collect_irgs, NULL, irg_set);
interprocedural_view = true;
set_interprocedural_view(true);
visited = get_max_irg_visited() + 1;
for (irg = eset_first(irg_set); irg; irg = eset_next(irg_set)) {
set_irg_visited(irg, visited);
......@@ -266,14 +266,14 @@ static INLINE ir_graph *
switch_irg (ir_node *n, int index) {
ir_graph *old_current = current_ir_graph;