summary refs log tree commit diff
path: root/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-13 11:01:53 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-13 12:39:54 -0400
commit0e85eb82829f4cadf856ae4d60749d63a195588a (patch)
tree5936b03bcbbba0fc4fdb53fdb14f0ac761f12b17 /emit.c
parentb067c4eea4e6a12c1157321f65d08a1595690d8e (diff)
downloadroux-0e85eb82829f4cadf856ae4d60749d63a195588a.tar.gz
handle the bad jump case
Diffstat (limited to 'emit.c')
-rw-r--r--emit.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/emit.c b/emit.c
index 5f9f604..e88f550 100644
--- a/emit.c
+++ b/emit.c
@@ -537,6 +537,7 @@ emitfn(Fn *fn, FILE *f)
 			);
 			break;
 		case JJmp:
+		Jmp:
 			if (b->s1 != b->link)
 				fprintf(f, "\tjmp %sbb%d /* %s */\n",
 					locprefix, id0+b->s1->id, b->s1->name);
@@ -546,14 +547,13 @@ emitfn(Fn *fn, FILE *f)
 			if (0 <= c && c <= NXICmp) {
 				if (b->link == b->s2) {
 					s = b->s1;
-				} else if (b->link == b->s1) {
-					c = cneg(c);
-					s = b->s2;
+					b->s1 = b->s2;
+					b->s2 = s;
 				} else
-					die("unhandled jump");
-				fprintf(f, "\tj%s %sbb%d /* %s */\n",
-					ctoa[c], locprefix, id0+s->id, s->name);
-				break;
+					c = cneg(c);
+				fprintf(f, "\tj%s %sbb%d /* %s */\n", ctoa[c],
+					locprefix, id0+b->s2->id, b->s2->name);
+				goto Jmp;
 			}
 			die("unhandled jump %d", b->jmp.type);
 		}