becopyheur2: Cache the admissible registers eagerly.
[libfirm] / ir / ir / irverify_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief    New checker of irnodes for correctness.
9  * @author   Michael Beck
10  */
11 #ifndef FIRM_IR_IRVERIFY_T_H
12 #define FIRM_IR_IRVERIFY_T_H
13
14 #include "irflag_t.h"
15 #include "irverify.h"
16 #include "irdump.h"
17
18 #include "beutil.h"
19
20 extern const char *firm_verify_failure_msg;
21
22 #ifdef NDEBUG
23 /*
24  * in RELEASE mode, returns ret if the expression expr evaluates to zero
25  * in ASSERT mode, asserts the expression expr (and the string string).
26  */
27 #define ASSERT_AND_RET(expr, string, ret)       do { if (!(expr)) return (ret); } while (0)
28
29 /*
30  * in RELEASE mode, returns ret if the expression expr evaluates to zero
31  * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
32  */
33 #define ASSERT_AND_RET_DBG(expr, string, ret, blk)     do { if (!(expr)) return (ret); } while (0)
34 #else
35 #define ASSERT_AND_RET(expr, string, ret) \
36 do { \
37   if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
38     if (!(expr) && current_ir_graph != get_const_code_irg()) \
39       dump_ir_graph(current_ir_graph, "assert"); \
40     assert((expr) && string); } \
41   if (!(expr)) { \
42     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
43       fprintf(stderr, #expr " : " string "\n"); \
44     firm_verify_failure_msg = #expr " && " string; \
45     return (ret); \
46   } \
47 } while(0)
48
49 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
50 do { \
51   if (!(expr)) { \
52     firm_verify_failure_msg = #expr " && " string; \
53     if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk } \
54     if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
55       fprintf(stderr, #expr " : " string "\n"); \
56     else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
57       if (!(expr) && current_ir_graph != get_const_code_irg()) \
58         dump_ir_graph(current_ir_graph, "assert"); \
59       assert((expr) && string); \
60     } \
61     return (ret); \
62   } \
63 } while(0)
64
65 #endif
66
67 /**
68  * Set the default verify_node and verify_proj_node operations.
69  */
70 void ir_register_verify_node_ops(void);
71
72 #endif