From 57f6b41047e95374701ee276248f0f8615168450 Mon Sep 17 00:00:00 2001
From: Kimplul <kimi.h.kuparinen@gmail.com>
Date: Thu, 13 Mar 2025 19:20:56 +0200
Subject: improve register allocation

+ Still linear, but orders regs by some kind of priority
+ Use all registers available, not just callee-save
---
 examples/matrix_mult.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'examples')

diff --git a/examples/matrix_mult.c b/examples/matrix_mult.c
index 04ebb9d..fab2319 100644
--- a/examples/matrix_mult.c
+++ b/examples/matrix_mult.c
@@ -63,7 +63,7 @@ static struct ejit_func *compile()
 	struct ejit_reloc inner = ejit_bgei(f, KR, X);
 
 	/* A[i][k] at addr 4 * (i * 400 + k) */
-	ejit_movi(f, TMP, 400);
+	ejit_movi(f, TMP, X);
 	ejit_mulr(f, AX, IR, TMP);
 	ejit_addr(f, AX, AX, KR);
 	ejit_movi(f, TMP, 4);
@@ -71,7 +71,7 @@ static struct ejit_func *compile()
 	EJIT_LDXR(f, int, AX, AR, AX);
 
 	/* B[k][j] at addr 4 * (k * 400 + j) */
-	ejit_movi(f, TMP, 400);
+	ejit_movi(f, TMP, X);
 	ejit_mulr(f, BX, KR, TMP);
 	ejit_addr(f, BX, BX, JR);
 	ejit_movi(f, TMP, 4);
@@ -79,7 +79,7 @@ static struct ejit_func *compile()
 	EJIT_LDXR(f, int, BX, BR, BX);
 
 	/* C[i][j] at addr 4 * (i * 400 + j) */
-	ejit_movi(f, TMP, 400);
+	ejit_movi(f, TMP, X);
 	ejit_mulr(f, CX, IR, TMP);
 	ejit_addr(f, CX, CX, JR);
 	ejit_movi(f, TMP, 4);
-- 
cgit v1.2.3