rename set_using_visited to set_using_irn_visited, some cosmetics, remove obsolete...
[libfirm] / ir / ir / irmode_t.h
index 6e79a80..dce37f1 100644 (file)
@@ -1,69 +1,46 @@
 /*
- * Project:     libFIRM
- * File name:   ir/ir/irmode_t.h
- * Purpose:     Data modes of operations -- private header.
- * Author:      Martin Trapp, Christian Schaefer
- * Modified by: Goetz Lindenmaier, Mathias Heil
- * Created:
- * CVS-ID:      $Id$
- * Copyright:   (c) 1998-2003 Universität Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2008 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 irmode_t.h
+ * @file
+ * @brief   Data modes of operations -- private header.
+ * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil,
+ *          Michael Beck
+ * @version $Id$
  */
+#ifndef FIRM_IR_IRMODE_T_H
+#define FIRM_IR_IRMODE_T_H
 
-# ifndef _IRMODE_T_H_
-# define _IRMODE_T_H_
-
-# include "irmode.h"
-# include "tv.h"
-
-/** This struct is supposed to completely define a mode. **/
-struct ir_mode {
-  firm_kind         kind;       /**< distinguishes this node from others */
-  modecode          code;       /**< unambiguous identifier of a mode */
-  ident             *name;      /**< Name ident of this mode */
-
-  /* ----------------------------------------------------------------------- */
-  /* On changing this struct you have to evaluate the mode_are_equal function!*/
-  mode_sort         sort;          /**< coarse classification of this mode:
-                                     int, float, reference ...
-                                     (see irmode.h) */
-  mode_arithmetic   arithmetic;    /**< different arithmetic operations possible with a mode */
-  int               size;          /**< size of the mode in Bits. */
-  unsigned          sign:1;        /**< signedness of this mode */
-  unsigned int      modulo_shift;  /**< number of bits a values of this mode will be shifted */
-  unsigned          vector_elem;   /**< if this is not equal 1, this is a vector mode with
-                                       vector_elem number of elements, size contains the size
-                                       of all bits and must be dividable by vector_elem */
-
-  /* ----------------------------------------------------------------------- */
-  tarval            *min;       /**< the minimum value that can be expressed */
-  tarval            *max;       /**< the maximum value that can be expressed */
-  tarval            *null;      /**< the value 0 */
-  tarval            *one;       /**< the value 1 */
-  tarval            *minus_one; /**< the value -1 */
-  void              *link;      /**< To store some intermediate information */
-  const void        *tv_priv;   /**< tarval module will save private data here */
-};
-
+#include <assert.h>
+#include "irtypes.h"
+#include "irmode.h"
 
 /* ------------------------------- *
  * inline functions                *
  * ------------------------------- */
-extern ir_mode *mode_P_mach;
+extern ir_mode *mode_P_code, *mode_P_data;
 
 static INLINE ir_mode *
-_get_modeP_mach(void) { return mode_P_mach; }
+_get_modeP_code(void) { return mode_P_code; }
 
-static INLINE void
-_set_modeP_mach(ir_mode *p) {
-  assert(mode_is_reference(p));
-  mode_P_mach = p;
-}
+static INLINE ir_mode *
+_get_modeP_data(void) { return mode_P_data; }
 
 static INLINE modecode
 _get_mode_modecode(const ir_mode *mode) { return mode->code; }
@@ -74,20 +51,20 @@ _get_mode_ident(const ir_mode *mode) { return mode->name; }
 static INLINE mode_sort
 _get_mode_sort(const ir_mode* mode) { return mode->sort; }
 
-static INLINE int
+static INLINE unsigned
 _get_mode_size_bits(const ir_mode *mode) { return mode->size; }
 
-static INLINE int
+static INLINE unsigned
 _get_mode_size_bytes(const ir_mode *mode) {
-  int size = _get_mode_size_bits(mode);
-  if ((size & 7) != 0) return -1;
-  return size >> 3;
+       unsigned size = _get_mode_size_bits(mode);
+       if ((size & 7) != 0) return (unsigned) -1;
+       return size >> 3;
 }
 
 static INLINE int
 _get_mode_sign(const ir_mode *mode) { return mode->sign; }
 
-static INLINE int
+static INLINE mode_arithmetic
 _get_mode_arithmetic(const ir_mode *mode) { return mode->arithmetic; }
 
 static INLINE unsigned int
