瀏覽代碼

* generate correct entry code on mips for subroutines with a stack frame >2^15-1

git-svn-id: trunk@21238 -
florian 13 年之前
父節點
當前提交
edbb826521
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      compiler/mips/cgcpu.pas

+ 7 - 1
compiler/mips/cgcpu.pas

@@ -1418,7 +1418,13 @@ begin
   list.concat(Taicpu.op_none(A_P_SET_NOREORDER));
   list.concat(Taicpu.op_none(A_P_SET_NOREORDER));
   list.concat(Taicpu.op_none(A_P_SET_NOMACRO));
   list.concat(Taicpu.op_none(A_P_SET_NOMACRO));
 
 
-  list.concat(Taicpu.Op_reg_reg_const(A_ADDIU,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,-LocalSize));
+  if (-LocalSize >= simm16lo) and (-LocalSize <= simm16hi) then
+    list.concat(Taicpu.Op_reg_reg_const(A_ADDIU,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,-LocalSize))
+  else
+    begin
+      list.concat(Taicpu.Op_reg_const(A_LI,NR_R3,-LocalSize));
+      list.concat(Taicpu.Op_reg_reg_reg(A_ADD,NR_STACK_POINTER_REG,NR_STACK_POINTER_REG,NR_R3));
+    end;
 
 
   if (cs_create_pic in current_settings.moduleswitches) and
   if (cs_create_pic in current_settings.moduleswitches) and
     (pi_needs_got in current_procinfo.flags) then
     (pi_needs_got in current_procinfo.flags) then