used new verify_node operation
[libfirm] / ir / ir / irvrfy_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ir/irvrfy_t.h
4  * Purpose:     New checker of irnodes for correctness.
5  * Author:      Michael Beck
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2005 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 #ifndef _IRVRFY_T_H_
13 #define _IRVRFY_T_H_
14
15 #include "irvrfy.h"
16
17 extern node_verification_t opt_do_node_verification;
18 extern const char *firm_vrfy_failure_msg;
19
20 #ifdef NDEBUG
21 /*
22  * in RELEASE mode, returns ret if the expression expr evaluates to zero
23  * in ASSERT mode, asserts the expression expr (and the string string).
24  */
25 #define ASSERT_AND_RET(expr, string, ret)       if (!(expr)) return (ret)
26
27 /*
28  * in RELEASE mode, returns ret if the expression expr evaluates to zero
29  * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
30  */
31 #define ASSERT_AND_RET_DBG(expr, string, ret, blk)      if (!(expr)) return (ret)
32 #else
33 #define ASSERT_AND_RET(expr, string, ret) \
34 do { \
35   if (opt_do_node_verification == NODE_VERIFICATION_ON) {\
36     if (!(expr) && current_ir_graph != get_const_code_irg()) \
37     dump_ir_block_graph(current_ir_graph, "-assert"); \
38     assert((expr) && string); } \
39   if (!(expr)) { \
40     if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
41       fprintf(stderr, #expr " : " string "\n"); \
42     firm_vrfy_failure_msg = #expr " && " string; \
43     return (ret); \
44   } \
45 } while(0)
46
47 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
48 do { \
49   if (!(expr)) { \
50     firm_vrfy_failure_msg = #expr " && " string; \
51     if (opt_do_node_verification != NODE_VERIFICATION_ERROR_ONLY) { blk; } \
52     if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
53       fprintf(stderr, #expr " : " string "\n"); \
54     else if (opt_do_node_verification == NODE_VERIFICATION_ON) \
55       assert((expr) && string); \
56     return (ret); \
57   } \
58 } while(0)
59
60 #endif
61
62 /**
63  * Set the default verify_node and verify_proj_node operation.
64  */
65 void firm_set_default_verifyer(ir_op *op);
66
67 #endif /* _IRVRFY_T_H_ */