Commit 8fd12b17 authored by Matthias Braun's avatar Matthias Braun
Browse files

fixed/warnings make it possible to build without interprocedural view and...

fixed/warnings make it possible to build without interprocedural view and enable that mode by default

[r16182]
parent 75e3b5fe
......@@ -94,6 +94,7 @@ int get_irg_loop_depth(ir_graph *irg);
this irg. */
int get_irg_recursion_depth(ir_graph *irg);
#ifdef INTERPROCEDURAL_VIEW
/** Returns the method execution frequency of a graph. */
double get_irg_method_execution_frequency(ir_graph *irg);
......@@ -180,5 +181,7 @@ void set_irp_loop_nesting_depth_state(loop_nesting_depth_sta
/** Marks the nesting depth state of the program representation as inconsistent. */
void set_irp_loop_nesting_depth_state_inconsistent(void);
#endif
#endif /* _CALLGRAPH_H_ */
......@@ -28,6 +28,10 @@
#ifndef FIRM_IR_IRCGCONS_H
#define FIRM_IR_IRCGCONS_H
#include "firm_config.h"
#ifdef INTERPROCEDURAL_VIEW
#include "firm_types.h"
/** Return the current state of the interprocedural view. */
......@@ -53,3 +57,5 @@ void cg_construct(int arr_len, ir_entity *free_methods_arr[]);
void cg_destruct(void);
#endif
#endif
......@@ -125,10 +125,14 @@ extern ir_graph *current_ir_graph;
ir_graph *get_current_ir_graph(void);
void set_current_ir_graph(ir_graph *graph);
#ifdef INTERPROCEDURAL_VIEW
/** This flag indicate the current view. The behavior of some methods
* (get_irn_*, set_irn_*) is influenced by this flag. */
int get_interprocedural_view(void);
void set_interprocedural_view(int state);
#else
#define get_interprocedural_view() 0
#endif
/**
* Create a new ir graph to build ir for a procedure.
......
......@@ -121,6 +121,7 @@ void irg_walk_in_or_dep_graph(ir_graph *irg, irg_walk_func *pre, irg_walk_func *
*/
void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
#ifdef INTERPROCEDURAL_VIEW
/**
* Walks all irgs in interprocedural view.
*
......@@ -132,6 +133,7 @@ void all_irg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
* Visits each node only once. Sets current_ir_graph properly. Does not use the link field.
*/
void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env);
#endif
/** Walks only over Block nodes in the graph.
*
......
......@@ -48,10 +48,12 @@
*/
/* ------------------------------------------------------------------- */
#ifdef INTERPROCEDURAL_VIEW
/** Returns true if the predecessor pos is a backedge in the interprozeduralem view. */
int is_inter_backedge(ir_node *n, int pos);
/** Returns true if the predecessor pos is a backedge in the intraprocedural view. */
int is_intra_backedge(ir_node *n, int pos);
#endif
/** Returns non-zero if the predecessor pos is a backedge. */
int is_backedge (ir_node *n, int pos);
/** Marks edge pos as a backedge. */
......@@ -151,6 +153,7 @@ void *get_loop_link (const ir_loop *loop);
/* @@@ Well, maybe construct_loop_information or analyze_loops ? */
int construct_backedges(ir_graph *irg);
#ifdef INTERPROCEDURAL_VIEW
/** Constructs backedges for all irgs in interprocedural view.
*
* @see As construct_backedges(), but for interprocedural view.
......@@ -164,6 +167,7 @@ int construct_backedges(ir_graph *irg);
* @returns Maximal depth of loop tree.
*/
int construct_ip_backedges(void);
#endif
/** Construct loop tree only for control flow.
*
......@@ -180,11 +184,13 @@ int construct_ip_backedges(void);
*/
int construct_cf_backedges(ir_graph *irg);
#ifdef INTERPROCEDURAL_VIEW
/** Construct interprocedural loop tree for control flow.
*
* @see construct_cf_backedges() and construct_ip_backedges().
*/
int construct_ip_cf_backedges (void);
#endif
/** Removes all loop information.
* Resets all backedges. Works for any construction algorithm.
......
......@@ -381,6 +381,7 @@ void mark_Block_block_visited(ir_node *node);
int Block_not_block_visited(const ir_node *node);
int Block_block_visited(const ir_node *node);
#ifdef INTERPROCEDURAL_VIEW
/* Set and remove interprocedural predecessors. If the interprocedural
* predecessors are removed, the node has the same predecessors in
* both views.
......@@ -395,6 +396,8 @@ int get_Block_cg_n_cfgpreds(ir_node *node);
ir_node *get_Block_cg_cfgpred(ir_node *node, int pos);
/** Frees the memory allocated for interprocedural predecessors. */
void remove_Block_cg_cfgpred_arr(ir_node *node);
#endif
/** Returns the extended basic block a block belongs to. */
ir_extblk *get_Block_extbb(const ir_node *block);
/** Sets the extended basic block a block belongs to. */
......
......@@ -88,10 +88,13 @@ void compute_irp_outs(void);
void assure_irg_outs(ir_graph *irg);
#ifdef INTERPROCEDURAL_VIEW
/** Computes the out edges in interprocedural view */
void compute_ip_outs(void);
/** Frees the out datastructures. Sets the flag in irg to "outs_none". */
void free_ip_outs(void);
#endif
void free_irg_outs(ir_graph *irg);
void free_irp_outs(void);
......
......@@ -28,6 +28,8 @@
# include "config.h"
#endif
#ifdef INTERPROCEDURAL_VIEW
#ifdef HAVE_STRING_H
# include <string.h>
#endif
......@@ -79,6 +81,7 @@ ir_graph *get_irg_caller(ir_graph *irg, int pos) {
return NULL;
}
#ifdef INTERPROCEDURAL_VIEW
/* Returns non-zero if the caller at position pos is "a backedge", i.e. a recursion. */
int is_irg_caller_backedge(ir_graph *irg, int pos) {
assert (pos >= 0 && pos < get_irg_n_callers(irg));
......@@ -110,6 +113,7 @@ int has_irg_caller_backedge(ir_graph *irg) {
}
return 0;
}
#endif
/**
* Find the reversion position of a caller.
......@@ -172,6 +176,7 @@ int has_irg_callee_backedge(ir_graph *irg) {
return 0;
}
#ifdef INTERPROCEDURAL_VIEW
/**
* Mark the callee at position pos as a backedge.
*/
......@@ -185,6 +190,7 @@ static void set_irg_callee_backedge(ir_graph *irg, int pos) {
irg->callee_isbe = xcalloc(n, sizeof(irg->callee_isbe[0]));
irg->callee_isbe[pos] = 1;
}
#endif
/* Returns the maximal loop depth of call nodes that call along this edge. */
int get_irg_callee_loop_depth(ir_graph *irg, int pos) {
......@@ -409,8 +415,10 @@ static ir_loop *current_loop; /**< Current cfloop construction is working
static int loop_node_cnt = 0; /**< Counts the number of allocated cfloop nodes.
Each cfloop node gets a unique number.
What for? ev. remove. @@@ */
#ifdef INTERPROCEDURAL_VIEW
static int current_dfn = 1; /**< Counter to generate depth first numbering
of visited nodes. */
#endif
/*-----------------*/
......@@ -580,6 +588,7 @@ static INLINE void pop_scc_to_loop(ir_graph *irg) {
} while(m != irg);
}
#ifdef INTERPROCEDURAL_VIEW
/* GL ??? my last son is my grandson??? Removes cfloops with no
ir_nodes in them. Such loops have only another loop as son. (Why
can't they have two loops as sons? Does it never get that far? ) */
......@@ -605,6 +614,7 @@ static void close_loop(ir_loop *l) {
current_loop = l;
}
#endif
/**
* Removes and unmarks all nodes up to n from the stack.
......@@ -623,6 +633,7 @@ static INLINE void pop_scc_unmark_visit(ir_graph *n) {
/* The loop data structure. **/
/**********************************************************************/
#ifdef INTERPROCEDURAL_VIEW
/**
* Allocates a new loop as son of current_loop. Sets current_loop
* to the new loop and returns the father.
......@@ -738,7 +749,6 @@ is_endless_head(ir_graph *n, ir_graph *root)
return !some_outof_loop & some_in_loop;
}
/**
* Check whether there is a parallel edge in the ip control flow.
* Only
......@@ -946,7 +956,6 @@ find_tail(ir_graph *n) {
}
#endif
/*-----------------------------------------------------------*
* The core algorithm. *
*-----------------------------------------------------------*/
......@@ -1041,6 +1050,7 @@ static void reset_isbe(void) {
irg->callee_isbe = NULL;
}
}
#endif
......@@ -1182,6 +1192,7 @@ static void compute_rec_depth (ir_graph *irg, void *env) {
/* nodes to evaluate a callgraph edge. */
/* ----------------------------------------------------------------------------------- */
#ifdef INTERPROCEDURAL_VIEW
/* Returns the method execution frequency of a graph. */
double get_irg_method_execution_frequency (ir_graph *irg) {
return irg->method_execution_frequency;
......@@ -1376,6 +1387,7 @@ void compute_performance_estimates(void) {
}
}
}
#endif
/* Returns the maximal loop depth of all paths from an external visible method to
this irg. */
......@@ -1424,3 +1436,5 @@ void set_irp_loop_nesting_depth_state_inconsistent(void) {
if (irp->lnd_state == loop_nesting_depth_consistent)
irp->lnd_state = loop_nesting_depth_inconsistent;
}
#endif
......@@ -28,6 +28,8 @@
# include "config.h"
#endif
#ifdef INTERPROCEDURAL_VIEW
#include <math.h>
#include "field_temperature.h"
......@@ -402,3 +404,5 @@ int is_jack_rts_entity(ir_entity *e) {
}
#endif /* if 0 */
#endif
......@@ -134,6 +134,7 @@ void fix_backedges(struct obstack *obst, ir_node *n) {
}*/
}
#ifdef INTERPROCEDURAL_VIEW
int is_inter_backedge(ir_node *n, int pos) {
int res;
int rem = get_interprocedural_view();
......@@ -151,6 +152,7 @@ int is_intra_backedge(ir_node *n, int pos) {
set_interprocedural_view(rem);
return res;
}
#endif
/* Returns non-zero if the predecessor pos is a backedge. */
......@@ -189,15 +191,18 @@ int has_backedges (ir_node *n) {
/** Sets all backedge information to zero. */
void clear_backedges (ir_node *n) {
int i, arity;
int rem = get_interprocedural_view();
int *ba;
#ifdef INTERPROCEDURAL_VIEW
int rem = get_interprocedural_view();
set_interprocedural_view(0);
#endif
ba = get_backarray (n);
if (ba) {
arity = get_irn_arity(n);
for (i = 0; i < arity; i++)
ba[i] = 0;
}
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(1);
ba = get_backarray (n);
if (ba) {
......@@ -206,6 +211,7 @@ void clear_backedges (ir_node *n) {
ba[i] = 0;
}
set_interprocedural_view(rem);
#endif
}
int *new_backedge_arr(struct obstack *obst, int size) {
......
......@@ -332,6 +332,7 @@ init_scc (ir_graph *irg) {
irg_walk_graph(irg, init_node, NULL, NULL);
}
#ifdef INTERPROCEDURAL_VIEW
/**
* Initializes the scc algorithm for the interprocedural case.
*/
......@@ -344,6 +345,7 @@ init_ip_scc (void) {
cg_walk (link_to_reg_end, NULL, NULL);
#endif
}
#endif
/**
* Condition for breaking the recursion: n is the block
......@@ -696,7 +698,7 @@ int construct_cf_backedges(ir_graph *irg) {
return max_loop_depth;
}
#ifdef INTERPROCEDURAL_VIEW
int construct_ip_cf_backedges (void) {
ir_graph *rem = current_ir_graph;
int rem_ipv = get_interprocedural_view();
......@@ -768,20 +770,27 @@ int construct_ip_cf_backedges (void) {
set_interprocedural_view(rem_ipv);
return max_loop_depth;
}
#endif
/**
* Clear the intra- and the interprocedural
* backedge information pf a block.
*/
static void reset_backedges(ir_node *block) {
int rem = get_interprocedural_view();
int rem;
assert(is_Block(block));
#ifdef INTERPROCEDURAL_VIEW
rem = get_interprocedural_view();
set_interprocedural_view(1);
clear_backedges(block);
set_interprocedural_view(0);
clear_backedges(block);
set_interprocedural_view(rem);
#else
(void) rem;
clear_backedges(block);
#endif
}
/**
......@@ -812,10 +821,14 @@ void free_cfloop_information(ir_graph *irg) {
void free_all_cfloop_information (void) {
int i;
#ifdef INTERPROCEDURAL_VIEW
int rem = get_interprocedural_view();
set_interprocedural_view(1); /* To visit all filter nodes */
#endif
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
free_cfloop_information(get_irp_irg(i));
}
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(rem);
#endif
}
......@@ -374,7 +374,6 @@ void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *po
int i;
assert(blk);
assert(!get_interprocedural_view()); /* interprocedural_view not implemented */
inc_irg_block_visited(current_ir_graph);
/* assure the start block is the first one */
......
......@@ -500,6 +500,7 @@ void free_irp_outs(void) {
*------------------------------------------------------------*/
#ifdef INTERPROCEDURAL_VIEW
/**
* Inits the number of outedges for each node
* before counting.
......@@ -531,7 +532,6 @@ static void node_arity_count(ir_node * node, void * env) {
}
}
/*
* Inits all nodes for setting the outedges
* Returns the overall count of edges
......@@ -626,6 +626,7 @@ void free_ip_outs(void) {
}
irp->outs_state = outs_none;
}
#endif
void free_irg_outs(ir_graph *irg) {
......
......@@ -544,6 +544,7 @@ init_scc (ir_graph *irg) {
*/
}
#ifdef INTERPROCEDURAL_VIEW
static INLINE void
init_ip_scc (void) {
init_scc_common();
......@@ -553,6 +554,7 @@ init_ip_scc (void) {
cg_walk (link_to_reg_end, NULL, NULL);
#endif
}
#endif
/* Condition for breaking the recursion. */
static int is_outermost_Start(ir_node *n) {
......@@ -1139,6 +1141,7 @@ int construct_backedges(ir_graph *irg) {
}
#ifdef INTERPROCEDURAL_VIEW
int construct_ip_backedges (void) {
ir_graph *rem = current_ir_graph;
int rem_ipv = get_interprocedural_view();
......@@ -1276,9 +1279,11 @@ void my_construct_ip_backedges (void) {
current_ir_graph = rem;
set_interprocedural_view(rem_ipv);
}
#endif
static void reset_backedges(ir_node *n) {
if (is_possible_loop_head(n)) {
#ifdef INTERPROCEDURAL_VIEW
int rem = get_interprocedural_view();
set_interprocedural_view(1);
......@@ -1286,6 +1291,9 @@ static void reset_backedges(ir_node *n) {
set_interprocedural_view(1);
clear_backedges(n);
set_interprocedural_view(rem);
#else
clear_backedges(n);
#endif
}
}
......@@ -1326,12 +1334,16 @@ void free_loop_information(ir_graph *irg) {
void free_all_loop_information (void) {
int i;
#ifdef INTERPROCEDURAL_VIEW
int rem = get_interprocedural_view();
set_interprocedural_view(1); /* To visit all filter nodes */
#endif
for (i = 0; i < get_irp_n_irgs(); i++) {
free_loop_information(get_irp_irg(i));
}
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(rem);
#endif
}
......
......@@ -123,7 +123,7 @@ static ir_type *find_type_for_Proj(ir_node *n) {
ir_type *mtp = get_Call_type(pred_pred);
tp = get_method_res_type(mtp, get_Proj_proj(n));
} else if (get_irn_op(pred_pred) == op_Tuple) {
assert(0 && "Encountered nested Tuple");
panic("Encountered nested Tuple");
} else {
VERBOSE_UNKNOWN_TYPE(("Proj %ld from Proj from ??: unknown type\n", get_irn_node_nr(n)));
tp = firm_unknown_type;
......
......@@ -244,9 +244,11 @@ static int rta_fill_incremental (void)
int i;
int n_runs = 0;
int rerun = TRUE;
#ifdef INTERPROCEDURAL_VIEW
int old_ip_view = get_interprocedural_view();
set_interprocedural_view(0); /* save this for later */
#endif
/* init_tables has added main_irg to _live_graphs */
......@@ -296,7 +298,9 @@ static int rta_fill_incremental (void)
n_runs ++;
}
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(old_ip_view); /* cover up our traces */
#endif
return (n_runs);
}
......
......@@ -47,10 +47,12 @@ static void count_nodes(ir_node *n, void *env) {
* totals. */
void print_graph_counts(int verbosity) {
int i, counter, total = 0;
int view = get_interprocedural_view();
ir_graph *old = current_ir_graph;
#ifdef INTERPROCEDURAL_VIEW
int view = get_interprocedural_view();
set_interprocedural_view(0);
#endif
for (i = 0; i < get_irp_n_irgs(); i++) {
counter = 0;
......@@ -62,7 +64,9 @@ void print_graph_counts(int verbosity) {
printf(" +++ There are %d graphs with total %d nodes.\n", get_irp_n_irgs(), total);
current_ir_graph = old;
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(view);
#endif
}
/** Prints number of types, number of entities and totals.
......
......@@ -29,10 +29,9 @@
# include "config.h"
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef INTERPROCEDURAL_VIEW
#include <string.h>
#include <stdbool.h>
#include "ircgcons.h"
......@@ -609,6 +608,7 @@ static bool is_outermost_graph(ir_graph *irg) {
return true;
}
#ifdef INTERPROCEDURAL_VIEW
/* Grundblock der Call-Operation aufteilen. CallBegin- und Filter-Operationen
* einfgen. Die Steuer- und Datenflussabhngigkeiten von den aufgerufenen
* Methoden auf die CallBegin-Operation, und von der Aufrufstelle auf die
......@@ -819,6 +819,7 @@ static void construct_call(ir_node * call) {
DEL_ARR_F(irgs);
DEL_ARR_F(data);
}
#endif
void cg_construct(int arr_len, ir_entity ** free_methods_arr) {
......@@ -925,3 +926,5 @@ void cg_destruct(void) {
set_irp_ip_view(ip_view_no);
}
}
#endif
......@@ -594,7 +594,9 @@ static void collect_node(ir_node * node, void *env) {
*/
static ir_node **construct_block_lists(ir_graph *irg) {
int i;
#ifdef INTERPROCEDURAL_VIEW
int rem_view = get_interprocedural_view();
#endif
int walk_flag = using_visited(irg);
ir_graph *rem = current_ir_graph;
......@@ -608,15 +610,19 @@ static ir_node **construct_block_lists(ir_graph *irg) {
ird_walk_graph(current_ir_graph, clear_link, collect_node, current_ir_graph);
#ifdef INTERPROCEDURAL_VIEW
/* Collect also EndReg and EndExcept. We do not want to change the walker. */
set_interprocedural_view(0);
#endif
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);
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(rem_view);
#endif
if(walk_flag)
set_using_visited(current_ir_graph);
......@@ -1122,13 +1128,17 @@ handle_lut:
#include "execution_frequency.h"
static void dump_node_ana_vals(FILE *F, ir_node *n) {
(void) F;
(void) n;
return;
#ifdef INTERPROCEDURAL_VIEW
fprintf(F, " %lf*(%2.0lf + %2.0lf) = %2.0lf ",
get_irn_exec_freq(n),
get_irg_method_execution_frequency(get_irn_irg(n)),
pow(5, get_irg_recursion_depth(get_irn_irg(n))),
get_irn_exec_freq(n) * (get_irg_method_execution_frequency(get_irn_irg(n)) + pow(5, get_irg_recursion_depth(get_irn_irg(n))))
);
#endif
}
......@@ -2728,21 +2738,27 @@ dump_cfg(ir_graph *irg, const char *suffix)
f = vcg_open(irg, suffix, "-cfg");
if (f != NULL) {
ir_graph *rem = current_ir_graph;
#ifdef INTERPROCEDURAL_VIEW
int ipv = get_interprocedural_view();
#endif
current_ir_graph = irg;
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
#ifdef INTERPROCEDURAL_VIEW
if (ipv) {
printf("Warning: dumping cfg not in interprocedural view!\n");
set_interprocedural_view(0);
}
#endif
/* walk over the blocks in the graph */
irg_block_walk(get_irg_end(irg), dump_block_to_cfg, NULL, f);
dump_node(f, get_irg_bad(irg));
#ifdef INTERPROCEDURAL_VIEW
set_interprocedural_view(ipv);
#endif
vcg_close(f);
current_ir_graph = rem;
}
......@@ -2782,7 +2798,7 @@ void dump_subgraph(ir_node *root, int depth, const char *suffix) {
}
}
#if 0
static int weight_overall(int rec, int loop) {
return 2*rec + loop;
}
......@@ -2828,24 +2844,29 @@ static int get_entity_color(ir_entity *ent) {
return my_overall_color;