ref: 4c09eaec1c1f81e175b6e8b6266e8a2c9aa7afaa
parent: ebe3dbb901f3c769622378f067ce41a8b3d7e6e5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Dec 17 05:03:08 EST 2017
[as-z80] Unfify all the register class cases These cases can be unified in only one clase using a function pointer.
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -57,6 +57,7 @@
unsigned char *p;
int arg;
Node *np;
+ int (*class)(int);
if (!op->args)
return args == NULL;
@@ -83,27 +84,20 @@
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: