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

- add graph pass for edges_verify()

[r26529]
parent 33249fb0
...@@ -166,6 +166,16 @@ int edges_verify(ir_graph *irg); ...@@ -166,6 +166,16 @@ int edges_verify(ir_graph *irg);
*/ */
void edges_init_dbg(int do_dbg); void edges_init_dbg(int do_dbg);
/**
* Creates an ir_graph pass for edges_verify().
*
* @param name the name of this pass or NULL
* @param assert_on_problem assert if problems were found
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *irg_verify_edges_pass(const char *name, unsigned assert_on_problem);
/************************************************************************/ /************************************************************************/
/* Begin Old Interface */ /* Begin Old Interface */
/************************************************************************/ /************************************************************************/
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "set.h" #include "set.h"
#include "bitset.h" #include "bitset.h"
#include "error.h" #include "error.h"
#include "irpass_t.h"
#include "iredgeset.h" #include "iredgeset.h"
#include "hashptr.h" #include "hashptr.h"
...@@ -75,8 +76,15 @@ ...@@ -75,8 +76,15 @@
*/ */
typedef void (set_edge_func_t)(ir_node *src, int pos, ir_node *tgt); typedef void (set_edge_func_t)(ir_node *src, int pos, ir_node *tgt);
/**
* A function that returns the "arity" of a given edge kind
* for a node.
*/
typedef int (get_edge_src_arity_func_t)(const ir_node *src); typedef int (get_edge_src_arity_func_t)(const ir_node *src);
/**
* A function that returns the pos'th edge of a given edge kind for a node.
*/
typedef ir_node *(get_edge_src_n_func_t)(const ir_node *src, int pos); typedef ir_node *(get_edge_src_n_func_t)(const ir_node *src, int pos);
/** /**
...@@ -93,9 +101,9 @@ typedef struct { ...@@ -93,9 +101,9 @@ typedef struct {
/** /**
* Get the predecessor block. * Get the predecessor block.
*/ */
static ir_node *get_block_n(const ir_node *irn, int pos) { static ir_node *get_block_n(const ir_node *block, int pos) {
if (is_Block(irn)) if (is_Block(block))
return get_Block_cfgpred_block(irn, pos); return get_Block_cfgpred_block(block, pos);
/* might be a Bad */ /* might be a Bad */
return NULL; return NULL;
} }
...@@ -135,6 +143,9 @@ static int edges_dbg = 0; ...@@ -135,6 +143,9 @@ static int edges_dbg = 0;
static long last_edge_num = -1; static long last_edge_num = -1;
#endif #endif
/**
* Returns an ID for the given edge.
*/
static inline long edge_get_id(const ir_edge_t *e) { static inline long edge_get_id(const ir_edge_t *e) {
#ifdef DEBUG_libfirm #ifdef DEBUG_libfirm
return e->edge_nr; return e->edge_nr;
...@@ -871,6 +882,37 @@ int edges_verify(ir_graph *irg) { ...@@ -871,6 +882,37 @@ int edges_verify(ir_graph *irg) {
return problem_found ? 1 : w.problem_found; return problem_found ? 1 : w.problem_found;
} }
struct pass_t {
ir_graph_pass_t pass;
unsigned assert_on_problem;
};
/**
* Wrapper to edges_verify to be run as an ir_graph pass.
*/
static int edges_verify_wrapper(ir_graph *irg, void *context) {
struct pass_t *pass = context;
int problems_found = edges_verify(irg);
/* do NOT rerun the pass if verify is ok :-) */
assert(problems_found && pass->assert_on_problem);
return 0;
}
/* Creates an ir_graph pass for edges_verify(). */
ir_graph_pass_t *irg_verify_edges_pass(const char *name, unsigned assert_on_problem) {
struct pass_t *pass = XMALLOCZ(struct pass_t);
def_graph_pass_constructor(
&pass->pass, name ? name : "edges_verify", edges_verify_wrapper);
/* neither dump nor verify */
pass->pass.dump_irg = (DUMP_ON_IRG_FUNC)ir_prog_no_dump;
pass->pass.verify_irg = (RUN_ON_IRG_FUNC)ir_prog_no_verify;
pass->assert_on_problem = assert_on_problem;
return &pass->pass;
}
void init_edges(void) { void init_edges(void) {
FIRM_DBG_REGISTER(dbg, DBG_EDGES); FIRM_DBG_REGISTER(dbg, DBG_EDGES);
/* firm_dbg_set_mask(dbg, -1); */ /* firm_dbg_set_mask(dbg, -1); */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment