static void
optimize_in_place_wrapper (ir_node *n, void *env) {
int i;
- ir_node *optimized;
+ ir_node *optimized, *old;
for (i = 0; i < get_irn_arity(n); i++) {
- optimized = optimize_in_place_2(get_irn_n(n, i));
+ /* get?irn_n skips Id nodes, so comparison old != optimized does not
+ show all optimizations. Therefore always set new predecessor. */
+ old = get_irn_n(n, i);
+ optimized = optimize_in_place_2(old);
set_irn_n(n, i, optimized);
}
ir_mode *mode_X;
ir_mode *mode_M;
ir_mode *mode_BB;
+ir_mode *mode_ANY;
+ir_mode *mode_BAD;
/* predefined numerical modes: */
ir_mode *mode_F; /* float */
INLINE ir_mode *get_modeX(void) { ANNOUNCE(); return mode_X; }
INLINE ir_mode *get_modeM(void) { ANNOUNCE(); return mode_M; }
INLINE ir_mode *get_modeBB(void) { ANNOUNCE(); return mode_BB; }
+INLINE ir_mode *get_modeANY(void) { ANNOUNCE(); return mode_ANY; }
+INLINE ir_mode *get_modeBAD(void) { ANNOUNCE(); return mode_BAD; }
/**
* Registers a new mode if not defined yet, else returns
mode_T->sign = 0;
mode_T->tv_priv = NULL;
+ /* ANY */
+ mode_ANY = &modes[irm_ANY];
+ mode_ANY->name = id_from_str("ANY", 3);
+ mode_ANY->code = irm_ANY;
+ mode_ANY->sort = irms_auxiliary;
+ mode_ANY->sign = 0;
+ mode_ANY->align = 0;
+ mode_ANY->size = 0;
+ mode_ANY->tv_priv = NULL;
+
+ /* BAD */
+ mode_BAD = &modes[irm_BAD];
+ mode_BAD->name = id_from_str("BAD", 3);
+ mode_BAD->code = irm_BAD;
+ mode_BAD->sort = irms_auxiliary;
+ mode_BAD->sign = 0;
+ mode_BAD->align = 0;
+ mode_BAD->size = 0;
+ mode_BAD->tv_priv = NULL;
+
/* boolean */
mode_b = &modes[irm_b];
mode_b->name = id_from_str("b", 1);
irm_M, /**< memory */
irm_T, /**< tuple */
irm_U, /**< unicode character */
+ irm_ANY, /**< undefined mode */
+ irm_BAD, /**< bad mode */
irm_max /**< maximum value for modecode */
} modecode;
*/
typedef enum {
/* Predefined sorts of modes */
- irms_auxiliary, /**< Only for Firm use. Not extensible. (irm_T) */
+ irms_auxiliary, /**< Only for Firm use. Not extensible. (irm_T, irm_ANY, irm_BAD) */
/* irms_control_flow **< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */
/* irms_memory **< Marks the memory mode. Not extensible. (irm_M) */
irms_internal_boolean, /**< Internal boolean representation.
extern ir_mode *mode_U; /**< 16 bit unicode char */
extern ir_mode *mode_P; /**< pointer */
+extern ir_mode *mode_ANY;/**< undefined mode */
+extern ir_mode *mode_BAD;/**< bad mode */
+
/*@{*/
/** Access routines for JNI Interface */
ir_mode *get_modeT(void);
ir_mode *get_modeX(void);
ir_mode *get_modeM(void);
ir_mode *get_modeBB(void);
+ir_mode *get_modeANY(void);
+ir_mode *get_modeBAD(void);
/**
Functions to check, whether a modecode is signed, float, int, num, data,
int mode_is_data (const ir_mode *mode);
int mode_is_datab (const ir_mode *mode);
int mode_is_dataM (const ir_mode *mode);
+
/** Returns true if sm can be converted to lm without loss
according to firm definiton */
int smaller_mode(const ir_mode *sm, const ir_mode *lm);
return tarval_bad;
}
-/* if n can be computed, return the value, else NULL. Performs
+/* if n can be computed, return the value, else tarval_bad. Performs
constant folding. GL: Only if n is arithmetic operator? */
tarval *
computed_value (ir_node *n)
ir_node *on;
/* After running compute_node there is only one constant predecessor.
Find this predecessors value and remember the other node: */
- if ((tv = computed_value (a))) {
+ if ((tv = computed_value (a)) != tarval_bad) {
on = b;
- } else if ((tv = computed_value (b))) {
+ } else if ((tv = computed_value (b)) != tarval_bad) {
on = a;
} else break;
memset(quot, SC_0, CALC_BUFFER_SIZE);
memset(rem, SC_0, CALC_BUFFER_SIZE);
+ /* if the divisor is zero this won't work (quot is zero) */
+ if (sc_comp(divisor, quot) == 0) assert(0 && "division by zero!");
+
/* if the dividend is zero result is zero (quot is zero)*/
if (sc_comp(dividend, quot) == 0)
return;
- /* if the divisor is zero this won't work (quot is zero) */
- if (sc_comp(divisor, quot) == 0) assert(0 && "division by zero!");
if (_sign(dividend) == -1)
{
ANNOUNCE();
tarval_bad = (tarval*)malloc(sizeof(tarval));
- tarval_bad->mode = NULL;
+ tarval_bad->mode = mode_BAD;
tarval_undefined = (tarval*)malloc(sizeof(tarval));
- tarval_undefined->mode = NULL;
+ tarval_undefined->mode = mode_ANY;
tarval_b_true = (tarval*)malloc(sizeof(tarval));
tarval_b_true->mode = mode_b;