made CondJmp and SwitchJmp pinned
[libfirm] / ir / tv / tv.c
index 8d07988..f7a8f22 100644 (file)
@@ -1,31 +1,40 @@
 /*
- * Project:     libFIRM
- * File name:   ir/tv/tv.c
- * Purpose:     Representation of and static computations on target machine
- *              values.
- * Author:      Mathias Heil
- * Modified by:
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 2003-2007 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.
  */
 
-/*
- *    Values are stored in a format depending upon chosen arithmetic
- *    module. Default uses strcalc and fltcalc.
+/**
+ * @file
+ * @brief    Representation of and static computations on target machine
+ *           values.
+ * @date     2003
+ * @author   Mathias Heil
+ * @version  $Id$
+ * @summary
  *
+ * Values are stored in a format depending upon chosen arithmetic
+ * module. Default uses strcalc and fltcalc.
+ * This implementation assumes:
+ *  - target has IEEE-754 floating-point arithmetic.
  */
-
-/* This implementation assumes:
- *  - target has IEEE-754 floating-point arithmetic.  */
-
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-
 #include <assert.h>         /* assertions */
 #include <stdlib.h>         /* atoi() */
 #ifdef HAVE_STRING_H
 #ifdef HAVE_STDLIB_H
 # include <stdlib.h>
 #endif
-#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-#endif
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
 
 #include "tv_t.h"
 #include "set.h"            /* to store tarvals in */
@@ -327,7 +330,7 @@ int tarval_is_long(tarval *tv) {
 
        if (sort != irms_int_number && sort != irms_character) return 0;
 
-       if (get_mode_size_bits(tv->mode) > (sizeof(long) << 3)) {
+       if (get_mode_size_bits(tv->mode) > (int) (sizeof(long) << 3)) {
                /* the value might be too big to fit in a long */
                sc_max_from_bits(sizeof(long) << 3, 0, NULL);
                if (sc_comp(sc_get_buffer(), tv->value) == -1) {
@@ -834,14 +837,15 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m) {
                }
                break;
 
-       /* cast int to something */
+       /* cast int/characters to something */
        case irms_int_number:
+       case irms_character:
                switch (get_mode_sort(m)) {
                case irms_int_number:
                case irms_character:
                        buffer = alloca(sc_get_buffer_length());
                        memcpy(buffer, src->value, sc_get_buffer_length());
-                       sign_extend(buffer, src->mode);
+                       sign_extend(buffer, m);
                        return get_tarval_overflow(buffer, src->length, m);
 
                case irms_internal_boolean:
@@ -894,9 +898,17 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m) {
                }
                break;
 
-       case irms_character:
-               break;
        case irms_reference:
+               switch(get_mode_sort(m)) {
+               case irms_int_number:
+                       buffer = alloca(sc_get_buffer_length());
+                       memcpy(buffer, src->value, sc_get_buffer_length());
+                       sign_extend(buffer, src->mode);
+                       return get_tarval_overflow(buffer, src->length, m);
+               default:
+                       break;
+               }
+
                break;
        }
 
@@ -1426,7 +1438,7 @@ int tarval_printf(tarval *tv) {
        int res;
 
        res = tarval_snprintf(buf, sizeof(buf), tv);
-       assert(res < sizeof(buf) && "buffer to small for tarval_snprintf");
+       assert(res < (int) sizeof(buf) && "buffer to small for tarval_snprintf");
        printf(buf);
        return res;
 }