summaryrefslogtreecommitdiff
path: root/utils/cc/pgen.c
diff options
context:
space:
mode:
authorforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
committerforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
commit45a20ab721a513710138340faff3d59a31c3e01e (patch)
treeeea29d2684c51cc73725b8992a2125bede48e118 /utils/cc/pgen.c
parentcd8e99851af33e52bcdf8faf34f9d4e62fa0cbaf (diff)
sync compilers with Plan 9
remove 1[acl] 2[acl]
Diffstat (limited to 'utils/cc/pgen.c')
-rw-r--r--utils/cc/pgen.c70
1 files changed, 57 insertions, 13 deletions
diff --git a/utils/cc/pgen.c b/utils/cc/pgen.c
index 131ff012..a5f67df2 100644
--- a/utils/cc/pgen.c
+++ b/utils/cc/pgen.c
@@ -70,8 +70,12 @@ codgen(Node *n, Node *nn)
canreach = 1;
warnreach = 1;
gen(n);
- if(canreach && thisfn->link->etype != TVOID)
- warn(Z, "no return at end of function: %s", n1->sym->name);
+ if(canreach && thisfn->link->etype != TVOID){
+ if(debug['B'])
+ warn(Z, "no return at end of function: %s", n1->sym->name);
+ else
+ diag(Z, "no return at end of function: %s", n1->sym->name);
+ }
noretval(3);
gbranch(ORETURN);
@@ -105,10 +109,20 @@ supgen(Node *n)
warnreach = owarn;
}
+Node*
+uncomma(Node *n)
+{
+ while(n != Z && n->op == OCOMMA) {
+ cgen(n->left, Z);
+ n = n->right;
+ }
+ return n;
+}
+
void
gen(Node *n)
{
- Node *l, nod;
+ Node *l, nod, rn;
Prog *sp, *spc, *spb;
Case *cn;
long sbc, scc;
@@ -129,6 +143,7 @@ loop:
case OLABEL:
case OCASE:
case OLIST:
+ case OCOMMA:
case OBREAK:
case OFOR:
case OWHILE:
@@ -151,6 +166,7 @@ loop:
break;
case OLIST:
+ case OCOMMA:
gen(n->left);
rloop:
@@ -163,7 +179,7 @@ loop:
complex(n);
if(n->type == T)
break;
- l = n->left;
+ l = uncomma(n->left);
if(l == Z) {
noretval(3);
gbranch(ORETURN);
@@ -181,6 +197,20 @@ loop:
gbranch(ORETURN);
break;
}
+ if(newvlongcode && !typefd[n->type->etype]){
+ regret(&rn, n);
+ regfree(&rn);
+ nod = znode;
+ nod.op = OAS;
+ nod.left = &rn;
+ nod.right = l;
+ nod.type = n->type;
+ nod.complex = l->complex;
+ cgen(&nod, Z);
+ noretval(2);
+ gbranch(ORETURN);
+ break;
+ }
regret(&nod, n);
cgen(l, &nod);
regfree(&nod);
@@ -241,16 +271,15 @@ loop:
complex(l);
if(l->type == T)
goto rloop;
- if(l->op == OCONST)
- if(typeword[l->type->etype] && l->type->etype != TIND) {
- casf();
- cases->val = l->vconst;
- cases->def = 0;
- cases->label = pc;
- cases->isv = typev[l->type->etype];
+ if(l->op != OCONST || !typeswitch[l->type->etype]) {
+ diag(n, "case expression must be integer constant");
goto rloop;
}
- diag(n, "case expression must be integer constant");
+ casf();
+ cases->val = l->vconst;
+ cases->def = 0;
+ cases->label = pc;
+ cases->isv = typev[l->type->etype];
goto rloop;
case OSWITCH:
@@ -258,7 +287,7 @@ loop:
complex(l);
if(l->type == T)
break;
- if(!typeword[l->type->etype] || l->type->etype == TIND) {
+ if(!typeswitch[l->type->etype]) {
diag(n, "switch expression must be integer");
break;
}
@@ -531,6 +560,8 @@ usedset(Node *n, int o)
int
bcomplex(Node *n, Node *c)
{
+ Node *b, nod;
+
complex(n);
if(n->type != T)
@@ -542,6 +573,19 @@ bcomplex(Node *n, Node *c)
}
if(c != Z && n->op == OCONST && deadheads(c))
return 1;
+ if(newvlongcode && typev[n->type->etype] && machcap(Z)) {
+ nod = znode;
+ b = &nod;
+ b->op = ONE;
+ b->left = n;
+ b->right = new(0, Z, Z);
+ *b->right = *nodconst(0);
+ b->right->type = n->type;
+ b->type = types[TLONG];
+ xcom(b);
+ boolgen(b, 1, Z);
+ return 0;
+ }
bool64(n);
boolgen(n, 1, Z);
return 0;