Commit 5e792b6c authored by Russ Cox's avatar Russ Cox

move portable object routines (especially

signature generation) into gc.

R=ken
OCL=26933
CL=26933
parent 941ed00b
......@@ -15,11 +15,11 @@ HFILES=\
OFILES=\
list.$O\
obj.$O\
align.$O\
gen.$O\
cgen.$O\
gsubr.$O\
obj.$O\
peep.$O\
reg.$O\
../6l/enam.$O\
......
......@@ -4,6 +4,10 @@
#include "gg.h"
int thechar = '6';
char* thestring = "amd64";
/*
* go declares several platform-specific type aliases:
* int, uint, float, and uintptr
......
......@@ -41,18 +41,6 @@ struct Prog
void* reg; // pointer to containing Reg struct
};
typedef struct Plist Plist;
struct Plist
{
Node* name;
Dcl* locals;
Prog* firstpc;
int recur;
Plist* link;
};
EXTERN Plist* plist;
EXTERN Plist* plast;
EXTERN Biobuf* bout;
EXTERN int32 dynloc;
EXTERN uchar reg[D_NONE];
......@@ -146,18 +134,5 @@ int Rconv(Fmt*);
int Yconv(Fmt*);
void listinit(void);
/*
* obj
*/
void zname(Biobuf*, Sym*, int);
void zaddr(Biobuf*, Addr*, int);
void ieeedtod(Ieee*, double);
void dumpstrings(void);
void dumpsignatures(void);
void outhist(Biobuf*);
/*
* align
*/
void dowidth(Type*);
uint32 rnd(uint32, uint32);
......@@ -1938,10 +1938,39 @@ Prog*
gjmp(Prog *to)
{
Prog *p;
p = gbranch(AJMP, T);
if(to != P)
patch(p, to);
return p;
}
void
ggloblnod(Node *nam, int32 width)
{
Prog *p;
p = gins(AGLOBL, nam, N);
p->lineno = nam->lineno;
p->to.sym = S;
p->to.type = D_CONST;
p->to.offset = width;
}
void
ggloblsym(Sym *s, int32 width, int dupok)
{
Prog *p;
p = gins(AGLOBL, N, N);
p->from.type = D_EXTERN;
if(s == symstringo)
p->from.type = D_STATIC;
p->from.index = D_NONE;
p->from.sym = s;
p->to.type = D_CONST;
p->to.index = D_NONE;
p->to.offset = width;
if(dupok)
p->from.scale = DUPOK;
}
This diff is collapsed.
......@@ -31,6 +31,7 @@ OFILES=\
bits.$O\
align.$O\
gen.$O\
obj.$O\
$(LIB): $(OFILES)
ar rsc $(LIB) $(OFILES)
......
......@@ -592,8 +592,8 @@ EXTERN Node* typeswvar;
EXTERN char* context;
EXTERN char* pkgcontext;
EXTERN int thechar;
EXTERN char* thestring;
extern int thechar;
extern char* thestring;
EXTERN char* hunk;
EXTERN int32 nhunk;
EXTERN int32 thunk;
......@@ -979,6 +979,19 @@ struct Label
EXTERN Label* labellist;
EXTERN Label* findlab(Sym*);
typedef struct Plist Plist;
struct Plist
{
Node* name;
Dcl* locals;
Prog* firstpc;
int recur;
Plist* link;
};
EXTERN Plist* plist;
EXTERN Plist* plast;
EXTERN Prog* continpc;
EXTERN Prog* breakpc;
EXTERN Prog* pc;
......@@ -994,10 +1007,20 @@ Label* findlab(Sym *s);
void gen(Node *n);
void newlab(int op, Sym *s);
Node* sysfunc(char *name);
Plist* newplist(void);
/*
* obj.c
*/
void Bputdot(Biobuf *b);
void dumpfuncs(void);
void dumpglobls(void);
void dumpobj(void);
void ieeedtod(uint64 *ieee, double native);
void outhist(Biobuf *b);
/*
* gen.c/gsubr.c/obj.c
* arch-specific gen.c/gsubr.c/obj.c
*/
void betypeinit(void);
vlong convvtox(vlong, int);
......@@ -1021,3 +1044,21 @@ int isfat(Type*);
void clearfat(Node *n);
void cgen(Node*, Node*);
void gused(Node*);
void dumpstrings(void);
void dumpsignatures(void);
void dumpfuncs(void);
void ggloblnod(Node *nam, int32 width);
void ggloblsym(Sym *s, int32 width, int dupok);
void zfile(Biobuf *b, char *p, int n);
void zhist(Biobuf *b, int line, vlong offset);
void zname(Biobuf *b, Sym *s, int t);
void dumpstrings(void);
void nopout(Prog*);
void datastring(char *s, int len);
int dstringptr(Sym *s, int off, char *str);
int dsymptr(Sym *s, int off, Sym *x);
int duint16(Sym *s, int off, uint32 v);
int duint32(Sym *s, int off, uint32 v);
int duintptr(Sym *s, int off, uint32 v);
int duintxx(Sym *s, int off, uint64 v, int wid);
void genembedtramp(Type*, Sig*);
......@@ -213,8 +213,6 @@ findpkg(String *name)
goroot = getenv("GOROOT");
}
// BOTCH need to get .6 from backend
// try .a before .6. important for building libraries:
// if there is an array.6 in the array.a library,
// want to find all of array.a, not just array.6.
......@@ -222,7 +220,7 @@ findpkg(String *name)
snprint(namebuf, sizeof(namebuf), "%s/%Z.a", p->dir, name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/%Z.6", p->dir, name);
snprint(namebuf, sizeof(namebuf), "%s/%Z.%c", p->dir, name, thechar);
if(access(namebuf, 0) >= 0)
return 1;
}
......@@ -230,14 +228,14 @@ findpkg(String *name)
snprint(namebuf, sizeof(namebuf), "%Z.a", name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%Z.6", name);
snprint(namebuf, sizeof(namebuf), "%Z.%c", name, thechar);
if(access(namebuf, 0) >= 0)
return 1;
if(goroot != nil) {
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.a", goroot, name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.6", goroot, name);
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.%c", goroot, name, thechar);
if(access(namebuf, 0) >= 0)
return 1;
}
......@@ -1300,7 +1298,6 @@ mkpackage(char* pkg)
lookup(package)->lexical = LPACK;
if(outfile == nil) {
// BOTCH need to get .6 from backend
p = strrchr(infile, '/');
if(p == nil)
p = infile;
......@@ -1310,7 +1307,6 @@ mkpackage(char* pkg)
p = strrchr(namebuf, '.');
if(p != nil)
*p = 0;
strncat(namebuf, ".6", sizeof(namebuf));
outfile = strdup(namebuf);
outfile = smprint("%s.%c", namebuf, thechar);
}
}
This diff is collapsed.
......@@ -2403,102 +2403,6 @@ tempname(Node *n, Type *t)
n->xoffset = -stksize;
}
void
stringpool(Node *n)
{
Pool *p;
int w;
if(n->op != OLITERAL || n->val.ctype != CTSTR) {
if(n->val.ctype == CTNIL)
return;
fatal("stringpool: not string %N", n);
}
p = mal(sizeof(*p));
p->sval = n->val.u.sval;
p->link = nil;
if(poolist == nil)
poolist = p;
else
poolast->link = p;
poolast = p;
w = types[TINT32]->width;
symstringo->offset += w; // len
symstringo->offset += p->sval->len; // str[len]
symstringo->offset = rnd(symstringo->offset, w);
}
Sig*
lsort(Sig *l, int(*f)(Sig*, Sig*))
{
Sig *l1, *l2, *le;
if(l == 0 || l->link == 0)
return l;
l1 = l;
l2 = l;
for(;;) {
l2 = l2->link;
if(l2 == 0)
break;
l2 = l2->link;
if(l2 == 0)
break;
l1 = l1->link;
}
l2 = l1->link;
l1->link = 0;
l1 = lsort(l, f);
l2 = lsort(l2, f);
/* set up lead element */
if((*f)(l1, l2) < 0) {
l = l1;
l1 = l1->link;
} else {
l = l2;
l2 = l2->link;
}
le = l;
for(;;) {
if(l1 == 0) {
while(l2) {
le->link = l2;
le = l2;
l2 = l2->link;
}
le->link = 0;
break;
}
if(l2 == 0) {
while(l1) {
le->link = l1;
le = l1;
l1 = l1->link;
}
break;
}
if((*f)(l1, l2) < 0) {
le->link = l1;
le = l1;
l1 = l1->link;
} else {
le->link = l2;
le = l2;
l2 = l2->link;
}
}
le->link = 0;
return l;
}
void
setmaxarg(Type *t)
{
......
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