From 5dbc5dc2c9816821db6e7f1a2903c54a7d549efd Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Thu, 25 Mar 2021 13:51:25 -0700
Subject: [PATCH] arm64: handle copy of constant to slot

If registers spill onto the stack, we may end up with SSA like

	S320 =l copy 0

after rega(). Handle this case in arm64 emit().
---
 arm64/emit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arm64/emit.c b/arm64/emit.c
index f48dbee..eda1079 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -308,9 +308,15 @@ emitins(Ins *i, E *e)
 		if (req(i->to, i->arg[0]))
 			break;
 		if (rtype(i->to) == RSlot) {
-			if (rtype(i->arg[0]) == RSlot) {
+			switch (rtype(i->arg[0])) {
+			case RSlot:
 				emitf("ldr %?, %M0\n\tstr %?, %M=", i, e);
-			} else {
+				break;
+			case RCon:
+				loadcon(&e->fn->con[i->arg[0].val], R18, i->cls, e->f);
+				emitf("str %?, %M=", i, e);
+				break;
+			default:
 				assert(isreg(i->arg[0]));
 				emitf("str %0, %M=", i, e);
 			}