summary refs log tree commit diff
path: root/amd64
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-03-14 23:10:39 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-03-14 23:14:48 +0100
commitc5769f62b4912e429a332c9aa0bead3a383fe966 (patch)
tree4a10efe9455184ce71bd7e4a8a7429c327ba66e8 /amd64
parent329a18a30b9f8db598db39b7326fc4149bcc1431 (diff)
downloadroux-c5769f62b4912e429a332c9aa0bead3a383fe966.tar.gz
dynamic stack allocs for arm64
I also moved some isel logic
that would have been repeated
a third time in util.c.
Diffstat (limited to 'amd64')
-rw-r--r--amd64/isel.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index 4181e26..9dffd06 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -203,7 +203,6 @@ sel(Ins i, ANum *an, Fn *fn)
 {
 	Ref r0, r1, tmp[7];
 	int x, j, k, kc, sh, swap;
-	int64_t sz;
 	Ins *i0, *i1;
 
 	if (rtype(i.to) == RTmp)
@@ -375,31 +374,10 @@ Emit:
 		fixarg(&i1->arg[0], argcls(&i, 0), i1, fn);
 		fixarg(&i1->arg[1], argcls(&i, 1), i1, fn);
 		break;
-	case Oalloc:
-	case Oalloc+1:
-	case Oalloc+2: /* == Oalloc1 */
-		/* we need to make sure
-		 * the stack remains aligned
-		 * (rsp = 0) mod 16
-		 */
-		fn->dynalloc = 1;
-		if (rtype(i.arg[0]) == RCon) {
-			sz = fn->con[i.arg[0].val].bits.i;
-			if (sz < 0 || sz >= INT_MAX-15)
-				err("invalid alloc size %"PRId64, sz);
-			sz = (sz + 15)  & -16;
-			emit(Osalloc, Kl, i.to, getcon(sz, fn), R);
-		} else {
-			/* r0 = (i.arg[0] + 15) & -16 */
-			r0 = newtmp("isel", Kl, fn);
-			r1 = newtmp("isel", Kl, fn);
-			emit(Osalloc, Kl, i.to, r0, R);
-			emit(Oand, Kl, r0, r1, getcon(-16, fn));
-			emit(Oadd, Kl, r1, i.arg[0], getcon(15, fn));
-			if (fn->tmp[i.arg[0].val].slot != -1)
-				err("unlikely argument %%%s in %s",
-					fn->tmp[i.arg[0].val].name, optab[i.op].name);
-		}
+	case Oalloc4:
+	case Oalloc8:
+	case Oalloc16:
+		salloc(i.to, i.arg[0], fn);
 		break;
 	default:
 		if (isext(i.op))