فهرست منبع

* powerpc nested procedure fixes, should work completely now if all
local variables of the parent procedure are declared before the
nested procedures are declared

Jonas Maebe 22 سال پیش
والد
کامیت
d816c6a8c6
4فایلهای تغییر یافته به همراه52 افزوده شده و 11 حذف شده
  1. 12 1
      compiler/cgbase.pas
  2. 8 2
      compiler/powerpc/cpupi.pas
  3. 13 5
      compiler/powerpc/nppccal.pas
  4. 19 3
      compiler/psub.pas

+ 12 - 1
compiler/cgbase.pas

@@ -422,6 +422,12 @@ implementation
 
     procedure tprocinfo.after_pass1;
       begin
+{$ifdef powerpc}
+         { do it again because of implicit para's (HACK, JM) }
+         { Retrieve function result offset }
+         if assigned(procdef.funcretsym) then
+           current_procinfo.return_offset:=tvarsym(procdef.funcretsym).adjusted_address;
+{$endif powerpc}
       end;
 
 
@@ -579,7 +585,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.48  2003-05-15 18:58:53  peter
+  Revision 1.49  2003-05-16 20:00:39  jonas
+    * powerpc nested procedure fixes, should work completely now if all
+      local variables of the parent procedure are declared before the
+      nested procedures are declared
+
+  Revision 1.48  2003/05/15 18:58:53  peter
     * removed selfpointer_offset, vmtpointer_offset
     * tvarsym.adjusted_address
     * address in localsymtable is now in the real direction

+ 8 - 2
compiler/powerpc/cpupi.pas

@@ -66,8 +66,9 @@ unit cpupi;
     procedure tppcprocinfo.after_header;
       begin
          { this value is necessary for nested procedures }
+         procdef.parast.address_fixup:=0;
          if assigned(procdef.localst) then
-           procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
+           procdef.localst.address_fixup:=procdef.parast.address_fixup+procdef.parast.datasize;
          inherited after_header;
      end;
 
@@ -115,7 +116,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.15  2003-05-15 19:39:09  florian
+  Revision 1.16  2003-05-16 20:00:39  jonas
+    * powerpc nested procedure fixes, should work completely now if all
+      local variables of the parent procedure are declared before the
+      nested procedures are declared
+
+  Revision 1.15  2003/05/15 19:39:09  florian
     * fixed ppc compiler which was broken by Peter's changes
 
   Revision 1.14  2003/05/10 23:57:23  florian

+ 13 - 5
compiler/powerpc/nppccal.pas

@@ -82,7 +82,8 @@ implementation
             { pass the same framepointer as the current procedure got }
             hregister2.enum:=R_INTREGISTER;
             hregister2.number:=NR_R11;
-            cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,current_procinfo.framepointer,hregister2);
+            reference_reset_base(href,current_procinfo.framepointer,current_procinfo.framepointer_offset);
+            cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister2);
             { it must be adjusted! }
          end
          { this is only true if the difference is one !!
@@ -94,19 +95,21 @@ implementation
             hregister1.number:=NR_R1;
             hregister2.enum:=R_INTREGISTER;
             hregister2.number:=NR_R11;
-            exprasmlist.concat(taicpu.op_reg_reg_const(A_ADDI,hregister2,hregister1,current_procinfo.procdef.localst.address_fixup));
+            exprasmlist.concat(taicpu.op_reg_reg_const(A_ADDI,hregister2,hregister1,current_procinfo.procdef.parast.address_fixup));
          end
        else if (current_procdef.parast.symtablelevel>(tprocdef(procdefinition).parast.symtablelevel)) then
          begin
             hregister1:=rg.getregisterint(exprasmlist,OS_ADDR);
             reference_reset_base(href,current_procinfo.framepointer,current_procinfo.framepointer_offset);
             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
-            i:=current_procdef.parast.symtablelevel;
+            { the previous frame pointer is always saved at }
+            { previous_framepointer-sizeof(pointer)         }
+            reference_reset_base(href,hregister1,-POINTER_SIZE);
+            i:=current_procdef.parast.symtablelevel-1;
             while (i>tprocdef(procdefinition).parast.symtablelevel) do
               begin
                  {we should get the correct frame_pointer_offset at each level
                  how can we do this !!! }
-                 reference_reset_base(href,hregister2,current_procinfo.framepointer_offset);
                  cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
                  dec(i);
               end;
@@ -123,7 +126,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2003-04-27 11:21:36  peter
+  Revision 1.11  2003-05-16 20:00:39  jonas
+    * powerpc nested procedure fixes, should work completely now if all
+      local variables of the parent procedure are declared before the
+      nested procedures are declared
+
+  Revision 1.10  2003/04/27 11:21:36  peter
     * aktprocdef renamed to current_procdef
     * procinfo renamed to current_procinfo
     * procinfo will now be stored in current_module so it can be

+ 19 - 3
compiler/psub.pas

@@ -964,16 +964,27 @@ implementation
             { Insert local copies for value para }
             pd.parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}insert_local_value_para,nil);
 
-            { Update parameter information }
-            current_procinfo.allocate_implicit_parameter;
 {$ifdef i386}
             { add implicit pushes for interrupt routines }
             if (po_interrupt in pd.procoptions) then
               current_procinfo.allocate_interrupt_stackframe;
 {$endif i386}
 
+{$ifdef powerpc}
+            { temp hack for nested procedures on ppc }
+
+            { Calculate offsets }
+            current_procinfo.after_header;
+
+            { Update parameter information }
+            current_procinfo.allocate_implicit_parameter;
+{$else powerpc}
+            { Update parameter information }
+            current_procinfo.allocate_implicit_parameter;
+
             { Calculate offsets }
             current_procinfo.after_header;
+{$endif powerpc}
 
             { set _FAIL as keyword if constructor }
             if (pd.proctypeoption=potype_constructor) then
@@ -1130,7 +1141,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.113  2003-05-16 14:33:31  peter
+  Revision 1.114  2003-05-16 20:00:39  jonas
+    * powerpc nested procedure fixes, should work completely now if all
+      local variables of the parent procedure are declared before the
+      nested procedures are declared
+
+  Revision 1.113  2003/05/16 14:33:31  peter
     * regvar fixes
 
   Revision 1.112  2003/05/13 21:26:38  peter