Skip to content

Commit

Permalink
6g cleanup suggested by ken.
Browse files Browse the repository at this point in the history
remove TPTR wrapper around TMAP, TCHAN, TSTRING.

R=ken
OCL=22406
CL=22409
  • Loading branch information
rsc committed Jan 9, 2009
1 parent 484ba93 commit a91af04
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 179 deletions.
4 changes: 4 additions & 0 deletions src/cmd/6g/align.c
Expand Up @@ -219,6 +219,10 @@ belexinit(int lextype)
Sym *s;
Type *t;

simtype[TMAP] = tptr;
simtype[TCHAN] = tptr;
simtype[TSTRING] = tptr;

zprog.link = P;
zprog.as = AGOK;
zprog.from.type = D_NONE;
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/6g/cgen.c
Expand Up @@ -218,7 +218,7 @@ cgen(Node *n, Node *res)
break;

case OLEN:
if(isptrto(nl->type, TSTRING)) {
if(istype(nl->type, TSTRING)) {
regalloc(&n1, types[tptr], res);
cgen(nl, &n1);

Expand All @@ -237,7 +237,7 @@ cgen(Node *n, Node *res)
regfree(&n1);
break;
}
if(isptrto(nl->type, TMAP)) {
if(istype(nl->type, TMAP)) {
regalloc(&n1, types[tptr], res);
cgen(nl, &n1);
n1.op = OINDREG;
Expand Down Expand Up @@ -964,7 +964,7 @@ sgen(Node *n, Node *ns, int32 w)
gconreg(AMOVQ, c, D_CX);
gins(AREP, N, N); // repeat
gins(AMOVSB, N, N); // MOVB *(SI)+,*(DI)+

} else
while(c > 0) {
gins(AMOVSB, N, N); // MOVB *(SI)+,*(DI)+
Expand Down
8 changes: 2 additions & 6 deletions src/cmd/6g/gen.c
Expand Up @@ -1141,13 +1141,11 @@ cgen_as(Node *nl, Node *nr)
iszer = 1;
nr = &nc;
memset(nr, 0, sizeof(*nr));
switch(tl->etype) {
switch(simtype[tl->etype]) {
default:
fatal("cgen_as: tl %T", tl);
break;

case TINT:
case TUINT:
case TINT8:
case TUINT8:
case TINT16:
Expand All @@ -1156,13 +1154,11 @@ cgen_as(Node *nl, Node *nr)
case TUINT32:
case TINT64:
case TUINT64:
case TUINTPTR:
nr->val.u.xval = mal(sizeof(*nr->val.u.xval));
mpmovecfix(nr->val.u.xval, 0);
nr->val.ctype = CTINT;
break;

case TFLOAT:
case TFLOAT32:
case TFLOAT64:
case TFLOAT80:
Expand Down Expand Up @@ -1195,7 +1191,7 @@ cgen_as(Node *nl, Node *nr)
cgen(nr, nl);
if(iszer && nl->addable)
gins(ANOP, nl, N); // used


ret:
;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/6g/gsubr.c
Expand Up @@ -998,7 +998,7 @@ naddr(Node *n, Addr *a)
case ONAME:
a->etype = 0;
if(n->type != T)
a->etype = n->type->etype;
a->etype = simtype[n->type->etype];
a->offset = n->xoffset;
a->sym = n->sym;
if(a->sym == S)
Expand Down Expand Up @@ -1045,7 +1045,7 @@ naddr(Node *n, Addr *a)
a->offset = mpgetfix(n->val.u.xval);
break;
case CTSTR:
a->etype = n->etype;
a->etype = simtype[n->etype];
a->sym = symstringo;
a->type = D_ADDR;
a->index = D_STATIC;
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/gc/const.c
Expand Up @@ -61,8 +61,6 @@ convlit1(Node *n, Type *t, int conv)
goto bad1;

case Wlitnil:
if(isptrto(t, TSTRING))
goto bad1;
switch(et) {
default:
goto bad1;
Expand All @@ -71,6 +69,8 @@ convlit1(Node *n, Type *t, int conv)
case TPTR64:
case TINTER:
case TARRAY:
case TMAP:
case TCHAN:
break;
}
break;
Expand All @@ -80,7 +80,7 @@ convlit1(Node *n, Type *t, int conv)
defaultlit(n);
return;
}
if(isptrto(t, TSTRING))
if(et == TSTRING)
break;
goto bad1;

Expand Down Expand Up @@ -127,7 +127,7 @@ convlit1(Node *n, Type *t, int conv)
goto bad1;

// only done as string(CONST)
if(isptrto(t, TSTRING)) {
if(et == TSTRING) {
Rune rune;
int l;
String *s;
Expand Down Expand Up @@ -180,7 +180,7 @@ convlit1(Node *n, Type *t, int conv)
goto bad1;
}
n->type = t;

return;

bad1:
Expand Down
17 changes: 0 additions & 17 deletions src/cmd/gc/dcl.c
Expand Up @@ -495,14 +495,6 @@ stotype(Node *n, Type **t)
if(n->op != ODCLFIELD || n->type == T)
fatal("stotype: oops %N\n", n);

switch(n->type->etype) {
case TCHAN:
case TMAP:
case TSTRING:
yyerror("%T can exist only in pointer form", n->type);
break;
}

switch(n->val.ctype) {
case CTSTR:
note = n->val.u.sval;
Expand Down Expand Up @@ -749,15 +741,6 @@ addvar(Node *n, Type *t, int ctxt)
pushdcl(s);
}

if(t != T) {
switch(t->etype) {
case TCHAN:
case TMAP:
case TSTRING:
yyerror("%T can exist only in pointer form", t);
}
}

redeclare("variable", s);
s->vargen = gen;
s->oname = n;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/gc/export.c
Expand Up @@ -59,7 +59,7 @@ dumpprereq(Type *t)
if(t == T)
return;

if(t->printed || t == types[t->etype] || t == types[TSTRING])
if(t->printed || t == types[t->etype])
return;
t->printed = 1;

Expand Down
1 change: 1 addition & 0 deletions src/cmd/gc/go.h
Expand Up @@ -626,6 +626,7 @@ void dump(char*, Node*);
Type* aindex(Node*, Type*);
int isnil(Node*);
int isptrto(Type*, int);
int istype(Type*, int);
int isptrsarray(Type*);
int isptrdarray(Type*);
int issarray(Type*);
Expand Down
13 changes: 0 additions & 13 deletions src/cmd/gc/go.y
Expand Up @@ -1031,7 +1031,6 @@ convtype:
$$ = typ(TMAP);
$$->down = $3;
$$->type = $5;
$$ = ptrto($$);
}
| structtype

Expand Down Expand Up @@ -1116,21 +1115,18 @@ Aothertype:
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Crecv;
$$ = ptrto($$);
}
| LCHAN LCOMM Anon_chan_type
{
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Csend;
$$ = ptrto($$);
}
| LMAP '[' type ']' Atype
{
$$ = typ(TMAP);
$$->down = $3;
$$->type = $5;
$$ = ptrto($$);
}
| '*' Atype
{
Expand All @@ -1153,21 +1149,18 @@ Bothertype:
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Crecv;
$$ = ptrto($$);
}
| LCHAN LCOMM Bnon_chan_type
{
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Csend;
$$ = ptrto($$);
}
| LMAP '[' type ']' Btype
{
$$ = typ(TMAP);
$$->down = $3;
$$->type = $5;
$$ = ptrto($$);
}
| '*' Btype
{
Expand All @@ -1184,7 +1177,6 @@ Achantype:
$$ = typ(TCHAN);
$$->type = $2;
$$->chan = Cboth;
$$ = ptrto($$);
}

Bchantype:
Expand All @@ -1193,7 +1185,6 @@ Bchantype:
$$ = typ(TCHAN);
$$->type = $2;
$$->chan = Cboth;
$$ = ptrto($$);
}

structtype:
Expand Down Expand Up @@ -1865,7 +1856,6 @@ hidden_type1:
$$ = typ(TMAP);
$$->down = $3;
$$->type = $5;
$$ = ptrto($$);
}
| LSTRUCT '{' ohidden_structdcl_list '}'
{
Expand All @@ -1886,14 +1876,12 @@ hidden_type1:
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Crecv;
$$ = ptrto($$);
}
| LCHAN LCOMM hidden_type1
{
$$ = typ(TCHAN);
$$->type = $3;
$$->chan = Csend;
$$ = ptrto($$);
}
| LDDD
{
Expand All @@ -1906,7 +1894,6 @@ hidden_type2:
$$ = typ(TCHAN);
$$->type = $2;
$$->chan = Cboth;
$$ = ptrto($$);
}
| '(' ohidden_funarg_list ')' ohidden_funres
{
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/gc/lex.c
Expand Up @@ -1150,6 +1150,8 @@ lexinit(void)
case TPTR32:
case TPTR64:
case TINTER:
case TMAP:
case TCHAN:
okforeq[i] = 1;
break;
}
Expand Down Expand Up @@ -1196,8 +1198,6 @@ lexinit(void)
continue;
}
t = typ(etype);
if(etype == TSTRING)
t = ptrto(t);
t->sym = s;

dowidth(t);
Expand Down

0 comments on commit a91af04

Please sign in to comment.