becopyheur2: Cache the admissible registers eagerly.
[libfirm] / ir / ir / irio.c
index ceb1917..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,
@@ -276,18 +261,11 @@ static void symtbl_init(void)
        INSERTENUM(tt_initializer, IR_INITIALIZER_NULL);
        INSERTENUM(tt_initializer, IR_INITIALIZER_COMPOUND);
 
-       INSERT(tt_mode_arithmetic, "uninitialized",      irma_uninitialized);
        INSERT(tt_mode_arithmetic, "none",               irma_none);
        INSERT(tt_mode_arithmetic, "twos_complement",    irma_twos_complement);
        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);
@@ -331,7 +309,6 @@ static const char *get_visibility_name(ir_visibility visibility)
 static const char *get_mode_arithmetic_name(ir_mode_arithmetic arithmetic)
 {
        switch (arithmetic) {
-       case irma_uninitialized:      return "uninitialized";
        case irma_none:               return "none";
        case irma_twos_complement:    return "twos_complement";
        case irma_ieee754:            return "ieee754";
@@ -340,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)
 {
@@ -573,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);
@@ -633,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");
                }
@@ -881,21 +839,16 @@ static void write_node_nr(write_env_t *env, const ir_node *node)
 
 static void write_ASM(write_env_t *env, const ir_node *node)
 {
-       ir_asm_constraint *input_constraints    = get_ASM_input_constraints(node);
-       ir_asm_constraint *output_constraints   = get_ASM_output_constraints(node);
-       ident            **clobbers             = get_ASM_clobbers(node);
-       size_t             n_input_constraints  = get_ASM_n_input_constraints(node);
-       size_t             n_output_constraints = get_ASM_n_output_constraints(node);
-       size_t             n_clobbers           = get_ASM_n_clobbers(node);
-       size_t             i;
-
        write_symbol(env, "ASM");
        write_node_nr(env, node);
        write_node_nr(env, get_nodes_block(node));
+       write_node_nr(env, get_ASM_mem(node));
 
        write_ident(env, get_ASM_text(node));
        write_list_begin(env);
-       for (i = 0; i < n_input_constraints; ++i) {
+       ir_asm_constraint *input_constraints = get_ASM_input_constraints(node);
+       int                n_inputs          = get_ASM_n_inputs(node);
+       for (int i = 0; i < n_inputs; ++i) {
                const ir_asm_constraint *constraint = &input_constraints[i];
                write_unsigned(env, constraint->pos);
                write_ident(env, constraint->constraint);
@@ -904,7 +857,9 @@ static void write_ASM(write_env_t *env, const ir_node *node)
        write_list_end(env);
 
        write_list_begin(env);
-       for (i = 0; i < n_output_constraints; ++i) {
+       ir_asm_constraint *output_constraints  = get_ASM_output_constraints(node);
+       size_t            n_output_constraints = get_ASM_n_output_constraints(node);
+       for (size_t i = 0; i < n_output_constraints; ++i) {
                const ir_asm_constraint *constraint = &output_constraints[i];
                write_unsigned(env, constraint->pos);
                write_ident(env, constraint->constraint);
@@ -913,14 +868,16 @@ static void write_ASM(write_env_t *env, const ir_node *node)
        write_list_end(env);
 
        write_list_begin(env);
-       for (i = 0; i < n_clobbers; ++i) {
+       ident **clobbers   = get_ASM_clobbers(node);
+       size_t  n_clobbers = get_ASM_n_clobbers(node);
+       for (size_t i = 0; i < n_clobbers; ++i) {
                ident *clobber = clobbers[i];
                write_ident(env, clobber);
        }
        write_list_end(env);
 
        write_pin_state(env, get_irn_pinned(node));
-       write_pred_refs(env, node, 0);
+       write_pred_refs(env, node, n_ASM_max+1);
 }
 
 static void write_Phi(write_env_t *env, const ir_node *node)
@@ -966,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)
@@ -986,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)
@@ -1171,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);
@@ -1566,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";
@@ -1664,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);
@@ -2093,6 +2042,7 @@ static ir_node *read_ASM(read_env_t *env)
        ir_asm_constraint *output_constraints = NEW_ARR_F(ir_asm_constraint, 0);
        ident            **clobbers           = NEW_ARR_F(ident*, 0);
        ir_node           *block              = read_node_ref(env);
+       ir_node           *mem                = read_node_ref(env);
        op_pin_state       pin_state;
 
        ident *asm_text = read_ident(env);
@@ -2131,7 +2081,7 @@ static ir_node *read_ASM(read_env_t *env)
                return new_r_Bad(env->irg, mode_T);
        }
 
-       newnode = new_r_ASM(block, n_in, in,
+       newnode = new_r_ASM(block, mem, n_in, in,
                input_constraints, ARR_LEN(output_constraints),
                output_constraints, ARR_LEN(clobbers),
                clobbers, asm_text);
@@ -2277,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;
@@ -2418,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) {