ref: d660f92ea19fe51531e7e5bc562a79de7f75a792
parent: 128a304c58ed737c2f3c3bfff6957ccfc4c5bd50
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Jun 15 12:08:28 EDT 2012
Rename files.
--- a/8/Makefile
+++ b/8/Makefile
@@ -1,9 +1,9 @@
BIN=8m
OBJ=isel.o \
+ locs.o \
main.o \
ra.o \
reduce.o \
- regalloc.o \
DEPS=../parse/libparse.a ../opt/libopt.a
--- /dev/null
+++ b/8/locs.c
@@ -1,0 +1,156 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "parse.h"
+#include "opt.h"
+#include "asm.h"
+
+Mode regmodes[] = {+#define Reg(r, name, mode) mode,
+#include "regs.def"
+#undef Reg
+};
+
+char *regnames[] = {+#define Reg(r, name, mode) name,
+#include "regs.def"
+#undef Reg
+};
+
+
+const Reg reginterferes[Nreg][Nmode + 1] = {+ /* byte */
+ [Ral] = {Ral, Rax, Reax},+ [Rcl] = {Rcl, Rcx, Recx},+ [Rdl] = {Rdl, Rdx, Redx},+ [Rbl] = {Rbl, Rbx, Rebx},+
+ /* word */
+ [Rax] = {Ral, Rax, Reax},+ [Rcx] = {Rcl, Rcx, Recx},+ [Rdx] = {Rdl, Rdx, Redx},+ [Rbx] = {Rbl, Rbx, Rebx},+ [Rsi] = {Rsi, Resi},+ [Rdi] = {Rdi, Redi},+
+ /* dword */
+ [Reax] = {Ral, Rax, Reax},+ [Recx] = {Rcl, Rcx, Recx},+ [Redx] = {Rdl, Rdx, Redx},+ [Rebx] = {Rbl, Rbx, Rebx},+ [Resi] = {Rsi, Resi},+ [Redi] = {Rdi, Redi},+ [Resp] = {Resp},+ [Rebp] = {Rebp},+};
+
+Loc *locstrlbl(char *lbl)
+{+ Loc *l;
+
+ l = zalloc(sizeof(Loc));
+ l->type = Loclbl;
+ l->mode = ModeL;
+ l->lbl = strdup(lbl);
+ return l;
+}
+
+Loc *loclbl(Node *lbl)
+{+ assert(lbl->type = Nlbl);
+ return locstrlbl(lbl->lbl.name);
+}
+
+Loc **locmap = NULL;
+size_t maxregid = 0;
+
+Loc *locreg(Mode m)
+{+ Loc *l;
+
+ l = zalloc(sizeof(Loc));
+ l->type = Locreg;
+ l->mode = m;
+ l->reg.id = maxregid++;
+ locmap = xrealloc(locmap, maxregid * sizeof(Loc*));
+ locmap[l->reg.id] = l;
+ return l;
+}
+
+Loc *locphysreg(Reg r)
+{+ static Loc *physregs[Nreg] = {0,};+
+ if (physregs[r])
+ return physregs[r];
+ physregs[r] = locreg(regmodes[r]);
+ physregs[r]->reg.colour = r;
+ return physregs[r];
+}
+
+Loc *locmem(long disp, Loc *base, Loc *idx, Mode mode)
+{+ Loc *l;
+
+ l = zalloc(sizeof(Loc));
+ l->type = Locmem;
+ l->mode = mode;
+ l->mem.constdisp = disp;
+ l->mem.base = base;
+ l->mem.idx = idx;
+ l->mem.scale = 0;
+ return l;
+}
+
+Loc *locmems(long disp, Loc *base, Loc *idx, int scale, Mode mode)
+{+ Loc *l;
+
+ l = locmem(disp, base, idx, mode);
+ l->mem.scale = scale;
+ return l;
+}
+
+Loc *locmeml(char *disp, Loc *base, Loc *idx, Mode mode)
+{+ Loc *l;
+
+ l = zalloc(sizeof(Loc));
+ l->type = Locmem;
+ l->mode = mode;
+ l->mem.lbldisp = strdup(disp);
+ l->mem.base = base;
+ l->mem.idx = idx;
+ l->mem.scale = 0;
+ return l;
+}
+
+Loc *locmemls(char *disp, Loc *base, Loc *idx, int scale, Mode mode)
+{+ Loc *l;
+
+ l = locmeml(disp, base, idx, mode);
+ l->mem.scale = scale;
+ return l;
+}
+
+
+Loc *loclit(long val)
+{+ Loc *l;
+
+ l = zalloc(sizeof(Loc));
+ l->type = Loclit;
+ l->mode = ModeL; /* FIXME: what do we do for mode? */
+ l->lit = val;
+ return l;
+}
--- a/8/reduce.c
+++ b/8/reduce.c
@@ -48,9 +48,9 @@
static Node *lval(Simp *s, Node *n);
static void declarelocal(Simp *s, Node *n);
+/* useful constants */
static Node *one;
static Node *ptrsz;
-
static void append(Simp *s, Node *n)
{--- a/8/regalloc.c
+++ /dev/null
@@ -1,156 +1,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "parse.h"
-#include "opt.h"
-#include "asm.h"
-
-Mode regmodes[] = {-#define Reg(r, name, mode) mode,
-#include "regs.def"
-#undef Reg
-};
-
-char *regnames[] = {-#define Reg(r, name, mode) name,
-#include "regs.def"
-#undef Reg
-};
-
-
-const Reg reginterferes[Nreg][Nmode + 1] = {- /* byte */
- [Ral] = {Ral, Rax, Reax},- [Rcl] = {Rcl, Rcx, Recx},- [Rdl] = {Rdl, Rdx, Redx},- [Rbl] = {Rbl, Rbx, Rebx},-
- /* word */
- [Rax] = {Ral, Rax, Reax},- [Rcx] = {Rcl, Rcx, Recx},- [Rdx] = {Rdl, Rdx, Redx},- [Rbx] = {Rbl, Rbx, Rebx},- [Rsi] = {Rsi, Resi},- [Rdi] = {Rdi, Redi},-
- /* dword */
- [Reax] = {Ral, Rax, Reax},- [Recx] = {Rcl, Rcx, Recx},- [Redx] = {Rdl, Rdx, Redx},- [Rebx] = {Rbl, Rbx, Rebx},- [Resi] = {Rsi, Resi},- [Redi] = {Rdi, Redi},- [Resp] = {Resp},- [Rebp] = {Rebp},-};
-
-Loc *locstrlbl(char *lbl)
-{- Loc *l;
-
- l = zalloc(sizeof(Loc));
- l->type = Loclbl;
- l->mode = ModeL;
- l->lbl = strdup(lbl);
- return l;
-}
-
-Loc *loclbl(Node *lbl)
-{- assert(lbl->type = Nlbl);
- return locstrlbl(lbl->lbl.name);
-}
-
-Loc **locmap = NULL;
-size_t maxregid = 0;
-
-Loc *locreg(Mode m)
-{- Loc *l;
-
- l = zalloc(sizeof(Loc));
- l->type = Locreg;
- l->mode = m;
- l->reg.id = maxregid++;
- locmap = xrealloc(locmap, maxregid * sizeof(Loc*));
- locmap[l->reg.id] = l;
- return l;
-}
-
-Loc *locphysreg(Reg r)
-{- static Loc *physregs[Nreg] = {0,};-
- if (physregs[r])
- return physregs[r];
- physregs[r] = locreg(regmodes[r]);
- physregs[r]->reg.colour = r;
- return physregs[r];
-}
-
-Loc *locmem(long disp, Loc *base, Loc *idx, Mode mode)
-{- Loc *l;
-
- l = zalloc(sizeof(Loc));
- l->type = Locmem;
- l->mode = mode;
- l->mem.constdisp = disp;
- l->mem.base = base;
- l->mem.idx = idx;
- l->mem.scale = 0;
- return l;
-}
-
-Loc *locmems(long disp, Loc *base, Loc *idx, int scale, Mode mode)
-{- Loc *l;
-
- l = locmem(disp, base, idx, mode);
- l->mem.scale = scale;
- return l;
-}
-
-Loc *locmeml(char *disp, Loc *base, Loc *idx, Mode mode)
-{- Loc *l;
-
- l = zalloc(sizeof(Loc));
- l->type = Locmem;
- l->mode = mode;
- l->mem.lbldisp = strdup(disp);
- l->mem.base = base;
- l->mem.idx = idx;
- l->mem.scale = 0;
- return l;
-}
-
-Loc *locmemls(char *disp, Loc *base, Loc *idx, int scale, Mode mode)
-{- Loc *l;
-
- l = locmeml(disp, base, idx, mode);
- l->mem.scale = scale;
- return l;
-}
-
-
-Loc *loclit(long val)
-{- Loc *l;
-
- l = zalloc(sizeof(Loc));
- l->type = Loclit;
- l->mode = ModeL; /* FIXME: what do we do for mode? */
- l->lit = val;
- return l;
-}
--- a/muse/Makefile
+++ /dev/null
@@ -1,8 +1,0 @@
-BIN=muse
-OBJ=main.o
-
-CFLAGS+=-I../parse
-LDFLAGS+=-L../parse -lparse
-EXTRADEP=../parse/libparse.a
-
-include ../mk/c.mk
--- a/muse/main.c
+++ /dev/null
@@ -1,79 +1,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "parse.h"
-
-Node *file;
-static char *outfile;
-int debug;
-
-static void usage(char *prog)
-{- printf("%s [-h] [-o outfile] inputs\n", prog);- printf("\t-h\tPrint this help\n");- printf("\t-d\tPrint debug dumps\n");- printf("\t-o\tOutput to outfile\n");-}
-
-int main(int argc, char **argv)
-{- int opt;
- int i;
- Stab *globls;
- Node *rdback;
- FILE *tmp;
-
- while ((opt = getopt(argc, argv, "dho:")) != -1) {- switch (opt) {- case 'o':
- outfile = optarg;
- break;
- case 'h':
- case 'd':
- debug++;
- break;
- default:
- usage(argv[0]);
- exit(0);
- break;
- }
- }
-
- for (i = optind; i < argc; i++) {- globls = mkstab();
- tyinit(globls);
- tokinit(argv[i]);
- file = mkfile(argv[i]);
- file->file.exports = mkstab();
- file->file.globls = globls;
- yyparse();
-
- if (debug) {- /* test storing tree to file */
- tmp = fopen("a.pkl", "w");- pickle(file, tmp);
- fclose(tmp);
-
- /* and reading it back */
- tmp = fopen("a.pkl", "r");- rdback = unpickle(tmp);
- dump(rdback, stdout);
- fclose(tmp);
-
- /* before we do anything to the parse */
- dump(file, stdout);
- }
- infer(file);
- die("FIXME: IMPLEMENT ME!");- }
-
- return 0;
-}
--- /dev/null
+++ b/util/Makefile
@@ -1,0 +1,8 @@
+BIN=muse
+OBJ=main.o
+
+CFLAGS+=-I../parse
+LDFLAGS+=-L../parse -lparse
+EXTRADEP=../parse/libparse.a
+
+include ../mk/c.mk
--- /dev/null
+++ b/util/main.c
@@ -1,0 +1,79 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "parse.h"
+
+Node *file;
+static char *outfile;
+int debug;
+
+static void usage(char *prog)
+{+ printf("%s [-h] [-o outfile] inputs\n", prog);+ printf("\t-h\tPrint this help\n");+ printf("\t-d\tPrint debug dumps\n");+ printf("\t-o\tOutput to outfile\n");+}
+
+int main(int argc, char **argv)
+{+ int opt;
+ int i;
+ Stab *globls;
+ Node *rdback;
+ FILE *tmp;
+
+ while ((opt = getopt(argc, argv, "dho:")) != -1) {+ switch (opt) {+ case 'o':
+ outfile = optarg;
+ break;
+ case 'h':
+ case 'd':
+ debug++;
+ break;
+ default:
+ usage(argv[0]);
+ exit(0);
+ break;
+ }
+ }
+
+ for (i = optind; i < argc; i++) {+ globls = mkstab();
+ tyinit(globls);
+ tokinit(argv[i]);
+ file = mkfile(argv[i]);
+ file->file.exports = mkstab();
+ file->file.globls = globls;
+ yyparse();
+
+ if (debug) {+ /* test storing tree to file */
+ tmp = fopen("a.pkl", "w");+ pickle(file, tmp);
+ fclose(tmp);
+
+ /* and reading it back */
+ tmp = fopen("a.pkl", "r");+ rdback = unpickle(tmp);
+ dump(rdback, stdout);
+ fclose(tmp);
+
+ /* before we do anything to the parse */
+ dump(file, stdout);
+ }
+ infer(file);
+ die("FIXME: IMPLEMENT ME!");+ }
+
+ return 0;
+}
--
⑨