[hackers] [scc/qbe] [cc2-qbe] Add type parameter to tmpnode() || Roberto E. Vargas Caballero
commit 78f9181916841fb978bf13efb3df7f44eccda367
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Aug 17 10:12:38 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Aug 17 13:35:53 2016 +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.
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index f133ea4..6db1123 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -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;
_AT_@ -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:
_AT_@ -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);
_AT_@ -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:
Received on Wed Aug 17 2016 - 14:29:49 CEST
This archive was generated by hypermail 2.3.0
: Wed Aug 17 2016 - 14:36:28 CEST