renamed type opcode to ir_opcode
[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 "irflag_t.h"
16 #include "irvrfy.h"
17 #include "irdump.h"
18
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)       do { if (!(expr)) return (ret); } while (0)
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)     do { if (!(expr)) return (ret); } while (0)
33 #else
34 #define ASSERT_AND_RET(expr, string, ret) \
35 do { \
36   if (opt_do_node_verification == FIRM_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 == FIRM_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 != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
53     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
54       fprintf(stderr, #expr " : " string "\n"); \
55     else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
56       if (!(expr) && current_ir_graph != get_const_code_irg()) \
57         dump_ir_block_graph(current_ir_graph, "-assert"); \
58       assert((expr) && string); \
59     } \
60     return (ret); \
61   } \
62 } while(0)
63
64 #endif
65
66 /**
67  * Set the default verify_node and verify_proj_node operation for an ir_op_ops.
68  */
69 void firm_set_default_verifyer(ir_opcode code, ir_op_ops *ops);
70
71 #endif /* _IRVRFY_T_H_ */