Browse Source

* first part of PowerPC fixes

florian 23 years ago
parent
commit
a7a354956d

+ 33 - 19
compiler/powerpc/cgcpu.pas

@@ -248,13 +248,16 @@ const
       var
         href : treference;
       begin
-         { save our RTOC register value. Only necessary when doing pointer based    }
-         { calls or cross TOC calls, but currently done always                      }
-         reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
-         list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+         if target_info.system=system_powerpc_macos then
+           begin
+              { save our RTOC register value. Only necessary when doing pointer based    }
+              { calls or cross TOC calls, but currently done always                      }
+              reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
+              list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+           end;
          list.concat(taicpu.op_sym(A_BL,objectlibrary.newasmsymbol(s)));
-         reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
-         list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
+         if target_info.system=system_powerpc_macos then
+           list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
          procinfo.flags:=procinfo.flags or pi_do_call;
       end;
 
@@ -263,13 +266,17 @@ const
       var
         href : treference;
       begin
-        { save our RTOC register value. Only necessary when doing pointer based    }
-        { calls or cross TOC calls, but currently done always                      }
-        reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
-        list.concat(taicpu.op_reg(A_MTCTR,reg));
-        list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+         list.concat(taicpu.op_reg(A_MTCTR,reg));
+         if target_info.system=system_powerpc_macos then
+           begin
+              { save our RTOC register value. Only necessary when doing pointer based    }
+              { calls or cross TOC calls, but currently done always                      }
+              reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
+              list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+           end;
         list.concat(taicpu.op_none(A_BCCTRL));
-        list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
+        if target_info.system=system_powerpc_macos then
+          list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
         procinfo.flags:=procinfo.flags or pi_do_call;
       end;
 
@@ -280,16 +287,20 @@ const
         href : treference;
         tmpreg : tregister;
       begin
-        { save our RTOC register value. Only necessary when doing pointer based    }
-        { calls or cross TOC calls, but currently done always                      }
-        reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
-        list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+        if target_info.system=system_powerpc_macos then
+          begin
+             { save our RTOC register value. Only necessary when doing pointer based    }
+             { calls or cross TOC calls, but currently done always                      }
+             reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
+             list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
+          end;
         tmpreg := get_scratch_reg_int(list);
         a_load_ref_reg(list,OS_ADDR,ref,tmpreg);
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
         free_scratch_reg(list,tmpreg);
         list.concat(taicpu.op_none(A_BCCTRL));
-        list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
+        if target_info.system=system_powerpc_macos then
+          list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
         procinfo.flags:=procinfo.flags or pi_do_call;
       end;
 
@@ -1703,7 +1714,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.53  2002-09-07 15:25:14  peter
+  Revision 1.54  2002-09-07 17:54:58  florian
+    * first part of PowerPC fixes
+
+  Revision 1.53  2002/09/07 15:25:14  peter
     * old logs removed and tabs fixed
 
   Revision 1.52  2002/09/02 10:14:51  jonas
@@ -1781,4 +1795,4 @@ end.
   Revision 1.33  2002/08/04 12:57:55  jonas
     * more misc. fixes, mostly constant-related
 
-}
+}

+ 6 - 3
compiler/powerpc/cpubase.pas

@@ -461,9 +461,9 @@ uses
       firstsavemmreg  = R_NO;
       lastsavemmreg   = R_NO;
 
-      maxvarregs = 18;
+      maxvarregs = 17;
       varregs : Array [1..maxvarregs] of Tregister =
