summary refs log tree commit diff
path: root/amd64/sysv.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2017-04-11 09:51:35 -0400
committerQuentin Carbonneaux <quentin@c9x.me>2017-04-11 09:57:13 -0400
commit669d8086ae0cd939f8016ad495389a19f6ba8c8f (patch)
tree2a2051bf9f06f308739e11db0114d78dadbd40e9 /amd64/sysv.c
parentdc4cc4969749940f55f36814b95d70c6c1da4d15 (diff)
downloadroux-669d8086ae0cd939f8016ad495389a19f6ba8c8f.tar.gz
simplify amd64 aggregates classification
Diffstat (limited to 'amd64/sysv.c')
-rw-r--r--amd64/sysv.c74
1 files changed, 34 insertions, 40 deletions
diff --git a/amd64/sysv.c b/amd64/sysv.c
index ea81eee..014452a 100644
--- a/amd64/sysv.c
+++ b/amd64/sysv.c
@@ -17,51 +17,47 @@ struct RAlloc {
 };
 
 static void
-classify(AClass *a, Typ *t, int *pn, int *pe)
+classify(AClass *a, Typ *t, uint s)
 {
-	Field *fld;
-	int s, *cls;
-	uint n;
-
-	for (n=0; n<t->nunion; n++) {
-		fld = t->fields[n];
-		for (s=0; *pe<2; (*pe)++) {
-			cls = &a->cls[*pe];
-			for (; *pn<8; s++) {
-				switch (fld[s].type) {
-				case FEnd:
-					goto Done;
-				case FPad:
-					/* don't change anything */
-					break;
-				case Fs:
-				case Fd:
-					if (*cls == Kx)
-						*cls = Kd;
-					break;
-				case Fb:
-				case Fh:
-				case Fw:
-				case Fl:
-					*cls = Kl;
-					break;
-				case FTyp:
-					classify(a, &typ[fld[s].len], pn, pe);
-					continue;
-				}
-				*pn += fld[s].len;
+	Field *f;
+	int *cls;
+	uint n, s1;
+
+	for (n=0, s1=s; n<t->nunion; n++, s=s1)
+		for (f=t->fields[n]; f->type!=FEnd; f++) {
+			assert(s <= 16);
+			cls = &a->cls[s/8];
+			switch (f->type) {
+			case FEnd:
+				die("unreachable");
+			case FPad:
+				/* don't change anything */
+				s += f->len;
+				break;
+			case Fs:
+			case Fd:
+				if (*cls == Kx)
+					*cls = Kd;
+				s += f->len;
+				break;
+			case Fb:
+			case Fh:
+			case Fw:
+			case Fl:
+				*cls = Kl;
+				s += f->len;
+				break;
+			case FTyp:
+				classify(a, &typ[f->len], s);
+				s += typ[f->len].size;
+				break;
 			}
-		Done:
-			assert(*pn <= 8);
-			*pn = 0;
 		}
-	}
 }
 
 static void
 typclass(AClass *a, Typ *t)
 {
-	int e, n;
 	uint sz, al;
 
 	sz = t->size;
@@ -90,9 +86,7 @@ typclass(AClass *a, Typ *t)
 	a->cls[0] = Kx;
 	a->cls[1] = Kx;
 	a->inmem = 0;
-	n = 0;
-	e = 0;
-	classify(a, t, &n, &e);
+	classify(a, t, 0);
 }
 
 static int