becopyheur2: Cache the admissible registers eagerly.
[libfirm] / ir / ir / irio.c
index b31fb83..654e921 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2011 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.
  */
 
 /**
@@ -91,7 +77,6 @@ typedef enum typetag_t {
        tt_builtin_kind,
        tt_cond_jmp_predicate,
        tt_initializer,
-       tt_irg_inline_property,
        tt_keyword,
        tt_linkage,
        tt_mode_arithmetic,
@@ -281,12 +266,6 @@ static void symtbl_init(void)
        INSERT(tt_mode_arithmetic, "ieee754",            irma_ieee754);
        INSERT(tt_mode_arithmetic, "x86_extended_float", irma_x86_extended_float);
 
-       INSERT(tt_irg_inline_property, "any",            irg_inline_any);
-       INSERT(tt_irg_inline_property, "recommended",    irg_inline_recomended);
-       INSERT(tt_irg_inline_property, "forbidden",      irg_inline_forbidden);
-       INSERT(tt_irg_inline_property, "forced",         irg_inline_forced);
-       INSERT(tt_irg_inline_property, "forced_no_body", irg_inline_forced_no_body);
-
        INSERTENUM(tt_pin_state, op_pin_state_floats);
        INSERTENUM(tt_pin_state, op_pin_state_pinned);
        INSERTENUM(tt_pin_state, op_pin_state_exc_pinned);
@@ -338,18 +317,6 @@ static const char *get_mode_arithmetic_name(ir_mode_arithmetic arithmetic)
        panic("invalid mode_arithmetic");
 }
 
-static const char *get_irg_inline_property_name(irg_inline_property prop)
-{
-       switch (prop) {
-       case irg_inline_any:            return "any";
-       case irg_inline_recomended:     return "recommended";
-       case irg_inline_forbidden:      return "forbidden";
-       case irg_inline_forced:         return "forced";
-       case irg_inline_forced_no_body: return "forced_no_body";
-       }
-       panic("invalid irg_inline_property");
-}
-
 /** Returns the according symbol value for the given string and tag, or SYMERROR if none was found. */
 static unsigned symbol(const char *str, typetag_t typetag)
 {
@@ -571,12 +538,6 @@ static void write_volatility(write_env_t *env, ir_volatility vol)
        fputc(' ', env->file);
 }
 
-static void write_inline_property(write_env_t *env, irg_inline_property prop)
-{
-       fputs(get_irg_inline_property_name(prop), env->file);
-       fputc(' ', env->file);
-}
-
 static void write_type_state(write_env_t *env, ir_type_state state)
 {
        fputs(get_type_state_name(state), env->file);
@@ -631,9 +592,8 @@ static void write_type_compound(write_env_t *env, ir_type *tp)
        size_t i;
 
        if (is_Class_type(tp)) {
-               if (get_class_n_subtypes(tp) > 0 || get_class_n_supertypes(tp) > 0
-                   || get_class_type_info(tp) != NULL || get_class_vtable_size(tp) > 0) {
-                       /* sub/superclass export not implemented yet, it's unclear wether
+               if (get_class_n_subtypes(tp) > 0 || get_class_n_supertypes(tp) > 0 || get_class_vtable_size(tp) > 0) {
+                       /* sub/superclass export not implemented yet, it's unclear whether
                         * class types will stay in libfirm anyway */
                        panic("can't export class types yet");
                }
@@ -963,11 +923,11 @@ static void write_SymConst(write_env_t *env, const ir_node *node)
        write_entity_ref(env, get_SymConst_entity(node));
 }
 
-typedef void (*write_node_func)(write_env_t *env, const ir_node *node);
+typedef void write_node_func(write_env_t *env, ir_node const *node);
 
-static void register_node_writer(ir_op *op, write_node_func func)
+static void register_node_writer(ir_op *op, write_node_func *func)
 {
-       set_generic_function_ptr(op, (op_func)func);
+       set_generic_function_ptr(op, func);
 }
 
 static void writers_init(void)
@@ -983,8 +943,8 @@ static void writers_init(void)
 
 static void write_node(const ir_node *node, write_env_t *env)
 {
-       ir_op          *op   = get_irn_op(node);
-       write_node_func func = (write_node_func) get_generic_function_ptr(op);
+       ir_op           *const op   = get_irn_op(node);
+       write_node_func *const func = get_generic_function_ptr(write_node_func, op);
 
        fputc('\t', env->file);
        if (func == NULL)
@@ -1168,8 +1128,6 @@ static void write_irg(write_env_t *env, ir_graph *irg)
        write_symbol(env, "irg");
        write_entity_ref(env, get_irg_entity(irg));
        write_type_ref(env, get_irg_frame_type(irg));
-       write_inline_property(env, get_irg_inline_property(irg));
-       write_unsigned(env, get_irg_additional_properties(irg));
        write_scope_begin(env);
        ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
        inc_irg_visited(irg);
@@ -1563,7 +1521,6 @@ static const char *get_typetag_name(typetag_t typetag)
        case tt_builtin_kind:        return "builtin kind";
        case tt_cond_jmp_predicate:  return "cond_jmp_predicate";
        case tt_initializer:         return "initializer kind";
-       case tt_irg_inline_property: return "irg_inline_property";
        case tt_keyword:             return "keyword";
        case tt_linkage:             return "linkage";
        case tt_mode_arithmetic:     return "mode_arithmetic";
@@ -1661,11 +1618,6 @@ static keyword_t read_keyword(read_env_t *env)
        return (keyword_t)read_enum(env, tt_keyword);
 }
 
-static irg_inline_property read_inline_property(read_env_t *env)
-{
-       return (irg_inline_property)read_enum(env, tt_irg_inline_property);
-}
-
 static ir_relation read_relation(read_env_t *env)
 {
        return (ir_relation)read_long(env);
@@ -2275,14 +2227,10 @@ next_delayed_pred: ;
 
 static ir_graph *read_irg(read_env_t *env)
 {
-       ir_entity          *irgent = get_entity(env, read_long(env));
-       ir_graph           *irg    = new_ir_graph(irgent, 0);
-       ir_type            *frame  = read_type_ref(env);
-       irg_inline_property prop   = read_inline_property(env);
-       unsigned            props  = read_unsigned(env);
+       ir_entity *irgent = get_entity(env, read_long(env));
+       ir_graph  *irg    = new_ir_graph(irgent, 0);
+       ir_type   *frame  = read_type_ref(env);
        set_irg_frame_type(irg, frame);
-       set_irg_inline_property(irg, prop);
-       set_irg_additional_properties(irg, (mtp_additional_properties)props);
        read_graph(env, irg);
        irg_finalize_cons(irg);
        return irg;
@@ -2416,6 +2364,10 @@ int ir_import_file(FILE *input, const char *inputname)
        /* read first character */
        read_c(env);
 
+       /* if the first line starts with '#', it contains a comment. */
+       if (env->c == '#')
+               skip_to(env, '\n');
+
        set_optimize(0);
 
        while (true) {