From 8fd12b1714e2024889e81aa4b351d1b6640e1c79 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 12 Oct 2007 20:40:45 +0000 Subject: [PATCH] fixed/warnings make it possible to build without interprocedural view and enable that mode by default [r16182] --- include/libfirm/callgraph.h | 3 +++ include/libfirm/ircgcons.h | 6 ++++++ include/libfirm/irgraph.h | 4 ++++ include/libfirm/irgwalk.h | 2 ++ include/libfirm/irloop.h | 6 ++++++ include/libfirm/irnode.h | 3 +++ include/libfirm/irouts.h | 3 +++ ir/ana/callgraph.c | 18 ++++++++++++++++-- ir/ana/field_temperature.c | 4 ++++ ir/ana/irbackedge.c | 8 +++++++- ir/ana/ircfscc.c | 17 +++++++++++++++-- ir/ana/irextbb.c | 1 - ir/ana/irouts.c | 3 ++- ir/ana/irscc.c | 12 ++++++++++++ ir/ana/irsimpletype.c | 2 +- ir/ana/rta.c | 4 ++++ ir/common/statistics.c | 6 +++++- ir/ir/ircgcons.c | 9 ++++++--- ir/ir/irdump.c | 32 +++++++++++++++++++++++++++----- ir/ir/irdumptxt.c | 34 ++++++++++++++++++++++++++++++++++ ir/ir/irgopt.c | 6 ++++++ ir/ir/irgraph.c | 3 ++- ir/ir/irgraph_t.h | 16 +++++++++------- ir/ir/irgwalk.c | 7 ++++++- ir/ir/irgwalk_blk.c | 6 +++++- ir/ir/irnode.c | 2 ++ ir/ir/irnode_t.h | 10 ++++++++++ ir/ir/irtypes.h | 2 ++ ir/ir/irvrfy.c | 8 ++++++++ ir/lower/lower_hl.c | 2 ++ ir/tr/type.c | 5 +++++ 31 files changed, 217 insertions(+), 27 deletions(-) diff --git a/include/libfirm/callgraph.h b/include/libfirm/callgraph.h index 79d935341..63ad0311a 100644 --- a/include/libfirm/callgraph.h +++ b/include/libfirm/callgraph.h @@ -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_ */ diff --git a/include/libfirm/ircgcons.h b/include/libfirm/ircgcons.h index aad48408a..d001a3c5f 100644 --- a/include/libfirm/ircgcons.h +++ b/include/libfirm/ircgcons.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 diff --git a/include/libfirm/irgraph.h b/include/libfirm/irgraph.h index 0b065ffb7..2ed896860 100644 --- a/include/libfirm/irgraph.h +++ b/include/libfirm/irgraph.h @@ -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. diff --git a/include/libfirm/irgwalk.h b/include/libfirm/irgwalk.h index b2572d49e..496673012 100644 --- a/include/libfirm/irgwalk.h +++ b/include/libfirm/irgwalk.h @@ -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. * diff --git a/include/libfirm/irloop.h b/include/libfirm/irloop.h index b7d1180f9..f5c3a05cc 100644 --- a/include/libfirm/irloop.h +++ b/include/libfirm/irloop.h @@ -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. diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index e21c058ea..d51649ead 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -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. */ diff --git a/include/libfirm/irouts.h b/include/libfirm/irouts.h index 200a8546e..ef84bca41 100644 --- a/include/libfirm/irouts.h +++ b/include/libfirm/irouts.h @@ -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); diff --git a/ir/ana/callgraph.c b/ir/ana/callgraph.c index 9ae1dee37..d64e3b983 100644 --- a/ir/ana/callgraph.c +++ b/ir/ana/callgraph.c @@ -28,6 +28,8 @@ # include "config.h" #endif +#ifdef INTERPROCEDURAL_VIEW + #ifdef HAVE_STRING_H # include #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 diff --git a/ir/ana/field_temperature.c b/ir/ana/field_temperature.c index 01352b583..ef9766925 100644 --- a/ir/ana/field_temperature.c +++ b/ir/ana/field_temperature.c @@ -28,6 +28,8 @@ # include "config.h" #endif +#ifdef INTERPROCEDURAL_VIEW + #include #include "field_temperature.h" @@ -402,3 +404,5 @@ int is_jack_rts_entity(ir_entity *e) { } #endif /* if 0 */ + +#endif diff --git a/ir/ana/irbackedge.c b/ir/ana/irbackedge.c index 7bfd1c0c2..a554f19b7 100644 --- a/ir/ana/irbackedge.c +++ b/ir/ana/irbackedge.c @@ -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) { diff --git a/ir/ana/ircfscc.c b/ir/ana/ircfscc.c index 889e3c5d4..a1dcc0b66 100644 --- a/ir/ana/ircfscc.c +++ b/ir/ana/ircfscc.c @@ -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 } diff --git a/ir/ana/irextbb.c b/ir/ana/irextbb.c index de41e7cb7..ac826ba4a 100644 --- a/ir/ana/irextbb.c +++ b/ir/ana/irextbb.c @@ -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 */ diff --git a/ir/ana/irouts.c b/ir/ana/irouts.c index e0b6eed8a..48c9efa90 100644 --- a/ir/ana/irouts.c +++ b/ir/ana/irouts.c @@ -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) { diff --git a/ir/ana/irscc.c b/ir/ana/irscc.c index 46c6582e6..e9bb836e6 100644 --- a/ir/ana/irscc.c +++ b/ir/ana/irscc.c @@ -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 } diff --git a/ir/ana/irsimpletype.c b/ir/ana/irsimpletype.c index c84e696a8..71781edd2 100644 --- a/ir/ana/irsimpletype.c +++ b/ir/ana/irsimpletype.c @@ -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; diff --git a/ir/ana/rta.c b/ir/ana/rta.c index ebac2a221..24d743f94 100644 --- a/ir/ana/rta.c +++ b/ir/ana/rta.c @@ -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); } diff --git a/ir/common/statistics.c b/ir/common/statistics.c index 631fb6965..b5c645188 100644 --- a/ir/common/statistics.c +++ b/ir/common/statistics.c @@ -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. diff --git a/ir/ir/ircgcons.c b/ir/ir/ircgcons.c index 74215b9ae..b27406eab 100644 --- a/ir/ir/ircgcons.c +++ b/ir/ir/ircgcons.c @@ -29,10 +29,9 @@ # include "config.h" #endif -#ifdef HAVE_STRING_H -#include -#endif +#ifdef INTERPROCEDURAL_VIEW +#include #include #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 * einfügen. Die Steuer- und Datenflussabhängigkeiten 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 diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 38572b8c2..5a1ce2883 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -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; } } +#endif +#ifdef INTERPROCEDURAL_VIEW void dump_callgraph(const char *suffix) { FILE *F = vcg_open_name("Callgraph", suffix); if (F != NULL) { - int i, rem = edge_label, colorize; + int i, rem = edge_label; + //int colorize; edge_label = 1; dump_vcg_header(F, "Callgraph", NULL); - colorize = get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent; + //colorize = get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent; for (i = get_irp_n_irgs() - 1; i >= 0; --i) { ir_graph *irg = get_irp_irg(i); ir_entity *ent = get_irg_entity(irg); - int j, n_callees = get_irg_n_callees(irg); + int j; + //int n_callees = get_irg_n_callees(irg); int color; - color = colorize ? get_entity_color(ent) : ird_color_green; + //color = colorize ? get_entity_color(ent) : ird_color_green; + color = ird_color_green; dump_entity_node(F, ent, color); for (j = 0; j < n_callees; ++j) { ir_entity *c = get_irg_entity(get_irg_callee(irg, j)); @@ -2893,6 +2914,7 @@ void dump_all_cg_block_graph(const char *suffix) { set_interprocedural_view(rem_view); } } +#endif /*---------------------------------------------------------------------*/ /* the following routines dumps type information without any ir nodes. */ diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index 1317f7b60..783b6245b 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -125,6 +125,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1))); } +#ifdef INTERPROCEDURAL_VIEW fprintf(F, " arity: %d\n", get_irn_intra_arity(n)); /* show all predecessor nodes */ fprintf(F, " pred nodes: \n"); @@ -138,12 +139,28 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { dump_node_opcode(F, get_irn_intra_n(n, i)); fprintf(F, " %ld\n", get_irn_node_nr(get_irn_intra_n(n, i))); } +#else + fprintf(F, " arity: %d\n", get_irn_arity(n)); + /* show all predecessor nodes */ + fprintf(F, " pred nodes: \n"); + if (!is_Block(n)) { + fprintf(F, " -1: "); + dump_node_opcode(F, get_irn_n(n, -1)); + fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, -1))); + } + for ( i = 0; i < get_irn_arity(n); ++i) { + fprintf(F, " %d: %s ", i, is_backedge(n, i) ? "be" : " "); + dump_node_opcode(F, get_irn_n(n, i)); + fprintf(F, " %ld\n", get_irn_node_nr(get_irn_n(n, i))); + } +#endif fprintf(F, " Private Attributes:\n"); if (get_irn_opcode(n) == iro_Proj) fprintf(F, " proj nr: %ld\n", get_Proj_proj(n)); +#ifdef INTERPROCEDURAL_VIEW if ((get_irp_ip_view_state() != ip_view_no) && (get_irn_opcode(n) == iro_Filter || get_irn_opcode(n) == iro_Block)) { fprintf(F, " inter arity: %d\n", get_irn_inter_arity(n)); @@ -154,6 +171,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, " %ld\n", get_irn_node_nr(get_irn_inter_n(n, i))); } } +#endif if (is_fragile_op(n)) { fprintf(F, " pinned state: %s\n", get_op_pin_state_name(get_irn_pinned(n))); @@ -192,6 +210,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { fprintf(F, " Execution freqency statistics:\n"); if (get_irg_exec_freq_state(get_irn_irg(n)) != exec_freq_none) fprintf(F, " procedure local evaluation: %8.2lf\n", get_irn_exec_freq(n)); +#ifdef INTERPROCEDURAL_VIEW if (get_irp_loop_nesting_depth_state() != loop_nesting_depth_none) fprintf(F, " call freqency of procedure: %8.2lf\n", get_irg_method_execution_frequency(get_irn_irg(n))); @@ -201,6 +220,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { (get_irp_loop_nesting_depth_state() != loop_nesting_depth_none) && (get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent)) fprintf(F, " final evaluation: **%8.2lf**\n", get_irn_final_cost(n)); +#endif if (has_Block_label(n)) fprintf(F, " Label: %lu\n", get_Block_label(n)); @@ -212,6 +232,7 @@ int dump_irnode_to_file(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)); +#ifdef 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); @@ -222,6 +243,7 @@ int dump_irnode_to_file(FILE *F, ir_node *n) { get_irg_dump_name(get_irn_irg(cfgpred))); } } +#endif } break; case iro_Cond: { fprintf(F, " condition kind: %s\n", get_Cond_kind(n) == dense ? "dense" : "fragmentary"); @@ -674,10 +696,12 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned if (is_Method_type(get_entity_type(ent))) { if (get_entity_irg(ent)) /* can be null */ { fprintf(F, "\n%s irg = %ld", prefix, get_irg_graph_nr(get_entity_irg(ent))); +#ifdef INTERPROCEDURAL_VIEW if (get_irp_callgraph_state() == irp_callgraph_and_calltree_consistent) { fprintf(F, "\n%s recursion depth %d", prefix, get_irg_recursion_depth(get_entity_irg(ent))); fprintf(F, "\n%s loop depth %d", prefix, get_irg_loop_depth(get_entity_irg(ent))); } +#endif } else { fprintf(F, "\n%s irg = NULL", prefix); } @@ -797,6 +821,7 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned free(L_freq); #endif if (get_trouts_state() != outs_none) { +#ifdef INTERPROCEDURAL_VIEW if (is_Method_type(get_entity_type(ent))) { fprintf(F, "%s Estimated #Calls: %lf\n", prefix, get_entity_estimated_n_calls(ent)); fprintf(F, "%s Estimated #dynCalls: %lf\n", prefix, get_entity_estimated_n_calls(ent)); @@ -804,6 +829,7 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned fprintf(F, "%s Estimated #Loads: %lf\n", prefix, get_entity_estimated_n_loads(ent)); fprintf(F, "%s Estimated #Stores: %lf\n", prefix, get_entity_estimated_n_stores(ent)); } +#endif } } } @@ -908,6 +934,7 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, /* Output the entity name. */ fprintf(F, "%s%-40s ", prefix, get_entity_ld_name(ent)); +#ifdef INTERPROCEDURAL_VIEW if (get_trouts_state() != outs_none) { if (is_Method_type(get_entity_type(ent))) { //fprintf(F, "%s Estimated #Calls: %lf\n", prefix, get_entity_estimated_n_calls(ent)); @@ -917,11 +944,13 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, fprintf(F, "%6.2lf", get_entity_estimated_n_stores(ent)); } } +#endif fprintf(F, "\n"); } } +#ifdef INTERPROCEDURAL_VIEW /* A fast hack to dump a CSV-file. */ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const char *comma) { int i; @@ -1010,6 +1039,7 @@ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const } } } +#endif void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) { int i; @@ -1241,6 +1271,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) { free(freq); #endif +#ifdef INTERPROCEDURAL_VIEW if (get_trouts_state() != outs_none) { fprintf(F, " Estimated #Instances: %lf\n", get_type_estimated_n_instances(tp)); if (is_Class_type(tp) && (get_irp_typeinfo_state() != ir_typeinfo_none)) { @@ -1250,6 +1281,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) { assert(get_class_n_upcasts(tp) + get_class_n_downcasts(tp) == get_type_n_casts(tp)); } } +#endif } @@ -1280,9 +1312,11 @@ void dump_types_as_text(unsigned verbosity, const char *suffix) { //if (is_jack_rts_class(t)) continue; dump_type_to_file(F, t, verbosity); +#ifdef INTERPROCEDURAL_VIEW if (CSV) { dump_typecsv_to_file(CSV, t, verbosity, ""); } +#endif } fclose(F); diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index 0e98606a2..26937a736 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -615,7 +615,9 @@ void dead_node_elimination(ir_graph *irg) { if (get_opt_optimize() && get_opt_dead_node_elimination()) { ir_graph *rem; +#ifdef INTERPROCEDURAL_VIEW int rem_ipview = get_interprocedural_view(); +#endif struct obstack *graveyard_obst = NULL; struct obstack *rebirth_obst = NULL; assert(! edges_activated(irg) && "dead node elimination requires disabled edges"); @@ -626,7 +628,9 @@ dead_node_elimination(ir_graph *irg) { /* Remember external state of current_ir_graph. */ rem = current_ir_graph; current_ir_graph = irg; +#ifdef INTERPROCEDURAL_VIEW set_interprocedural_view(0); +#endif assert(get_irg_phase_state(irg) != phase_building); @@ -665,7 +669,9 @@ dead_node_elimination(ir_graph *irg) { hook_dead_node_elim(irg, 0); current_ir_graph = rem; +#ifdef INTERPROCEDURAL_VIEW set_interprocedural_view(rem_ipview); +#endif } } diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 0686a1cd3..f16a8302f 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -74,7 +74,7 @@ void set_current_ir_graph(ir_graph *graph) { current_ir_graph = graph; } - +#ifdef INTERPROCEDURAL_VIEW int firm_interprocedural_view = 0; int (get_interprocedural_view)(void) { @@ -94,6 +94,7 @@ void (set_interprocedural_view)(int state) { _get_irn_n = _get_irn_intra_n; } } +#endif /** contains the suffix for frame type names */ static ident *frame_type_suffix = NULL; diff --git a/ir/ir/irgraph_t.h b/ir/ir/irgraph_t.h index 9bea0eea6..c4411ad21 100644 --- a/ir/ir/irgraph_t.h +++ b/ir/ir/irgraph_t.h @@ -82,13 +82,6 @@ int node_is_in_irgs_storage(ir_graph *irg, ir_node *n); /* inline functions for graphs */ /*-------------------------------------------------------------------*/ -extern int firm_interprocedural_view; - -static INLINE int -_get_interprocedural_view(void) { - return firm_interprocedural_view; -} - static INLINE int _is_ir_graph(const void *thing) { return (get_kind(thing) == k_ir_graph); @@ -521,8 +514,17 @@ set_irg_anchor(ir_graph *irg, int idx, ir_node *irn) { set_irn_n(irg->anchor, idx, irn); } +#ifdef INTERPROCEDURAL_VIEW +extern int firm_interprocedural_view; + +static INLINE int +_get_interprocedural_view(void) { + return firm_interprocedural_view; +} #define get_interprocedural_view() _get_interprocedural_view() +#endif + #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) diff --git a/ir/ir/irgwalk.c b/ir/ir/irgwalk.c index 3fc2fa993..e332d295d 100644 --- a/ir/ir/irgwalk.c +++ b/ir/ir/irgwalk.c @@ -251,6 +251,7 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) { assert(is_ir_node(node)); +#ifdef INTERPROCEDURAL_VIEW if (get_interprocedural_view()) { pset_new_t irg_set; pset_new_iterator_t iter; @@ -271,11 +272,14 @@ void irg_walk(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void *env) irg_walk_cg(node, visited, &irg_set, pre, post, env); pset_new_destroy(&irg_set); } else { +#endif set_using_visited(current_ir_graph); inc_irg_visited(current_ir_graph); nodes_touched = irg_walk_2(node, pre, post, env); clear_using_visited(current_ir_graph); +#ifdef INTERPROCEDURAL_VIEW } +#endif return; } @@ -493,7 +497,7 @@ cg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) return; } - +#ifdef INTERPROCEDURAL_VIEW /* Walks all irgs in interprocedural view. Visits each node only once. */ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { int i; @@ -552,6 +556,7 @@ void cg_walk(irg_walk_func *pre, irg_walk_func *post, void *env) { set_interprocedural_view(rem_view); current_ir_graph = rem; } +#endif /***************************************************************************/ diff --git a/ir/ir/irgwalk_blk.c b/ir/ir/irgwalk_blk.c index e45278923..86c876e31 100644 --- a/ir/ir/irgwalk_blk.c +++ b/ir/ir/irgwalk_blk.c @@ -357,11 +357,13 @@ do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *en ir_node *end_node = get_irg_end(irg); ir_node *end_blk = get_irg_end_block(irg); blk_collect_data_t blks; - int old_view = get_interprocedural_view(); block_entry_t *entry; +#ifdef INTERPROCEDURAL_VIEW /* switch off interprocedural view */ + int old_view = get_interprocedural_view(); set_interprocedural_view(0); +#endif obstack_init(&blks.obst); blks.blk_map = new_pset(addr_cmp, 1); @@ -389,7 +391,9 @@ do_irg_walk_blk(ir_graph *irg, irg_walk_func *pre, irg_walk_func *post, void *en del_pset(blks.blk_map); obstack_free(&blks.obst, NULL); +#ifdef INTERPROCEDURAL_VIEW set_interprocedural_view(old_view); +#endif clear_using_visited(irg); } diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 8a8902350..554eff905 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -798,6 +798,7 @@ set_Block_graph_arr (ir_node *node, int pos, ir_node *value) { node->attr.block.graph_arr[pos+1] = value; } +#ifdef INTERPROCEDURAL_VIEW void set_Block_cg_cfgpred_arr(ir_node *node, int arity, ir_node *in[]) { assert(node->op == op_Block); if (node->attr.block.in_cg == NULL || arity != ARR_LEN(node->attr.block.in_cg) - 1) { @@ -842,6 +843,7 @@ void remove_Block_cg_cfgpred_arr(ir_node *node) { assert(node->op == op_Block); node->attr.block.in_cg = NULL; } +#endif ir_node *(set_Block_dead)(ir_node *block) { return _set_Block_dead(block); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index 7aa1901d3..20d006a7e 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -175,12 +175,18 @@ _get_irn_inter_arity(const ir_node *node) { return _get_irn_intra_arity(node); } +#ifdef INTERPROCEDURAL_VIEW /** * Returns the number of predecessors without the block predecessor. * Intern version for libFirm. */ extern int (*_get_irn_arity)(const ir_node *node); +#else + +#define _get_irn_arity(n) _get_irn_intra_arity(n) +#endif + /** * Intern version for libFirm. */ @@ -228,7 +234,11 @@ _get_irn_inter_n(const ir_node *node, int n) { * If it is a block, the entry -1 is NULL. * Intern version for libFirm. */ +#ifdef INTERPROCEDURAL_VIEW extern ir_node *(*_get_irn_n)(const ir_node *node, int n); +#else +#define _get_irn_n(n,i) _get_irn_intra_n(n,i) +#endif static INLINE int _get_irn_deps(const ir_node *node) { return node->deps ? ARR_LEN(node->deps) : 0; diff --git a/ir/ir/irtypes.h b/ir/ir/irtypes.h index 4dbe31353..28b80ae53 100644 --- a/ir/ir/irtypes.h +++ b/ir/ir/irtypes.h @@ -539,7 +539,9 @@ struct ir_prog { double max_method_execution_frequency; /**< needed in callgraph. */ irp_temperature_state temperature_state; /**< accumulated temperatures computed? */ exec_freq_state execfreq_state; /**< The state of execution frequency information */ +#ifdef INTERPROCEDURAL_VIEW loop_nesting_depth_state lnd_state; /**< The state of loop nesting depth information. */ +#endif ir_class_cast_state class_cast_state; /**< The state of cast operations in code. */ ir_address_taken_computed_state globals_adr_taken_state; /**< Address taken state of the globals. */ diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index 8a4dedb56..818f55c7d 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -747,9 +747,11 @@ static int verify_node_Proj_CallBegin(ir_node *n, ir_node *p) { static int verify_node_Proj_EndReg(ir_node *n, ir_node *p) { (void) n; (void) p; +#ifdef INTERPROCEDURAL_VIEW ASSERT_AND_RET( (get_irp_ip_view_state() != ip_view_no), "EndReg may only appear if ip view is constructed.", 0); +#endif return 1; } @@ -759,9 +761,11 @@ static int verify_node_Proj_EndReg(ir_node *n, ir_node *p) { static int verify_node_Proj_EndExcept(ir_node *n, ir_node *p) { (void) n; (void) p; +#ifdef INTERPROCEDURAL_VIEW ASSERT_AND_RET( (get_irp_ip_view_state() != ip_view_no), "EndExcept may only appear if ip view is constructed.", 0); +#endif return 1; } @@ -926,8 +930,10 @@ static int verify_node_Break(ir_node *n, ir_graph *irg) { ir_mode *mymode = get_irn_mode(n); (void) irg; +#ifdef INTERPROCEDURAL_VIEW ASSERT_AND_RET((get_irp_ip_view_state() != ip_view_no), "Break may only appear if ip view is constructed.", 0); +#endif ASSERT_AND_RET( /* Jmp: BB --> X */ mymode == mode_X, "Break node", 0 @@ -1615,8 +1621,10 @@ static int verify_node_Phi(ir_node *n, ir_graph *irg) { static int verify_node_Filter(ir_node *n, ir_graph *irg) { (void) n; (void) irg; +#ifdef INTERPROCEDURAL_VIEW ASSERT_AND_RET((get_irp_ip_view_state() != ip_view_no), "Filter may only appear if ip view is constructed.", 0); +#endif /* We should further do tests as for Proj and Phi. */ return 1; } diff --git a/ir/lower/lower_hl.c b/ir/lower/lower_hl.c index 86fcd7bac..c6282a50c 100644 --- a/ir/lower/lower_hl.c +++ b/ir/lower/lower_hl.c @@ -510,6 +510,7 @@ static void lower_bitfields_stores(ir_node *store) { * Lowers unaligned Loads. */ static void lower_unaligned_Load(ir_node *load) { + (void) load; /* NYI */ } @@ -517,6 +518,7 @@ static void lower_unaligned_Load(ir_node *load) { * Lowers unaligned Stores */ static void lower_unaligned_Store(ir_node *store) { + (void) store; /* NYI */ } diff --git a/ir/tr/type.c b/ir/tr/type.c index 8bb3eed96..0247de9de 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -1239,6 +1239,7 @@ ir_type *new_type_method(ident *name, int n_param, int n_res) { } void free_method_entities(ir_type *method) { + (void) method; assert(method && (method->type_op == type_method)); } @@ -1614,6 +1615,7 @@ void free_array_automatic_entities(ir_type *array) { } void free_array_entities (ir_type *array) { + (void) array; assert(array && (array->type_op == type_array)); } @@ -1788,6 +1790,7 @@ ir_type *new_type_enumeration(ident *name, int n_enums) { } void free_enumeration_entities(ir_type *enumeration) { + (void) enumeration; assert(enumeration && (enumeration->type_op == type_enumeration)); } void free_enumeration_attrs(ir_type *enumeration) { @@ -1876,10 +1879,12 @@ ir_type *new_type_pointer(ident *name, ir_type *points_to, ir_mode *ptr_mode) { } void free_pointer_entities(ir_type *pointer) { + (void) pointer; assert(pointer && (pointer->type_op == type_pointer)); } void free_pointer_attrs(ir_type *pointer) { + (void) pointer; assert(pointer && (pointer->type_op == type_pointer)); } -- 2.20.1