diff options
Diffstat (limited to 'src/cmd/6g')
-rw-r--r-- | src/cmd/6g/cgen.c | 10 | ||||
-rw-r--r-- | src/cmd/6g/galign.c | 8 | ||||
-rw-r--r-- | src/cmd/6g/gg.h | 2 | ||||
-rw-r--r-- | src/cmd/6g/ggen.c | 61 | ||||
-rw-r--r-- | src/cmd/6g/gsubr.c | 29 | ||||
-rw-r--r-- | src/cmd/6g/opt.h | 20 | ||||
-rw-r--r-- | src/cmd/6g/reg.c | 8 |
7 files changed, 74 insertions, 64 deletions
diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c index 4dd505b08..d13c98dad 100644 --- a/src/cmd/6g/cgen.c +++ b/src/cmd/6g/cgen.c @@ -247,7 +247,6 @@ cgen(Node *n, Node *res) case OOR: case OXOR: case OADD: - case OADDPTR: case OMUL: a = optoas(n->op, nl->type); if(a == AIMULB) { @@ -752,12 +751,7 @@ agenr(Node *n, Node *a, Node *res) regalloc(&n3, types[tptr], res); p1 = gins(ALEAQ, N, &n3); datastring(nl->val.u.sval->s, nl->val.u.sval->len, &p1->from); - if(flag_largemodel) { - gins(AADDQ, &n2, &n3); - } else { - p1->from.scale = 1; - p1->from.index = n2.val.u.reg; - } + gins(AADDQ, &n2, &n3); goto indexdone; } @@ -1457,7 +1451,7 @@ sgen(Node *n, Node *ns, int64 w) p = gins(ADUFFCOPY, N, N); p->to.type = D_ADDR; p->to.sym = linksym(pkglookup("duffcopy", runtimepkg)); - // 14 and 128 = magic constants: see ../../pkg/runtime/asm_amd64.s + // 14 and 128 = magic constants: see ../../runtime/asm_amd64.s p->to.offset = 14*(128-q); } else while(q > 0) { diff --git a/src/cmd/6g/galign.c b/src/cmd/6g/galign.c index 1d32c5a61..5670e6fac 100644 --- a/src/cmd/6g/galign.c +++ b/src/cmd/6g/galign.c @@ -30,10 +30,10 @@ int cmpptr = ACMPQ; */ Typedef typedefs[] = { - "int", TINT, TINT64, - "uint", TUINT, TUINT64, - "uintptr", TUINTPTR, TUINT64, - 0 + {"int", TINT, TINT64}, + {"uint", TUINT, TUINT64}, + {"uintptr", TUINTPTR, TUINT64}, + {0} }; void diff --git a/src/cmd/6g/gg.h b/src/cmd/6g/gg.h index a5da17d61..fe69d5c96 100644 --- a/src/cmd/6g/gg.h +++ b/src/cmd/6g/gg.h @@ -51,7 +51,6 @@ void allocparams(void); void checklabels(void); void ginscall(Node*, int); int gen_as_init(Node*); -void clearslim(Node*); /* * cgen.c @@ -100,7 +99,6 @@ int sudoaddable(int, Node*, Addr*); void afunclit(Addr*, Node*); void nodfconst(Node*, Type*, Mpflt*); void gtrack(Sym*); -void gargsize(vlong); void fixlargeoffset(Node *n); /* diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c index 9665d831b..363620769 100644 --- a/src/cmd/6g/ggen.c +++ b/src/cmd/6g/ggen.c @@ -175,7 +175,6 @@ fixautoused(Prog *p) void ginscall(Node *f, int proc) { - int32 arg; Prog *p; Node reg, con; Node r1; @@ -183,21 +182,6 @@ ginscall(Node *f, int proc) if(f->type != T) setmaxarg(f->type); - arg = -1; - // Most functions have a fixed-size argument block, so traceback uses that during unwind. - // Not all, though: there are some variadic functions in package runtime, - // and for those we emit call-specific metadata recorded by caller. - // Reflect generates functions with variable argsize (see reflect.methodValueCall/makeFuncStub), - // so we do this for all indirect calls as well. - if(f->type != T && (f->sym == S || (f->sym != S && f->sym->pkg == runtimepkg) || proc == 1 || proc == 2)) { - arg = f->type->argwid; - if(proc == 1 || proc == 2) - arg += 2*widthptr; - } - - if(arg != -1) - gargsize(arg); - switch(proc) { default: fatal("ginscall: bad proc %d", proc); @@ -275,9 +259,6 @@ ginscall(Node *f, int proc) } break; } - - if(arg != -1) - gargsize(-1); } /* @@ -1121,26 +1102,54 @@ clearfat(Node *nl) c = w % 8; // bytes q = w / 8; // quads + if(q < 4) { + // Write sequence of MOV 0, off(base) instead of using STOSQ. + // The hope is that although the code will be slightly longer, + // the MOVs will have no dependencies and pipeline better + // than the unrolled STOSQ loop. + // NOTE: Must use agen, not igen, so that optimizer sees address + // being taken. We are not writing on field boundaries. + agenr(nl, &n1, N); + n1.op = OINDREG; + nodconst(&z, types[TUINT64], 0); + while(q-- > 0) { + n1.type = z.type; + gins(AMOVQ, &z, &n1); + n1.xoffset += 8; + } + if(c >= 4) { + nodconst(&z, types[TUINT32], 0); + n1.type = z.type; + gins(AMOVL, &z, &n1); + n1.xoffset += 4; + c -= 4; + } + nodconst(&z, types[TUINT8], 0); + while(c-- > 0) { + n1.type = z.type; + gins(AMOVB, &z, &n1); + n1.xoffset++; + } + regfree(&n1); + return; + } + savex(D_DI, &n1, &oldn1, N, types[tptr]); agen(nl, &n1); savex(D_AX, &ax, &oldax, N, types[tptr]); gconreg(AMOVL, 0, D_AX); - if(q > 128 || (q >= 4 && nacl)) { + if(q > 128 || nacl) { gconreg(movptr, q, D_CX); gins(AREP, N, N); // repeat gins(ASTOSQ, N, N); // STOQ AL,*(DI)+ - } else if(q >= 4) { + } else { p = gins(ADUFFZERO, N, N); p->to.type = D_ADDR; p->to.sym = linksym(pkglookup("duffzero", runtimepkg)); - // 2 and 128 = magic constants: see ../../pkg/runtime/asm_amd64.s + // 2 and 128 = magic constants: see ../../runtime/asm_amd64.s p->to.offset = 2*(128-q); - } else - while(q > 0) { - gins(ASTOSQ, N, N); // STOQ AL,*(DI)+ - q--; } z = ax; diff --git a/src/cmd/6g/gsubr.c b/src/cmd/6g/gsubr.c index e4d00bf41..5bd924660 100644 --- a/src/cmd/6g/gsubr.c +++ b/src/cmd/6g/gsubr.c @@ -31,11 +31,11 @@ #include <u.h> #include <libc.h> #include "gg.h" -#include "../../pkg/runtime/funcdata.h" +#include "../../runtime/funcdata.h" // TODO(rsc): Can make this bigger if we move // the text segment up higher in 6l for all GOOS. -// At the same time, can raise StackBig in ../../pkg/runtime/stack.h. +// At the same time, can raise StackBig in ../../runtime/stack.h. vlong unmappedzero = 4096; void @@ -215,17 +215,7 @@ gtrack(Sym *s) } void -gargsize(vlong size) -{ - Node n1, n2; - - nodconst(&n1, types[TINT32], PCDATA_ArgSize); - nodconst(&n2, types[TINT32], size); - gins(APCDATA, &n1, &n2); -} - -void -ggloblsym(Sym *s, int32 width, int dupok, int rodata) +ggloblsym(Sym *s, int32 width, int8 flags) { Prog *p; @@ -236,10 +226,7 @@ ggloblsym(Sym *s, int32 width, int dupok, int rodata) p->to.type = D_CONST; p->to.index = D_NONE; p->to.offset = width; - if(dupok) - p->from.scale |= DUPOK; - if(rodata) - p->from.scale |= RODATA; + p->from.scale = flags; } int @@ -584,6 +571,7 @@ ginscon(int as, vlong c, Node *n2) } #define CASE(a,b) (((a)<<16)|((b)<<0)) +/*c2go int CASE(int, int); */ /* * Is this node a memory operand? @@ -600,11 +588,8 @@ ismem(Node *n) case ONAME: case OPARAM: case OCLOSUREVAR: - return 1; case OADDR: - if(flag_largemodel) - return 1; - break; + return 1; } return 0; } @@ -1542,14 +1527,12 @@ optoas(int op, Type *t) case CASE(OADD, TINT32): case CASE(OADD, TUINT32): case CASE(OADD, TPTR32): - case CASE(OADDPTR, TPTR32): a = AADDL; break; case CASE(OADD, TINT64): case CASE(OADD, TUINT64): case CASE(OADD, TPTR64): - case CASE(OADDPTR, TPTR64): a = AADDQ; break; diff --git a/src/cmd/6g/opt.h b/src/cmd/6g/opt.h index bf356af0c..dbd039d89 100644 --- a/src/cmd/6g/opt.h +++ b/src/cmd/6g/opt.h @@ -49,6 +49,24 @@ typedef struct Reg Reg; typedef struct Rgn Rgn; +/*c2go +extern Node *Z; +enum +{ + D_HI = D_NONE, + D_LO = D_NONE, + CLOAD = 5, + CREF = 5, + CINF = 1000, + LOOP = 3, +}; + +uint32 BLOAD(Reg*); +uint32 BSTORE(Reg*); +uint32 LOAD(Reg*); +uint32 STORE(Reg*); +*/ + // A Reg is a wrapper around a single Prog (one instruction) that holds // register optimization information while the optimizer runs. // r->prog is the instruction. @@ -71,8 +89,10 @@ struct Reg int32 regu; // register used bitmap }; #define R ((Reg*)0) +/*c2go extern Reg *R; */ #define NRGN 600 +/*c2go enum { NRGN = 600 }; */ struct Rgn { Reg* enter; diff --git a/src/cmd/6g/reg.c b/src/cmd/6g/reg.c index f3b1e55de..1f757e197 100644 --- a/src/cmd/6g/reg.c +++ b/src/cmd/6g/reg.c @@ -35,6 +35,11 @@ #define NREGVAR 32 /* 16 general + 16 floating */ #define REGBITS ((uint32)0xffffffff) +/*c2go enum { + NREGVAR = 32, + REGBITS = 0xffffffff, +}; +*/ static Reg* firstr; static int first = 1; @@ -839,7 +844,7 @@ prop(Reg *r, Bits ref, Bits cal) if(v == v1 || ((cal.b[j/32]>>(j&31))&1) == 0) { for(; v1 != nil; v1 = v1->nextinnode) { j = v1 - var; - cal.b[j/32] |= 1<<(j&31); + cal.b[j/32] |= 1UL<<(j&31); } } } @@ -1186,6 +1191,7 @@ void addreg(Adr *a, int rn) { a->sym = nil; + a->node = nil; a->offset = 0; a->type = rn; |