From 79d669bb8941b0d8639a95378d449d8459244929 Mon Sep 17 00:00:00 2001 From: koba-e964 <3303362+koba-e964@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:47:34 +0900 Subject: [PATCH] We don't support too many arguments --- src/arm64/asm.rs | 2 +- src/arm64/reg_alloc.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/arm64/asm.rs b/src/arm64/asm.rs index 51b1e16..db56186 100644 --- a/src/arm64/asm.rs +++ b/src/arm64/asm.rs @@ -249,7 +249,7 @@ pub fn seq(id_gen: &mut id::IdGen, e1: Exp, e2: Asm) -> Asm { } pub fn regs() -> Vec { - let mut res = vec!["".to_string(); 4]; + let mut res = vec!["".to_string(); 30]; for (i, item) in res.iter_mut().enumerate() { *item = format!("$x{i}"); } diff --git a/src/arm64/reg_alloc.rs b/src/arm64/reg_alloc.rs index 29d22d6..104c80c 100644 --- a/src/arm64/reg_alloc.rs +++ b/src/arm64/reg_alloc.rs @@ -378,6 +378,7 @@ fn target_exp(src: &str, dest_t: &(String, Type), exp: &Exp) -> (bool, Vec Vec { let mut ans = vec![]; + // We don't support too many arguments for a function call. assert!(ys.len() < all.len()); for i in 0..ys.len() { if ys[i] == src { @@ -390,7 +391,7 @@ fn target_args(src: &str, all: &[String], ys: &[String]) -> Vec { /// The author hasn't understood the meaning of this function. /// TODO understand this /// "register sourcing" (?) as opposed to register targeting -/// (arm64の2オペランド命令のためのregister coalescing) *) TODO +/// (arm64の2オペランド命令のためのregister coalescing) *) fn source(t: &Type, asm: &Asm) -> Vec { match asm { Asm::Ans(ref exp) => source_exp(t, exp), @@ -474,7 +475,7 @@ fn add(x: String, reg: String, mut regenv: RegEnv) -> RegEnv { regenv } -// Decide to allocate a register or spill. +/// Decides to allocate a register or spill. fn alloc(cont: Asm, regenv: &RegEnv, x: String, t: Type, preference: &[String]) -> AllocResult { assert!(!regenv.contains_key(&x)); let all = match t {