shithub: scc

Download patch

ref: 8db36cf9b7f61d5dcd4af5324a1cc1c68dc7ed30
parent: bbef0f7405b510a0913d209bf77f647280d9184a
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Dec 29 09:28:36 EST 2017

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

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

--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -24,7 +24,6 @@
 	case AREG_H:
 	case AREG_L:
 		return RCLASS;
-		break;
 	case AREG_IXL:
 	case AREG_IXH:
 		return PCLASS;
@@ -33,19 +32,15 @@
 		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:
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -75,7 +75,6 @@
 			--p;
 		if ((np = *args++) == NULL)
 			return (arg & (AREP|AOPT)) != 0;
-		class = getclass(np);
 
 		arg &= ~(AREP|AOPT);
 		switch (arg) {
@@ -119,35 +118,30 @@
 				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: