From e248d72f5ca07c889fcfa90640d3d647acc63bee Mon Sep 17 00:00:00 2001 From: mxr <> Date: Wed, 15 Apr 2026 12:34:38 +0800 Subject: [PATCH] =?UTF-8?q?(mir)=E4=BF=AE=E5=A4=8D=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=98=AF=E6=8C=87=E9=92=88=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir/Lowering.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mir/Lowering.cpp b/src/mir/Lowering.cpp index a509514..cfb6285 100644 --- a/src/mir/Lowering.cpp +++ b/src/mir/Lowering.cpp @@ -590,8 +590,11 @@ void LowerInstruction(const ir::Instruction& inst, MachineFunction& function, EmitValueToReg(arg, reg, slots, block, function); fpArgCount++; } else { - // 整数参数 - PhysReg reg = static_cast(static_cast(PhysReg::W0) + intArgCount); + // 区分指针与普通整数:指针使用 64 位 Xn 寄存器 + bool isPointer = argType->IsPtrInt32() || argType->IsPtrFloat() || argType->IsPtrInt1() || + argType->IsArray(); // 数组在作为函数参数时会退化为指针 + PhysReg baseReg = isPointer ? PhysReg::X0 : PhysReg::W0; + PhysReg reg = static_cast(static_cast(baseReg) + intArgCount); EmitValueToReg(arg, reg, slots, block, function); intArgCount++; }