scc

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

commit fdb7271e3c40cf0caa2be373aa23af8295256136
parent 6a23855a90cb151f1be6f88588a02253efb2dc94
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 29 Dec 2017 14:28:36 +0000

[as-z80] Don't call getclass() in every match iteration

We only have to call to getclass when we are matching a class argument.

Diffstat:
Mas/target/x80/ins.c | 5-----
Mas/target/z80/proc.c | 40+++++++++++++++++-----------------------
2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/as/target/x80/ins.c b/as/target/x80/ins.c @@ -24,7 +24,6 @@ getclass(Node *np) case AREG_H: case AREG_L: return RCLASS; - break; case AREG_IXL: case AREG_IXH: return PCLASS; @@ -33,19 +32,15 @@ getclass(Node *np) return QCLASS; case AREG_HL: return DDCLASS | QQCLASS; - break; case AREG_BC: case AREG_DE: return DDCLASS | QQCLASS | PPCLASS | RRCLASS; - break; case AREG_SP: return DDCLASS | PPCLASS | RRCLASS; - break; case AREG_AF: return QQCLASS; case AREG_IX: return PPCLASS; - break; case AREG_IY: return RRCLASS; case AREG_NZ: diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -75,7 +75,6 @@ match(Op *op, Node **args) --p; if ((np = *args++) == NULL) return (arg & (AREP|AOPT)) != 0; - class = getclass(np); arg &= ~(AREP|AOPT); switch (arg) { @@ -119,35 +118,30 @@ match(Op *op, Node **args) return 0; break; case AREG_RCLASS: - if ((class & RCLASS) == 0) - return 0; - break; + class = RCLASS; + goto check_class; case AREG_PCLASS: - if ((class & PCLASS) == 0) - return 0; - break; + class = PCLASS; + goto check_class; case AREG_QCLASS: - if ((class & QCLASS) == 0) - return 0; - break; + class = QCLASS; + goto check_class; case AREG_QQCLASS: - if ((class & QQCLASS) == 0) - return 0; - break; + class = QQCLASS; + goto check_class; case AREG_PPCLASS: - if ((class & PPCLASS) == 0) - return 0; - break; + class = PPCLASS; + goto check_class; case AREG_RRCLASS: - if ((class & RRCLASS) == 0) - return 0; - break; + class = RRCLASS; + goto check_class; case AREG_CCCLASS: - if ((class & CCCLASS) == 0) - return 0; - break; + class = CCCLASS; + goto check_class; case AREG_DDCLASS: - if ((class & DDCLASS) == 0) + class = DDCLASS; + check_class: + if ((getclass(np) & class) == 0) return 0; break; case AINDEX_IY: