use ffreep st instead of fstp st on athlon
[libfirm] / ir / lower / lower_dw.c
index 7cfc3be..4132338 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <assert.h>
 
+#include "lowering.h"
 #include "irnode_t.h"
 #include "irgraph_t.h"
 #include "irmode_t.h"
@@ -49,7 +50,6 @@
 #include "firmstat.h"
 #include "irgwalk.h"
 #include "ircons.h"
-#include "lower_dw.h"
 #include "irflag.h"
 #include "irtools.h"
 #include "debug.h"
@@ -424,6 +424,8 @@ static void lower_Store(ir_node *node, ir_mode *mode, lower_env_t *env) {
        dbg_info *dbg;
        int      idx;
        node_entry_t *entry;
+       (void) node;
+       (void) mode;
 
        irn = get_Store_value(node);
        entry = env->entries[get_irn_idx(irn)];
@@ -1174,42 +1176,6 @@ static void lower_Not(ir_node *node, ir_mode *mode, lower_env_t *env) {
        env->entries[idx]->high_word = new_rd_Not(dbg, current_ir_graph, block, op_h, mode);
 }  /* lower_Not */
 
-/**
- * Translate a Minus.
- *
- * Create two Minus'.
- */
-static void lower_Minus(ir_node *node, ir_mode *mode, lower_env_t *env) {
-       ir_node  *block, *irn;
-       ir_node  *op_l, *op_h;
-       dbg_info *dbg;
-       int      idx;
-       ir_graph *irg;
-       node_entry_t *entry;
-
-       irn   = get_Minus_op(node);
-       entry = env->entries[get_irn_idx(irn)];
-       assert(entry);
-
-       if (! entry->low_word) {
-               /* not ready yet, wait */
-               pdeq_putr(env->waitq, node);
-               return;
-       }  /* if */
-
-       op_l = entry->low_word;
-       op_h = entry->high_word;
-
-       dbg   = get_irn_dbg_info(node);
-       block = get_nodes_block(node);
-       irg   = current_ir_graph;
-
-       idx = get_irn_idx(node);
-       assert(idx < env->n_entries);
-       env->entries[idx]->low_word  = new_rd_Minus(dbg, current_ir_graph, block, op_l, mode);
-       env->entries[idx]->high_word = new_rd_Minus(dbg, current_ir_graph, block, op_h, mode);
-}  /* lower_Minus */
-
 /**
  * Translate a Cond.
  */
@@ -1218,6 +1184,7 @@ static void lower_Cond(ir_node *node, ir_mode *mode, lower_env_t *env) {
        ir_node *sel = get_Cond_selector(node);
        ir_mode *m = get_irn_mode(sel);
        int     idx;
+       (void) mode;
 
        if (m == mode_b) {
                node_entry_t *lentry, *rentry;
@@ -1229,7 +1196,13 @@ static void lower_Cond(ir_node *node, ir_mode *mode, lower_env_t *env) {
                pn_Cmp   pnc;
                dbg_info *dbg;
 
+               if(!is_Proj(sel))
+                       return;
+
                cmp   = get_Proj_pred(sel);
+               if(!is_Cmp(cmp))
+                       return;
+
                left  = get_Cmp_left(cmp);
                idx   = get_irn_idx(left);
                lentry = env->entries[idx];
@@ -1450,8 +1423,13 @@ static void lower_Conv_to_Ls(ir_node *node, lower_env_t *env) {
                                op = new_rd_Conv(dbg, irg, block, op, dst_mode);
 
                        env->entries[idx]->low_word  = op;
-                       env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op,
-                               new_Const_long(mode_Iu, get_mode_size_bits(dst_mode) - 1), dst_mode);
+
+                       if (mode_is_signed(imode)) {
+                               env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op,
+                                       new_Const_long(mode_Iu, get_mode_size_bits(dst_mode) - 1), dst_mode);
+                       } else {
+                               env->entries[idx]->high_word = new_Const(dst_mode, get_mode_null(dst_mode));
+                       }  /* if */
                }  /* if */
        } else {
                ir_node *irn, *call;
@@ -1500,7 +1478,13 @@ static void lower_Conv_to_Lu(ir_node *node, lower_env_t *env) {
                                op = new_rd_Conv(dbg, irg, block, op, dst_mode);
 
                        env->entries[idx]->low_word  = op;
-                       env->entries[idx]->high_word = new_Const(dst_mode, get_mode_null(dst_mode));
+
+                       if (mode_is_signed(imode)) {
+                               env->entries[idx]->high_word = new_rd_Shrs(dbg, irg, block, op,
+                                       new_Const_long(mode_Iu, get_mode_size_bits(dst_mode) - 1), dst_mode);
+                       } else {
+                               env->entries[idx]->high_word = new_Const(dst_mode, get_mode_null(dst_mode));
+                       }  /* if */
                }  /* if */
        } else {
                ir_node *irn, *call;
@@ -1531,6 +1515,12 @@ static void lower_Conv_from_Ls(ir_node *node, lower_env_t *env) {
 
        assert(idx < env->n_entries);
 
+       if (! env->entries[idx]->low_word) {
+               /* not ready yet, wait */
+               pdeq_putr(env->waitq, node);
+               return;
+       }  /* if */
+
        if (mode_is_int(omode) || mode_is_reference(omode)) {
                op = env->entries[idx]->low_word;
 
@@ -1569,6 +1559,12 @@ static void lower_Conv_from_Lu(ir_node *node, lower_env_t *env) {
 
        assert(idx < env->n_entries);
 
+       if (! env->entries[idx]->low_word) {
+               /* not ready yet, wait */
+               pdeq_putr(env->waitq, node);
+               return;
+       }  /* if */
+
        if (mode_is_int(omode) || mode_is_reference(omode)) {
                op = env->entries[idx]->low_word;
 
@@ -1718,6 +1714,7 @@ static void lower_Return(ir_node *node, ir_mode *mode, lower_env_t *env) {
        ir_node   **in;
        int       i, j, n, idx;
        int       need_conv = 0;
+       (void) mode;
 
        /* check if this return must be lowered */
        for (i = 0, n = get_Return_n_ress(node); i < n; ++i) {
@@ -1776,6 +1773,7 @@ static void lower_Start(ir_node *node, ir_mode *mode, lower_env_t *env) {
        long      *new_projs;
        int       i, j, n_params, rem;
        ir_node   *proj, *args;
+       (void) mode;
 
        if (is_lowered_type(tp)) {
                mtp = get_associated_type(tp);
@@ -1863,6 +1861,7 @@ static void lower_Call(ir_node *node, ir_mode *mode, lower_env_t *env) {
        int      n_params, n_res, need_lower = 0;
        int      i, j;
        long     *res_numbers = NULL;
+       (void) mode;
 
        if (is_lowered_type(tp)) {
                call_tp = get_associated_type(tp);
@@ -2267,6 +2266,7 @@ static void lower_ops(ir_node *node, void *env)
 static int cmp_op_mode(const void *elt, const void *key, size_t size) {
        const op_mode_entry_t *e1 = elt;
        const op_mode_entry_t *e2 = key;
+       (void) size;
 
        return (e1->op - e2->op) | (e1->imode - e2->imode) | (e1->omode - e2->omode);
 }  /* cmp_op_mode */
@@ -2277,6 +2277,7 @@ static int cmp_op_mode(const void *elt, const void *key, size_t size) {
 static int cmp_conv_tp(const void *elt, const void *key, size_t size) {
        const conv_tp_entry_t *e1 = elt;
        const conv_tp_entry_t *e2 = key;
+       (void) size;
 
        return (e1->imode - e2->imode) | (e1->omode - e2->omode);
 }  /* static int cmp_conv_tp */
@@ -2405,11 +2406,11 @@ void lower_dw_ops(const lwrdw_param_t *param)
        LOWER(Shr);
        LOWER(Shrs);
        LOWER(Rot);
-       LOWER(Minus);
        LOWER(DivMod);
        LOWER(Div);
        LOWER(Mod);
        LOWER_UN(Abs);
+       LOWER_UN(Minus);
 
        LOWER(Conv);
 
@@ -2477,6 +2478,7 @@ ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
        char buf[64];
        ident *id;
        ir_entity *ent;
+       (void) context;
 
        if (imode == omode) {
                snprintf(buf, sizeof(buf), "__l%s%s", get_op_name(op), get_mode_name(imode));