scc

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

commit 30f27528f11cb62062805ee9d854c1011d0933cd
parent 13ce3ce2a3c0bd19452d9bdbe9669a62382a44a0
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Sun,  8 May 2016 20:12:18 +0200

[cc2-qbe] Emit abbrev statements

Abbrev statements are the combination of a assignation
and some other operator, and they don't have special
meaning in QBE. They must be expanded.

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

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -231,6 +231,20 @@ cast(Node *nd) return nd; } +static Node * +abbrev(Node *np) +{ + Node *tmp; + + if (np->u.subop == 0) + return np->right; + tmp = newnode(np->u.subop); + tmp->type = np->type; + tmp->right = np->right; + tmp->left = np->left; + return np->right = cgen(tmp); +} + Node * cgen(Node *np) { @@ -317,6 +331,7 @@ cgen(Node *np) case ODEC: abort(); case OASSIG: + r = abbrev(np); switch (tp->size) { case 1: op = ASSTB;