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

- removed verify and dump parameters from passes

- add more passes

[r26366]
parent 29c77ce9
......@@ -47,12 +47,9 @@ void gc_irgs(int n_keep, ir_entity *keep_arr[]);
* Creates an ir_prog pass for gc_irgs().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param params The parameters for the if conversion.
*
* @return the newly created ir_graph pass
*/
ir_prog_pass_t *gc_irgs_pass(const char *name, int verify, int dump);
ir_prog_pass_t *gc_irgs_pass(const char *name);
#endif
......@@ -181,12 +181,10 @@ void place_code(ir_graph *irg);
* place_code();
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *place_code_pass(const char *name, int verify, int dump);
ir_graph_pass_t *place_code_pass(const char *name);
/** Places an empty basic block on critical control flow edges thereby
* removing them.
......
......@@ -66,12 +66,10 @@ void opt_jumpthreading(ir_graph* irg);
* Creates an ir_graph pass for opt_jumpthreading().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_jumpthreading_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_jumpthreading_pass(const char *name);
/**
* Try to simplify boolean expression in the given ir graph.
......@@ -85,12 +83,10 @@ void opt_bool(ir_graph *irg);
* Creates an ir_graph pass for opt_bool().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_bool_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_bool_pass(const char *name);
/**
* Try to reduce the number of conv nodes in the given ir graph.
......@@ -105,12 +101,10 @@ int conv_opt(ir_graph *irg);
* Creates an ir_graph pass for conv_opt().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *conv_opt_pass(const char *name, int verify, int dump);
ir_graph_pass_t *conv_opt_pass(const char *name);
/**
* Do the scalar replacement optimization.
......@@ -201,8 +195,6 @@ void optimize_funccalls(int force_run, check_alloc_entity_func callback);
* Creates an ir_prog pass for optimize_funccalls().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param force_run if non-zero, an optimization run is started even
* if no const function graph was detected.
* Else calls are only optimized if at least one
......@@ -213,7 +205,7 @@ void optimize_funccalls(int force_run, check_alloc_entity_func callback);
* @return the newly created ir_prog pass
*/
ir_prog_pass_t *optimize_funccalls_pass(
const char *name, int verify, int dump,
const char *name,
int force_run, check_alloc_entity_func callback);
/**
......@@ -230,13 +222,11 @@ void do_gvn_pre(ir_graph *irg);
/**
* Creates an ir_graph pass for do_gvn_pre().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *do_gvn_pre_pass(const char *name, int verify, int dump);
ir_graph_pass_t *do_gvn_pre_pass(const char *name);
/**
* This function is called to evaluate, if a mux can build
......@@ -276,14 +266,12 @@ void opt_if_conv(ir_graph *irg, const ir_settings_if_conv_t *params);
* Creates an ir_graph pass for opt_if_conv().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param params The parameters for the if conversion.
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_if_conv_pass(
const char *name, int verify, int dump, const ir_settings_if_conv_t *params);
const char *name, const ir_settings_if_conv_t *params);
void opt_sync(ir_graph *irg);
......@@ -291,12 +279,10 @@ void opt_sync(ir_graph *irg);
* Creates an ir_graph pass for opt_sync().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_sync_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_sync_pass(const char *name);
/*
* Check if we can replace the load by a given const from
......@@ -344,12 +330,10 @@ int optimize_load_store(ir_graph *irg);
* Creates an ir_graph pass for optimize_load_store().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *optimize_load_store_pass(const char *name, int verify, int dump);
ir_graph_pass_t *optimize_load_store_pass(const char *name);
/**
* New experimental alternative to optimize_load_store.
......@@ -362,12 +346,10 @@ int opt_ldst(ir_graph *irg);
* Creates an ir_graph pass for opt_ldst().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_ldst_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_ldst_pass(const char *name);
/**
* Do Loop unrolling in the given graph.
......@@ -378,12 +360,10 @@ void optimize_loop_unrolling(ir_graph *irg);
* Creates an ir_graph pass for optimize_loop_unrolling().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *optimize_loop_unrolling_pass(const char *name, int verify, int dump);
ir_graph_pass_t *optimize_loop_unrolling_pass(const char *name);
/**
* Optimize the frame type of an irg by removing
......@@ -401,12 +381,10 @@ void opt_frame_irg(ir_graph *irg);
* Creates an ir_graph pass for opt_frame_irg().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_frame_irg_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_frame_irg_pass(const char *name);
/** Possible flags for the Operator Scalar Replacement. */
typedef enum osr_flags {
......@@ -487,13 +465,11 @@ void opt_osr(ir_graph *irg, unsigned flags);
* Creates an ir_graph pass for remove_phi_cycles().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param flags set of osr_flags
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_osr_pass(const char *name, int verify, int dump, unsigned flags);
ir_graph_pass_t *opt_osr_pass(const char *name, unsigned flags);
/**
* Removes useless Phi cycles, i.e cycles of Phi nodes with only one
......@@ -511,13 +487,10 @@ void remove_phi_cycles(ir_graph *irg);
* Creates an ir_graph pass for remove_phi_cycles().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param params The parameters for the if conversion.
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *remove_phi_cycles_pass(const char *name, int verify, int dump);
ir_graph_pass_t *remove_phi_cycles_pass(const char *name);
/** A default threshold. */
......@@ -558,12 +531,10 @@ int optimize_reassociation(ir_graph *irg);
* Creates an ir_graph pass for optimize_reassociation().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *optimize_reassociation_pass(const char *name, int verify, int dump);
ir_graph_pass_t *optimize_reassociation_pass(const char *name);
/**
* Normalize the Returns of a graph by creating a new End block
......@@ -591,12 +562,10 @@ void normalize_one_return(ir_graph *irg);
* Creates an ir_graph pass for normalize_one_return().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *normalize_one_return_pass(const char *name, int verify, int dump);
ir_graph_pass_t *normalize_one_return_pass(const char *name);
/**
* Normalize the Returns of a graph by moving
......@@ -624,12 +593,10 @@ void normalize_n_returns(ir_graph *irg);
* Creates an ir_graph pass for normalize_n_returns().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *normalize_n_returns_pass(const char *name, int verify, int dump);
ir_graph_pass_t *normalize_n_returns_pass(const char *name);
/**
* Do the scalar replacement optimization.
......@@ -646,12 +613,10 @@ int scalar_replacement_opt(ir_graph *irg);
* Creates an ir_graph pass for scalar_replacement_opt().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *scalar_replacement_opt_pass(const char *name, int verify, int dump);
ir_graph_pass_t *scalar_replacement_opt_pass(const char *name);
/** Performs strength reduction for the passed graph. */
void reduce_strength(ir_graph *irg);
......@@ -678,12 +643,10 @@ int opt_tail_rec_irg(ir_graph *irg);
* Creates an ir_graph pass for opt_tail_rec_irg().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *opt_tail_rec_irg_pass(const char *name, int verify, int dump);
ir_graph_pass_t *opt_tail_rec_irg_pass(const char *name);
/**
* Optimize tail-recursion calls for all IR-Graphs.
......@@ -702,12 +665,10 @@ void opt_tail_recursion(void);
* Creates an ir_prog pass for opt_tail_recursion().
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_prog pass
*/
ir_prog_pass_t *opt_tail_recursion_pass(const char *name, int verify, int dump);
ir_prog_pass_t *opt_tail_recursion_pass(const char *name);
/** This is the type for a method, that returns a pointer type to
* tp. This is needed in the normalization. */
......@@ -785,12 +746,10 @@ void combo(ir_graph *irg);
* Creates an ir_graph pass for combo.
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *combo_pass(const char *name, int verify, int dump);
ir_graph_pass_t *combo_pass(const char *name);
/** Inlines all small methods at call sites where the called address comes
* from a SymConst node that references the entity representing the called
......
......@@ -205,13 +205,26 @@ ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
* Replace Sel nodes by address computation. Also resolves array access.
* Handle bit fields by added And/Or calculations.
*
* @param irg the graph to lower
* @param irg the graph to lower
* @param lower_bitfields the graph contains old-style bitfield
* constructs
*
* @note: There is NO lowering ob objects oriented types. This is highly compiler
* and ABI specific and should be placed directly in the compiler.
*/
void lower_highlevel_graph(ir_graph *irg, int lower_bitfields);
/**
* Creates an ir_graph pass for lower_highlevel_graph().
*
* @param name the name of this pass or NULL
* @param lower_bitfields the graph contains old-style bitfield
* constructs
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *lower_highlevel_graph_pass(const char *name, int lower_bitfields);
/**
* Replaces SymConsts by a real constant if possible.
* Replace Sel nodes by address computation. Also resolves array access.
......@@ -323,16 +336,12 @@ unsigned lower_intrinsics(i_record *list, int length, int part_block_used);
* Creates an irprog pass for lower_intrinsics.
*
* @param name the name of this pass or NULL
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param list an array of intrinsic map records
* @param length the length of the array
* @param part_block_used set to true if part_block() must be using during lowering
*/
ir_prog_pass_t *lower_intrinsics_pass(
const char *name,
int verify,
int dump,
i_record *list, int length, int part_block_used);
/**
......
......@@ -601,8 +601,8 @@ void construct_confirms(ir_graph *irg) {
} /* construct_confirms */
/* Construct a pass. */
ir_graph_pass_t *construct_confirms_pass(const char *name, int verify, int dump) {
return def_graph_pass(name ? name : "confirm", verify, dump, construct_confirms);
ir_graph_pass_t *construct_confirms_pass(const char *name) {
return def_graph_pass(name ? name : "confirm", construct_confirms);
} /* construct_confirms_pass */
#if 0
......@@ -638,6 +638,6 @@ void remove_confirms(ir_graph *irg) {
} /* remove_confirms */
/* Construct a pass. */
ir_graph_pass_t *remove_confirms_pass(const char *name, int verify, int dump) {
return def_graph_pass(name ? name : "rem_confirm", verify, dump, remove_confirms);
ir_graph_pass_t *remove_confirms_pass(const char *name) {
return def_graph_pass(name ? name : "rem_confirm", remove_confirms);
} /* remove_confirms_pass */
......@@ -178,8 +178,7 @@ static int void_graph_wrapper(ir_graph *irg, void *context) {
/* Creates an ir_graph pass for running void function(ir_graph *irg). */
ir_graph_pass_t *def_graph_pass(
const char *name, int verify, int dump,
void (*function)(ir_graph *irg))
const char *name, void (*function)(ir_graph *irg))
{
struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
......@@ -187,8 +186,6 @@ ir_graph_pass_t *def_graph_pass(
pass->run_on_irg = void_graph_wrapper;
pass->context = function;
pass->name = name;
pass->verify = verify != 0;
pass->dump = dump != 0;
INIT_LIST_HEAD(&pass->list);
......@@ -214,8 +211,6 @@ ir_graph_pass_t *def_graph_pass_ret(
pass->run_on_irg = int_graph_wrapper;
pass->context = function;
pass->name = name;
pass->verify = verify != 0;
pass->dump = dump != 0;
INIT_LIST_HEAD(&pass->list);
......@@ -235,7 +230,7 @@ static int void_prog_wrapper(ir_prog *irp, void *context) {
/* Creates an ir_prog pass for running void function(void). */
ir_prog_pass_t *def_prog_pass(
const char *name, int verify, int dump,
const char *name,
void (*function)(void))
{
struct ir_prog_pass_t *pass = XMALLOCZ(ir_prog_pass_t);
......@@ -244,8 +239,6 @@ ir_prog_pass_t *def_prog_pass(
pass->run_on_irprog = void_prog_wrapper;
pass->context = function;
pass->name = name;
pass->verify = verify != 0;
pass->dump = dump != 0;
INIT_LIST_HEAD(&pass->list);
......
......@@ -111,15 +111,12 @@ ir_node *exact_copy(const ir_node *n);
* The pass returns always 0.
*
* @param name the name of this pass
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param function the function to run
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *def_graph_pass(
const char *name, int verify, int dump,
void (*function)(ir_graph *irg));
const char *name, void (*function)(ir_graph *irg));
/**
* Creates an ir_graph pass for running int function(ir_graph *irg).
......@@ -127,15 +124,12 @@ ir_graph_pass_t *def_graph_pass(
* The pass returns the return value of function.
*
* @param name the name of this pass
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param function the function to run
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *def_graph_pass_ret(
const char *name, int verify, int dump,
int (*function)(ir_graph *irg));
const char *name, int (*function)(ir_graph *irg));
/**
* Creates an ir_prog pass for running void function().
......@@ -143,14 +137,11 @@ ir_graph_pass_t *def_graph_pass_ret(
* The pass returns always 0.
*
* @param name the name of this pass
* @param verify should this pass be verified?
* @param dump should this pass result be dumped?
* @param function the function to run
*
* @return the newly created ir_graph pass
*/
ir_prog_pass_t *def_prog_pass(
const char *name, int verify, int dump,
void (*function)(void));
const char *name, void (*function)(void));
#endif
......@@ -223,7 +223,7 @@ int optimize_graph_df(ir_graph *irg) {
}
/* Creates an ir_graph pass for optimize_graph_df. */
ir_graph_pass_t *optimize_graph_df_pass(const char *name, int verify, int dump)
ir_graph_pass_t *optimize_graph_df_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "optimize_graph_df", verify, dump, optimize_graph_df);
return def_graph_pass_ret(name ? name : "optimize_graph_df", optimize_graph_df);
} /* optimize_graph_df_pass */
......@@ -108,8 +108,6 @@ static ir_prog_pass_t *create_wrapper_pass(ir_graph_pass_manager_t *graph_mgr)
/* do not verify nor dump: this is handled by the graph manager */
pass->verify_irprog = no_verify;
pass->dump_irprog = no_dump;
pass->dump = 0;
pass->verify = 0;
pass->is_wrapper = 1;
pass->add_to_mgr = NULL;
......@@ -184,7 +182,7 @@ int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
if (pass_res != 0)
res = 1;
/* verify is necessary */
if (mgr->verify_all || pass->verify) {
if (mgr->verify_all) {
if (pass->verify_irg) {
pass->verify_irg(irg, pass->context);
} else {
......@@ -192,7 +190,7 @@ int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
}
}
/* dump */
if (mgr->dump_all || pass->dump) {
if (mgr->dump_all) {
if (pass->dump_irg) {
pass->dump_irg(irg, pass->context, idx);
} else {
......@@ -232,7 +230,7 @@ int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
if (pass_res != 0)
res = 1;
/* verify is necessary */
if (mgr->verify_all || pass->verify) {
if (mgr->verify_all) {
if (pass->verify_irprog) {
pass->verify_irprog(irp, pass->context);
} else {
......@@ -240,7 +238,7 @@ int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
}
}
/* dump */
if (mgr->dump_all || pass->dump) {
if (mgr->dump_all) {
if (pass->dump_irprog) {
pass->dump_irprog(irp, pass->context, idx);
} else {
......
......@@ -56,7 +56,7 @@ typedef void (*DUMP_ON_IRPROG_FUNC)(ir_prog *irg, void *ctx, unsigned idx);
typedef void (*INIT_TERM_FUNC)(void *ctx);
/**
* A graph pass.
* An ir_sgraph pass.
*/
struct ir_graph_pass_t {
/** The firm kind. */
......@@ -80,12 +80,11 @@ struct ir_graph_pass_t {
/** Links all passes. */
list_head list;
unsigned verify:1; /**< Set if this pass should be verified. */
unsigned dump:1; /**< Set if this pass should be dumped. */
unsigned run_parallel:1; /**< if set this pass can run parallel on all graphs. */
};
/**
* A irprog pass.
* An ir_prog pass.
*/
struct ir_prog_pass_t {
/** The firm kind. */
......@@ -109,13 +108,11 @@ struct ir_prog_pass_t {
/** Links all passes */
list_head list;
unsigned verify:1; /**< Set if this pass should be verified. */
unsigned dump:1; /**< Set if this pass should be dumped. */
unsigned is_wrapper:1; /**< set if this is a wrapper pass. */
};
/**
* A graph pass manager.
* An ir_graph pass manager.
*/
struct ir_graph_pass_manager_t {
firm_kind kind; /**< The firm kind. */
......@@ -128,7 +125,7 @@ struct ir_graph_pass_manager_t {
};
/**
* A irprog pass manager.
* An ir_prog pass manager.
*/
struct ir_prog_pass_manager_t {
firm_kind kind; /**< The firm kind. */
......
......@@ -35,6 +35,8 @@
#include "irhooks.h"
#include "irgmod.h"
#include "irgwalk.h"
#include "irtools.h"
#include "irpass_t.h"
/**
* Lower a Sel node. Do not touch Sels accessing entities on the frame type.
......@@ -576,6 +578,36 @@ void lower_highlevel_graph(ir_graph *irg, int lower_bitfields) {
irg_walk_graph(irg, NULL, lower_irnode, NULL);
} /* lower_highlevel_graph */
struct pass_t {
ir_graph_pass_t pass;
int lower_bitfields;
};
/**
* Wrapper for running lower_highlevel_graph() as an ir_graph pass.
*/
static int lower_highlevel_graph_wrapper(ir_graph *irg, void *context) {
struct pass_t *pass = context;
lower_highlevel_graph(irg, pass->lower_bitfields);
return 0;
} /* lower_highlevel_graph_wrapper */
ir_graph_pass_t *lower_highlevel_graph_pass(const char *name, int lower_bitfields) {
struct pass_t *pass = XMALLOCZ(struct pass_t);
pass->pass.kind = k_ir_graph_pass;
pass->pass.run_on_irg = lower_highlevel_graph_wrapper;
pass->pass.context = pass;
pass->pass.name = name;
INIT_LIST_HEAD(&pass->pass.list);
pass->lower_bitfields = lower_bitfields;
return &pass->pass;
} /* lower_highlevel_graph_pass */
/*
* does the same as lower_highlevel() for all nodes on the const code irg
*/
......@@ -584,7 +616,7 @@ void lower_const_code(void) {
} /* lower_const_code */
ir_prog_pass_t *lower_const_code_pass(const char *name) {
return def_prog_pass(name ? name : "lower_const_code", 0, 0, lower_const_code);
return def_prog_pass(name ? name : "lower_const_code", lower_const_code);
}
/*
......
......@@ -182,16 +182,12 @@ static int pass_wrapper(ir_prog *irp, void *context)
* Creates an ir_prog pass for lower_intrinsics.
*