becopyheur2: Cache the admissible registers eagerly.
[libfirm] / ir / tr / tpop.c
index aecddcd..1b7113d 100644 (file)
@@ -1,27 +1,12 @@
 /*
- * 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.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
  * @file
  * @brief   Opcode of types.
  * @author  Goetz Lindenmaier, Michael Beck
- * @version $Id$
  */
 #include "config.h"
 
@@ -38,7 +23,6 @@ const tp_op *type_array;         const tp_op *get_tpop_array      (void) { retur
 const tp_op *type_enumeration;   const tp_op *get_tpop_enumeration(void) { return type_enumeration; }
 const tp_op *type_pointer;       const tp_op *get_tpop_pointer    (void) { return type_pointer;     }
 const tp_op *type_primitive;     const tp_op *get_tpop_primitive  (void) { return type_primitive;   }
-const tp_op *type_id;            const tp_op *get_tpop_id         (void) { return type_id;          }
 const tp_op *tpop_code;          const tp_op *get_tpop_code_type  (void) { return tpop_code;        }
 const tp_op *tpop_none;          const tp_op *get_tpop_none       (void) { return tpop_none;        }
 const tp_op *tpop_unknown;       const tp_op *get_tpop_unknown    (void) { return tpop_unknown;     }
@@ -53,15 +37,15 @@ new_tpop(tp_opcode code, ident *name, unsigned flags, size_t attr_size, const tp
        res->attr_size     = attr_size;
 
        if (ops)
-               memcpy(&res->ops, ops, sizeof(res->ops));
+               res->ops = *ops;
        else
                memset(&res->ops, 0, sizeof(res->ops));
 
        return res;
 }
 
-void
-free_tpop(const tp_op *tpop) {
+void free_tpop(const tp_op *tpop)
+{
        xfree((void *)tpop);
 }
 
@@ -160,35 +144,31 @@ static const tp_op_ops
                NULL,
                NULL,
                NULL,
-               NULL,
+               set_default_size,
                NULL,
                NULL,
                NULL
        };
 
-#define C     TP_OP_FLAG_COMPOUND
+void init_tpop(void)
+{
 #define ID(s) new_id_from_chars(s, sizeof(s) - 1)
-
-void init_tpop(void) {
-       type_class       = new_tpop(tpo_class      , ID("class"),       C, sizeof (cls_attr), &class_ops);
-       type_struct      = new_tpop(tpo_struct     , ID("struct"),      C, sizeof (stc_attr), &struct_ops);
-       type_method      = new_tpop(tpo_method     , ID("method"),      0, sizeof (mtd_attr), &method_ops);
-       type_union       = new_tpop(tpo_union      , ID("union"),       C, sizeof (uni_attr), &union_ops);
-       type_array       = new_tpop(tpo_array      , ID("array"),       C, sizeof (arr_attr), &array_ops);
-       type_enumeration = new_tpop(tpo_enumeration, ID("enumeration"), 0, sizeof (enm_attr), &enum_ops);
-       type_pointer     = new_tpop(tpo_pointer    , ID("pointer"),     0, sizeof (ptr_attr), &pointer_ops);
-       type_primitive   = new_tpop(tpo_primitive  , ID("primitive"),   0, sizeof (pri_attr), &null_ops);
-       tpop_code        = new_tpop(tpo_code       , ID("code"),        0, /* sizeof (non_attr) */ 0, &null_ops);
-       type_id          = new_tpop(tpo_id         , ID("type_id"),     0, /* sizeof (id_attr)  */ 0, &null_ops);
-       tpop_none        = new_tpop(tpo_none       , ID("None"),        0, /* sizeof (non_attr) */ 0, &pseudo_ops);
-       tpop_unknown     = new_tpop(tpo_unknown    , ID("Unknown"),     0, /* sizeof (ukn_attr) */ 0, &pseudo_ops);
-}
+       type_class       = new_tpop(tpo_class      , ID("class"),       TP_OP_FLAG_COMPOUND, sizeof(cls_attr), &class_ops);
+       type_struct      = new_tpop(tpo_struct     , ID("struct"),      TP_OP_FLAG_COMPOUND, sizeof(stc_attr), &struct_ops);
+       type_method      = new_tpop(tpo_method     , ID("method"),      0,                   sizeof(mtd_attr), &method_ops);
+       type_union       = new_tpop(tpo_union      , ID("union"),       TP_OP_FLAG_COMPOUND, sizeof(uni_attr), &union_ops);
+       type_array       = new_tpop(tpo_array      , ID("array"),       0,                   sizeof(arr_attr), &array_ops);
+       type_enumeration = new_tpop(tpo_enumeration, ID("enumeration"), 0,                   sizeof(enm_attr), &enum_ops);
+       type_pointer     = new_tpop(tpo_pointer    , ID("pointer"),     0,                   sizeof(ptr_attr), &pointer_ops);
+       type_primitive   = new_tpop(tpo_primitive  , ID("primitive"),   0,                   sizeof(pri_attr), &null_ops);
+       tpop_code        = new_tpop(tpo_code       , ID("code"),        0,                   0,                &null_ops);
+       tpop_none        = new_tpop(tpo_none       , ID("None"),        0,                   0,                &pseudo_ops);
+       tpop_unknown     = new_tpop(tpo_unknown    , ID("Unknown"),     0,                   0,                &pseudo_ops);
 #undef ID
-#undef C
+}
 
-/* Finalize the tpop module.
- * Frees all type opcodes.  */
-void finish_tpop(void) {
+void finish_tpop(void)
+{
        free_tpop(type_class      ); type_class       = NULL;
        free_tpop(type_struct     ); type_struct      = NULL;
        free_tpop(type_method     ); type_method      = NULL;
@@ -198,25 +178,16 @@ void finish_tpop(void) {
        free_tpop(type_pointer    ); type_pointer     = NULL;
        free_tpop(type_primitive  ); type_primitive   = NULL;
        free_tpop(tpop_code       ); tpop_code        = NULL;
-       free_tpop(type_id         ); type_id          = NULL;
        free_tpop(tpop_none       ); tpop_none        = NULL;
        free_tpop(tpop_unknown    ); tpop_unknown     = NULL;
 }
 
-/* Returns the string for the tp_opcode. */
-const char  *get_tpop_name(const tp_op *op) {
+const char *get_tpop_name(const tp_op *op)
+{
        return get_id_str(op->name);
 }
 
-tp_opcode (get_tpop_code)(const tp_op *op) {
+tp_opcode (get_tpop_code)(const tp_op *op)
+{
        return _get_tpop_code(op);
 }
-
-ident *(get_tpop_ident)(const tp_op *op) {
-       return _get_tpop_ident(op);
-}
-
-/* returns the attribute size of the operator. */
-int (get_tpop_attr_size)(const tp_op *op) {
-       return _get_tpop_attr_size(op);
-}