scc

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

commit 386c2e594104b251c60ba48d200902628cbadc39
parent 1f60dda2c451783a43a2ead554b4792ee6c9ee92
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 17 Dec 2017 10:03:08 +0100

[as-z80] Unfify all the register class cases

These cases can be unified in only one clase using a function
pointer.

Diffstat:
Mas/target/z80/proc.c | 26++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -57,6 +57,7 @@ match(Op *op, Node **args) unsigned char *p; int arg; Node *np; + int (*class)(int); if (!op->args) return args == NULL; @@ -83,27 +84,20 @@ match(Op *op, Node **args) return 0; break; case AREG_RCLASS: - if (np->addr != AREG) - return 0; - if (!rclass(np->sym->argtype)) - return 0; - break; + class = rclass; + goto register_class; case AREG_PCLASS: - if (np->addr != AREG) - return 0; - if (!pclass(np->sym->argtype)) - return 0; - break; + class = pclass; + goto register_class; case AREG_QCLASS: - if (np->addr != AREG) - return 0; - if (!qclass(np->sym->argtype)) - return 0; - break; + class = qclass; + goto register_class; case AREG_DDCLASS: + class = ddclass; + register_class: if (np->addr != AREG) return 0; - if (!ddclass(np->sym->argtype)) + if (!(*class)(np->sym->argtype)) return 0; break; case AIMM8: