ref: b474f4b5e52fdabfec503d8666aefe35bdbdb7f1
parent: f6e81804fafb07980cde274e5350e081e61a6a28
author: Ori Bernstein <[email protected]>
date: Tue Jan 29 04:58:30 EST 2013
Stub in callee save registers. Don't enable them since they're broken, but stub them in.
--- a/6/asm.h
+++ b/6/asm.h
@@ -4,7 +4,7 @@
#define Wordsz 4 /* the size of a "natural int" */
#define Ptrsz 8 /* the size of a machine word (ie, pointer size) */
#define K 14 /* the number of allocatable registers */
-#define Nsaved 14 /* number of registers saved in the ABI */
+#define Nsaved 13 /* number of registers saved in the ABI */
typedef size_t regid;
@@ -195,7 +195,6 @@
void iprintf(FILE *fd, Insn *insn);
/* emitting instructions */
-void g(Isel *s, AsmOp op, ...);
Insn *mkinsn(AsmOp op, ...);
/* register allocation */
--- a/6/isel.c
+++ b/6/isel.c
@@ -131,7 +131,7 @@
return i;
}
-static void g(Isel *s, AsmOp op, ...)
+Insn *mkinsn(AsmOp op, ...)
{
va_list ap;
Insn *i;
@@ -139,6 +139,17 @@
va_start(ap, op);
i = mkinsnv(op, ap);
va_end(ap);
+ return i;
+}
+
+void g(Isel *s, AsmOp op, ...)
+{
+ va_list ap;
+ Insn *i;
+
+ va_start(ap, op);
+ i = mkinsnv(op, ap);
+ va_end(ap);
if (debugopt['i']) {
printf("GEN ");
iprintf(stdout, i);
@@ -749,18 +760,44 @@
}
}
+Reg savedregs[] = {
+ Rrcx,
+ Rrdx,
+ Rrbx,
+ Rrsi,
+ Rrdi,
+ Rr8,
+ Rr9,
+ Rr10,
+ Rr11,
+ Rr12,
+ Rr13,
+ Rr14,
+ Rr15
+};
+
static void prologue(Isel *s, size_t sz)
{
Loc *rsp;
Loc *rbp;
Loc *stksz;
+ //size_t i;
rsp = locphysreg(Rrsp);
rbp = locphysreg(Rrbp);
stksz = loclit(sz, ModeQ);
+ /* enter function */
g(s, Ipush, rbp, NULL);
g(s, Imov, rsp, rbp, NULL);
g(s, Isub, stksz, rsp, NULL);
+#if 0
+ /* save registers */
+ for (i = 0; i < sizeof(savedregs)/sizeof(savedregs[0]); i++) {
+ s->calleesave[i] = locreg(ModeQ);
+ g(s, Imov, locphysreg(savedregs[i]), s->calleesave[i], NULL);
+ }
+#endif
+
s->stksz = stksz; /* need to update if we spill */
}
@@ -768,6 +805,7 @@
{
Loc *rsp, *rbp;
Loc *ret;
+ //size_t i;
rsp = locphysreg(Rrsp);
rbp = locphysreg(Rrbp);
@@ -775,6 +813,12 @@
ret = loc(s, s->ret);
g(s, Imov, ret, coreg(Rax, ret->mode), NULL);
}
+#if 0
+ /* restore registers */
+ for (i = 0; i < Nsaved; i++)
+ g(s, Imov, s->calleesave[i], locphysreg(savedregs[i]), NULL);
+ /* leave function */
+#endif
g(s, Imov, rbp, rsp, NULL);
g(s, Ipop, rbp, NULL);
g(s, Iret, NULL);
--- a/6/ra.c
+++ b/6/ra.c
@@ -996,8 +996,10 @@
s->prepainted = mkbs();
s->shouldspill = mkbs();
s->neverspill = mkbs();
+#if 0
for (i = 0; i < Nsaved; i++)
bsput(s->shouldspill, s->calleesave[i]->reg.id);
+#endif
for (i = 0; i < maxregid; i++)
if (locmap[i]->reg.colour)
bsput(s->prepainted, i);