1
0
mirror of https://github.com/golang/go synced 2024-11-22 12:34:48 -07:00

floating point

SVN=121607
This commit is contained in:
Ken Thompson 2008-06-08 16:11:14 -07:00
parent 8200a0b088
commit 36bfd2a906
2 changed files with 28 additions and 40 deletions

View File

@ -14,7 +14,7 @@ cgen(Node *n, Node *res)
Prog *p1, *p2, *p3; Prog *p1, *p2, *p3;
if(debug['g']) { if(debug['g']) {
dump("\ncgen-l", res); dump("\ncgen-res", res);
dump("cgen-r", n); dump("cgen-r", n);
} }
if(n == N || n->type == T) if(n == N || n->type == T)
@ -441,9 +441,9 @@ void
bgen(Node *n, int true, Prog *to) bgen(Node *n, int true, Prog *to)
{ {
long lno; long lno;
int et, a, b; int et, a;
Node *nl, *nr, *r; Node *nl, *nr, *r;
Node n1, n2, tmp; Node n1, n2;
Prog *p1, *p2; Prog *p1, *p2;
if(n == N) if(n == N)
@ -560,48 +560,17 @@ bgen(Node *n, int true, Prog *to)
} }
a = optoas(a, nr->type); a = optoas(a, nr->type);
if(nr->addable) {
regalloc(&n1, nl->type, N); regalloc(&n1, nl->type, N);
cgen(nl, &n1); cgen(nl, &n1);
b = optoas(OCMP, nr->type);
switch(b) {
case ACMPQ:
if(nr->op == OLITERAL)
if(nr->val.vval >= (1LL<<32))
goto dolit;
case AUCOMISS:
if(nr->op == OLITERAL)
goto dolit;
if(nr->op == ONAME)
goto dolit;
}
gins(b, &n1, nr);
patch(gbranch(a, nr->type), to);
regfree(&n1);
break;
dolit:
regalloc(&n2, nr->type, N); regalloc(&n2, nr->type, N);
cgen(nr, &n2); cgen(nr, &n2);
gins(b, &n1, &n2);
gins(optoas(OCMP, nr->type), &n1, &n2);
patch(gbranch(a, nr->type), to); patch(gbranch(a, nr->type), to);
regfree(&n1);
regfree(&n2); regfree(&n2);
regfree(&n1);
break;
}
tempname(&tmp, nr->type);
cgen(nr, &tmp);
regalloc(&n1, nl->type, N);
cgen(nl, &n1);
gins(optoas(OCMP, nr->type), &n1, &tmp);
patch(gbranch(a, nr->type), to);
regfree(&n1);
break; break;
} }
goto ret; goto ret;

View File

@ -1058,16 +1058,32 @@ arg_type_list_r:
$$ = nod(OLIST, $1, $3); $$ = nod(OLIST, $1, $3);
} }
/*
* need semi in front NO
* need semi in back NO
*/
Astmt: Astmt:
complex_stmt complex_stmt
| compound_stmt
/*
* need semi in front NO
* need semi in back YES
*/
Bstmt: Bstmt:
semi_stmt semi_stmt
| common_dcl | common_dcl
/*
* need semi in front YES
* need semi in back YES
*/
Cstmt: Cstmt:
simple_stmt simple_stmt
/*
* statement list that need semi in back NO
*/
Astmt_list_r: Astmt_list_r:
Astmt Astmt
| Astmt_list_r Astmt | Astmt_list_r Astmt
@ -1081,6 +1097,9 @@ Astmt_list_r:
$$ = N; $$ = N;
} }
/*
* statement list that need semi in back YES
*/
Bstmt_list_r: Bstmt_list_r:
Bstmt Bstmt
| Cstmt | Cstmt