fixed warnings
[libfirm] / ir / opt / opt_osr.c
index 26e8647..5bbff09 100644 (file)
@@ -1,27 +1,37 @@
+/*
+ * 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.
+ */
+
 /**
- * Project:     libFIRM
- * File name:   ir/opt/opt_osr.c
- * Purpose:     Operator Strength Reduction, based on
- *              Keith D. Cooper, L. Taylor Simpson, Christopher A. Vick
- * Author:      Michael Beck
- * Modified by:
- * Created:     12.5.2006
- * CVS-ID:      $Id$
- * Copyright:   (c) 2006 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * @file
+ * @brief   Operator Strength Reduction.
+ * @date    12.5.2006
+ * @author  Michael Beck
+ * @version $Id$
+ * @summary
+ *  Implementation of the Operator Strength Reduction algorithm
+ *  by Keith D. Cooper, L. Taylor Simpson, Christopher A. Vick.
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#include "opt_osr.h"
+#include "iroptimize.h"
 #include "irgraph.h"
 #include "ircons.h"
 #include "irop_t.h"
@@ -40,6 +50,7 @@
 #include "irloop_t.h"
 #include "array.h"
 #include "firmstat.h"
+#include "xmalloc.h"
 
 /** The debug handle. */
 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
@@ -80,21 +91,21 @@ typedef struct iv_env {
  * An entry in the (op, node, node) -> node map.
  */
 typedef struct quadruple_t {
-       opcode  code;  /**< the opcode of the reduced operation */
-       ir_node *op1;  /**< the first operand the reduced operation */
-       ir_node *op2;  /**< the second operand of the reduced operation */
+       ir_opcode code;  /**< the opcode of the reduced operation */
+       ir_node   *op1;  /**< the first operand the reduced operation */
+       ir_node   *op2;  /**< the second operand of the reduced operation */
 
-       ir_node *res; /**< the reduced operation */
+       ir_node   *res; /**< the reduced operation */
 } quadruple_t;
 
 /**
  * A LFTR edge.
  */
 typedef struct LFTR_edge {
-       ir_node *src;   /**< the source node */
-       ir_node *dst;   /**< the destination node */
-       opcode  code;   /**< the opcode that must be applied */
-       ir_node *rc;    /**< the region const that must be applied */
+       ir_node   *src;   /**< the source node */
+       ir_node   *dst;   /**< the destination node */
+       ir_opcode code;   /**< the opcode that must be applied */
+       ir_node   *rc;    /**< the region const that must be applied */
 } LFTR_edge;
 
 /* forward */
@@ -106,6 +117,7 @@ static ir_node *reduce(ir_node *orig, ir_node *iv, ir_node *rc, iv_env *env);
 static int LFTR_cmp(const void *e1, const void *e2, size_t size) {
        const LFTR_edge *l1 = e1;
        const LFTR_edge *l2 = e2;
+       (void) size;
 
        return l1->src != l2->src;
 }
@@ -126,7 +138,7 @@ static LFTR_edge *LFTR_find(ir_node *src, iv_env *env) {
 /**
  * Add a LFTR edge.
  */
-static void LFTR_add(ir_node *src, ir_node *dst, opcode code, ir_node *rc, iv_env *env) {
+static void LFTR_add(ir_node *src, ir_node *dst, ir_opcode code, ir_node *rc, iv_env *env) {
        LFTR_edge key;
 
        key.src  = src;
@@ -187,6 +199,7 @@ static int is_rc(ir_node *irn, ir_node *header_block) {
 static int quad_cmp(const void *e1, const void *e2, size_t size) {
        const quadruple_t *c1 = e1;
        const quadruple_t *c2 = e2;
+       (void) size;
 
        return c1->code != c2->code || c1->op1 != c2->op1 || c1->op2 != c2->op2;
 }
@@ -201,7 +214,7 @@ static int quad_cmp(const void *e1, const void *e2, size_t size) {
  *
  * @return the already reduced node or NULL if this operation is not yet reduced
  */
-static ir_node *search(opcode code, ir_node *op1, ir_node *op2, iv_env *env) {
+static ir_node *search(ir_opcode code, ir_node *op1, ir_node *op2, iv_env *env) {
        quadruple_t key, *entry;
 
        key.code = code;
@@ -224,7 +237,7 @@ static ir_node *search(opcode code, ir_node *op1, ir_node *op2, iv_env *env) {
  * @param result  the result of the reduced operation
  * @param env     the environment
  */
-static void add(opcode code, ir_node *op1, ir_node *op2, ir_node *result, iv_env *env) {
+static void add(ir_opcode code, ir_node *op1, ir_node *op2, ir_node *result, iv_env *env) {
        quadruple_t key;
 
        key.code = code;
@@ -265,7 +278,7 @@ static ir_node *find_location(ir_node *block1, ir_node *block2) {
  *
  * @return the newly created node
  */
-static ir_node *do_apply(opcode code, dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode) {
+static ir_node *do_apply(ir_opcode code, dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode) {
        ir_graph *irg = current_ir_graph;
        ir_node *result;
        ir_node *block = find_location(get_nodes_block(op1), get_nodes_block(op2));
@@ -299,7 +312,7 @@ static ir_node *do_apply(opcode code, dbg_info *db, ir_node *op1, ir_node *op2,
  * @return the newly created node
  */
 static ir_node *apply(ir_node *orig, ir_node *op1, ir_node *op2, iv_env *env) {
-       opcode code = get_irn_opcode(orig);
+       ir_opcode code = get_irn_opcode(orig);
        ir_node *result = search(code, op1, op2, env);
 
        if (! result) {
@@ -332,7 +345,7 @@ static ir_node *apply(ir_node *orig, ir_node *op1, ir_node *op2, iv_env *env) {
  * @return the reduced node
  */
 static ir_node *reduce(ir_node *orig, ir_node *iv, ir_node *rc, iv_env *env) {
-       opcode code = get_irn_opcode(orig);
+       ir_opcode code = get_irn_opcode(orig);
        ir_node *result = search(code, iv, rc, env);
 
        if (! result) {
@@ -422,10 +435,10 @@ static int replace(ir_node *irn, ir_node *iv, ir_node *rc, iv_env *env) {
  * @return non-zero if irn should be Replace'd
  */
 static int check_replace(ir_node *irn, iv_env *env) {
-       ir_node *left, *right, *iv, *rc;
-       ir_op   *op  = get_irn_op(irn);
-       opcode  code = get_op_code(op);
-       ir_node *liv, *riv;
+       ir_node   *left, *right, *iv, *rc;
+       ir_op     *op  = get_irn_op(irn);
+       ir_opcode code = get_op_code(op);
+       ir_node   *liv, *riv;
 
        switch (code) {
        case iro_Mul:
@@ -1004,6 +1017,7 @@ static void lftr(ir_graph *irg, iv_env *env) {
  */
 static void clear_and_fix(ir_node *irn, void *env)
 {
+       (void) env;
        set_irn_link(irn, NULL);
 
        if (is_Proj(irn)) {