typos fixed
[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 #include "irdump.h"
17
18 extern node_verification_t opt_do_node_verification;
19 extern const char *firm_vrfy_failure_msg;
20
21 #ifdef NDEBUG
22 /*
23  * in RELEASE mode, returns ret if the expression expr evaluates to zero
24  * in ASSERT mode, asserts the expression expr (and the string string).
25  */
26 #define ASSERT_AND_RET(expr, string, ret)       if (!(expr)) return (ret)
27
28 /*
29  * in RELEASE mode, returns ret if the expression expr evaluates to zero
30  * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
31  */
32 #define ASSERT_AND_RET_DBG(expr, string, ret, blk)      if (!(expr)) return (ret)
33 #else
34 #define ASSERT_AND_RET(expr, string, ret) \
35 do { \
36   if (opt_do_node_verification == NODE_VERIFICATION_ON) {\
37     if (!(expr) && current_ir_graph != get_const_code_irg()) \
38     dump_ir_block_graph(current_ir_graph, "-assert"); \
39     assert((expr) && string); } \
40   if (!(expr)) { \
41     if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
42       fprintf(stderr, #expr " : " string "\n"); \
43     firm_vrfy_failure_msg = #expr " && " string; \
44     return (ret); \
45   } \
46 } while(0)
47
48 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
49 do { \
50   if (!(expr)) { \
51     firm_vrfy_failure_msg = #expr " && " string; \
52     if (opt_do_node_verification != NODE_VERIFICATION_ERROR_ONLY) { blk; } \
53     if (opt_do_node_verification == NODE_VERIFICATION_REPORT) \
54       fprintf(stderr, #expr " : " string "\n"); \
55     else if (opt_do_node_verification == NODE_VERIFICATION_ON) \
56       assert((expr) && string); \
57     return (ret); \
58   } \
59 } while(0)
60
61 #endif
62
63 /**
64  * Set the default verify_node and verify_proj_node operation.
65  */
66 void firm_set_default_verifyer(ir_op *op);
67
68 #endif /* _IRVRFY_T_H_ */