浏览代码

* only use r12 as frame pointer in the entry code for ppc if necessary

git-svn-id: trunk@2086 -
Jonas Maebe 19 年之前
父节点
当前提交
c423e23bb4
共有 4 个文件被更改,包括 20 次插入30 次删除
  1. 7 2
      compiler/ncgutil.pas
  2. 2 17
      compiler/powerpc/cgcpu.pas
  3. 6 2
      compiler/powerpc/cpupara.pas
  4. 5 9
      compiler/powerpc/cpupi.pas

+ 7 - 2
compiler/ncgutil.pas

@@ -127,7 +127,11 @@ implementation
     regvars,dwarf,dbgbase,
     pass_1,pass_2,
     ncon,nld,nutils,
-    tgobj,cgobj;
+    tgobj,cgobj
+{$ifdef powerpc}
+    , cpupi
+{$endif}
+;
 
 
 {*****************************************************************************
@@ -1502,7 +1506,8 @@ implementation
 {$ifdef powerpc}
         { unget the register that contains the stack pointer before the procedure entry, }
         { which is used to access the parameters in their original callee-side location  }
-        cg.a_reg_dealloc(list,NR_R12);
+        if (tppcprocinfo(current_procinfo).needs_frame_pointer) then
+          cg.a_reg_dealloc(list,NR_R12);
 {$endif powerpc}
 {$ifdef powerpc64}
         { unget the register that contains the stack pointer before the procedure entry, }

+ 2 - 17
compiler/powerpc/cgcpu.pas

@@ -1097,15 +1097,9 @@ const
             usesgpr := firstregint <> 32;
             usesfpr := firstregfpu <> 32;
 
-            { !!! always allocate space for all registers for now !!! }
-{            if usesfpr or usesgpr then }
-             if (localsize <> 0) and
-                { check is imperfect, is actualy only necessary if there are }
-                { parameters to copy                                         }
-                (tppcprocinfo(current_procinfo).uses_stack_temps) then
+             if (tppcprocinfo(current_procinfo).needs_frame_pointer) then
               begin
                 a_reg_alloc(list,NR_R12);
-                { save end of fpr save area }
                 list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
               end;
           end;
@@ -1163,20 +1157,11 @@ const
                   a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter,R_SUBNONE),href);
                   dec(href.offset,4);
                 end;
-{
-            r.enum:=R_INTREGISTER;
-            r.:=;
-            reference_reset_base(href,NR_R12,-((NR_R31-firstreggpr) shr 8+1)*4);
-            list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
-}
-
           end;
 
-{ see "!!! always allocate space for all registers for now !!!" above }
-
 {        done in ncgutil because it may only be released after the parameters }
 {        have been moved to their final resting place                         }
-{        if usesfpr or usesgpr then }
+{        if (tppcprocinfo(current_procinfo).needs_frame_pointer) then }
 {          a_reg_dealloc(list,NR_R12); }
 
 

+ 6 - 2
compiler/powerpc/cpupara.pas

@@ -54,7 +54,8 @@ unit cpupara;
     uses
        verbose,systems,
        defutil,
-       cgutils;
+       cgutils,
+       procinfo,cpupi;
 
 
     function tppcparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
@@ -507,7 +508,10 @@ unit cpupara;
                        if (side = callerside) then
                          paraloc^.reference.index:=NR_STACK_POINTER_REG
                        else
-                         paraloc^.reference.index:=NR_R12;
+                         begin
+                           paraloc^.reference.index:=NR_R12;
+                           tppcprocinfo(current_procinfo).needs_frame_pointer := true;
+                         end;
                        paraloc^.reference.offset:=stack_offset;
                        inc(stack_offset,align(paralen,4));
                        paralen := 0;

+ 5 - 9
compiler/powerpc/cpupi.pas

@@ -43,11 +43,12 @@ unit cpupi;
 
           function uses_stack_temps: boolean;
          private
-          start_temp_offset: aint;
           first_save_int_reg, first_save_fpu_reg: tsuperregister;
          public
           property get_first_save_int_reg: tsuperregister read first_save_int_reg;
           property get_first_save_fpu_reg: tsuperregister read first_save_fpu_reg;
+
+          needs_frame_pointer: boolean;
        end;
 
 
@@ -66,9 +67,9 @@ unit cpupi;
       begin
          inherited create(aparent);
          maxpushedparasize:=0;
-         start_temp_offset:=-1;
          first_save_int_reg:=-1;
          first_save_fpu_reg:=-1;
+         needs_frame_pointer:=false;
       end;
 
 
@@ -88,19 +89,16 @@ unit cpupi;
                 internalerror(200402191);
             end;
             tg.setfirsttemp(ofs);
-            start_temp_offset := ofs;
           end
         else
           begin
             locals := 0;
-            start_temp_offset := 0;
             current_procinfo.procdef.localst.foreach_static(@count_locals,@locals);
             if locals <> 0 then
               begin
                 { at 0(r1), the previous value of r1 will be stored }
                 tg.setfirsttemp(4);
-                start_temp_offset := 4;
-              end;
+              end
           end;
       end;
 
@@ -137,9 +135,7 @@ unit cpupi;
 
     function tppcprocinfo.uses_stack_temps: boolean;
       begin
-        if (start_temp_offset = -1) then
-          internalerror(200512301);
-        result := start_temp_offset <> tg.lasttemp;
+        result := tg.firsttemp <> tg.lasttemp;
       end;