fix warnings
[libfirm] / ir / ir / irvrfy_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    New checker of irnodes for correctness.
23  * @author   Michael Beck
24  * @version  $Id$
25  */
26 #ifndef FIRM_IR_IRVRFY_T_H
27 #define FIRM_IR_IRVRFY_T_H
28
29 #include "irflag_t.h"
30 #include "irvrfy.h"
31 #include "irdump.h"
32
33 extern const char *firm_vrfy_failure_msg;
34
35 #ifdef NDEBUG
36 /*
37  * in RELEASE mode, returns ret if the expression expr evaluates to zero
38  * in ASSERT mode, asserts the expression expr (and the string string).
39  */
40 #define ASSERT_AND_RET(expr, string, ret)       do { if (!(expr)) return (ret); } while (0)
41
42 /*
43  * in RELEASE mode, returns ret if the expression expr evaluates to zero
44  * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
45  */
46 #define ASSERT_AND_RET_DBG(expr, string, ret, blk)     do { if (!(expr)) return (ret); } while (0)
47 #else
48 #define ASSERT_AND_RET(expr, string, ret) \
49 do { \
50   if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
51     if (!(expr) && current_ir_graph != get_const_code_irg()) \
52       dump_ir_block_graph_sched(current_ir_graph, "-assert"); \
53     assert((expr) && string); } \
54   if (!(expr)) { \
55     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
56       fprintf(stderr, #expr " : " string "\n"); \
57     firm_vrfy_failure_msg = #expr " && " string; \
58     return (ret); \
59   } \
60 } while(0)
61
62 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
63 do { \
64   if (!(expr)) { \
65     firm_vrfy_failure_msg = #expr " && " string; \
66     if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
67     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
68       fprintf(stderr, #expr " : " string "\n"); \
69     else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
70       if (!(expr) && current_ir_graph != get_const_code_irg()) \
71         dump_ir_block_graph_sched(current_ir_graph, "-assert"); \
72       assert((expr) && string); \
73     } \
74     return (ret); \
75   } \
76 } while(0)
77
78 #endif
79
80 /**
81  * Set the default verify_node and verify_proj_node operation for an ir_op_ops.
82  */
83 void firm_set_default_verifyer(ir_opcode code, ir_op_ops *ops);
84
85 #endif