summary refs log tree commit diff
path: root/lisc/tools/pmov.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-21 14:22:08 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:32 -0400
commit13e04cd1debf1ad715b8849d320ec058c4c919ae (patch)
tree36ff519d7002ba6dc9821c7313d9a375236261d7 /lisc/tools/pmov.c
parentdd805c38b121ead74437f7b04de3bede86ec76e4 (diff)
downloadroux-13e04cd1debf1ad715b8849d320ec058c4c919ae.tar.gz
add helpful diagnostics
Diffstat (limited to 'lisc/tools/pmov.c')
-rw-r--r--lisc/tools/pmov.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/lisc/tools/pmov.c b/lisc/tools/pmov.c
index 246f4f0..e3d2104 100644
--- a/lisc/tools/pmov.c
+++ b/lisc/tools/pmov.c
@@ -4,15 +4,20 @@
 #include <stdlib.h>
 #include <string.h>
 
+static void assert_test(char *, int), fail(void);
+
 #include "../rega.c"
 
+static RMap mbeg;
+static Ins ins[NReg], *ip;
+
 int
 main()
 {
 	Blk dummyb;
-	Ins ins[NReg], *ip, *i1;
+	Ins *i1;
 	unsigned long long tm, rm;
-	RMap mbeg, mend;
+	RMap mend;
 	int reg[NReg];
 	int t, i, r, nr;
 
@@ -131,12 +136,44 @@ main()
 	exit(0);
 }
 
+
+/* failure diagnostics */
+static void
+fail()
+{
+	Ins *i1;
+	int i;
+
+	printf("\nIn registers: ");
+	for (i=0; i<mbeg.n; i++)
+		printf("%s(r%d) ",
+			tmp[mbeg.t[i]].name,
+			mbeg.r[i]);
+	printf("\n");
+	printf("Parallel move:\n");
+	for (i1=ins; i1<ip; i1++)
+		printf("\t %s <- r%d\n",
+			tmp[i1->to.val].name,
+			i1->arg[0].val);
+	exit(1);
+}
+
+static void
+assert_test(char *s, int x)
+{
+	if (x)
+		return;
+	printf("!assertion failure: %s\n", s);
+	fail();
+}
+
+
 /* symbols required by the linker */
 char debug['Z'+1];
 Ins insb[NIns], *curi;
 
 void diag(char *s)
-{ printf("!diag failure: %s\n", s); exit(1); }
+{ printf("!diag failure: %s\n", s); fail(); }
 
 void *alloc(size_t n)
 { return malloc(n); }