2008-02-14 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / aliasing.c
index ac1eb3998922c6b47840a1203333c36cf965a49d..b30e21cbcefbb4ea979c354bc5af047fa4a8724d 100644 (file)
@@ -48,7 +48,7 @@ static const char *mono_stack_type_names[] = {
 
 
 #define OP_IS_OUTARG(op) (((op)==OP_OUTARG)||((op)==OP_OUTARG_REG)||((op)==OP_OUTARG_IMM)||((op)==OP_OUTARG_R4)||((op)==OP_OUTARG_R8)||((op)==OP_OUTARG_VT))
-#define OP_IS_CALL(op) (((op)==CEE_CALLI)||((op)==CEE_CALL)||((op)==CEE_CALLVIRT)||(((op)>=OP_VOIDCALL)&&((op)<=OP_CALL_MEMBASE)))
+#define OP_IS_CALL(op) (((op)==CEE_CALLI)||((op)==OP_CALL)||((op)==OP_CALLVIRT)||(((op)>=OP_VOIDCALL)&&((op)<=OP_CALL_MEMBASE)))
 #define OP_IS_STORE(op) (((op)==CEE_STIND_REF)||((op)==CEE_STIND_I1)||((op)==CEE_STIND_I2)||((op)==CEE_STIND_I4)||((op)==CEE_STIND_I8)||((op)==CEE_STIND_R4)||((op)==CEE_STIND_R8)||((op)==CEE_STIND_I))
 #define OP_IS_LOAD(op) (((op)==CEE_LDIND_REF)||((op)==CEE_LDIND_I1)||((op)==CEE_LDIND_I2)||((op)==CEE_LDIND_I4)||((op)==CEE_LDIND_U1)||((op)==CEE_LDIND_U2)||((op)==CEE_LDIND_U4)||((op)==CEE_LDIND_I8)||((op)==CEE_LDIND_R4)||((op)==CEE_LDIND_R8)||((op)==CEE_LDIND_I))
 #define OP_IS_CONST(op) (((op)==OP_ICONST)||((op)==OP_I8CONST)||((op)==OP_R4CONST)||((op)==OP_R8CONST)||((op)==OP_AOTCONST))
@@ -158,8 +158,8 @@ print_tree_node (MonoInst *tree) {
        case CEE_NEWARR:
                printf ("[%s]",  tree->inst_newa_class->name);
                break;
-       case CEE_CALL:
-       case CEE_CALLVIRT:
+       case OP_CALL:
+       case OP_CALLVIRT:
        case OP_FCALL:
        case OP_FCALLVIRT:
        case OP_LCALL:
@@ -167,7 +167,8 @@ print_tree_node (MonoInst *tree) {
        case OP_VCALL:
        case OP_VCALLVIRT:
        case OP_VOIDCALL:
-       case OP_VOIDCALLVIRT: {
+       case OP_VOIDCALLVIRT:
+       case OP_TRAMPCALL_VTABLE: {
                MonoCallInst *call = (MonoCallInst*)tree;
                if (call->method)
                        printf ("[%s]", call->method->name);
@@ -199,7 +200,7 @@ print_tree_node (MonoInst *tree) {
        case OP_LOADI2_MEMBASE:
                printf ("[%s] <- [%s + 0x%x]", mono_arch_regname (tree->dreg), mono_arch_regname (tree->inst_basereg), (int)tree->inst_offset);
                break;
-       case CEE_BR:
+       case OP_BR:
        case OP_CALL_HANDLER:
                printf ("[B%d]", tree->inst_target_bb->block_num);
                break;
@@ -314,7 +315,7 @@ print_code_with_aliasing_information (MonoAliasingInformation *info) {
                
                printf ("CODE FOR BB %d\n", bb_info->bb->block_num);
                mono_aliasing_initialize_code_traversal (info, bb_info->bb);
-               for (inst = bb_info->bb->code; inst != NULL; inst = inst->next) {
+               MONO_BB_FOR_EACH_INS (bb_info->bb, inst) {
                        print_tree_with_aliasing_information (info, inst);
                        printf ("\n");
                }
@@ -642,7 +643,7 @@ update_aliasing_information_on_inst (MonoAliasingInformation *info, MonoAliasing
        } else if ((inst->opcode == OP_UNBOXCAST) || OP_IS_PCONV (inst->opcode) || OP_IS_ICONV (inst->opcode)) {
                father_alias->type = context.subtree_aliases [0].type;
                father_alias->variable_index = context.subtree_aliases [0].variable_index;
-       } else if ((inst->opcode == CEE_LDELEMA) || (inst->opcode == OP_COMPARE) || (inst->opcode == CEE_SWITCH)) {
+       } else if ((inst->opcode == CEE_LDELEMA) || (inst->opcode == OP_COMPARE) || (inst->opcode == OP_SWITCH)) {
                if (father_alias != NULL) {
                        father_alias->type = MONO_ALIASING_TYPE_NO_ALIAS;
                }
@@ -733,7 +734,7 @@ mono_build_aliasing_information (MonoCompile *cfg) {
                bb_info->potential_alias_uses = NULL;
                info->next_interesting_inst = NULL;
                
-               for (inst = bb->code; inst != NULL; inst = inst->next) {
+               MONO_BB_FOR_EACH_INS (bb, inst) {
                        if (FOLLOW_ALIAS_ANALYSIS) {
                                printf ("TRAVERSING INST: ");
                                mono_print_tree_nl (inst);
@@ -826,6 +827,7 @@ mono_aliasing_get_affected_variables_for_inst_traversing_code (MonoAliasingInfor
        }
 }
 
+#if 0
 static MonoLocalVariableList*
 mono_aliasing_get_affected_variables_for_inst_in_bb (MonoAliasingInformation *info, MonoInst *inst, MonoBasicBlock *bb) {
        MonoAliasUsageInformation *use;
@@ -838,6 +840,7 @@ mono_aliasing_get_affected_variables_for_inst_in_bb (MonoAliasingInformation *in
        g_assert_not_reached ();
        return NULL;
 }
+#endif
 
 MonoLocalVariableList*
 mono_aliasing_get_affected_variables_for_inst (MonoAliasingInformation *info, MonoInst *inst) {
@@ -942,7 +945,7 @@ mono_aliasing_deadce_on_inst (MonoAliasingInformation *info, MonoInst **possibly
                                                printf ("KILLING slot %d at inst ", affected_variable->variable_index);
                                                mono_print_tree_nl (inst);
                                        }
-                                       possibly_dead_assignments [affected_variable->variable_index]->opcode = CEE_NOP;
+                                       possibly_dead_assignments [affected_variable->variable_index]->opcode = OP_NOP;
                                        possibly_dead_assignments [affected_variable->variable_index]->ssa_op = MONO_SSA_NOP;
                                        possibly_dead_assignments [affected_variable->variable_index] = NULL;
                                }
@@ -1003,9 +1006,9 @@ mono_aliasing_deadce (MonoAliasingInformation *info) {
                        printf ("Working on BB %d\n", bb->block_num);
                }
                
-               for (inst = bb->code; inst != NULL; inst = inst->next) {
+               MONO_BB_FOR_EACH_INS (bb, inst) {
                        mono_aliasing_deadce_on_inst (info, possibly_dead_assignments, inst);
-                       if (inst->opcode == CEE_JMP) {
+                       if (inst->opcode == OP_JMP) {
                                /* Keep arguments live! */
                                for (variable_index = 0; variable_index < cfg->num_varinfo; variable_index++) {
                                        if (cfg->varinfo [variable_index]->opcode == OP_ARG) {
@@ -1028,7 +1031,7 @@ mono_aliasing_deadce (MonoAliasingInformation *info) {
                                
                                //printf ("FAST DEADCE DEAD LOCAL\n");
                                
-                               possibly_dead_assignments [variable_index]->opcode = CEE_NOP;
+                               possibly_dead_assignments [variable_index]->opcode = OP_NOP;
                                possibly_dead_assignments [variable_index]->ssa_op = MONO_SSA_NOP;
                        }
                }