#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"
* all intervals.
*/
typedef struct interval_t {
- tarval *min; /**< lowest border */
- tarval *max; /**< highest border */
+ ir_tarval *min; /**< lowest border */
+ ir_tarval *max; /**< highest border */
unsigned char flags; /**< border flags */
} interval_t;
#ifdef DEBUG_CONFIRM
-#define compare_iv(l_iv, r_iv, pnc) compare_iv_dbg(l_iv, r_iv, pnc)
+#define compare_iv(l_iv, r_iv, pnc) compare_iv_dbg(l_iv, r_iv, pnc)
/* forward */
static tarval *compare_iv_dbg(const interval_t *l_iv, const interval_t *r_iv, pn_Cmp pnc);
* 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
- tarval *tv;
+ ir_tarval *tv;
ir_mode *mode = get_irn_mode(n);
pn_Cmp pnc;
* - 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)
{
- tarval *tv;
+ ir_tarval *tv;
*confirm = NULL;
n = skip_Cast_const(n);
if (is_Global(n)) {
/* global references are never NULL */
return 1;
- } else if (n == get_irg_frame(current_ir_graph)) {
+ } else if (n == get_irg_frame(get_irn_irg(n))) {
/* local references are never NULL */
return 1;
} else if (is_Alloc(n)) {
/* check for more Confirms */
for (; is_Confirm(n); n = skip_Cast(get_Confirm_value(n))) {
if (get_Confirm_cmp(n) == pn_Cmp_Lg) {
- ir_node *bound = get_Confirm_bound(n);
- tarval *tv = value_of(bound);
+ ir_node *bound = get_Confirm_bound(n);
+ ir_tarval *tv = value_of(bound);
if (tarval_is_null(tv)) {
*confirm = n;
return 0;
} /* value_not_null */
+#ifdef __cplusplus
+extern "C++" {
+ static inline ir_value_classify_sign operator *(ir_value_classify_sign sign, int mul) {
+ return (ir_value_classify_sign) (sign*mul);
+ }
+}
+#endif
+
/*
* 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.
*/
-value_classify_sign classify_value_sign(ir_node *n)
+FIRM_API ir_value_classify_sign classify_value_sign(ir_node *n)
{
- tarval *tv, *c;
+ ir_tarval *tv, *c;
ir_mode *mode;
pn_Cmp cmp, ncmp;
int negate = 1;
for (;;) {
- ir_opcode code = get_irn_opcode(n);
+ unsigned code = get_irn_opcode(n);
switch (code) {
case iro_Minus:
* @return the filled interval or NULL if no interval
* can be created (happens only on floating point
*/
-static interval_t *get_interval_from_tv(interval_t *iv, tarval *tv)
+static interval_t *get_interval_from_tv(interval_t *iv, ir_tarval *tv)
{
ir_mode *mode = get_tarval_mode(tv);
*/
static interval_t *get_interval(interval_t *iv, ir_node *bound, pn_Cmp pnc)
{
- ir_mode *mode = get_irn_mode(bound);
- tarval *tv = value_of(bound);
+ ir_mode *mode = get_irn_mode(bound);
+ ir_tarval *tv = value_of(bound);
if (tv == tarval_bad) {
/* There is nothing we could do here. For integer
* tarval_b_true or tarval_b_false it it can be evaluated,
* tarval_bad else
*/
-static tarval *(compare_iv)(const interval_t *l_iv, const interval_t *r_iv, pn_Cmp pnc)
+static ir_tarval *(compare_iv)(const interval_t *l_iv, const interval_t *r_iv, pn_Cmp pnc)
{
- pn_Cmp res;
- unsigned flags;
- tarval *tv_true = tarval_b_true, *tv_false = tarval_b_false;
+ pn_Cmp res;
+ unsigned flags;
+ ir_tarval *tv_true = tarval_b_true, *tv_false = tarval_b_false;
/* if one interval contains NaNs, we cannot evaluate anything */
if (! l_iv || ! r_iv)
/* we can only check ordered relations */
if (pnc & pn_Cmp_Uo) {
- tarval *t;
+ ir_tarval *t;
pnc = get_negated_pnc(pnc, get_tarval_mode(l_iv->min));
t = tv_true;
* @param right the right operand of the Cmp
* @param pnc the compare relation
*/
-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;
- interval_t l_iv, r_iv;
- tarval *tv;
- ir_mode *mode;
+ ir_node *l_bound;
+ pn_Cmp l_pnc, res_pnc, neg_pnc;
+ interval_t l_iv, r_iv;
+ ir_tarval *tv;
+ ir_mode *mode;
if (is_Confirm(right)) {
/* we want the Confirm on the left side */