fix some warnings, represent mode size as unsigned value
[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 #include "beutil.h"
34
35 extern const char *firm_vrfy_failure_msg;
36
37 #ifdef NDEBUG
38 /*
39  * in RELEASE mode, returns ret if the expression expr evaluates to zero
40  * in ASSERT mode, asserts the expression expr (and the string string).
41  */
42 #define ASSERT_AND_RET(expr, string, ret)       do { if (!(expr)) return (ret); } while (0)
43
44 /*
45  * in RELEASE mode, returns ret if the expression expr evaluates to zero
46  * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
47  */
48 #define ASSERT_AND_RET_DBG(expr, string, ret, blk)     do { if (!(expr)) return (ret); } while (0)
49 #else
50 #define ASSERT_AND_RET(expr, string, ret) \
51 do { \
52   if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
53     if (!(expr) && current_ir_graph != get_const_code_irg()) \
54       dump_ir_block_graph_sched(current_ir_graph, "-assert"); \
55     assert((expr) && string); } \
56   if (!(expr)) { \
57     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
58       fprintf(stderr, #expr " : " string "\n"); \
59     firm_vrfy_failure_msg = #expr " && " string; \
60     return (ret); \
61   } \
62 } while(0)
63
64 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
65 do { \
66   if (!(expr)) { \
67     firm_vrfy_failure_msg = #expr " && " string; \
68     if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
69     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
70       fprintf(stderr, #expr " : " string "\n"); \
71     else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
72       if (!(expr) && current_ir_graph != get_const_code_irg()) \
73         dump_ir_block_graph_sched(current_ir_graph, "-assert"); \
74       assert((expr) && string); \
75     } \
76     return (ret); \
77   } \
78 } while(0)
79
80 #endif
81
82 /**
83  * Set the default verify_node and verify_proj_node operation for an ir_op_ops.
84  */
85 void firm_set_default_verifyer(ir_opcode code, ir_op_ops *ops);
86
87 #endif