added new licence header
[libfirm] / ir / opt / opt_confirms.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  * Project:     libFIRM
22  * File name:   ir/opt/opt_confirms.h
23  * Purpose:     Optimizations regarding Confirm nodes
24  * Author:      Michael Beck
25  * Modified by:
26  * Created:
27  * CVS-ID:      $Id$
28  * Copyright:   (c) 1998-2005 Universität Karlsruhe
29  * License:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
30  */
31 #ifndef _OPT_CONFIRMS_H_
32 #define _OPT_CONFIRMS_H_
33
34 #include "irnode.h"
35
36 /**a
37  * @file opt_confirms.h
38  *
39  * Optimizations regarding Confirm nodes.
40  * These optimizations are not means to be run from
41  * frontends, they are called from iropt.
42  */
43
44 /**
45  * Check, if the value of a node is != 0.
46  *
47  * This is a often needed case, so we handle here Confirm
48  * nodes too.
49  *
50  * @param n        a node representing the value
51  * @param confirm  if n is confirmed to be != 0, returns
52  *                 the the Confirm-node, else NULL
53  */
54 int value_not_zero(ir_node *n, ir_node **confirm);
55
56 /**
57  * Check, if the value of a node cannot represent a NULL pointer.
58  *
59  * - If sel_based_null_check_elim is enabled, all
60  *   Sel nodes can be skipped.
61  * - A SymConst(entity) is NEVER a NULL pointer
62  * - A Const != NULL is NEVER a NULL pointer
63  * - Confirms are evaluated
64  *
65  * @param n        a node representing the value
66  * @param confirm  if n is confirmed to be != NULL, returns
67  *                 the the Confirm-node, else NULL
68  */
69 int value_not_null(ir_node *n, ir_node **confirm);
70
71 /**
72  * Possible return values of value_classify().
73  */
74 typedef enum _value_classify_sign {
75   value_classified_unknown  = 0,   /**< could not classify */
76   value_classified_positive = 1,   /**< value is positive, i.e. >= 0 */
77   value_classified_negative = -1   /**< value is negative, i.e. <= 0 if
78                                         no signed zero exists or < 0 else */
79 } value_classify_sign;
80
81 /**
82  * Check, if the value of a node can be confirmed >= 0 or <= 0,
83  * If the mode of the value did not honor signed zeros, else
84  * check for >= 0 or < 0.
85  *
86  * @param n  a node representing the value
87  */
88 value_classify_sign classify_value_sign(ir_node *n);
89
90 /**
91  * Return the value of a Cmp if one or both predecessors
92  * are Confirm nodes.
93  *
94  * @param cmp    the compare node that will be evaluated
95  * @param left   the left operand of the Cmp
96  * @param right  the right operand of the Cmp
97  * @param pnc    the compare relation
98  */
99 tarval *computed_value_Cmp_Confirm(ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc);
100
101 #endif /* _OPT_CONFIRMS_H_ */