Commit 0eb2a79f authored by Ken Thompson's avatar Ken Thompson

8g optimizer

R=rsc
http://go/go-review/1025011
parent 832ce7c1
......@@ -1146,7 +1146,7 @@ allreg(uint32 b, Rgn *r)
switch(v->etype) {
default:
fatal("unknown etype %d/%d", bitno(b), v->etype);
fatal("unknown etype %d/%E", bitno(b), v->etype);
break;
case TINT8:
......
......@@ -11,7 +11,7 @@ HFILES=\
../gc/go.h\
../8l/8.out.h\
gg.h\
# opt.h\
opt.h\
OFILES=\
../8l/enam.$O\
......@@ -22,8 +22,8 @@ OFILES=\
gsubr.$O\
cgen.$O\
cgen64.$O\
# peep.$O\
# reg.$O\
peep.$O\
reg.$O\
LIB=\
../gc/gc.a$O
......
......@@ -23,12 +23,13 @@ struct Addr
Prog* branch;
char sval[NSNAME];
Sym* gotype;
Sym* sym;
int width;
uchar type;
uchar index;
uchar etype;
uchar scale; /* doubles as width in DATA op */
Sym* gotype;
};
#define A ((Addr*)0)
......
......@@ -5,6 +5,7 @@
#undef EXTERN
#define EXTERN
#include "gg.h"
#include "opt.h"
void
compile(Node *fn)
......@@ -78,9 +79,9 @@ compile(Node *fn)
pc->as = ARET; // overwrite AEND
pc->lineno = lineno;
// if(!debug['N'] || debug['R'] || debug['P'])
// regopt(ptxt);
if(!debug['N'] || debug['R'] || debug['P']) {
regopt(ptxt);
}
// fill in argument size
ptxt->to.offset2 = rnd(curfn->type->argwid, maxround);
......
......@@ -1714,6 +1714,7 @@ naddr(Node *n, Addr *a, int canemitcode)
// n->left is PHEAP ONAME for stack parameter.
// compute address of actual parameter on stack.
a->etype = n->left->type->etype;
a->width = n->left->type->width;
a->offset = n->xoffset;
a->sym = n->left->sym;
a->type = D_PARAM;
......@@ -1721,8 +1722,10 @@ naddr(Node *n, Addr *a, int canemitcode)
case ONAME:
a->etype = 0;
a->width = 0;
if(n->type != T) {
a->etype = simtype[n->type->etype];
a->width = n->type->width;
a->gotype = ngotype(n);
}
a->offset = n->xoffset;
......
// Derived from Inferno utils/6c/gc.h
// http://code.google.com/p/inferno-os/source/browse/utils/6c/gc.h
//
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright © 1997-1999 Vita Nuova Limited
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright © 2004,2006 Bruce Ellis
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright © 2009 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#define Z N
#define Adr Addr
#define D_HI D_NONE
#define D_LO D_NONE
#define isregtype(t) ((t)>= D_AX && (t)<=D_R15)
#define BLOAD(r) band(bnot(r->refbehind), r->refahead)
#define BSTORE(r) band(bnot(r->calbehind), r->calahead)
#define LOAD(r) (~r->refbehind.b[z] & r->refahead.b[z])
#define STORE(r) (~r->calbehind.b[z] & r->calahead.b[z])
#define CLOAD 5
#define CREF 5
#define CINF 1000
#define LOOP 3
typedef struct Reg Reg;
typedef struct Rgn Rgn;
struct Reg
{
Bits set;
Bits use1;
Bits use2;
Bits refbehind;
Bits refahead;
Bits calbehind;
Bits calahead;
Bits regdiff;
Bits act;
int32 regu; // register used bitmap
int32 rpo; // reverse post ordering
int32 active;
uint16 loop; // x5 for every loop
uchar refset; // diagnostic generated
Reg* p1;
Reg* p2;
Reg* p2link;
Reg* s1;
Reg* s2;
Reg* link;
Prog* prog;
};
#define R ((Reg*)0)
#define NRGN 600
struct Rgn
{
Reg* enter;
short cost;
short varno;
short regno;
};
EXTERN int32 exregoffset; // not set
EXTERN int32 exfregoffset; // not set
EXTERN Reg* firstr;
EXTERN Reg* lastr;
EXTERN Reg zreg;
EXTERN Reg* freer;
EXTERN Reg** rpo2r;
EXTERN Rgn region[NRGN];
EXTERN Rgn* rgp;
EXTERN int nregion;
EXTERN int nvar;
EXTERN int32 regbits;
EXTERN int32 exregbits;
EXTERN Bits externs;
EXTERN Bits params;
EXTERN Bits consts;
EXTERN Bits addrs;
EXTERN Bits ovar;
EXTERN int change;
EXTERN int32 maxnr;
EXTERN int32* idom;
EXTERN struct
{
int32 ncvtreg;
int32 nspill;
int32 nreload;
int32 ndelmov;
int32 nvar;
int32 naddr;
} ostats;
/*
* reg.c
*/
Reg* rega(void);
int rcmp(const void*, const void*);
void regopt(Prog*);
void addmove(Reg*, int, int, int);
Bits mkvar(Reg*, Adr*);
void prop(Reg*, Bits, Bits);
void loopit(Reg*, int32);
void synch(Reg*, Bits);
uint32 allreg(uint32, Rgn*);
void paint1(Reg*, int);
uint32 paint2(Reg*, int);
void paint3(Reg*, int, int32, int);
void addreg(Adr*, int);
void dumpone(Reg*);
void dumpit(char*, Reg*);
int noreturn(Prog *p);
/*
* peep.c
*/
void peep(void);
void excise(Reg*);
Reg* uniqp(Reg*);
Reg* uniqs(Reg*);
int regtyp(Adr*);
int anyvar(Adr*);
int subprop(Reg*);
int copyprop(Reg*);
int copy1(Adr*, Adr*, Reg*, int);
int copyu(Prog*, Adr*, Adr*);
int copyas(Adr*, Adr*);
int copyau(Adr*, Adr*);
int copysub(Adr*, Adr*, Adr*, int);
int copysub1(Prog*, Adr*, Adr*, int);
int32 RtoB(int);
int32 FtoB(int);
int BtoR(int32);
int BtoF(int32);
This diff is collapsed.
This diff is collapsed.
......@@ -408,25 +408,25 @@ enum
TFLOAT64,
TFLOAT,
TBOOL, // 16
TBOOL, // 15
TPTR32, TPTR64, // 17
TPTR32, TPTR64, // 16
TDDD, // 19
TDDD, // 18
TFUNC,
TARRAY,
T_old_DARRAY,
TSTRUCT, // 23
TSTRUCT, // 22
TCHAN,
TMAP,
TINTER, // 26
TINTER, // 25
TFORW,
TFIELD,
TANY,
TSTRING,
// pseudo-types for literals
TIDEAL,
TIDEAL, // 30
TNIL,
TBLANK,
......
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