scc

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

commit a358fdfe767eae0b94100246316faf62d354cc43
parent 8eac854cc7c847897fdab85d0173178dbcf1ab2e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 11 Nov 2021 16:26:03 +0100

cc2: Simplify tmpnode()

It used to take a parameter to place the temporary node,
but we already saw that it was better to just use dynamic
allocation for them and the parameter didn't make sense
anymore.

Diffstat:
Msrc/cmd/cc/cc2/cc2.h | 2+-
Msrc/cmd/cc/cc2/code.c | 6+++---
Msrc/cmd/cc/cc2/target/qbe/cgen.c | 16++++++++--------
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/cmd/cc/cc2/cc2.h b/src/cmd/cc/cc2/cc2.h @@ -231,7 +231,7 @@ extern void defvar(Symbol *), defpar(Symbol *), defglobal(Symbol *); extern void setlabel(Symbol *sym), getbblocks(void); extern Node *label2node(Node *np, Symbol *sym); extern Node *constnode(Node *np, TUINT n, Type *tp); -extern Node *tmpnode(Node *, Type *); +extern Node *tmpnode(Type *); extern Symbol *newlabel(void); extern void pprint(char *s); diff --git a/src/cmd/cc/cc2/code.c b/src/cmd/cc/cc2/code.c @@ -135,13 +135,13 @@ label2node(Node *np, Symbol *sym) } Node * -tmpnode(Node *np, Type *tp) +tmpnode(Type *tp) { char flags; Symbol *sym; + Node *np; - if (!np) - np = node(OTMP); + np = node(OTMP); sym = getsym(TMPSYM); sym->type = np->type = *tp; flags = tp->flags & ~(PARF|INITF); diff --git a/src/cmd/cc/cc2/target/qbe/cgen.c b/src/cmd/cc/cc2/target/qbe/cgen.c @@ -196,7 +196,7 @@ load(Type *tp, Node *np) if ((flags & (INTF|SIGNF)) == INTF && tp->size < 8) ++op; - new = tmpnode(NULL, tp); + new = tmpnode(tp); code(op, new, np, NULL); return new; @@ -273,7 +273,7 @@ cast(Type *td, Node *np) op = (td->size == 4) ? ASEXTS : ASTRUNCD; } - tmp = tmpnode(NULL, td); + tmp = tmpnode(td); code(op, tmp, np, NULL); return tmp; @@ -290,12 +290,12 @@ call(Node *np, Node *fun) pars[n++] = rhs(p->left); tp = &np->type; - tmp = tmpnode(NULL, tp); + tmp = tmpnode(tp); code(ASCALL, tmp, fun, NULL); for (q = pars; q < &pars[n]; ++q) { op = (q == &pars[n-1]) ? ASPARE : ASPAR; - code(op, NULL, *q, tmpnode(NULL, &(*q)->type)); + code(op, NULL, *q, tmpnode(&(*q)->type)); } code((np->op == OCALL) ? ASCALLE : ASCALLEX, NULL, NULL, NULL); @@ -401,7 +401,7 @@ ternary(Node *np) { Node ifyes, ifno, phi, *colon, *tmp; - tmp = tmpnode(NULL, &np->type); + tmp = tmpnode(&np->type); label2node(&ifyes, NULL); label2node(&ifno, NULL); label2node(&phi, NULL); @@ -587,7 +587,7 @@ rhs(Node *np) true = newlabel(); false = newlabel(); phi = label2node(&aux1, NULL); - tmp = tmpnode(NULL, &int32type); + tmp = tmpnode(&int32type); bool(np, true, false); @@ -645,7 +645,7 @@ rhs(Node *np) abort(); } op = tbl[np->op] + off; - tmp = tmpnode(NULL, tp); + tmp = tmpnode(tp); code(op, tmp, l, r); return tmp; case OCALL: @@ -680,7 +680,7 @@ rhs(Node *np) return NULL; case BVA_ARG: l = rhs(l); - tmp = tmpnode(NULL, tp); + tmp = tmpnode(tp); code(ASVARG, tmp, l, NULL); return tmp; case BVA_COPY: