Bodge in enough phi support to let the instruction generator complete on basic
authorDavid Given <dg@cowlark.com>
Tue, 4 Oct 2016 19:58:31 +0000 (21:58 +0200)
committerDavid Given <dg@cowlark.com>
Tue, 4 Oct 2016 19:58:31 +0000 (21:58 +0200)
programs.

mach/proto/mcg/basicblock.h
mach/proto/mcg/pass_instructionselection.c
mach/proto/mcg/table

index 8f36e5e..7fb654a 100644 (file)
@@ -12,6 +12,8 @@ struct basicblock
     ARRAYOF(struct basicblock) nexts;
     int order; /* used by SSA code */
 
+       ARRAYOF(struct vreg) liveins;
+
     bool is_fake : 1;
     bool is_root : 1;
     bool is_terminated : 1;
index 48ede30..5f965c9 100644 (file)
@@ -191,15 +191,30 @@ static void select_instructions(void)
                int insnno;
 
                current_ir = current_bb->irs.item[i];
-        shadow = build_shadow_tree(current_ir, current_ir);
-               burm_label(shadow);
 
-               insnno = burm_rule(shadow->state_label, 1);
-               if (!insnno)
-                       burm_panic_cannot_match(shadow);
+        if (current_ir->opcode == IR_PHI)
+        {
+            int j;
+
+            current_ir->result = new_vreg();
+            array_append(&current_bb->liveins, current_ir->result);
+            tracef('I', "I: %d is phi:", current_ir->result->id);
+            for (j=0; j<current_ir->u.phivalue.count; j++)
+                tracef('I', " $%d", current_ir->u.phivalue.item[j]->id);
+            tracef('I', "\n");
+        }
+        else
+        {
+            shadow = build_shadow_tree(current_ir, current_ir);
+            burm_label(shadow);
 
-        ir_print('I', current_ir);
-               walk_instructions(shadow, 1);
+            insnno = burm_rule(shadow->state_label, 1);
+            if (!insnno)
+                burm_panic_cannot_match(shadow);
+
+            ir_print('I', current_ir);
+            walk_instructions(shadow, 1);
+        }
        }
 }
 
index 4d892c0..c333a63 100644 (file)
@@ -62,6 +62,7 @@ PATTERNS
 
        SETRET4(in:reg)
                with ret reg
+               emit "mov r0, %in"
                cost 4;
 
        STACKADJUST4(delta:aluparam)