@@ -104,7 +81,7 @@ _set_mode_link(ir_mode *mode, void *l) { mode->link = l; }
 
 /* Functions to check, whether a modecode is signed, float, int, num, data,
    datab or dataM. For more exact definitions read the corresponding pages
-   in the firm documentation or the followingenumeration
+   in the firm documentation or the following enumeration
 
    The set of "float" is defined as:
    ---------------------------------
@@ -141,74 +118,61 @@ _set_mode_link(ir_mode *mode, void *l) { mode->link = l; }
 
 static INLINE int
 _mode_is_signed(const ir_mode *mode) {
-  assert(mode);
-  return mode->sign;
+       assert(mode);
+       return mode->sign;
 }
 
 static INLINE int
 _mode_is_float(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_float_number);
+       assert(mode);
+       return (_get_mode_sort(mode) == irms_float_number);
 }
 
 static INLINE int
 _mode_is_int(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_int_number);
-}
-
-static INLINE int
-_mode_is_character(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_character);
+       assert(mode);
+       return (_get_mode_sort(mode) == irms_int_number);
 }
 
 static INLINE int
 _mode_is_reference(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_reference);
+       assert(mode);
+       return (_get_mode_sort(mode) == irms_reference);
 }
 
 static INLINE int
 _mode_is_num(const ir_mode *mode) {
-  assert(mode);
-  return (_mode_is_int(mode) || _mode_is_float(mode));
-}
-
-static INLINE int
-_mode_is_numP(const ir_mode *mode) {
-  assert(mode);
-  return (_mode_is_int(mode) || _mode_is_float(mode) || _mode_is_reference(mode));
+       assert(mode);
+       return (_mode_is_int(mode) || _mode_is_float(mode));
 }
 
 static INLINE int
 _mode_is_data(const ir_mode *mode) {
-  assert(mode);
-  return (_mode_is_num(mode) || _get_mode_sort(mode) == irms_character || _get_mode_sort(mode) == irms_reference);
+       return (_mode_is_int(mode) || _mode_is_float(mode) || _mode_is_reference(mode));
 }
 
 static INLINE int
 _mode_is_datab(const ir_mode *mode) {
-  assert(mode);
-  return (_mode_is_data(mode) || _get_mode_sort(mode) == irms_internal_boolean);
+       assert(mode);
+       return (_mode_is_data(mode) || _get_mode_sort(mode) == irms_internal_boolean);
 }
 
 static INLINE int
 _mode_is_dataM(const ir_mode *mode) {
-  assert(mode);
-  return (_mode_is_data(mode) || _get_mode_modecode(mode) == irm_M);
+       assert(mode);
+       return (_mode_is_data(mode) || _get_mode_modecode(mode) == irm_M);
 }
 
 static INLINE int
 _mode_is_float_vector(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_float_number) && (_get_mode_vector_elems(mode) > 1);
+       assert(mode);
+       return (_get_mode_sort(mode) == irms_float_number) && (_get_mode_vector_elems(mode) > 1);
 }
 
 static INLINE int
 _mode_is_int_vector(const ir_mode *mode) {
-  assert(mode);
-  return (_get_mode_sort(mode) == irms_int_number) && (_get_mode_vector_elems(mode) > 1);
+       assert(mode);
+       return (_get_mode_sort(mode) == irms_int_number) && (_get_mode_vector_elems(mode) > 1);
 }
 
 /** mode module initialization, call once before use of any other function **/
@@ -217,8 +181,8 @@ void init_mode(void);
 /** mode module finalization. frees all memory.  */
 void finish_mode(void);
 
-#define get_modeP_mach()               _get_modeP_mach()
-#define set_modeP_mach(p)              _set_modeP_mach(p)
+#define get_modeP_code()               _get_modeP_code()
+#define get_modeP_data()               _get_modeP_data()
 #define get_mode_modecode(mode)        _get_mode_modecode(mode)
 #define get_mode_ident(mode)           _get_mode_ident(mode)
 #define get_mode_sort(mode)            _get_mode_sort(mode)
@@ -233,14 +197,12 @@ void finish_mode(void);
 #define mode_is_signed(mode)           _mode_is_signed(mode)
 #define mode_is_float(mode)            _mode_is_float(mode)
 #define mode_is_int(mode)              _mode_is_int(mode)
-#define mode_is_character(mode)        _mode_is_character(mode)
 #define mode_is_reference(mode)        _mode_is_reference(mode)
 #define mode_is_num(mode)              _mode_is_num(mode)
-#define mode_is_numP(mode)             _mode_is_numP(mode)
 #define mode_is_data(mode)             _mode_is_data(mode)
 #define mode_is_datab(mode)            _mode_is_datab(mode)
 #define mode_is_dataM(mode)            _mode_is_dataM(mode)
 #define mode_is_float_vector(mode)     _mode_is_float_vector(mode)
 #define mode_is_int_vector(mode)       _mode_is_int_vector(mode)
 
-#endif /* _IRMODE_T_H_ */
+#endif