scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 78f9181916841fb978bf13efb3df7f44eccda367
parent 3fa1dbda75aaf02f90d66c9a5261001838a0d2a5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 17 Aug 2016 10:12:38 +0200

[cc2-qbe] Add type parameter to tmpnode()

It is a common operation to create a new temporary node
and assign it the type after the creation, so the best place
for doing this operation is in tmpnode() itself.

Diffstat:
Mcc2/arch/qbe/cgen.c | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -93,12 +93,12 @@ static char opasmd[] = { extern Type int32type; static Node * -tmpnode(Node *np) +tmpnode(Node *np, Type *tp) { Symbol *sym; sym = getsym(TMPSYM); - sym->type = np->type; + sym->type = np->type = *tp; sym->kind = STMP; np->u.sym = sym; np->op = OTMP; @@ -113,8 +113,7 @@ load(Node *np, Node *new) Type *tp; tp = &np->type; - new->type = *tp; - tmpnode(new); + tmpnode(new, tp); switch (tp->size) { case 1: @@ -264,8 +263,7 @@ rhs(Node *np, Node *ret) true = newlabel(); false = newlabel(); phi = label2node(newlabel()); - ret->type = int32type; - tmpnode(ret); + tmpnode(ret, &int32type); bool(np, true, false); @@ -321,7 +319,7 @@ rhs(Node *np, Node *ret) abort(); } op = tbl[np->op] + off; - ret = tmpnode(ret); + tmpnode(ret, tp); code(op, ret, &aux1, &aux2); return ret; case OASSIG: