summary refs log tree commit diff
path: root/lisc/lisc.h
diff options
context:
space:
mode:
Diffstat (limited to 'lisc/lisc.h')
-rw-r--r--lisc/lisc.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/lisc/lisc.h b/lisc/lisc.h
index 2f6ada4..0ed9411 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -1,41 +1,56 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 typedef unsigned int uint;
 typedef unsigned short ushort;
 typedef unsigned char uchar;
+typedef unsigned long long ullong;
 
 enum {
 	NReg    = 32,
 	Tmp0    = NReg+1,
+
 	NString = 32,
 	NPred   = 15,
 	NBlk    = 128,
 	NIns    = 256,
+
+	BITS    = 4,
+	NBit    = 8 * sizeof(ullong),
 };
 
+typedef struct Bits Bits;
+typedef struct Ref Ref;
 typedef struct OpDesc OpDesc;
 typedef struct Ins Ins;
 typedef struct Phi Phi;
 typedef struct Blk Blk;
 typedef struct Sym Sym;
 typedef struct Fn Fn;
-typedef struct Ref Ref;
+
+struct Bits {
+	ullong t[BITS];
+};
+
+#define BGET(b, n) (1&((b).t[n/NBit]>>(n%NBit)))
+#define BSET(b, n) ((b).t[n/NBit] |= (ullong)1<<(n%NBit))
+#define BCLR(b, n) ((b).t[n/NBit] &= ~((ullong)1<<(n%NBit)))
 
 struct Ref {
 	ushort type:1;
 	ushort val:15;
 };
 
+#define R (Ref){0, 0} // Invalid reference
+
 static inline int
 req(Ref a, Ref b)
 {
 	return a.type == b.type && a.val == b.val;
 }
 
-#define R (Ref){0, 0} // Invalid reference
-
 enum {
 	RSym = 0,
 	RConst = 1,
@@ -46,7 +61,7 @@ enum {
 #define CONST(x) (Ref){RConst, x}
 
 enum {
-	OXXX,
+	OXXX = 0,
 	OAdd,
 	OSub,
 	ODiv,
@@ -58,12 +73,6 @@ enum {
 	OLast
 };
 
-struct OpDesc {
-	int arity;
-	int commut:1;
-	char *name;
-};
-
 enum {
 	JXXX,
 	JRet,
@@ -71,6 +80,12 @@ enum {
 	JJez,
 };
 
+struct OpDesc {
+	int arity;
+	int commut:1;
+	char *name;
+};
+
 struct Ins {
 	short op;
 	Ref to;
@@ -99,6 +114,7 @@ struct Blk {
 
 	Blk **pred;
 	uint npred;
+	Bits in, out;
 	char name[NString];
 	int id;
 };
@@ -124,7 +140,6 @@ struct Fn {
 
 /* parse.c */
 extern OpDesc opdesc[];
-
 void *alloc(size_t);
 Fn *parsefn(FILE *);
 void printfn(Fn *, FILE *);
@@ -133,3 +148,6 @@ void printfn(Fn *, FILE *);
 void fillpreds(Fn *);
 void fillrpo(Fn *);
 void ssafix(Fn *, int);
+
+/* live.c */
+void filllive(Fn *);