# include "config.h"
#endif
-# include "irprog.h"
-# include "irop_t.h"
-# include "irgraph_t.h"
-# include "ircgcons.h"
-# include "irvrfy_t.h"
-# include "irgwalk.h"
-# include "irdump.h"
-# include "irdom_t.h"
-# include "irprintf.h"
-# include "irouts.h"
+#include "irprog.h"
+#include "irop_t.h"
+#include "irgraph_t.h"
+#include "ircgcons.h"
+#include "irvrfy_t.h"
+#include "irgwalk.h"
+#include "irdump.h"
+#include "irdom_t.h"
+#include "irprintf.h"
+#include "irouts.h"
+#include "irflag_t.h"
/** if this flag is set, verify entity types in Load & Store nodes */
static int vrfy_entities = 0;
-node_verification_t opt_do_node_verification = NODE_VERIFICATION_ON;
const char *firm_vrfy_failure_msg;
/* enable verification of Load/Store entities */
return get_mode_name(mode);
}
-void do_node_verification(node_verification_t mode) {
- opt_do_node_verification = mode;
-}
-
/** the last IRG, on which a verify error was found */
static ir_graph *last_irg_error = NULL;
*/
static void show_node_on_graph(ir_graph *irg, ir_node *n)
{
- entity *ent = get_irg_entity(irg);
-
- if (ent)
- fprintf(stderr, "\nFIRM: irn_vrfy_irg() of entity %s, node %ld %s%s\n",
- get_entity_name(ent),
- get_irn_node_nr(n), get_irn_opname(n), get_irn_modename(n));
- else
- fprintf(stderr, "\nFIRM: irn_vrfy_irg() of graph %p, node %ld %s%s\n",
- (void *)irg,
- get_irn_node_nr(n), get_irn_opname(n), get_irn_modename(n));
+ ir_fprintf(stderr, "\nFIRM: irn_vrfy_irg() of %+F, node %+F\n", irg, n);
}
/**
- * Show call params
+ * Show call parameters
*/
static void show_call_param(ir_node *n, type *mt)
{
);
ASSERT_AND_RET(mymode == mode_T, "Cond mode is not a tuple", 0);
- if (op1mode == mode_b && get_irg_outs_state(irg) == outs_consistent &&
- !is_Block_dead(get_nodes_block(n))) {
- /* we have consistent outs, check for the right number of Proj's */
- ASSERT_AND_RET(
- get_irn_n_outs(n) == 2,
- "Live binary Cond node must have 2 successors", 0);
- }
return 1;
}
int i;
ir_op *op;
- if (!opt_do_node_verification)
- return 1;
+ if (!get_node_verification_mode())
+ return 1;
if (!get_interprocedural_view()) {
/*
current_ir_graph = rem;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT && ! res) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT && ! res) {
entity *ent = get_irg_entity(current_ir_graph);
if (ent)
int irn_vrfy_irg_dump(ir_node *n, ir_graph *irg, const char **bad_string)
{
int res;
- node_verification_t old = opt_do_node_verification;
+ firm_verification_t old = get_node_verification_mode();
firm_vrfy_failure_msg = NULL;
- opt_do_node_verification = NODE_VERIFICATION_ERROR_ONLY;
+ do_node_verification(FIRM_VERIFICATION_ERROR_ONLY);
res = irn_vrfy_irg(n, irg);
if (! res && get_irg_dom_state(irg) == dom_consistent &&
get_irg_pinned(irg) == op_pin_state_pinned)
res = check_dominance_for_node(n);
- opt_do_node_verification = old;
+ do_node_verification(old);
*bad_string = firm_vrfy_failure_msg;
return res;
if (is_Bad(pred)) {
venv->res |= BAD_CF;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT) {
fprintf(stderr, "irg_vrfy_bads: Block %ld has Bad predecessor\n", get_irn_node_nr(node));
}
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
assert(0 && "Bad CF detected");
}
}
if (is_Bad(get_nodes_block(node))) {
venv->res |= BAD_BLOCK;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT) {
fprintf(stderr, "irg_vrfy_bads: node %ld has Bad Block\n", get_irn_node_nr(node));
}
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
assert(0 && "Bad CF detected");
}
}
if (get_irn_op(node) == op_Tuple) {
venv->res |= TUPLE;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT) {
fprintf(stderr, "irg_vrfy_bads: node %ld is a Tuple\n", get_irn_node_nr(node));
}
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
assert(0 && "Tuple detected");
}
}
else {
venv->res |= BAD_CF;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT) {
fprintf(stderr, "irg_vrfy_bads: Phi %ld has Bad Input\n", get_irn_node_nr(node));
}
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
assert(0 && "Bad CF detected");
}
}
if ((venv->flags & BAD_DF) == 0) {
venv->res |= BAD_DF;
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_REPORT) {
fprintf(stderr, "irg_vrfy_bads: node %ld has Bad Input\n", get_irn_node_nr(node));
}
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {
+ if (get_node_verification_mode() == FIRM_VERIFICATION_ON) {
assert(0 && "Bad NON-CF detected");
}
}
}
/*
- * verify occurance of bad nodes
+ * verify occurrence of bad nodes
*/
int irg_vrfy_bads(ir_graph *irg, int flags)
{
*/
/**
-* @file irvrfy.h
-*
-* ir graph verification.
-*
-* @author Christian Schaefer
-*/
-
-# ifndef _IRVRFY_H_
-# define _IRVRFY_H_
-
-# include "irnode.h"
-# include "irgraph.h"
-
-typedef enum _node_verification_t {
- NODE_VERIFICATION_OFF = 0, /**< do not verify nodes at all */
- NODE_VERIFICATION_ON = 1, /**< do node verification and assert on error in debug version */
- NODE_VERIFICATION_REPORT = 2, /**< do node verification, but report to stderr only */
- NODE_VERIFICATION_ERROR_ONLY = 3 /**< do node verification, but NEVER do assert nor report */
-} node_verification_t;
-
-/** Select verification of nodes.
+ * @file irvrfy.h
+ *
+ * ir graph verification.
*
- * Per default the verification is in mode NODE_VERIFICATION_ASSERT.
- * Turn the verification off during development to check partial implementations.
+ * @author Christian Schaefer
*/
-void do_node_verification(node_verification_t mode);
+#ifndef _IRVRFY_H_
+#define _IRVRFY_H_
+
+#include "firm_types.h"
/**
* Tests the modes of checknode and its predecessors.
- * Checknode must be in current_ir_graph.
+ * checknode must be in current_ir_graph.
*
* \return
* NON-zero on success
*/
-int irn_vrfy(struct ir_node *checknode);
+int irn_vrfy(ir_node *checknode);
/**
* Tests the modes of checknode and its predecessors.
- * Checknode must be in given ir_graph.
+ * checknode must be in given ir_graph.
*
* \return
* NON-zero on success
*/
-int irn_vrfy_irg(struct ir_node *checknode, ir_graph *irg);
+int irn_vrfy_irg(ir_node *checknode, ir_graph *irg);
/**
* Same as irn_vrfy_irg, but temporary sets verification mode to
* \return
* NON-zero on success
*/
-int irn_vrfy_irg_dump(struct ir_node *checknode, ir_graph *irg, const char **bad_string);
+int irn_vrfy_irg_dump(ir_node *checknode, ir_graph *irg, const char **bad_string);
/**
* Flags for irg_verify().
};
/**
- * Verify occurance of bad nodes in a graph.
+ * Verify occurrence of bad nodes in a graph.
*
* @param irg The graph to verify
* @param flags combination of verify_bad_flags_t flags describing
#ifndef _IRVRFY_T_H_
#define _IRVRFY_T_H_
+#include "irflag_t.h"
#include "irvrfy.h"
#include "irdump.h"
-extern node_verification_t opt_do_node_verification;
extern const char *firm_vrfy_failure_msg;
#ifdef NDEBUG
#else
#define ASSERT_AND_RET(expr, string, ret) \
do { \
- if (opt_do_node_verification == NODE_VERIFICATION_ON) {\
+ if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
if (!(expr) && current_ir_graph != get_const_code_irg()) \
dump_ir_block_graph(current_ir_graph, "-assert"); \
assert((expr) && string); } \
if (!(expr)) { \
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
fprintf(stderr, #expr " : " string "\n"); \
firm_vrfy_failure_msg = #expr " && " string; \
return (ret); \
do { \
if (!(expr)) { \
firm_vrfy_failure_msg = #expr " && " string; \
- if (opt_do_node_verification != NODE_VERIFICATION_ERROR_ONLY) { blk; } \
- if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
+ if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
fprintf(stderr, #expr " : " string "\n"); \
- else if (opt_do_node_verification == NODE_VERIFICATION_ON) { \
+ else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
if (!(expr) && current_ir_graph != get_const_code_irg()) \
dump_ir_block_graph(current_ir_graph, "-assert"); \
assert((expr) && string); \