shithub: scc

Download patch

ref: c4db51782e98cba3cd7b4203447db47dca8fa398
parent: 14390f9b8e3ae2871b6243adcddbdd3ea01eaf4f
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Feb 16 10:14:21 EST 2015

Convert code in a wrapper function

code was written only to be sure that the logic in the code generator
was correct, but we can move now to a better base for the code generator,
so we want to store in memory the assembler instruction in an internal
format, and then we will be able to optimize this output later.

--- a/cc2/code.c
+++ b/cc2/code.c
@@ -39,27 +39,4 @@
 void
 code(char op, ...)
 {
-	va_list va;
-	char *cp, c;
-
-	va_start(va, op);
-	for (cp = opfmt[op]; c = *cp; ++cp) {
-		switch (c) {
-		case 'o':
-			fputs(opnames[op], stdout);
-			break;
-		case 'r':
-			fputs(regnames[va_arg(va, int)], stdout);
-			break;
-		case 'i':
-			printf("%d", va_arg(va, int));
-			break;
-		default:
-			putchar(c);
-			break;
-		}
-	}
-	putchar('\n');
-
-	va_end(va);
 }