C99 feature removed.
[libfirm] / ir / opt / opt_confirms.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   Optimizations regarding Confirm nodes.
23  * @author  Michael Beck
24  * @version $Id$
25  *
26  * Optimizations regarding Confirm nodes.
27  * These optimizations are not means to be run from
28  * frontends, they are called from iropt.
29  */
30 #ifndef FIRM_OPT_CONFIRMS_H
31 #define FIRM_OPT_CONFIRMS_H
32
33 #include "firm_types.h"
34
35 /** Needed for MSVC to suporess warnings because it doest NOT handle const right. */
36 typedef const ir_node *ir_node_cnst_ptr;
37
38 /**
39  * Check, if the value of a node is != 0.
40  *
41  * This is a often needed case, so we handle here Confirm
42  * nodes too.
43  *
44  * @param n        a node representing the value
45  * @param confirm  if n is confirmed to be != 0, returns
46  *                 the the Confirm-node, else NULL
47  */
48 int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm);
49
50 /**
51  * Check, if the value of a node cannot represent a NULL pointer.
52  *
53  * - If option sel_based_null_check_elim is enabled, all
54  *   Sel nodes can be skipped.
55  * - A SymConst(entity) is NEVER a NULL pointer
56  * - A Const != NULL is NEVER a NULL pointer
57  * - Confirms are evaluated
58  *
59  * @param n        a node representing the value
60  * @param confirm  if n is confirmed to be != NULL, returns
61  *                 the the Confirm-node, else NULL
62  */
63 int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm);
64
65 /**
66  * Possible return values of value_classify().
67  */
68 typedef enum value_classify_sign {
69         value_classified_unknown  = 0,   /**< could not classify */
70         value_classified_positive = 1,   /**< value is positive, i.e. >= 0 */
71         value_classified_negative = -1   /**< value is negative, i.e. <= 0 if
72                                               no signed zero exists or < 0 else */
73 } value_classify_sign;
74
75 /**
76  * Check, if the value of a node can be confirmed >= 0 or <= 0,
77  * If the mode of the value did not honor signed zeros, else
78  * check for >= 0 or < 0.
79  *
80  * @param n  a node representing the value
81  */
82 value_classify_sign classify_value_sign(ir_node *n);
83
84 /**
85  * Return the value of a Cmp if one or both predecessors
86  * are Confirm nodes.
87  *
88  * @param cmp    the compare node that will be evaluated
89  * @param left   the left operand of the Cmp
90  * @param right  the right operand of the Cmp
91  * @param pnc    the compare relation
92  */
93 ir_tarval *computed_value_Cmp_Confirm(ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc);
94
95 #endif /* FIRM_OPT_CONFIRMS_H */