Commit 610644a1 authored by Ken Thompson's avatar Ken Thompson

asdf

SVN=121615
parent e285ed60
...@@ -127,62 +127,6 @@ cgen(Node *n, Node *res) ...@@ -127,62 +127,6 @@ cgen(Node *n, Node *res)
regfree(&n1); regfree(&n1);
break; break;
// case OINDEXPTRSTR:
// nl = n->left;
// nr = n->right;
// if(nl->addable) {
// cgen(nr);
// cgen(nl);
// gopcode(P_LOADI, T_ADDR, N);
// gopcodet(P_INDEXZ, nr->type, N);
// break;
// }
// break;
// case OINDEXSTR:
// nl = n->left;
// nr = n->right;
// if(nl->addable) {
// cgen(nr);
// gopcodet(P_INDEXZ, nr->type, nl);
// break;
// }
// cgen(nl);
// r = tempname(nl->type);
// gopcodet(P_STORE, nl->type, r);
// cgen(nr);
// gopcodet(P_INDEXZ, nr->type, r);
// break;
// case OSLICESTR:
// case OSLICEPTRSTR:
// nl = n->left; // name
// nr = n->right;
//
// r = nr->right; // index2
// if(!r->addable) {
// cgen(r);
// r = tempname(r->type);
// gopcodet(P_STORE, r->type, r);
// }
//
// // string into T_ADDR
// if(!nl->addable) {
// cgen(nl);
// gconv(T_ADDR, nl->type->etype);
// } else
// gopcode(P_LOAD, T_ADDR, nl);
//
// if(n->op == OSLICEPTRSTR)
// gopcode(P_LOADI, T_ADDR, N);
//
// // offset in int reg
// cgen(nr->left);
//
// // index 2 addressed
// gopcodet(P_SLICE, r->type, r);
// break;
case OS2I: case OS2I:
case OI2I: case OI2I:
case OI2S: case OI2S:
...@@ -210,11 +154,6 @@ cgen(Node *n, Node *res) ...@@ -210,11 +154,6 @@ cgen(Node *n, Node *res)
fatal("cgen: OLEN: unknown type %lT", nl->type); fatal("cgen: OLEN: unknown type %lT", nl->type);
break; break;
// case ODOTMETH:
// case ODOTINTER:
// cgen(n->left);
// break;
case OADDR: case OADDR:
agen(nl, res); agen(nl, res);
break; break;
...@@ -238,6 +177,7 @@ cgen(Node *n, Node *res) ...@@ -238,6 +177,7 @@ cgen(Node *n, Node *res)
case ODIV: case ODIV:
cgen_div(n->op, nl, nr, res); cgen_div(n->op, nl, nr, res);
break; break;
case OLSH: case OLSH:
case ORSH: case ORSH:
cgen_shift(n->op, nl, nr, res); cgen_shift(n->op, nl, nr, res);
...@@ -287,7 +227,7 @@ agen(Node *n, Node *res) ...@@ -287,7 +227,7 @@ agen(Node *n, Node *res)
{ {
Node *nl, *nr; Node *nl, *nr;
Node n1, n2, n3, tmp; Node n1, n2, n3, tmp;
ulong w; ulong w, lno;
Type *t; Type *t;
if(n == N || n->type == T) if(n == N || n->type == T)
...@@ -296,14 +236,21 @@ agen(Node *n, Node *res) ...@@ -296,14 +236,21 @@ agen(Node *n, Node *res)
if(!isptr[res->type->etype]) if(!isptr[res->type->etype])
fatal("agen: not tptr: %T", res->type); fatal("agen: not tptr: %T", res->type);
lno = dynlineno;
if(n->op != ONAME)
dynlineno = n->lineno; // for diagnostics
if(n->addable) { if(n->addable) {
regalloc(&n1, types[tptr], res); regalloc(&n1, types[tptr], res);
gins(ALEAQ, n, &n1); gins(ALEAQ, n, &n1);
gmove(&n1, res); gmove(&n1, res);
regfree(&n1); regfree(&n1);
return; goto ret;
} }
nl = n->left;
nr = n->right;
switch(n->op) { switch(n->op) {
default: default:
fatal("agen: unknown op %N", n); fatal("agen: unknown op %N", n);
...@@ -317,8 +264,6 @@ agen(Node *n, Node *res) ...@@ -317,8 +264,6 @@ agen(Node *n, Node *res)
// break; // break;
case OINDEXPTR: case OINDEXPTR:
nl = n->left;
nr = n->right;
w = n->type->width; w = n->type->width;
if(nr->addable) if(nr->addable)
goto iprad; goto iprad;
...@@ -347,8 +292,6 @@ agen(Node *n, Node *res) ...@@ -347,8 +292,6 @@ agen(Node *n, Node *res)
// case OINDREG: // case OINDREG:
case OINDEX: case OINDEX:
nl = n->left;
nr = n->right;
w = n->type->width; w = n->type->width;
if(nr->addable) if(nr->addable)
goto irad; goto irad;
...@@ -395,7 +338,6 @@ agen(Node *n, Node *res) ...@@ -395,7 +338,6 @@ agen(Node *n, Node *res)
// break; // break;
case ODOT: case ODOT:
nl = n->left;
t = nl->type; t = nl->type;
agen(nl, res); agen(nl, res);
if(n->xoffset != 0) { if(n->xoffset != 0) {
...@@ -405,7 +347,6 @@ agen(Node *n, Node *res) ...@@ -405,7 +347,6 @@ agen(Node *n, Node *res)
break; break;
case ODOTPTR: case ODOTPTR:
nl = n->left;
t = nl->type; t = nl->type;
if(!isptr[t->etype]) if(!isptr[t->etype])
fatal("agen: not ptr %N", n); fatal("agen: not ptr %N", n);
...@@ -416,6 +357,9 @@ agen(Node *n, Node *res) ...@@ -416,6 +357,9 @@ agen(Node *n, Node *res)
} }
break; break;
} }
ret:
dynlineno = lno;
} }
vlong vlong
...@@ -443,7 +387,7 @@ bgen(Node *n, int true, Prog *to) ...@@ -443,7 +387,7 @@ bgen(Node *n, int true, Prog *to)
long lno; long lno;
int et, a; int et, a;
Node *nl, *nr, *r; Node *nl, *nr, *r;
Node n1, n2; Node n1, n2, tmp;
Prog *p1, *p2; Prog *p1, *p2;
if(n == N) if(n == N)
...@@ -453,6 +397,9 @@ bgen(Node *n, int true, Prog *to) ...@@ -453,6 +397,9 @@ bgen(Node *n, int true, Prog *to)
if(n->op != ONAME) if(n->op != ONAME)
dynlineno = n->lineno; // for diagnostics dynlineno = n->lineno; // for diagnostics
nl = n->left;
nr = n->right;
if(n->type == T) { if(n->type == T) {
convlit(n, types[TBOOL]); convlit(n, types[TBOOL]);
if(n->type == T) if(n->type == T)
...@@ -558,8 +505,32 @@ bgen(Node *n, int true, Prog *to) ...@@ -558,8 +505,32 @@ bgen(Node *n, int true, Prog *to)
nl = nr; nl = nr;
nr = r; nr = r;
} }
a = optoas(a, nr->type); a = optoas(a, nr->type);
if(nr->ullman >= UINF) {
regalloc(&n1, nr->type, N);
cgen(nr, &n1);
tempname(&tmp, nr->type);
gmove(&n1, &tmp);
regfree(&n1);
regalloc(&n1, nl->type, N);
cgen(nl, &n1);
regalloc(&n2, nr->type, &n2);
cgen(&tmp, &n2);
gins(optoas(OCMP, nr->type), &n1, &n2);
patch(gbranch(a, nr->type), to);
regfree(&n1);
regfree(&n2);
break;
}
regalloc(&n1, nl->type, N); regalloc(&n1, nl->type, N);
cgen(nl, &n1); cgen(nl, &n1);
......
...@@ -1065,6 +1065,10 @@ arg_type_list_r: ...@@ -1065,6 +1065,10 @@ arg_type_list_r:
Astmt: Astmt:
complex_stmt complex_stmt
| compound_stmt | compound_stmt
| ';'
{
$$ = N;
}
/* /*
* need semi in front NO * need semi in front NO
...@@ -1091,11 +1095,6 @@ Astmt_list_r: ...@@ -1091,11 +1095,6 @@ Astmt_list_r:
$$ = nod(OLIST, $1, $2); $$ = nod(OLIST, $1, $2);
} }
| Bstmt_list_r ';' | Bstmt_list_r ';'
| Astmt_list_r ';'
| ';'
{
$$ = N;
}
/* /*
* statement list that need semi in back YES * statement list that need semi in back YES
...@@ -1107,11 +1106,11 @@ Bstmt_list_r: ...@@ -1107,11 +1106,11 @@ Bstmt_list_r:
{ {
$$ = nod(OLIST, $1, $2); $$ = nod(OLIST, $1, $2);
} }
| Astmt_list_r Cstmt | Astmt_list_r Bstmt
{ {
$$ = nod(OLIST, $1, $2); $$ = nod(OLIST, $1, $2);
} }
| Astmt_list_r Bstmt | Astmt_list_r Cstmt
{ {
$$ = nod(OLIST, $1, $2); $$ = nod(OLIST, $1, $2);
} }
......
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