From: David Given Date: Mon, 12 Dec 2016 22:54:25 +0000 (+0100) Subject: Add infrastructure for new, special move hops. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=043b9413932c06f48f47bac3662eecb8ecdd0f7a;p=ack.git Add infrastructure for new, special move hops. --- diff --git a/mach/proto/mcg/hop.c b/mach/proto/mcg/hop.c index c928b8fd0..ebf0568ff 100644 --- a/mach/proto/mcg/hop.c +++ b/mach/proto/mcg/hop.c @@ -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; iinsels.count; i++) { struct insel* insel = hop->insels.item[i]; diff --git a/mach/proto/mcg/hop.h b/mach/proto/mcg/hop.h index d7b8f34b4..1e6be2049 100644 --- a/mach/proto/mcg/hop.h +++ b/mach/proto/mcg/hop.h @@ -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);