emit .skip if a string initializer is shorter than the entity
[libfirm] / ir / arch / modeconv.c
index 1cc8251..b2fc2b8 100644 (file)
@@ -1,23 +1,33 @@
 /*
- * Project:     libFIRM
- * File name:   ir/arch/modeconv.c
- * Purpose:     integer mode conversion
- * Author:      Michael Beck
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2004 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 modeconv.c
- *
- * Contains the mode conversion for architectures that did not support lesser
- * integer modes. Converts all Op(mode_l) into Op(mode) operations by adding
- * conversions were needed. These Conv operations must be implemented in the backend
- * as bit-reducing ops.
+ * @file
+ * @brief    integer mode conversion
+ * @author   Michael Beck
+ * @version  $Id$
+ * @summary
+ *  Contains the mode conversion for architectures that did not support lesser
+ *  integer modes. Converts all Op(mode_l) into Op(mode) operations by adding
+ *  conversions were needed. These Conv operations must be implemented in the
+ *  backend as bit-reducing ops.
  */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 # include "firmstat.h"
 
 typedef struct _walker_t {
-  int bits;
-  ir_mode *s_mode;              /**< signed mode */
-  ir_mode *u_mode;              /**< unsigned mode */
-  int changes;
+  int bits;                     /**< number of bits in the destination mode */
+  ir_mode *s_mode;              /**< signed destination mode */
+  ir_mode *u_mode;              /**< unsigned destination mode */
+  int changes;                  /**< non-zero if the graph was changed */
 } walker_t;
 
 /**
@@ -49,7 +59,9 @@ static ir_node *fix_irn_output(ir_node *node, ir_mode *mode)
 {
   switch (get_irn_opcode(node)) {
     case iro_Proj:
+      /* Args, Load, Div, Mod */
     case iro_Conv:
+      /* Hmm, maybe the Conv should be replaced */
     case iro_Rot: {
       ir_node *block = get_nodes_block(node);
 
@@ -66,7 +78,7 @@ static ir_node *fix_irn_output(ir_node *node, ir_mode *mode)
 /**
  * Add a Conv node where needed on input
  */
-static ir_node *fix_irn_input(opcode code, ir_node *block, ir_node *pred, ir_mode *mode)
+static ir_node *fix_irn_input(ir_opcode code, ir_node *block, ir_node *pred, ir_mode *mode)
 {
   switch (code) {
     case iro_DivMod:
@@ -93,13 +105,13 @@ static ir_node *fix_irn_input(opcode code, ir_node *block, ir_node *pred, ir_mod
  */
 static void fix_mode(ir_node *n, ir_mode *mode)
 {
-  opcode code = get_irn_opcode(n);
+  ir_opcode code = get_irn_opcode(n);
 
   if (code == iro_Proj) {
     code = get_irn_opcode(get_Proj_pred(n));
   }
 
-  switch (code){
+  switch (code) {
   case iro_Return:
   case iro_Load:
   case iro_Proj:
@@ -119,16 +131,16 @@ static void do_mode_conv(ir_node *n, void *env)
   walker_t *wenv = env;
   ir_mode *mode  = get_irn_mode(n);
   ir_node *block;
-  opcode code;
+  ir_opcode code;
 
   /* save the old mode, we need this info later */
   set_irn_link(n, mode);
 
   /* special case: fix the Return */
-  if (get_irn_op(n) == op_Return) {
-    entity *ent = get_irg_entity(current_ir_graph);
-    ir_type *mt = get_entity_type(ent);
-    int i, n_ress = get_method_n_ress(mt);
+  if (is_Return(n)) {
+    ir_entity *ent = get_irg_entity(current_ir_graph);
+    ir_type *mt    = get_entity_type(ent);
+    int i, n_ress  = get_method_n_ress(mt);
 
     mode  = mode_is_signed(mode) ? wenv->s_mode : wenv->u_mode;
     block = get_nodes_block(n);
@@ -162,9 +174,6 @@ static void do_mode_conv(ir_node *n, void *env)
       ir_node *pred = get_Conv_op(n);
       ir_mode *modeA = get_irn_link(pred);
 
-      if (get_irn_node_nr(n) == 171)
-        printf("HAllo\n");
-
       if (modeA != get_irn_mode(pred)) {
         pred = new_r_Conv(current_ir_graph, get_nodes_block(pred), pred, modeA);
         set_Conv_op(n, pred);
@@ -240,13 +249,12 @@ void arch_mode_conversion(ir_graph *irg, ir_mode *mode)
   env.bits    = get_mode_size_bits(mode);
   env.changes = 0;
 
-  assert(env.s_mode && env.u_mode && "Cpould not find modes");
+  assert(env.s_mode && env.u_mode && "Could not find modes");
 
   irg_walk_graph(irg, NULL, do_mode_conv, &env);
 
-  /* Handle graph state */
+  /* Handle graph state. We never change control flow. */
   if (env.changes) {
-    if (get_irg_outs_state(current_ir_graph) == outs_consistent)
-      set_irg_outs_inconsistent(current_ir_graph);
+    set_irg_outs_inconsistent(current_ir_graph);
   }
 }