From 7547cf525ad54f59d2dc3f39d4b257911c94989b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 8 Oct 2010 19:20:35 +0000 Subject: [PATCH] Moved functions from opt_confirms.h into official header, do edgjfe can use them. [r28075] --- include/libfirm/firm.h | 2 +- include/libfirm/iroptimize.h | 62 +++++++++++++++++++++++ ir/ir/iropt.c | 4 +- ir/opt/jumpthreading.c | 4 +- ir/opt/opt_confirms.c | 10 ++-- ir/opt/opt_confirms.h | 95 ------------------------------------ 6 files changed, 72 insertions(+), 105 deletions(-) delete mode 100644 ir/opt/opt_confirms.h diff --git a/include/libfirm/firm.h b/include/libfirm/firm.h index 771203e76..cc44fb747 100644 --- a/include/libfirm/firm.h +++ b/include/libfirm/firm.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * diff --git a/include/libfirm/iroptimize.h b/include/libfirm/iroptimize.h index cb149fee7..9aa0e1d4e 100644 --- a/include/libfirm/iroptimize.h +++ b/include/libfirm/iroptimize.h @@ -26,6 +26,7 @@ #define FIRM_IROPTIMIZE_H #include "firm_types.h" +#include "nodeops.h" #include "begin.h" /** @@ -1078,6 +1079,67 @@ FIRM_API void fixpoint_vrp(ir_graph*); */ FIRM_API ir_graph_pass_t *fixpoint_vrp_irg_pass(const char *name); +/** Needed for MSVC to suppress warnings because it doest NOT handle const right. */ +typedef const ir_node *ir_node_cnst_ptr; + +/** + * Check, if the value of a node is != 0. + * + * This is a often needed case, so we handle here Confirm + * nodes too. + * + * @param n a node representing the value + * @param confirm if n is confirmed to be != 0, returns + * the the Confirm-node, else NULL + */ +FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm); + +/** + * Check, if the value of a node cannot represent a NULL pointer. + * + * - If option sel_based_null_check_elim is enabled, all + * Sel nodes can be skipped. + * - A SymConst(entity) is NEVER a NULL pointer + * - A Const != NULL is NEVER a NULL pointer + * - Confirms are evaluated + * + * @param n a node representing the value + * @param confirm if n is confirmed to be != NULL, returns + * the the Confirm-node, else NULL + */ +FIRM_API int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm); + +/** + * Possible return values of value_classify(). + */ +typedef enum ir_value_classify_sign { + value_classified_unknown = 0, /**< could not classify */ + value_classified_positive = 1, /**< value is positive, i.e. >= 0 */ + value_classified_negative = -1 /**< value is negative, i.e. <= 0 if + no signed zero exists or < 0 else */ +} ir_value_classify_sign; + +/** + * Check, if the value of a node can be confirmed >= 0 or <= 0, + * If the mode of the value did not honor signed zeros, else + * check for >= 0 or < 0. + * + * @param n a node representing the value + */ +FIRM_API ir_value_classify_sign classify_value_sign(ir_node *n); + +/** + * Return the value of a Cmp if one or both predecessors + * are Confirm nodes. + * + * @param cmp the compare node that will be evaluated + * @param left the left operand of the Cmp + * @param right the right operand of the Cmp + * @param pnc the compare relation + */ +FIRM_API ir_tarval *computed_value_Cmp_Confirm( + ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc); + #include "end.h" #endif diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index fc0bda722..783dccaee 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -36,6 +36,7 @@ #include "ircons_t.h" #include "irgmod.h" #include "irverify.h" +#include "iroptimize.h" #include "tv_t.h" #include "dbginfo_t.h" #include "iropt_dbg.h" @@ -43,7 +44,6 @@ #include "irhooks.h" #include "irarch.h" #include "hashptr.h" -#include "opt_confirms.h" #include "opt_polymorphy.h" #include "irtools.h" #include "irhooks.h" diff --git a/ir/opt/jumpthreading.c b/ir/opt/jumpthreading.c index d354e395c..bc417f53c 100644 --- a/ir/opt/jumpthreading.c +++ b/ir/opt/jumpthreading.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -42,7 +42,7 @@ #include "irtools.h" #include "irgraph.h" #include "tv.h" -#include "opt_confirms.h" +#include "iroptimize.h" #include "iropt_dbg.h" #include "irpass.h" #include "vrp.h" diff --git a/ir/opt/opt_confirms.c b/ir/opt/opt_confirms.c index 5cda6f189..d717ccd31 100644 --- a/ir/opt/opt_confirms.c +++ b/ir/opt/opt_confirms.c @@ -31,7 +31,7 @@ #include "irnode_t.h" #include "iropt_t.h" #include "iropt_dbg.h" -#include "opt_confirms.h" +#include "iroptimize.h" #include "irflag_t.h" #include "irprintf.h" @@ -95,7 +95,7 @@ static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, pn * This is a often needed case, so we handle here Confirm * nodes too. */ -int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) +FIRM_API int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) { #define RET_ON(x) if (x) { *confirm = n; return 1; }; break @@ -174,7 +174,7 @@ int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm) * - A SymConst(entity) is NEVER a NULL pointer * - Confirms are evaluated */ -int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) +FIRM_API int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) { ir_tarval *tv; @@ -229,7 +229,7 @@ int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm) * If the mode of the value did not honor signed zeros, else * check for >= 0 or < 0. */ -value_classify_sign classify_value_sign(ir_node *n) +FIRM_API ir_value_classify_sign classify_value_sign(ir_node *n) { ir_tarval *tv, *c; ir_mode *mode; @@ -627,7 +627,7 @@ static int is_transitive(pn_Cmp pnc) * @param right the right operand of the Cmp * @param pnc the compare relation */ -ir_tarval *computed_value_Cmp_Confirm(ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc) +FIRM_API ir_tarval *computed_value_Cmp_Confirm(ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc) { ir_node *l_bound; pn_Cmp l_pnc, res_pnc, neg_pnc; diff --git a/ir/opt/opt_confirms.h b/ir/opt/opt_confirms.h deleted file mode 100644 index 40c891457..000000000 --- a/ir/opt/opt_confirms.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. - * - * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. - */ - -/** - * @file - * @brief Optimizations regarding Confirm nodes. - * @author Michael Beck - * @version $Id$ - * - * Optimizations regarding Confirm nodes. - * These optimizations are not means to be run from - * frontends, they are called from iropt. - */ -#ifndef FIRM_OPT_CONFIRMS_H -#define FIRM_OPT_CONFIRMS_H - -#include "firm_types.h" - -/** Needed for MSVC to suporess warnings because it doest NOT handle const right. */ -typedef const ir_node *ir_node_cnst_ptr; - -/** - * Check, if the value of a node is != 0. - * - * This is a often needed case, so we handle here Confirm - * nodes too. - * - * @param n a node representing the value - * @param confirm if n is confirmed to be != 0, returns - * the the Confirm-node, else NULL - */ -int value_not_zero(const ir_node *n, ir_node_cnst_ptr *confirm); - -/** - * Check, if the value of a node cannot represent a NULL pointer. - * - * - If option sel_based_null_check_elim is enabled, all - * Sel nodes can be skipped. - * - A SymConst(entity) is NEVER a NULL pointer - * - A Const != NULL is NEVER a NULL pointer - * - Confirms are evaluated - * - * @param n a node representing the value - * @param confirm if n is confirmed to be != NULL, returns - * the the Confirm-node, else NULL - */ -int value_not_null(const ir_node *n, ir_node_cnst_ptr *confirm); - -/** - * Possible return values of value_classify(). - */ -typedef enum value_classify_sign { - value_classified_unknown = 0, /**< could not classify */ - value_classified_positive = 1, /**< value is positive, i.e. >= 0 */ - value_classified_negative = -1 /**< value is negative, i.e. <= 0 if - no signed zero exists or < 0 else */ -} value_classify_sign; - -/** - * Check, if the value of a node can be confirmed >= 0 or <= 0, - * If the mode of the value did not honor signed zeros, else - * check for >= 0 or < 0. - * - * @param n a node representing the value - */ -value_classify_sign classify_value_sign(ir_node *n); - -/** - * Return the value of a Cmp if one or both predecessors - * are Confirm nodes. - * - * @param cmp the compare node that will be evaluated - * @param left the left operand of the Cmp - * @param right the right operand of the Cmp - * @param pnc the compare relation - */ -ir_tarval *computed_value_Cmp_Confirm(ir_node *cmp, ir_node *left, ir_node *right, pn_Cmp pnc); - -#endif /* FIRM_OPT_CONFIRMS_H */ -- 2.20.1