Replaced set_irn_n(*, -1, *) and get_irn_n(*, -1) by new get_nodes_block()/set_nodes_...
[libfirm] / ir / ir / irprintf.c
index 2141195..42113f9 100644 (file)
@@ -1,22 +1,29 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ir/irprintf.c
- * Purpose:     A little printf helper unterstanding firm types
- * Author:      Sebastian Hack
- * Created:     29.11.2004
- * 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 irprintf.c
- *
- * A little printf helper unterstanding firm types.
- * @author Sebastian Hack
- * @date 29.11.2004
+ * @file
+ * @brief   A little printf helper unterstanding firm types
+ * @author  Sebastian Hack
+ * @date    29.11.2004
+ * @version $Id$
  */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -55,7 +62,8 @@
  */
 static void str_init(void *object, size_t n)
 {
-  strcpy(object, "");
+       (void) n;
+       strcpy(object, "");
 }
 
 /**
@@ -85,6 +93,8 @@ static void str_append_str(void *object, size_t n, const char *str)
  */
 static void file_init(void *object, size_t n)
 {
+       (void) object;
+       (void) n;
 }
 
 /**
@@ -92,7 +102,8 @@ static void file_init(void *object, size_t n)
  */
 static void file_append_char(void *object, size_t n, char ch)
 {
-  fputc(ch, object);
+       (void) n;
+       fputc(ch, object);
 }
 
 /**
@@ -100,7 +111,8 @@ static void file_append_char(void *object, size_t n, char ch)
  */
 static void file_append_str(void *object, size_t n, const char *str)
 {
-  fputs(str, object);
+       (void) n;
+       fputs(str, object);
 }
 
 /**
@@ -108,6 +120,8 @@ static void file_append_str(void *object, size_t n, const char *str)
  */
 static void obst_init(void *object, size_t n)
 {
+       (void) object;
+       (void) n;
 }
 
 /**
@@ -115,8 +129,9 @@ static void obst_init(void *object, size_t n)
  */
 static void obst_append_char(void *object, size_t n, char ch)
 {
-  struct obstack *obst = object;
-  obstack_1grow(obst, ch);
+       struct obstack *obst = object;
+       (void) n;
+       obstack_1grow(obst, ch);
 }
 
 /**
@@ -124,8 +139,9 @@ static void obst_append_char(void *object, size_t n, char ch)
  */
 static void obst_append_str(void *object, size_t n, const char *str)
 {
-  struct obstack *obst = object;
-  obstack_grow(obst, str, strlen(str));
+       struct obstack *obst = object;
+       (void) n;
+       obstack_grow(obst, str, strlen(str));
 }
 
 
@@ -255,7 +271,7 @@ static void dump_with_settings(const appender_t *app, void *object, size_t limit
 /**
  * Beware: do not set the entity ld_name
  */
-static const char *get_entity_ld_name_ex(entity *ent) {
+static const char *get_entity_ld_name_ex(ir_entity *ent) {
   if (ent->ld_name)
     return get_entity_ld_name(ent);
   return get_entity_name(ent);
@@ -274,7 +290,7 @@ static void firm_emit(char *buf, int buflen, char conversion,
   ir_node *block;
   char add[64];
   char tv_buf[256];
-  entity *ent;
+  ir_entity *ent;
 
   buf[0] = '\0';
   add[0] = '\0';
@@ -328,15 +344,21 @@ static void firm_emit(char *buf, int buflen, char conversion,
           case symconst_type_tag:    /* type tag */
             snprintf(tv_buf, sizeof(tv_buf), "<ID:%s>", get_type_name(get_SymConst_type(X)));
             break;
-          case symconst_size:        /* type size */
+          case symconst_type_size:   /* type size */
             snprintf(tv_buf, sizeof(tv_buf), "<SIZE:%s>", get_type_name(get_SymConst_type(X)));
             break;
+          case symconst_type_align:  /* type alignment */
+            snprintf(tv_buf, sizeof(tv_buf), "<ALIGN:%s>", get_type_name(get_SymConst_type(X)));
+            break;
           case symconst_addr_name:   /* linker name */
             snprintf(tv_buf, sizeof(tv_buf), "<EXT:%s>", get_id_str(get_SymConst_name(X)));
             break;
           case symconst_addr_ent:    /* entity name */
             snprintf(tv_buf, sizeof(tv_buf), "<%s>", get_entity_name(get_SymConst_entity(X)));
             break;
+          case symconst_enum_const:  /* enumeration constant */
+            snprintf(tv_buf, sizeof(tv_buf), "<ENUM:%s>", get_enumeration_name(get_SymConst_enum(X)));
+            break;
           default:
             tv_buf[0] = '\0';
           }
@@ -475,18 +497,27 @@ static void ir_common_vprintf(const appender_t *app, void *object,
                                case 'h':
                                        len_str = "h";
                                        len = len_short;
-                                       if((ch = fmt[++i]) == 'h') {
+                                       ++i;
+                                       if((ch = fmt[i]) == 'h') {
                                                len_str = "hh";
                                                len = len_char;
+                                               ++i;
                                        }
                                        break;
 
                                case 'l':
                                        len_str = "l";
                                        len = len_long;
-                                       if((ch = fmt[++i]) == 'l') {
+                                       ++i;
+                                       if ((ch = fmt[i]) == 'l') {
                                                len_str = "ll";
                                                len = len_long_long;
+                                               ++i;
+                                       }
+                                       else if ((ch = fmt[i]) == 'u') {
+                                               len_str = "lu";
+                                               len = len_long_long;
+                                               ++i;
                                        }
                                        break;