Peter Kuschnerus
2014-03-15 16:53:13 UTC
Hello
After I did work with the source code of pcc for longer periods,
now I am familiar with several parts of it.
If it is accepted, I would like to help at several issues.
But I depend on reviewing help.
For instance in module optim.c,
I did find some optimisations
where a comment tells, being not yet ready
because a subroutine tfree is not save for side effects.
So I wrote a new subroutine for this use:
/* as tfree, but handles side effect */
static void
tfreesav(NODE *p)
{
int op, opt;
op = p->n_op;
if (op == ASSIGN)
/* separate side effect */
ecode(p);
else {
opt = coptype(op);
if (opt == BITYPE)
tfreesav(p->n_right);
if (opt != LTYPE)
tfreesav(p->n_left);
nfree(p);
}
}
I tested this tentatively in module local.c and it seems to work.
But I am not quite shure whether the call of ecode is ok in this place.
If it is ok, some little optimisations in optim.c are possible,
using this new subroutine.
For example:
case MUL:
case AND:
/* check *0, &0 */
if ((RCON(p) && RV(p) == 0) || (LCON(p) && LV(p) == 0)) {
/* result zero */
tfreesav(p);
p = bcon(0);
}
break;
Then I consider some further uses for this subroutine in optim.c.
Regards
Peter Kuschnerus
After I did work with the source code of pcc for longer periods,
now I am familiar with several parts of it.
If it is accepted, I would like to help at several issues.
But I depend on reviewing help.
For instance in module optim.c,
I did find some optimisations
where a comment tells, being not yet ready
because a subroutine tfree is not save for side effects.
So I wrote a new subroutine for this use:
/* as tfree, but handles side effect */
static void
tfreesav(NODE *p)
{
int op, opt;
op = p->n_op;
if (op == ASSIGN)
/* separate side effect */
ecode(p);
else {
opt = coptype(op);
if (opt == BITYPE)
tfreesav(p->n_right);
if (opt != LTYPE)
tfreesav(p->n_left);
nfree(p);
}
}
I tested this tentatively in module local.c and it seems to work.
But I am not quite shure whether the call of ecode is ok in this place.
If it is ok, some little optimisations in optim.c are possible,
using this new subroutine.
For example:
case MUL:
case AND:
/* check *0, &0 */
if ((RCON(p) && RV(p) == 0) || (LCON(p) && LV(p) == 0)) {
/* result zero */
tfreesav(p);
p = bcon(0);
}
break;
Then I consider some further uses for this subroutine in optim.c.
Regards
Peter Kuschnerus