summaryrefslogtreecommitdiff
path: root/src/cmd/cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/cc')
-rw-r--r--src/cmd/cc/Makefile21
-rw-r--r--src/cmd/cc/acid.c12
-rw-r--r--src/cmd/cc/cc.h3
-rw-r--r--src/cmd/cc/com.c6
-rw-r--r--src/cmd/cc/dcl.c39
-rw-r--r--src/cmd/cc/dpchk.c13
-rw-r--r--src/cmd/cc/lex.c10
-rw-r--r--src/cmd/cc/macbody2
-rw-r--r--src/cmd/cc/pgen.c8
-rw-r--r--src/cmd/cc/pickle.c10
-rw-r--r--src/cmd/cc/pswt.c4
-rw-r--r--src/cmd/cc/sub.c8
12 files changed, 65 insertions, 71 deletions
diff --git a/src/cmd/cc/Makefile b/src/cmd/cc/Makefile
index 98b89f0a2..71f23383d 100644
--- a/src/cmd/cc/Makefile
+++ b/src/cmd/cc/Makefile
@@ -2,10 +2,10 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-include ../../Make.conf
+include ../../Make.inc
+O:=$(HOST_O)
-LIB=\
- cc.a$O\
+LIB=cc.a
HFILES=\
cc.h\
@@ -30,18 +30,7 @@ OFILES=\
dpchk.$O\
omachcap.$O\
-$(LIB): $(OFILES)
- ar rsc $(LIB) $(OFILES)
-
-$(OFILES): $(HFILES)
-
-y.tab.h: $(YFILES)
- bison -y $(YFLAGS) $(YFILES)
-
-y.tab.c: y.tab.h
- test -f y.tab.c && touch y.tab.c
-
-clean:
- rm -f *.$O *.6 enam.c 6.out a.out y.tab.h y.tab.c $(LIB)
+NOINSTALL=1
+include ../../Make.clib
install: $(LIB)
diff --git a/src/cmd/cc/acid.c b/src/cmd/cc/acid.c
index eb7968c4f..c6a6722bd 100644
--- a/src/cmd/cc/acid.c
+++ b/src/cmd/cc/acid.c
@@ -150,7 +150,7 @@ acidmember(Type *t, int32 off, int flag)
if(typesu[l->etype]) {
s1 = acidsue(l->link);
if(s1 != S) {
- Bprint(&outbuf, " 'A' %s %ld %s;\n",
+ Bprint(&outbuf, " 'A' %s %d %s;\n",
amap(s1->name),
t->offset+off, amap(s->name));
break;
@@ -189,7 +189,7 @@ acidmember(Type *t, int32 off, int flag)
if(s == S)
break;
if(flag) {
- Bprint(&outbuf, " '%c' %ld %s;\n",
+ Bprint(&outbuf, " '%c' %d %s;\n",
acidchar[t->etype], t->offset+off, amap(s->name));
} else {
Bprint(&outbuf, "\tprint(indent, \"%s\t\", addr.%s, \"\\n\");\n",
@@ -209,7 +209,7 @@ acidmember(Type *t, int32 off, int flag)
acidmember(l, t->offset+off, flag);
Bprint(&outbuf, " };\n");
} else {
- Bprint(&outbuf, " %s %ld %s;\n",
+ Bprint(&outbuf, " %s %d %s;\n",
amap(s1->name),
t->offset+off, amap(s->name));
}
@@ -223,7 +223,7 @@ acidmember(Type *t, int32 off, int flag)
} else {
Bprint(&outbuf, "\tprint(indent, \"%s {\\n\");\n",
amap(s1->name));
- Bprint(&outbuf, "\tindent_%s(addr+%ld, indent+\"\\t\");\n",
+ Bprint(&outbuf, "\tindent_%s(addr+%d, indent+\"\\t\");\n",
amap(s1->name), t->offset+off);
Bprint(&outbuf, "\tprint(indent, \"}\\n\");\n");
}
@@ -263,7 +263,7 @@ acidtype(Type *t)
if(debug['s'])
goto asmstr;
an = amap(s->name);
- Bprint(&outbuf, "sizeof%s = %ld;\n", an, t->width);
+ Bprint(&outbuf, "sizeof%s = %d;\n", an, t->width);
Bprint(&outbuf, "aggr %s\n{\n", an);
for(l = t->link; l != T; l = l->down)
acidmember(l, 0, 1);
@@ -280,7 +280,7 @@ acidtype(Type *t)
break;
for(l = t->link; l != T; l = l->down)
if(l->sym != S)
- Bprint(&outbuf, "#define\t%s.%s\t%ld\n",
+ Bprint(&outbuf, "#define\t%s.%s\t%d\n",
s->name,
l->sym->name,
l->offset);
diff --git a/src/cmd/cc/cc.h b/src/cmd/cc/cc.h
index 69adcccb0..3649bf5f6 100644
--- a/src/cmd/cc/cc.h
+++ b/src/cmd/cc/cc.h
@@ -166,6 +166,7 @@ struct Type
uchar nbits;
uchar etype;
uchar garb;
+ uchar align;
};
#define T ((Type*)0)
@@ -785,7 +786,7 @@ int32 outlstring(ushort*, int32);
void sextern(Sym*, Node*, int32, int32);
void xcom(Node*);
int32 exreg(Type*);
-int32 align(int32, Type*, int);
+int32 align(int32, Type*, int, int32*);
int32 maxround(int32, int32);
extern schar ewidth[];
diff --git a/src/cmd/cc/com.c b/src/cmd/cc/com.c
index 5cbe8b77c..b1a8a4704 100644
--- a/src/cmd/cc/com.c
+++ b/src/cmd/cc/com.c
@@ -638,10 +638,10 @@ tcomo(Node *n, int f)
n->addable = 1;
if(n->class == CEXREG) {
n->op = OREGISTER;
- // on 386, "extern register" generates
+ // on 386 or amd64, "extern register" generates
// memory references relative to the
- // fs segment.
- if(thechar == '8') // [sic]
+ // gs or fs segment.
+ if(thechar == '8' || thechar == '6') // [sic]
n->op = OEXREG;
n->reg = n->sym->offset;
n->xoffset = 0;
diff --git a/src/cmd/cc/dcl.c b/src/cmd/cc/dcl.c
index b4d8c4d14..f629925d1 100644
--- a/src/cmd/cc/dcl.c
+++ b/src/cmd/cc/dcl.c
@@ -195,7 +195,7 @@ doinit(Sym *s, Type *t, int32 o, Node *a)
dbgdecl(s);
}
if(debug['i']) {
- print("t = %T; o = %ld; n = %s\n", t, o, s->name);
+ print("t = %T; o = %d; n = %s\n", t, o, s->name);
prtree(a, "doinit value");
}
@@ -323,7 +323,7 @@ init1(Sym *s, Type *t, int32 o, int exflag)
return Z;
if(debug['i']) {
- print("t = %T; o = %ld; n = %s\n", t, o, s->name);
+ print("t = %T; o = %d; n = %s\n", t, o, s->name);
prtree(a, "init1 value");
}
@@ -479,7 +479,7 @@ init1(Sym *s, Type *t, int32 o, int exflag)
e = r->vconst;
if(t->width != 0)
if(e < 0 || e*w >= t->width) {
- diag(a, "initialization index out of range: %ld", e);
+ diag(a, "initialization index out of range: %d", e);
continue;
}
}
@@ -552,9 +552,10 @@ void
sualign(Type *t)
{
Type *l;
- int32 o, w;
+ int32 o, w, maxal;
o = 0;
+ maxal = 0;
switch(t->etype) {
case TSTRUCT:
@@ -577,13 +578,14 @@ sualign(Type *t)
l->sym->name);
else
diag(Z, "incomplete structure element");
- w = align(w, l, Ael1);
+ w = align(w, l, Ael1, &maxal);
l->offset = w;
- w = align(w, l, Ael2);
+ w = align(w, l, Ael2, &maxal);
}
}
- w = align(w, t, Asu2);
+ w = align(w, t, Asu2, &maxal);
t->width = w;
+ t->align = maxal;
acidtype(t);
pickletype(t);
return;
@@ -600,12 +602,13 @@ sualign(Type *t)
diag(Z, "incomplete union element");
l->offset = 0;
l->shift = 0;
- o = align(align(0, l, Ael1), l, Ael2);
+ o = align(align(0, l, Ael1, &maxal), l, Ael2, &maxal);
if(o > w)
w = o;
}
- w = align(w, t, Asu2);
+ w = align(w, t, Asu2, &maxal);
t->width = w;
+ t->align = maxal;
acidtype(t);
pickletype(t);
return;
@@ -663,7 +666,7 @@ argmark(Node *n, int pass)
{
Type *t;
- autoffset = align(0, thisfn->link, Aarg0);
+ autoffset = align(0, thisfn->link, Aarg0, nil);
stkoff = 0;
for(; n->left != Z; n = n->left) {
if(n->op != OFUNC || n->left->op != ONAME)
@@ -745,9 +748,9 @@ loop:
firstarg = s;
firstargtype = s->type;
}
- autoffset = align(autoffset, s->type, Aarg1);
+ autoffset = align(autoffset, s->type, Aarg1, nil);
s->offset = autoffset;
- autoffset = align(autoffset, s->type, Aarg2);
+ autoffset = align(autoffset, s->type, Aarg2, nil);
} else
dodecl(pdecl, CXXX, types[TINT], n);
break;
@@ -916,7 +919,7 @@ fnproto1(Node *n)
void
dbgdecl(Sym *s)
{
- print("decl \"%s\": C=%s [B=%d:O=%ld] T=%T\n",
+ print("decl \"%s\": C=%s [B=%d:O=%d] T=%T\n",
s->name, cnames[s->class], s->block, s->offset, s->type);
}
@@ -1275,7 +1278,7 @@ adecl(int c, Type *t, Sym *s)
}
switch(c) {
case CAUTO:
- autoffset = align(autoffset, t, Aaut3);
+ autoffset = align(autoffset, t, Aaut3, nil);
stkoff = maxround(stkoff, autoffset);
s->offset = -autoffset;
break;
@@ -1285,10 +1288,10 @@ adecl(int c, Type *t, Sym *s)
firstarg = s;
firstargtype = t;
}
- autoffset = align(autoffset, t, Aarg1);
+ autoffset = align(autoffset, t, Aarg1, nil);
if(s)
s->offset = autoffset;
- autoffset = align(autoffset, t, Aarg2);
+ autoffset = align(autoffset, t, Aarg2, nil);
break;
}
}
@@ -1571,7 +1574,7 @@ contig(Sym *s, Node *n, int32 v)
Type *zt;
if(debug['i']) {
- print("contig v = %ld; s = %s\n", v, s->name);
+ print("contig v = %d; s = %s\n", v, s->name);
prtree(n, "doinit value");
}
@@ -1587,7 +1590,7 @@ contig(Sym *s, Node *n, int32 v)
if(v != 0)
diag(n, "automatic adjustable array: %s", s->name);
v = s->offset;
- autoffset = align(autoffset, s->type, Aaut3);
+ autoffset = align(autoffset, s->type, Aaut3, nil);
s->offset = -autoffset;
stkoff = maxround(stkoff, autoffset);
symadjust(s, n, v - s->offset);
diff --git a/src/cmd/cc/dpchk.c b/src/cmd/cc/dpchk.c
index 046c0e4da..6eb5fb409 100644
--- a/src/cmd/cc/dpchk.c
+++ b/src/cmd/cc/dpchk.c
@@ -369,7 +369,7 @@ checkargs(Node *nn, char *s, int pos)
continue;
for(l=tprot; l; l=l->link)
if(sametype(a->type, l->type)) {
-/*print("checking %T/%ulx %T/%ulx\n", a->type, flag.b[0], l->type, l->flag.b[0]);*/
+/*print("checking %T/%ux %T/%ux\n", a->type, flag.b[0], l->type, l->flag.b[0]);*/
if(beq(flag, l->flag))
goto loop;
}
@@ -400,6 +400,7 @@ dpcheck(Node *n)
i = l->param;
b = n->right;
+ a = Z;
while(i > 0) {
b = nextarg(b, &a);
i--;
@@ -437,9 +438,9 @@ pragpack(void)
;
if(debug['f'])
if(packflg)
- print("%4ld: pack %d\n", lineno, packflg);
+ print("%4d: pack %d\n", lineno, packflg);
else
- print("%4ld: pack off\n", lineno);
+ print("%4d: pack off\n", lineno);
}
void
@@ -459,9 +460,9 @@ pragfpround(void)
;
if(debug['f'])
if(fproundflg)
- print("%4ld: fproundflg %d\n", lineno, fproundflg);
+ print("%4d: fproundflg %d\n", lineno, fproundflg);
else
- print("%4ld: fproundflg off\n", lineno);
+ print("%4d: fproundflg off\n", lineno);
}
void
@@ -477,7 +478,7 @@ pragtextflag(void)
while(getnsc() != '\n')
;
if(debug['f'])
- print("%4ld: textflag %d\n", lineno, textflag);
+ print("%4d: textflag %d\n", lineno, textflag);
}
void
diff --git a/src/cmd/cc/lex.c b/src/cmd/cc/lex.c
index c9facc667..3b413c246 100644
--- a/src/cmd/cc/lex.c
+++ b/src/cmd/cc/lex.c
@@ -38,7 +38,7 @@
int
systemtype(int sys)
{
-#ifdef __MINGW32__
+#ifdef _WIN32
return sys&Windows;
#else
return sys&Plan9;
@@ -630,7 +630,7 @@ l1:
vv = c;
yylval.vval = convvtox(vv, TUCHAR);
if(yylval.vval != vv)
- yyerror("overflow in character constant: 0x%lx", c);
+ yyerror("overflow in character constant: 0x%x", c);
else
if(c & 0x80){
nearln = lineno;
@@ -1410,11 +1410,11 @@ Lconv(Fmt *fp)
strcat(str, " ");
}
if(a[i].line)
- snprint(s, STRINGSZ, "%s:%ld[%s:%ld]",
+ snprint(s, STRINGSZ, "%s:%d[%s:%d]",
a[i].line->name, l-a[i].ldel+1,
a[i].incl->name, l-a[i].idel+1);
else
- snprint(s, STRINGSZ, "%s:%ld",
+ snprint(s, STRINGSZ, "%s:%d",
a[i].incl->name, l-a[i].idel+1);
if(strlen(s)+strlen(str) >= STRINGSZ-10)
break;
@@ -1463,7 +1463,7 @@ Tconv(Fmt *fp)
n = t->width;
if(t->link && t->link->width)
n /= t->link->width;
- sprint(s, "[%ld]", n);
+ sprint(s, "[%d]", n);
if(strlen(str) + strlen(s) < STRINGSZ)
strcat(str, s);
}
diff --git a/src/cmd/cc/macbody b/src/cmd/cc/macbody
index ca8a54c0b..35740e985 100644
--- a/src/cmd/cc/macbody
+++ b/src/cmd/cc/macbody
@@ -63,7 +63,7 @@ getsym(void)
if(cp <= symb+NSYMB-4)
*cp++ = c;
c = getc();
- if(isalnum(c) || c == '_' || c >= 0x80)
+ if(isalnum(c) || c == '_' || c >= 0x80 || c == '$')
continue;
unget(c);
break;
diff --git a/src/cmd/cc/pgen.c b/src/cmd/cc/pgen.c
index cd6fffc57..a9d7f1ef4 100644
--- a/src/cmd/cc/pgen.c
+++ b/src/cmd/cc/pgen.c
@@ -37,7 +37,7 @@ argsize(void)
int32 s;
//print("t=%T\n", thisfn);
- s = align(0, thisfn->link, Aarg0);
+ s = align(0, thisfn->link, Aarg0, nil);
for(t=thisfn->down; t!=T; t=t->down) {
switch(t->etype) {
case TVOID:
@@ -47,8 +47,8 @@ argsize(void)
s += 64;
break;
default:
- s = align(s, t, Aarg1);
- s = align(s, t, Aarg2);
+ s = align(s, t, Aarg1, nil);
+ s = align(s, t, Aarg2, nil);
break;
}
//print(" %d %T\n", s, t);
@@ -99,7 +99,7 @@ codgen(Node *n, Node *nn)
nod1 = *nodret->left;
nod1.sym = firstarg;
nod1.type = firstargtype;
- nod1.xoffset = align(0, firstargtype, Aarg1);
+ nod1.xoffset = align(0, firstargtype, Aarg1, nil);
nod1.etype = firstargtype->etype;
nodreg(&nod, &nod1, REGARG);
gmove(&nod, &nod1);
diff --git a/src/cmd/cc/pickle.c b/src/cmd/cc/pickle.c
index fb7ec585b..82cf5eb05 100644
--- a/src/cmd/cc/pickle.c
+++ b/src/cmd/cc/pickle.c
@@ -143,7 +143,7 @@ picklemember(Type *t, int32 off)
case TIND:
if(s == S)
Bprint(&outbuf,
- "%s\"p\", (char*)addr+%ld+_i*%ld);\n",
+ "%s\"p\", (char*)addr+%d+_i*%d);\n",
picklestr, t->offset+off, t->width);
else
Bprint(&outbuf,
@@ -164,14 +164,14 @@ picklemember(Type *t, int32 off)
case TFLOAT:
case TDOUBLE:
if(s == S)
- Bprint(&outbuf, "%s\"%c\", (char*)addr+%ld+_i*%ld);\n",
+ Bprint(&outbuf, "%s\"%c\", (char*)addr+%d+_i*%d);\n",
picklestr, picklechar[t->etype], t->offset+off, t->width);
else
Bprint(&outbuf, "%s\"%c\", &addr->%s);\n",
picklestr, picklechar[t->etype], pmap(s->name));
break;
case TARRAY:
- Bprint(&outbuf, "\tfor(_i = 0; _i < %ld; _i++) {\n\t",
+ Bprint(&outbuf, "\tfor(_i = 0; _i < %d; _i++) {\n\t",
t->width/t->link->width);
picklemember(t->link, t->offset+off);
Bprint(&outbuf, "\t}\n\t_i = 0;\n\tUSED(_i);\n");
@@ -183,7 +183,7 @@ picklemember(Type *t, int32 off)
if(s1 == S)
break;
if(s == S) {
- Bprint(&outbuf, "\tbp = pickle_%s(bp, ep, un, (%s*)((char*)addr+%ld+_i*%ld));\n",
+ Bprint(&outbuf, "\tbp = pickle_%s(bp, ep, un, (%s*)((char*)addr+%d+_i*%d));\n",
pmap(s1->name), pmap(s1->name), t->offset+off, t->width);
} else {
Bprint(&outbuf, "\tbp = pickle_%s(bp, ep, un, &addr->%s);\n",
@@ -235,7 +235,7 @@ pickletype(Type *t)
break;
for(l = t->link; l != T; l = l->down)
if(l->sym != S)
- Bprint(&outbuf, "#define\t%s.%s\t%ld\n",
+ Bprint(&outbuf, "#define\t%s.%s\t%d\n",
s->name,
l->sym->name,
l->offset);
diff --git a/src/cmd/cc/pswt.c b/src/cmd/cc/pswt.c
index 02d4e64a0..0e402dea7 100644
--- a/src/cmd/cc/pswt.c
+++ b/src/cmd/cc/pswt.c
@@ -80,7 +80,7 @@ doswit(Node *n)
qsort(iq, nc, sizeof(C1), swcmp);
if(debug['W'])
for(i=0; i<nc; i++)
- print("case %2ld: = %.8llux\n", i, (vlong)iq[i].val);
+ print("case %2d: = %.8llux\n", i, (vlong)iq[i].val);
for(i=0; i<nc-1; i++)
if(iq[i].val == iq[i+1].val)
diag(n, "duplicate cases in switch %lld", (vlong)iq[i].val);
@@ -115,7 +115,7 @@ outlstring(ushort *s, int32 n)
r = nstring;
while(n > 0) {
c = *s++;
- if(align(0, types[TCHAR], Aarg1)) {
+ if(align(0, types[TCHAR], Aarg1, nil)) {
buf[0] = c>>8;
buf[1] = c;
} else {
diff --git a/src/cmd/cc/sub.c b/src/cmd/cc/sub.c
index 335d30bfb..e0d5df719 100644
--- a/src/cmd/cc/sub.c
+++ b/src/cmd/cc/sub.c
@@ -92,18 +92,18 @@ prtree1(Node *n, int d, int f)
{
case ONAME:
print(" \"%F\"", n);
- print(" %ld", n->xoffset);
+ print(" %d", n->xoffset);
i = 0;
break;
case OINDREG:
- print(" %ld(R%d)", n->xoffset, n->reg);
+ print(" %d(R%d)", n->xoffset, n->reg);
i = 0;
break;
case OREGISTER:
if(n->xoffset)
- print(" %ld+R%d", n->xoffset, n->reg);
+ print(" %d+R%d", n->xoffset, n->reg);
else
print(" R%d", n->reg);
i = 0;
@@ -845,7 +845,7 @@ simplifyshift(Node *n)
/*
if(debug['h'])
- print("%.3o %ld %ld %d #%.lux\n",
+ print("%.3o %d %d %d #%.ux\n",
(s1<<3)|s2, c1, c2, topbit(c3), c3);
*/