ref: 2a064a18aa7bf944926109070f6f9eb60e361cf6
parent: caf73a3a056f46b507e7cfdf7af5102597777ac2
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 17 06:12:38 EDT 2016
[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.
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -93,12 +93,12 @@
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 @@
Type *tp;
tp = &np->type;
- new->type = *tp;
- tmpnode(new);
+ tmpnode(new, tp);
switch (tp->size) {
case 1:
@@ -264,8 +263,7 @@
true = newlabel();
false = newlabel();
phi = label2node(newlabel());
- ret->type = int32type;
- tmpnode(ret);
+ tmpnode(ret, &int32type);
bool(np, true, false);
@@ -321,7 +319,7 @@
abort();
}
op = tbl[np->op] + off;
- ret = tmpnode(ret);
+ tmpnode(ret, tp);
code(op, ret, &aux1, &aux2);
return ret;
case OASSIG: