shithub: scc

Download patch

ref: 8a564b2ea4084f554f6ac18034c8fe7fce65966e
parent: 3b779b98d1cbcf4e2803970c72927306f5e02603
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Nov 3 04:40:36 EDT 2021

cc2/qbe: Add support for register parameters

--- a/src/cmd/cc/cc1/decl.c
+++ b/src/cmd/cc/cc1/decl.c
@@ -486,6 +486,7 @@
 	switch (yytoken) {
 	case '{':
 	case TYPE:
+	case SCLASS:
 	case TYPEIDEN:
 		if (curctx != PARAMCTX)
 			errorp("nested function declaration");
--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -318,6 +318,7 @@
 lhs(Node *np, Node *new)
 {
 	switch (np->op) {
+	case OREG:
 	case OMEM:
 	case OAUTO:
 		*new = *np;
@@ -477,6 +478,7 @@
 		*ret = *np;
 		return np;
 	case OMEM:
+	case OREG:
 	case OAUTO:
 		return load(tp, np, ret);
 	case ONEG:
--- a/src/cmd/cc/cc2/target/qbe/code.c
+++ b/src/cmd/cc/cc2/target/qbe/code.c
@@ -294,6 +294,8 @@
 void
 defpar(Symbol *sym)
 {
+	if (sym->kind == SREG)
+		sym->kind = SAUTO;
 	sym->type.flags |= PARF;
 }