* @file
* @brief Check irnodes for correctness.
* @author Christian Schaefer, Goetz Lindenmaier, Till Riedel, Michael Beck
- * @version $Id$
*/
#include "config.h"
#include "irflag_t.h"
#include "irpass_t.h"
#include "irnodeset.h"
+#include "ircons.h"
/** if this flag is set, verify entity types in Load & Store nodes */
static int verify_entities = 0;
const char *firm_verify_failure_msg;
-/* enable verification of Load/Store entities */
void verify_enable_entity_tests(int enable)
{
verify_entities = enable;
(proj >= 0 && mode_is_datab(mode)),
"wrong Proj from Proj from Call", 0);
mt = get_Call_type(pred);
- ASSERT_AND_RET(mt == get_unknown_type() || is_Method_type(mt),
+ ASSERT_AND_RET(is_unknown_type(mt) || is_Method_type(mt),
"wrong call type on call", 0);
ASSERT_AND_RET(
(proj < (int)get_method_n_ress(mt)),
static int verify_switch_table(const ir_node *n)
{
const ir_switch_table *table = get_Switch_table(n);
- size_t n_entries = ir_switch_table_get_n_entries(table);
unsigned n_outs = get_Switch_n_outs(n);
+ ir_node *selector = get_Switch_selector(n);
+ ir_mode *mode = get_irn_mode(selector);
+ size_t n_entries;
size_t e;
+ ASSERT_AND_RET(table != NULL, "switch table is NULL", 0);
+
+ n_entries = ir_switch_table_get_n_entries(table);
for (e = 0; e < n_entries; ++e) {
const ir_switch_table_entry *entry
= ir_switch_table_get_entry_const(table, e);
continue;
ASSERT_AND_RET(entry->min != NULL && entry->max != NULL,
"switch table entry without min+max value", 0);
+ ASSERT_AND_RET(get_tarval_mode(entry->min) == mode &&
+ get_tarval_mode(entry->max) == mode,
+ "switch table entry with wrong modes", 0);
ASSERT_AND_RET(tarval_cmp(entry->min, entry->max) != ir_relation_greater,
"switch table entry without min+max value", 0);
ASSERT_AND_RET(entry->pn >= 0 && entry->pn < (long)n_outs,
ir_mode *mymode = get_irn_mode(n);
ir_mode *op1mode = get_irn_mode(get_Conv_op(n));
- ASSERT_AND_RET_DBG(mode_is_datab(op1mode) && mode_is_data(mymode),
+ ASSERT_AND_RET_DBG(mode_is_data(op1mode) && mode_is_data(mymode),
"Conv node", 0,
- show_unop_failure(n, "/* Conv: BB x datab --> data */");
+ show_unop_failure(n, "/* Conv: BB x data --> data */");
);
return 1;
}
return 1;
}
-/* Tests the modes of n and its predecessors. */
int irn_verify_irg(const ir_node *n, ir_graph *irg)
{
ir_op *op;
ir_printf("node %+F", n);
);
} else if (!is_Block(n) && is_irn_pinned_in_irg(n)
- && is_irg_state(irg, IR_GRAPH_STATE_NO_BADS)) {
+ && irg_has_properties(irg, IR_GRAPH_PROPERTY_NO_BADS)) {
ASSERT_AND_RET_DBG(is_Block(get_nodes_block(n)) || is_Anchor(n),
"block input is not a block", 0,
ir_printf("node %+F", n);
return env.res;
}
-/*
- * Calls irn_verify for each node in irg.
- * Graph must be in state "op_pin_state_pinned".
- * If dominance info is available, check the SSA property.
- */
int irg_verify(ir_graph *irg, unsigned flags)
{
int res = 1;
irg_walk_anchors(
irg,
- pinned && is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE)
+ pinned && irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE)
? verify_wrap_ssa : verify_wrap,
NULL,
&res
return 0;
}
-/* Creates an ir_graph pass for irg_verify(). */
ir_graph_pass_t *irg_verify_pass(const char *name, unsigned flags)
{
pass_t *pass = XMALLOCZ(pass_t);
return &pass->pass;
}
-/* create a verify pass */
int irn_verify_irg_dump(const ir_node *n, ir_graph *irg,
const char **bad_string)
{
firm_verify_failure_msg = NULL;
do_node_verification(FIRM_VERIFICATION_ERROR_ONLY);
res = irn_verify_irg(n, irg);
- if (res && is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE) &&
+ if (res && irg_has_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE) &&
get_irg_pinned(irg) == op_pin_state_pinned)
res = check_dominance_for_node(n);
do_node_verification(old);
}
}
-/*
- * verify occurrence of bad nodes
- */
int irg_verify_bads(ir_graph *irg, int flags)
{
verify_bad_env_t env;
return env.res;
}
-/*
- * set the default verify operation
- */
void firm_set_default_verifier(unsigned code, ir_op_ops *ops)
{
#define CASE(a) \