fehler 17
[libfirm] / ir / lower / lower_dw.c
index 605cae8..753eb9d 100644 (file)
@@ -1,23 +1,33 @@
 /*
- * Project:     libFIRM
- * File name:   ir/lower/lower_dw.c
- * Purpose:     Lower Double word operations, ie Mode L -> I.
- * Author:      Michael Beck
- * Created:     8.10.2004
- * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2006 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 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   Lower Double word operations, ie 64bit -> 32bit, 32bit -> 16bit etc.
+ * @date    8.10.2004
+ * @author  Michael Beck
+ * @version $Id$
  */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-#endif
 #ifdef HAVE_STRING_H
 # include <string.h>
 #endif
@@ -27,6 +37,7 @@
 
 #include <assert.h>
 
+#include "lowering.h"
 #include "irnode_t.h"
 #include "irgraph_t.h"
 #include "irmode_t.h"
@@ -39,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"
@@ -47,6 +57,7 @@
 #include "pmap.h"
 #include "pdeq.h"
 #include "irdump.h"
+#include "xmalloc.h"
 
 /** A map from mode to a primitive type. */
 static pmap *prim_types;
@@ -73,7 +84,7 @@ typedef struct _op_mode_entry {
        const ir_op   *op;    /**< the op */
        const ir_mode *imode; /**< the input mode */
        const ir_mode *omode; /**< the output mode */
-       entity        *ent;   /**< the associated entity of this (op, imode, omode) triple */
+       ir_entity     *ent;   /**< the associated entity of this (op, imode, omode) triple */
 } op_mode_entry_t;
 
 /**
@@ -490,7 +501,7 @@ static ir_node *get_intrinsic_address(ir_type *method, ir_op *op,
                                       ir_mode *imode, ir_mode *omode,
                                       ir_node *block, lower_env_t *env) {
        symconst_symbol sym;
-       entity *ent;
+       ir_entity *ent;
        op_mode_entry_t key, *entry;
 
        key.op    = op;
@@ -679,7 +690,9 @@ static void lower_Mod(ir_node *node, ir_mode *mode, lower_env_t *env) {
  * Create two intrinsic Calls.
  */
 static void lower_DivMod(ir_node *node, ir_mode *mode, lower_env_t *env) {
-       ir_node  *block, *proj, *irn, *mem, *callDiv, *callMod, *resDiv, *resMod;
+       ir_node  *block, *proj, *irn, *mem, *callDiv, *callMod;
+       ir_node  *resDiv = NULL;
+       ir_node  *resMod = NULL;
        ir_node  *in[4];
        ir_mode  *opmode;
        dbg_info *dbg;
@@ -1699,12 +1712,12 @@ static ir_type *lower_mtp(ir_type *mtp, lower_env_t *env) {
  * Translate a Return.
  */
 static void lower_Return(ir_node *node, ir_mode *mode, lower_env_t *env) {
-       ir_graph *irg = current_ir_graph;
-       entity   *ent = get_irg_entity(irg);
-       ir_type  *mtp = get_entity_type(ent);
-       ir_node  **in;
-       int      i, j, n, idx;
-       int      need_conv = 0;
+       ir_graph  *irg = current_ir_graph;
+       ir_entity *ent = get_irg_entity(irg);
+       ir_type   *mtp = get_entity_type(ent);
+       ir_node   **in;
+       int       i, j, n, idx;
+       int       need_conv = 0;
 
        /* check if this return must be lowered */
        for (i = 0, n = get_Return_n_ress(node); i < n; ++i) {
@@ -1756,13 +1769,13 @@ static void lower_Return(ir_node *node, ir_mode *mode, lower_env_t *env) {
  * Translate the parameters.
  */
 static void lower_Start(ir_node *node, ir_mode *mode, lower_env_t *env) {
-       ir_graph *irg = current_ir_graph;
-       entity   *ent = get_irg_entity(irg);
-       ir_type  *tp  = get_entity_type(ent);
-       ir_type  *mtp;
-       long     *new_projs;
-       int      i, j, n_params, rem;
-       ir_node  *proj, *args;
+       ir_graph  *irg = current_ir_graph;
+       ir_entity *ent = get_irg_entity(irg);
+       ir_type   *tp  = get_entity_type(ent);
+       ir_type   *mtp;
+       long      *new_projs;
+       int       i, j, n_params, rem;
+       ir_node   *proj, *args;
 
        if (is_lowered_type(tp)) {
                mtp = get_associated_type(tp);
@@ -2108,7 +2121,7 @@ static void lower_Psi(ir_node *psi, ir_mode *mode, lower_env_t *env) {
 /**
  * check for opcodes that must always be lowered.
  */
-static int always_lower(opcode code) {
+static int always_lower(ir_opcode code) {
        switch (code) {
        case iro_Proj:
        case iro_Start:
@@ -2447,8 +2460,6 @@ void lower_dw_ops(const lwrdw_param_t *param)
                                set_irg_extblk_inconsistent(irg);
                                set_irg_loopinfo_inconsistent(irg);
                        }  /* if */
-
-                       dump_ir_block_graph(irg, "-dw");
                }  /* if */
                pmap_destroy(lenv.proj_2_block);
                free(lenv.entries);
@@ -2459,13 +2470,13 @@ void lower_dw_ops(const lwrdw_param_t *param)
 }  /* lower_dw_ops */
 
 /* Default implementation. */
-entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
-                                 const ir_mode *imode, const ir_mode *omode,
-                                 void *context)
+ir_entity *def_create_intrinsic_fkt(ir_type *method, const ir_op *op,
+                                    const ir_mode *imode, const ir_mode *omode,
+                                    void *context)
 {
        char buf[64];
        ident *id;
-       entity *ent;
+       ir_entity *ent;
 
        if (imode == omode) {
                snprintf(buf, sizeof(buf), "__l%s%s", get_op_name(op), get_mode_name(imode));