summary refs log tree commit diff
path: root/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-28 15:35:40 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-29 10:10:27 -0400
commite4da265b5017332007bb130c7df55b24d6dc4214 (patch)
treeefd506d3bf4d76d02af0828361d47a808c0e6e93 /emit.c
parentb75cb8388fb9b5f2393443d008bb46c522c5ec9b (diff)
downloadroux-e4da265b5017332007bb130c7df55b24d6dc4214.tar.gz
make block labels per-function
Diffstat (limited to 'emit.c')
-rw-r--r--emit.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/emit.c b/emit.c
index 9b2975d..7309170 100644
--- a/emit.c
+++ b/emit.c
@@ -149,7 +149,10 @@ emitcon(Con *con, FILE *f)
 	default:
 		diag("emit: invalid constant");
 	case CAddr:
-		fprintf(f, "%s%s", con->local ? locprefix : symprefix, con->label);
+		if (con->local)
+			fprintf(f, "%s%s", locprefix, con->label);
+		else
+			fprintf(f, "%s%s", symprefix, con->label);
 		if (con->bits.i)
 			fprintf(f, "%+"PRId64, con->bits.i);
 		break;
@@ -493,6 +496,7 @@ emitfn(Fn *fn, FILE *f)
 		[ICXnp] = "np",
 		[ICXp]  = "p"
 	};
+	static int id0;
 	Blk *b, *s;
 	Ins *i, itmp;
 	int *r, c, fs;
@@ -516,7 +520,7 @@ emitfn(Fn *fn, FILE *f)
 		}
 
 	for (b=fn->start; b; b=b->link) {
-		fprintf(f, "%s%s:\n", locprefix, b->name);
+		fprintf(f, "%sbb%d: /* %s */\n", locprefix, id0+b->id, b->name);
 		for (i=b->ins; i!=&b->ins[b->nins]; i++)
 			emitins(*i, fn, f);
 		switch (b->jmp.type) {
@@ -533,7 +537,8 @@ emitfn(Fn *fn, FILE *f)
 			break;
 		case JJmp:
 			if (b->s1 != b->link)
-				fprintf(f, "\tjmp %s%s\n", locprefix, b->s1->name);
+				fprintf(f, "\tjmp %sbb%d /* %s */\n",
+					locprefix, id0+b->s1->id, b->s1->name);
 			break;
 		default:
 			c = b->jmp.type - JXJc;
@@ -545,13 +550,14 @@ emitfn(Fn *fn, FILE *f)
 					s = b->s2;
 				} else
 					diag("emit: unhandled jump (1)");
-				fprintf(f, "\tj%s %s%s\n", ctoa[c], locprefix, s->name);
+				fprintf(f, "\tj%s %sbb%d /* %s */\n",
+					ctoa[c], locprefix, id0+s->id, s->name);
 				break;
 			}
 			diag("emit: unhandled jump (2)");
 		}
 	}
-
+	id0 += fn->nblk;
 }
 
 void