added is_Add(), is_Sub()
[libfirm] / ir / tr / trvrfy.h
1 /*
2  * Copyright (C) 1995-2007 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    trvrfy.h
22  * @brief   Check types and entities for correctness.
23  * @date    29.1.2003
24  * @author  Michael Beck, Goetz Lindenmaier
25  * @version $Id$
26  */
27 #ifndef FIRM_TR_TRVRFY_H
28 #define FIRM_TR_TRVRFY_H
29
30 #include "firm_types.h"
31
32 /**
33  * possible trvrfy() error codes
34  */
35 enum trvrfy_error_codes {
36         no_error = 0,                      /**< no error */
37         error_ent_not_cont,                /**< overwritten entity not in superclass */
38         error_null_mem,                    /**< compound contains NULL member */
39         error_const_on_wrong_irg,          /**< constant placed on wrong IRG */
40         error_existent_entity_without_irg, /**< Method entities with pecularity_exist must have an irg */
41         error_wrong_ent_overwrites,        /**< number of entity overwrites exceeds number of class overwrites */
42         error_inherited_ent_without_const, /**< inherited method entity not pointing to existent entity */
43         error_glob_ent_allocation,         /**< wrong allocation of a global entity */
44         error_ent_const_mode,              /**< Mode of constant in entity did not match entities type. */
45         error_ent_wrong_owner              /**< Mode of constant in entity did not match entities type. */
46 };
47
48 /**
49  * Checks a type.
50  *
51  * @return
52  *  0   if no error encountered
53  */
54 int check_type(ir_type *tp);
55
56 /**
57  * Check an entity. Currently, we check only if initialized constants
58  * are build on the const irg graph.
59  *
60  * @return
61  *  0   if no error encountered
62  *  != 0    a trvrfy_error_codes code
63  */
64 int check_entity(ir_entity *ent);
65
66 /**
67  * Walks the type information and performs a set of sanity checks.
68  *
69  * Currently, the following checks are executed:
70  * - values of initialized entities must be allocated on the constant IRG
71  * - class types: doesn't have NULL members
72  * - class types: all overwrites are existent in the super type
73  *
74  * @return
75  *    0 if graph is correct
76  *    else error code.
77  */
78 int tr_vrfy(void);
79
80 /**
81  * If NDEBUG is defined performs nothing, else calls the tr_vrfy() function.
82  */
83 #ifdef NDEBUG
84 #define TR_VRFY()       0
85 #else
86 #define TR_VRFY()       tr_vrfy()
87 #endif
88
89 #endif /* FIRM_TR_TRVRFY_H */