Add infrastructure for new, special move hops.
authorDavid Given <dg@cowlark.com>
Mon, 12 Dec 2016 22:54:25 +0000 (23:54 +0100)
committerDavid Given <dg@cowlark.com>
Mon, 12 Dec 2016 22:54:25 +0000 (23:54 +0100)
mach/proto/mcg/hop.c
mach/proto/mcg/hop.h

index c928b8f..ebf0568 100644 (file)
@@ -17,6 +17,17 @@ struct hop* new_hop(struct basicblock* bb, struct ir* ir)
        return hop;
 }
 
+struct hop* new_copy_hop(struct basicblock* bb, struct vreg* src, struct vreg* dest)
+{
+       struct hop* hop = heap_alloc(&proc_heap, 1, sizeof(*hop));
+       hop->id = hop_count++;
+    hop->bb = bb;
+    hop->is_move = true;
+    array_append(&hop->ins, src);
+    array_append(&hop->outs, dest);
+       return hop;
+}
+
 static struct insel* new_insel(enum insel_type type)
 {
        struct insel* insel = heap_alloc(&proc_heap, 1, sizeof(*insel));
@@ -230,6 +241,9 @@ char* hop_render(struct hop* hop)
     bufferlen = 0;
        buffer[0] = '\0';
 
+    if (hop->is_move && (hop->insels.count == 0))
+        appendf("(move %%%d -> %%%d)\n", hop->ins.item[0]->id, hop->outs.item[0]->id);
+
        for (i=0; i<hop->insels.count; i++)
        {
                struct insel* insel = hop->insels.item[i];
index d7b8f34..1e6be20 100644 (file)
@@ -43,6 +43,7 @@ struct hop
     const struct burm_instruction_data* insndata;
        ARRAYOF(struct insel) insels;
        struct vreg* output;
+       bool is_move;
 
     PMAPOF(struct vreg, struct constraint) constraints;
 
@@ -54,6 +55,7 @@ struct hop
 };
 
 extern struct hop* new_hop(struct basicblock* bb, struct ir* ir);
+extern struct hop* new_copy_hop(struct basicblock* bb, struct vreg* src, struct vreg* dest);
 
 extern void hop_add_string_insel(struct hop* hop, const char* string);
 extern void hop_add_hreg_insel(struct hop* hop, struct hreg* hreg, int index);