-                (R_13,R_14,R_15,R_16,R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,
+                (R_14,R_15,R_16,R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,
                  R_26,R_27,R_28,R_29,R_30);
 
       maxfpuvarregs = 31-14+1;
@@ -710,7 +710,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.32  2002-09-07 15:25:14  peter
+  Revision 1.33  2002-09-07 17:54:59  florian
+    * first part of PowerPC fixes
+
+  Revision 1.32  2002/09/07 15:25:14  peter
     * old logs removed and tabs fixed
 
   Revision 1.31  2002/09/01 21:04:49  florian

+ 16 - 3
compiler/powerpc/cpupara.pas

@@ -36,6 +36,7 @@ unit cpupara;
           function getintparaloc(nr : longint) : tparalocation;override;
           procedure create_param_loc_info(p : tabstractprocdef);override;
           function getfuncretparaloc(p : tabstractprocdef) : tparalocation;override;
+          function passes_parameters_in_reg(p : tabstractprocdef) : boolean;override;
        end;
 
   implementation
@@ -127,7 +128,11 @@ unit cpupara;
          nextmmreg:=R_M1;
          stack_offset:=0;
          { pointer for structured results ? }
-         { !!!nextintreg:=R_4;              }
+         if not is_void(p.rettype.def) then
+           begin
+              if not(ret_in_reg(p)) then
+                inc(nextintreg);
+           end;
 
          { frame pointer for nested procedures? }
          { inc(nextintreg);                     }
@@ -220,10 +225,15 @@ unit cpupara;
       end;
 
     function tppcparamanager.getfuncretparaloc(p : tabstractprocdef) : tparalocation;
-
       begin
          getfuncretparaloc.loc:=LOC_REGISTER;
          getfuncretparaloc.register:=R_3;
+         getfuncretparaloc.size:=OS_ADDR;
+      end;
+
+    function tppcparamanager.passes_parameters_in_reg(p : tabstractprocdef) : boolean;
+      begin
+         passes_parameters_in_reg:=true;
       end;
 
 begin
@@ -231,7 +241,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2002-09-01 21:04:49  florian
+  Revision 1.11  2002-09-07 17:54:59  florian
+    * first part of PowerPC fixes
+
+  Revision 1.10  2002/09/01 21:04:49  florian
     * several powerpc related stuff fixed
 
   Revision 1.9  2002/08/31 12:43:31  florian

+ 15 - 3
compiler/powerpc/cpupi.pas

@@ -51,7 +51,8 @@ unit cpupi;
     uses
        globtype,globals,
        aasmtai,
-       tgobj;
+       tgobj,
+       symsym;
 
     constructor tppcprocinfo.create;
 
@@ -65,16 +66,24 @@ unit cpupi;
       begin
          { this value is necessary for nested procedures }
          procdef.localst.address_fixup:=align(procdef.parast.datasize,16);
-      end;
+         if assigned(aktprocdef.funcretsym) then
+           procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address;
+     end;
 
     procedure tppcprocinfo.after_pass1;
       begin
          procdef.parast.address_fixup:=align(maxpushedparasize,16);
          if cs_asm_source in aktglobalswitches then
            aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
+
          procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
+
+         if assigned(aktprocdef.funcretsym) then
+           procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
+
          if cs_asm_source in aktglobalswitches then
            aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
+
          procinfo.firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
          if cs_asm_source in aktglobalswitches then
            aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(procinfo.firsttemp_offset))));
@@ -89,7 +98,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2002-08-18 20:06:30  peter
+  Revision 1.3  2002-09-07 17:54:59  florian
+    * first part of PowerPC fixes
+
+  Revision 1.2  2002/08/18 20:06:30  peter
     * inlining is now also allowed in interface
     * renamed write/load to ppuwrite/ppuload
     * tnode storing in ppu

+ 5 - 2
compiler/powerpc/cpuswtch.pas

@@ -119,7 +119,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.7  2002-09-04 16:03:53  jonas
+  Revision 1.8  2002-09-07 17:54:59  florian
+    * first part of PowerPC fixes
+
+  Revision 1.7  2002/09/04 16:03:53  jonas
     + parse basic optimization parameters
 
   Revision 1.6  2002/08/10 14:52:52  carl
@@ -142,4 +145,4 @@ end.
 
   Revision 1.1  2002/05/13 19:52:46  peter
     * a ppcppc can be build again
-}
+}