Commit 4556c04d authored by Kai Backman's avatar Kai Backman

more changes to make 5g code generation arm compatible.

R=rsc
APPROVED=rsc
DELTA=72  (12 added, 52 deleted, 8 changed)
OCL=30748
CL=30793
parent 7986de6e
...@@ -29,8 +29,11 @@ betypeinit(void) ...@@ -29,8 +29,11 @@ betypeinit(void)
zprog.link = P; zprog.link = P;
zprog.as = AGOK; zprog.as = AGOK;
zprog.scond = C_SCOND_NONE;
zprog.reg = NREG;
zprog.from.type = D_NONE; zprog.from.type = D_NONE;
zprog.from.index = D_NONE; zprog.from.index = D_NONE;
zprog.from.reg = NREG;
zprog.from.scale = 0; zprog.from.scale = 0;
zprog.to = zprog.from; zprog.to = zprog.from;
......
...@@ -84,6 +84,7 @@ compile(Node *fn) ...@@ -84,6 +84,7 @@ compile(Node *fn)
// fill in argument size // fill in argument size
ptxt->to.type = D_CONST2; ptxt->to.type = D_CONST2;
ptxt->reg = 0; // flags
ptxt->to.offset2 = rnd(curfn->type->argwid, maxround); ptxt->to.offset2 = rnd(curfn->type->argwid, maxround);
// fill in final stack size // fill in final stack size
......
...@@ -64,8 +64,8 @@ zhist(Biobuf *b, int line, vlong offset) ...@@ -64,8 +64,8 @@ zhist(Biobuf *b, int line, vlong offset)
Addr a; Addr a;
Bputc(b, AHISTORY); Bputc(b, AHISTORY);
Bputc(b, 0); Bputc(b, C_SCOND_NONE);
Bputc(b, 0); Bputc(b, NREG);
Bputc(b, line); Bputc(b, line);
Bputc(b, line>>8); Bputc(b, line>>8);
Bputc(b, line>>16); Bputc(b, line>>16);
...@@ -89,8 +89,8 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -89,8 +89,8 @@ zaddr(Biobuf *b, Addr *a, int s)
switch(a->type) { switch(a->type) {
case D_STATIC: case D_STATIC:
case D_EXTERN:
case D_AUTO: case D_AUTO:
case D_EXTERN:
case D_PARAM: case D_PARAM:
Bputc(b, D_OREG); Bputc(b, D_OREG);
Bputc(b, a->reg); Bputc(b, a->reg);
...@@ -112,8 +112,6 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -112,8 +112,6 @@ zaddr(Biobuf *b, Addr *a, int s)
case D_REG: case D_REG:
case D_FREG: case D_FREG:
case D_PSR: case D_PSR:
case D_EXTERN:
case D_PARAM:
break; break;
case D_CONST2: case D_CONST2:
...@@ -128,6 +126,8 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -128,6 +126,8 @@ zaddr(Biobuf *b, Addr *a, int s)
case D_SHIFT: case D_SHIFT:
case D_STATIC: case D_STATIC:
case D_AUTO: case D_AUTO:
case D_EXTERN:
case D_PARAM:
l = a->offset; l = a->offset;
Bputc(b, l); Bputc(b, l);
Bputc(b, l>>8); Bputc(b, l>>8);
......
...@@ -34,10 +34,14 @@ void ...@@ -34,10 +34,14 @@ void
clearp(Prog *p) clearp(Prog *p)
{ {
p->as = AEND; p->as = AEND;
p->reg = NREG;
p->scond = C_SCOND_NONE;
p->from.type = D_NONE; p->from.type = D_NONE;
p->from.index = D_NONE; p->from.index = D_NONE;
p->from.reg = NREG;
p->to.type = D_NONE; p->to.type = D_NONE;
p->to.index = D_NONE; p->to.index = D_NONE;
p->to.reg = NREG;
p->loc = pcloc; p->loc = pcloc;
pcloc++; pcloc++;
} }
......
...@@ -38,7 +38,6 @@ listinit(void) ...@@ -38,7 +38,6 @@ listinit(void)
fmtinstall('A', Aconv); // as fmtinstall('A', Aconv); // as
fmtinstall('P', Pconv); // Prog* fmtinstall('P', Pconv); // Prog*
fmtinstall('D', Dconv); // Addr* fmtinstall('D', Dconv); // Addr*
fmtinstall('R', Rconv); // reg
fmtinstall('Y', Yconv); // sconst fmtinstall('Y', Yconv); // sconst
} }
...@@ -80,21 +79,13 @@ Dconv(Fmt *fp) ...@@ -80,21 +79,13 @@ Dconv(Fmt *fp)
a = va_arg(fp->args, Addr*); a = va_arg(fp->args, Addr*);
i = a->type; i = a->type;
// TODO(kaib): Add back
// if(i >= D_INDIR) {
// if(a->offset)
// snprint(str, sizeof(str), "%d(%R)", a->offset, i-D_INDIR);
// else
// snprint(str, sizeof(str), "(%R)", i-D_INDIR);
// goto brk;
// }
switch(i) { switch(i) {
default: default:
if(a->offset) if(a->type == D_OREG)
snprint(str, sizeof(str), "$%d,%R", a->offset, i); snprint(str, sizeof(str), "$%d(R%d)", a->offset, a->reg);
else else
snprint(str, sizeof(str), "%R", i); snprint(str, sizeof(str), "R%d", a->reg);
break; break;
case D_NONE: case D_NONE:
...@@ -149,50 +140,10 @@ Dconv(Fmt *fp) ...@@ -149,50 +140,10 @@ Dconv(Fmt *fp)
// a->type = D_ADDR; // a->type = D_ADDR;
// goto conv; // goto conv;
} }
brk:
if(a->index != D_NONE) {
snprint(s, sizeof(s), "(%R*%d)", (int)a->index, (int)a->scale);
strcat(str, s);
}
conv: conv:
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
} }
static char* regstr[] =
{
"R0",
"R1",
"R2",
"R3",
"R4",
"R5",
"R6",
"R7",
"R8",
"R9",
"R10",
"R11",
"R12",
"R13",
"R14",
"R15",
"NONE",
};
int
Rconv(Fmt *fp)
{
char str[STRINGSZ];
int r;
r = va_arg(fp->args, int);
if(r < 0 || r >= nelem(regstr) || regstr[r] == nil) {
snprint(str, sizeof(str), "BAD_R(%d)", r);
return fmtstrcpy(fp, str);
}
return fmtstrcpy(fp, regstr[r]);
}
int int
Aconv(Fmt *fp) Aconv(Fmt *fp)
{ {
......
...@@ -200,7 +200,8 @@ enum as ...@@ -200,7 +200,8 @@ enum as
#define C_SCOND_LT 11 #define C_SCOND_LT 11
#define C_SCOND_GT 12 #define C_SCOND_GT 12
#define C_SCOND_LE 13 #define C_SCOND_LE 13
#define C_SCOND_N 15 #define C_SCOND_NONE 14
#define C_SCOND_NV 15
/* type/name */ /* type/name */
#define D_GOK 0 #define D_GOK 0
......
...@@ -864,8 +864,8 @@ oplook(Prog *p) ...@@ -864,8 +864,8 @@ oplook(Prog *p)
p->optab = (o-otab)+1; p->optab = (o-otab)+1;
return o; return o;
} }
diag("illegal combination %A %d %d %d", diag("illegal combination %A %d %d %d, %d %d",
p->as, a1, a2, a3); p->as, a1, a2, a3, p->from.type, p->to.type);
prasm(p); prasm(p);
if(o == 0) if(o == 0)
o = otab; o = otab;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment