2
0
Эх сурвалжийг харах

* paraloc splitted in callerparaloc,calleeparaloc
* sparc calling convention updates

peter 22 жил өмнө
parent
commit
b7d99ec934

+ 34 - 96
compiler/cg64f32.pas

@@ -33,7 +33,7 @@ unit cg64f32;
 
 
     uses
     uses
        aasmbase,aasmtai,aasmcpu,
        aasmbase,aasmtai,aasmcpu,
-       cpuinfo, cpubase,
+       cpuinfo, cpubase,cpupara,
        cginfo, cgobj,
        cginfo, cgobj,
        node,symtype
        node,symtype
 {$ifdef delphi}
 {$ifdef delphi}
@@ -96,8 +96,11 @@ unit cg64f32;
        globtype,globals,systems,
        globtype,globals,systems,
        cgbase,
        cgbase,
        verbose,
        verbose,
-       symbase,symconst,symdef,defutil,rgobj,tgobj;
+       symbase,symconst,symdef,defutil,rgobj,tgobj,paramgr;
 
 
+{****************************************************************************
+                                     Helpers
+****************************************************************************}
 
 
     function joinreg64(reglo,reghi : tregister) : tregister64;
     function joinreg64(reglo,reghi : tregister) : tregister64;
       begin
       begin
@@ -105,20 +108,25 @@ unit cg64f32;
          result.reghi:=reghi;
          result.reghi:=reghi;
       end;
       end;
 
 
-    procedure tcg64f32.a_reg_alloc(list : taasmoutput;r : tregister64);
 
 
+{****************************************************************************
+                                   TCG64F32
+****************************************************************************}
+
+    procedure tcg64f32.a_reg_alloc(list : taasmoutput;r : tregister64);
       begin
       begin
          list.concat(tai_regalloc.alloc(r.reglo));
          list.concat(tai_regalloc.alloc(r.reglo));
          list.concat(tai_regalloc.alloc(r.reghi));
          list.concat(tai_regalloc.alloc(r.reghi));
       end;
       end;
 
 
-    procedure tcg64f32.a_reg_dealloc(list : taasmoutput;r : tregister64);
 
 
+    procedure tcg64f32.a_reg_dealloc(list : taasmoutput;r : tregister64);
       begin
       begin
          list.concat(tai_regalloc.dealloc(r.reglo));
          list.concat(tai_regalloc.dealloc(r.reglo));
          list.concat(tai_regalloc.dealloc(r.reghi));
          list.concat(tai_regalloc.dealloc(r.reghi));
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
     procedure tcg64f32.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
@@ -136,6 +144,7 @@ unit cg64f32;
         cg.a_load_reg_ref(list,OS_32,OS_32,reg.reghi,tmpref);
         cg.a_load_reg_ref(list,OS_32,OS_32,reg.reghi,tmpref);
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);
     procedure tcg64f32.a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);
       var
       var
         tmpref: treference;
         tmpref: treference;
@@ -224,6 +233,7 @@ unit cg64f32;
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi);
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi);
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);
     procedure tcg64f32.a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);
 
 
       begin
       begin
@@ -231,6 +241,7 @@ unit cg64f32;
         cg.a_load_const_reg(list,OS_32,hi(value),reg.reghi);
         cg.a_load_const_reg(list,OS_32,hi(value),reg.reghi);
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64{$ifdef newra};delete :boolean{$endif});
     procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64{$ifdef newra};delete :boolean{$endif});
 
 
       begin
       begin
@@ -288,7 +299,6 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-
     procedure tcg64f32.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
     procedure tcg64f32.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
       var
       var
         tmpref: treference;
         tmpref: treference;
@@ -317,6 +327,7 @@ unit cg64f32;
           end;
           end;
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
     procedure tcg64f32.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
       var
       var
         tmpref: treference;
         tmpref: treference;
@@ -331,6 +342,7 @@ unit cg64f32;
           end;
           end;
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
     procedure tcg64f32.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
       var
       var
         tmpref: treference;
         tmpref: treference;
@@ -345,6 +357,7 @@ unit cg64f32;
           end;
           end;
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
     procedure tcg64f32.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
       begin
       begin
         case l.loc of
         case l.loc of
@@ -488,37 +501,14 @@ unit cg64f32;
       {$endif}
       {$endif}
       end;
       end;
 
 
+
     procedure tcg64f32.a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);
     procedure tcg64f32.a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);
       var
       var
         tmplochi,tmploclo: tparalocation;
         tmplochi,tmploclo: tparalocation;
       begin
       begin
-        tmplochi:=locpara;
-        tmploclo:=locpara;
-        if locpara.size=OS_S64 then
-          tmplochi.size:=OS_S32
-        else
-          tmplochi.size:=OS_32;
-        tmploclo.size:=OS_32;
-        case locpara.loc of
-           LOC_REGISTER:
-             tmplochi.register:=tmplochi.registerhigh;
-           { !!! i386 doesn't pass proper locations here
-            so always take a loc_reference, since that's what it uses (JM)
-           LOC_REFERENCE:
-           }
-           else
-             if target_info.endian=endian_big then
-               inc(tmploclo.reference.offset,4)
-             else
-               inc(tmplochi.reference.offset,4);
-           {
-           else
-             internalerror(2003042702);
-           }
-        end;
-
-         cg.a_param_reg(list,OS_32,reg.reghi,tmplochi);
-         cg.a_param_reg(list,OS_32,reg.reglo,tmploclo);
+        paramanager.splitparaloc64(locpara,tmploclo,tmplochi);
+        cg.a_param_reg(list,OS_32,reg.reghi,tmplochi);
+        cg.a_param_reg(list,OS_32,reg.reglo,tmploclo);
       end;
       end;
 
 
 
 
@@ -526,30 +516,7 @@ unit cg64f32;
       var
       var
         tmplochi,tmploclo: tparalocation;
         tmplochi,tmploclo: tparalocation;
       begin
       begin
-        tmplochi:=locpara;
-        tmploclo:=locpara;
-        if locpara.size=OS_S64 then
-          tmplochi.size:=OS_S32
-        else
-          tmplochi.size:=OS_32;
-        tmploclo.size:=OS_32;
-        case locpara.loc of
-           LOC_REGISTER:
-             tmplochi.register:=tmplochi.registerhigh;
-           { !!! i386 doesn't pass proper locations here
-            so always take a loc_reference, since that's what it uses (JM)
-           LOC_REFERENCE:
-           }
-           else
-             if target_info.endian=endian_big then
-               inc(tmploclo.reference.offset,4)
-             else
-               inc(tmplochi.reference.offset,4);
-           {
-           else
-             internalerror(2003042702);
-           }
-        end;
+        paramanager.splitparaloc64(locpara,tmploclo,tmplochi);
         cg.a_param_const(list,OS_32,hi(value),tmplochi);
         cg.a_param_const(list,OS_32,hi(value),tmplochi);
         cg.a_param_const(list,OS_32,lo(value),tmploclo);
         cg.a_param_const(list,OS_32,lo(value),tmploclo);
       end;
       end;
@@ -560,46 +527,13 @@ unit cg64f32;
         tmprefhi,tmpreflo : treference;
         tmprefhi,tmpreflo : treference;
         tmploclo,tmplochi : tparalocation;
         tmploclo,tmplochi : tparalocation;
       begin
       begin
+        paramanager.splitparaloc64(locpara,tmploclo,tmplochi);
         tmprefhi:=r;
         tmprefhi:=r;
         tmpreflo:=r;
         tmpreflo:=r;
-        tmplochi:=locpara;
-        tmploclo:=locpara;
-        if locpara.size=OS_S64 then
-          tmplochi.size:=OS_S32
+        if target_info.endian=endian_big then
+          inc(tmpreflo.offset,4)
         else
         else
-          tmplochi.size:=OS_32;
-        tmploclo.size:=OS_32;
-        case locpara.loc of
-           LOC_REGISTER:
-             begin
-                if target_info.endian=endian_big then
-                  inc(tmpreflo.offset,4)
-                else
-                  inc(tmprefhi.offset,4);
-                tmplochi.register:=tmplochi.registerhigh;
-             end;
-           { !!! i386 doesn't pass proper locations here
-            so always take a loc_reference, since that's what it uses (JM)
-           LOC_REFERENCE:
-           }
-           else
-             begin
-                if target_info.endian=endian_big then
-                  begin
-                    inc(tmpreflo.offset,4);
-                    inc(tmploclo.reference.offset,4);
-                  end
-                else
-                  begin
-                    inc(tmprefhi.offset,4);
-                    inc(tmplochi.reference.offset,4);
-                  end;
-             end
-           {
-           else
-             internalerror(2003042701);
-           }
-        end;
+          inc(tmprefhi.offset,4);
         cg.a_param_ref(list,OS_32,tmprefhi,tmplochi);
         cg.a_param_ref(list,OS_32,tmprefhi,tmplochi);
         cg.a_param_ref(list,OS_32,tmpreflo,tmploclo);
         cg.a_param_ref(list,OS_32,tmpreflo,tmploclo);
       end;
       end;
@@ -616,8 +550,8 @@ unit cg64f32;
           LOC_CREFERENCE,
           LOC_CREFERENCE,
           LOC_REFERENCE :
           LOC_REFERENCE :
             a_param64_ref(list,l.reference,locpara);
             a_param64_ref(list,l.reference,locpara);
-        else
-          internalerror(200203287);
+          else
+            internalerror(200203287);
         end;
         end;
       end;
       end;
 
 
@@ -904,7 +838,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2003-06-03 21:11:09  peter
+  Revision 1.48  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.47  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 63 - 8
compiler/cgobj.pas

@@ -180,6 +180,11 @@ unit cgobj;
               second the destination
               second the destination
           }
           }
 
 
+          { Copy a parameter to a (temporary) reference }
+          procedure a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);virtual;
+          { Copy a parameter to a register }
+          procedure a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);virtual;
+
           {# Emits instruction to call the method specified by symbol name.
           {# Emits instruction to call the method specified by symbol name.
              This routine must be overriden for each new target cpu.
              This routine must be overriden for each new target cpu.
           }
           }
@@ -203,7 +208,7 @@ unit cgobj;
           procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual; abstract;
           procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual; abstract;
 
 
           { fpu move instructions }
           { fpu move instructions }
-          procedure a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister); virtual; abstract;
+          procedure a_loadfpu_reg_reg(list: taasmoutput; size:tcgsize; reg1, reg2: tregister); virtual; abstract;
           procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); virtual; abstract;
           procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); virtual; abstract;
           procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); virtual; abstract;
           procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); virtual; abstract;
           procedure a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
           procedure a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
@@ -699,13 +704,59 @@ unit cgobj;
            internalerror(2003010901);
            internalerror(2003010901);
          if locpara.sp_fixup<>0 then
          if locpara.sp_fixup<>0 then
            cg.g_stackpointer_alloc(list,locpara.sp_fixup);
            cg.g_stackpointer_alloc(list,locpara.sp_fixup);
-         reference_reset(ref);
-         ref.base:=locpara.reference.index;
-         ref.offset:=locpara.reference.offset;
+         reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
          cg.g_concatcopy(list,r,ref,size,false,false);
          cg.g_concatcopy(list,r,ref,size,false,false);
       end;
       end;
 
 
 
 
+    procedure tcg.a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);
+      begin
+        case locpara.loc of
+          LOC_CREGISTER,
+          LOC_REGISTER:
+            begin
+              if (locpara.size in [OS_S64,OS_64]) then
+                cg64.a_load64_reg_ref(list,locpara.register64,ref)
+              else
+                cg.a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
+            end;
+          LOC_FPUREGISTER,
+          LOC_CFPUREGISTER:
+            cg.a_loadfpu_reg_ref(list,locpara.size,locpara.register,ref);
+          else
+            internalerror(2002081302);
+        end;
+      end;
+
+
+    procedure tcg.a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);
+      var
+        href : treference;
+      begin
+        case locpara.loc of
+          LOC_CREGISTER,
+          LOC_REGISTER:
+            begin
+              if not(locpara.size in [OS_S64,OS_64]) then
+                cg.a_load_reg_reg(list,locpara.size,locpara.size,locpara.register,reg)
+              else
+                internalerror(2003053011);
+            end;
+          LOC_CFPUREGISTER,
+          LOC_FPUREGISTER:
+            cg.a_loadfpu_reg_reg(list,locpara.size,locpara.register,reg);
+          LOC_REFERENCE,
+          LOC_CREFERENCE:
+            begin
+              reference_reset_base(href,locpara.reference.index,locpara.reference.offset);
+              cg.a_load_ref_reg(list,locpara.size,locpara.size,href,reg);
+            end;
+          else
+            internalerror(2003053010);
+        end
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                        some generic implementations
                        some generic implementations
 ****************************************************************************}
 ****************************************************************************}
@@ -952,7 +1003,7 @@ unit cgobj;
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
             a_loadfpu_ref_reg(list,loc.size,loc.reference,reg);
             a_loadfpu_ref_reg(list,loc.size,loc.reference,reg);
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
-            a_loadfpu_reg_reg(list,loc.register,reg);
+            a_loadfpu_reg_reg(list,loc.size,loc.register,reg);
           else
           else
             internalerror(200203301);
             internalerror(200203301);
         end;
         end;
@@ -966,7 +1017,7 @@ unit cgobj;
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
             a_loadfpu_reg_ref(list,size,reg,loc.reference);
             a_loadfpu_reg_ref(list,size,reg,loc.reference);
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
-            a_loadfpu_reg_reg(list,reg,loc.register);
+            a_loadfpu_reg_reg(list,size,reg,loc.register);
           else
           else
             internalerror(48991);
             internalerror(48991);
          end;
          end;
@@ -982,7 +1033,7 @@ unit cgobj;
       begin
       begin
          case locpara.loc of
          case locpara.loc of
             LOC_FPUREGISTER,LOC_CFPUREGISTER:
             LOC_FPUREGISTER,LOC_CFPUREGISTER:
-              a_loadfpu_reg_reg(list,r,locpara.register);
+              a_loadfpu_reg_reg(list,size,r,locpara.register);
             LOC_REFERENCE,LOC_CREFERENCE:
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
               begin
                  if locpara.sp_fixup<>0 then
                  if locpara.sp_fixup<>0 then
@@ -1716,7 +1767,11 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.112  2003-06-13 21:19:30  peter
+  Revision 1.113  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.112  2003/06/13 21:19:30  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.111  2003/06/12 21:11:10  peter
   Revision 1.111  2003/06/12 21:11:10  peter

+ 18 - 10
compiler/i386/cpupara.pas

@@ -47,7 +47,7 @@ unit cpupara;
           function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
           function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
           procedure freeintparaloc(list: taasmoutput; nr : longint); override;
           procedure freeintparaloc(list: taasmoutput; nr : longint); override;
           function getparaloc(p : tdef) : tcgloc;
           function getparaloc(p : tdef) : tcgloc;
-          procedure create_param_loc_info(p : tabstractprocdef);override;
+          procedure create_paraloc_info(p : tabstractprocdef);override;
           function getselflocation(p : tabstractprocdef) : tparalocation;override;
           function getselflocation(p : tabstractprocdef) : tparalocation;override;
        end;
        end;
 
 
@@ -132,26 +132,30 @@ unit cpupara;
       end;
       end;
 
 
 
 
-    procedure ti386paramanager.create_param_loc_info(p : tabstractprocdef);
+    procedure ti386paramanager.create_paraloc_info(p : tabstractprocdef);
       var
       var
         hp : tparaitem;
         hp : tparaitem;
+        paraloc : tparalocation;
       begin
       begin
         hp:=tparaitem(p.para.first);
         hp:=tparaitem(p.para.first);
         while assigned(hp) do
         while assigned(hp) do
           begin
           begin
             if hp.paratyp in [vs_var,vs_out] then
             if hp.paratyp in [vs_var,vs_out] then
-              hp.paraloc.size:=OS_ADDR
+              paraloc.size:=OS_ADDR
             else
             else
-              hp.paraloc.size:=def_cgsize(hp.paratype.def);
-            hp.paraloc.loc:=LOC_REFERENCE;
+              paraloc.size:=def_cgsize(hp.paratype.def);
+            paraloc.loc:=LOC_REFERENCE;
             if assigned(current_procinfo) then
             if assigned(current_procinfo) then
-              hp.paraloc.reference.index:=current_procinfo.framepointer
+              paraloc.reference.index:=current_procinfo.framepointer
             else
             else
               begin
               begin
-                hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                hp.paraloc.reference.index.number:=NR_FRAME_POINTER_REG;
+                paraloc.reference.index.enum:=R_INTREGISTER;
+                paraloc.reference.index.number:=NR_FRAME_POINTER_REG;
               end;
               end;
-            hp.paraloc.reference.offset:=tvarsym(hp.parasym).adjusted_address;
+            paraloc.reference.offset:=tvarsym(hp.parasym).adjusted_address;
+            hp.calleeparaloc:=paraloc;
+{$warning callerparaloc shall not be the same as calleeparaloc}
+            hp.callerparaloc:=paraloc;
             hp:=tparaitem(hp.next);
             hp:=tparaitem(hp.next);
           end;
           end;
       end;
       end;
@@ -176,7 +180,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2003-06-17 16:34:19  peter
+  Revision 1.20  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.19  2003/06/17 16:34:19  peter
     * freeintparaloc added
     * freeintparaloc added
 
 
   Revision 1.18  2003/06/07 18:57:04  jonas
   Revision 1.18  2003/06/07 18:57:04  jonas

+ 6 - 2
compiler/i386/n386inl.pas

@@ -179,7 +179,7 @@ implementation
                       ;
                       ;
              LOC_CFPUREGISTER:
              LOC_CFPUREGISTER:
                begin
                begin
-                 cg.a_loadfpu_reg_reg(exprasmlist,
+                 cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,
                    left.location.register,location.register);
                    left.location.register,location.register);
                end;
                end;
              LOC_REFERENCE,LOC_CREFERENCE:
              LOC_REFERENCE,LOC_CREFERENCE:
@@ -347,7 +347,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  2003-06-03 13:01:59  daniel
+  Revision 1.64  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.63  2003/06/03 13:01:59  daniel
     * Register allocator finished
     * Register allocator finished
 
 
   Revision 1.62  2003/06/01 21:38:06  peter
   Revision 1.62  2003/06/01 21:38:06  peter

+ 6 - 2
compiler/i386/n386mat.pas

@@ -980,7 +980,7 @@ implementation
             begin
             begin
                { "load st,st" is ignored by the code generator }
                { "load st,st" is ignored by the code generator }
                r.enum:=R_ST;
                r.enum:=R_ST;
-               cg.a_loadfpu_reg_reg(exprasmlist,left.location.register,r);
+               cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,r);
                location.register.enum:=R_ST;
                location.register.enum:=R_ST;
                emit_none(A_FCHS,S_NO);
                emit_none(A_FCHS,S_NO);
             end;
             end;
@@ -1094,7 +1094,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.58  2003-06-13 21:19:31  peter
+  Revision 1.59  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.58  2003/06/13 21:19:31  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.57  2003/06/03 21:11:09  peter
   Revision 1.57  2003/06/03 21:11:09  peter

+ 53 - 19
compiler/ncgcal.pas

@@ -128,18 +128,18 @@ implementation
          objectlibrary.getlabel(falselabel);
          objectlibrary.getlabel(falselabel);
          secondpass(left);
          secondpass(left);
          { allocate paraloc }
          { allocate paraloc }
-         paramanager.allocparaloc(exprasmlist,paraitem.paraloc);
+         paramanager.allocparaloc(exprasmlist,paraitem.callerparaloc);
          { handle varargs first, because defcoll is not valid }
          { handle varargs first, because defcoll is not valid }
          if (nf_varargs_para in flags) then
          if (nf_varargs_para in flags) then
            begin
            begin
              if paramanager.push_addr_param(left.resulttype.def,calloption) then
              if paramanager.push_addr_param(left.resulttype.def,calloption) then
                begin
                begin
                  inc(pushedparasize,POINTER_SIZE);
                  inc(pushedparasize,POINTER_SIZE);
-                 cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
+                 cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.callerparaloc);
                  location_release(exprasmlist,left.location);
                  location_release(exprasmlist,left.location);
                end
                end
              else
              else
-               push_value_para(exprasmlist,left,calloption,para_offset,para_alignment,paraitem.paraloc);
+               push_value_para(exprasmlist,left,calloption,para_offset,para_alignment,paraitem.callerparaloc);
            end
            end
          { hidden parameters }
          { hidden parameters }
          else if paraitem.is_hidden then
          else if paraitem.is_hidden then
@@ -171,13 +171,13 @@ implementation
                     {$endif}
                     {$endif}
                     end
                     end
                   else
                   else
-                    cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
+                    cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.callerparaloc);
                   location_release(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                end
                end
              else
              else
                begin
                begin
                   push_value_para(exprasmlist,left,calloption,
                   push_value_para(exprasmlist,left,calloption,
-                    para_offset,para_alignment,paraitem.paraloc);
+                    para_offset,para_alignment,paraitem.callerparaloc);
                end;
                end;
            end
            end
          { filter array of const c styled args }
          { filter array of const c styled args }
@@ -205,7 +205,7 @@ implementation
                        cg.a_load_loc_ref(exprasmlist,OS_ADDR,left.location,href);
                        cg.a_load_loc_ref(exprasmlist,OS_ADDR,left.location,href);
                     end
                     end
                   else
                   else
-                    cg.a_param_loc(exprasmlist,left.location,paraitem.paraloc);
+                    cg.a_param_loc(exprasmlist,left.location,paraitem.callerparaloc);
                   location_release(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                 end
                 end
               else
               else
@@ -230,7 +230,7 @@ implementation
                      {$endif}
                      {$endif}
                      end
                      end
                    else
                    else
-                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
+                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.callerparaloc);
                    location_release(exprasmlist,left.location);
                    location_release(exprasmlist,left.location);
                 end;
                 end;
            end
            end
@@ -268,7 +268,7 @@ implementation
                 {$endif}
                 {$endif}
                 end
                 end
               else
               else
-                cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
+                cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.callerparaloc);
               location_release(exprasmlist,left.location);
               location_release(exprasmlist,left.location);
            end
            end
          else
          else
@@ -318,13 +318,13 @@ implementation
                      {$endif}
                      {$endif}
                      end
                      end
                    else
                    else
-                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.paraloc);
+                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,paraitem.callerparaloc);
                    location_release(exprasmlist,left.location);
                    location_release(exprasmlist,left.location);
                 end
                 end
               else
               else
                 begin
                 begin
                    push_value_para(exprasmlist,left,calloption,
                    push_value_para(exprasmlist,left,calloption,
-                     para_offset,para_alignment,paraitem.paraloc);
+                     para_offset,para_alignment,paraitem.callerparaloc);
                 end;
                 end;
            end;
            end;
          truelabel:=otlabel;
          truelabel:=otlabel;
@@ -485,7 +485,7 @@ implementation
                 inc(trgcpu(rg).fpuvaroffset);
                 inc(trgcpu(rg).fpuvaroffset);
 {$else x86}
 {$else x86}
                 hregister := rg.getregisterfpu(exprasmlist,location.size);
                 hregister := rg.getregisterfpu(exprasmlist,location.size);
-                cg.a_loadfpu_reg_reg(exprasmlist,location.register,hregister);
+                cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
                 location.register := hregister;
                 location.register := hregister;
 {$endif x86}
 {$endif x86}
               end
               end
@@ -584,7 +584,7 @@ implementation
             if cgsize<>OS_NO then
             if cgsize<>OS_NO then
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
               if cgsize in [OS_64,OS_S64] then
               if cgsize in [OS_64,OS_S64] then
-                begin 
+                begin
                   r.enum:=R_INTREGISTER;
                   r.enum:=R_INTREGISTER;
                   r.number:=NR_FUNCTION_RESULT64_LOW_REG;
                   r.number:=NR_FUNCTION_RESULT64_LOW_REG;
                   hregister.enum:=R_INTREGISTER;
                   hregister.enum:=R_INTREGISTER;
@@ -593,9 +593,9 @@ implementation
                   rg.ungetregisterint(exprasmlist,hregister);
                   rg.ungetregisterint(exprasmlist,hregister);
                 end
                 end
               else
               else
-{$endif cpu64bit}  
+{$endif cpu64bit}
                 begin
                 begin
-                  r.enum:=R_INTREGISTER;      
+                  r.enum:=R_INTREGISTER;
                   r.number:=NR_FUNCTION_RESULT_REG;
                   r.number:=NR_FUNCTION_RESULT_REG;
                   rg.ungetregisterint(exprasmlist,r);
                   rg.ungetregisterint(exprasmlist,r);
                 end;
                 end;
@@ -663,6 +663,7 @@ implementation
       {$endif}
       {$endif}
          pushedother : tpushedsavedother;
          pushedother : tpushedsavedother;
          oldpushedparasize : longint;
          oldpushedparasize : longint;
+         paraitem : tparaitem;
          { adress returned from an I/O-error }
          { adress returned from an I/O-error }
          iolabel : tasmlabel;
          iolabel : tasmlabel;
          { help reference pointer }
          { help reference pointer }
@@ -679,6 +680,13 @@ implementation
          if not assigned(procdefinition) then
          if not assigned(procdefinition) then
            internalerror(200305264);
            internalerror(200305264);
 
 
+         { calculate the parameter info for the procdef }
+         if not procdefinition.has_paraloc_info then
+           begin
+             paramanager.create_paraloc_info(procdefinition);
+             procdefinition.has_paraloc_info:=true;
+           end;
+
          iolabel:=nil;
          iolabel:=nil;
          rg.saveunusedstate(unusedstate);
          rg.saveunusedstate(unusedstate);
 
 
@@ -806,7 +814,7 @@ implementation
 {$ifdef i386}
 {$ifdef i386}
               regs_to_push_other := all_registers;
               regs_to_push_other := all_registers;
 {$else i386}
 {$else i386}
-              regs_to_push_other := [];                
+              regs_to_push_other := [];
 {$endif i386}
 {$endif i386}
               rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
               rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
 {$ifdef i386}
 {$ifdef i386}
@@ -923,7 +931,12 @@ implementation
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
 {$endif newra}
 {$endif newra}
                    { free the resources allocated for the parameters }
                    { free the resources allocated for the parameters }
-                   paramanager.freeparalocs(exprasmlist,tparaitem(procdefinition.para.first));
+                   paraitem:=tparaitem(procdefinition.para.first);
+                   while assigned(paraitem) do
+                     begin
+                       paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
+                       paraitem:=tparaitem(paraitem.next);
+                     end;
 
 
 {$ifdef newra}
 {$ifdef newra}
                    for i:=first_supreg to last_supreg do
                    for i:=first_supreg to last_supreg do
@@ -945,7 +958,12 @@ implementation
               else
               else
                 begin
                 begin
                  { free the resources allocated for the parameters }
                  { free the resources allocated for the parameters }
-                  paramanager.freeparalocs(exprasmlist,tparaitem(procdefinition.para.first));
+                  paraitem:=tparaitem(procdefinition.para.first);
+                  while assigned(paraitem) do
+                    begin
+                      paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
+                      paraitem:=tparaitem(paraitem.next);
+                    end;
 
 
 {$ifdef newra}
 {$ifdef newra}
                   for i:=first_supreg to last_supreg do
                   for i:=first_supreg to last_supreg do
@@ -995,7 +1013,12 @@ implementation
 {$endif newra}
 {$endif newra}
 
 
               { free the resources allocated for the parameters }
               { free the resources allocated for the parameters }
-              paramanager.freeparalocs(exprasmlist,tparaitem(procdefinition.para.first));
+              paraitem:=tparaitem(procdefinition.para.first);
+              while assigned(paraitem) do
+                begin
+                  paramanager.freeparaloc(exprasmlist,paraitem.callerparaloc);
+                  paraitem:=tparaitem(paraitem.next);
+                end;
 
 
 {$ifdef newra}
 {$ifdef newra}
               for i:=first_supreg to last_supreg do
               for i:=first_supreg to last_supreg do
@@ -1180,6 +1203,13 @@ implementation
          { we're inlining a procedure }
          { we're inlining a procedure }
          inlining_procedure:=true;
          inlining_procedure:=true;
 
 
+         { calculate the parameter info for the procdef }
+         if not procdefinition.has_paraloc_info then
+           begin
+             paramanager.create_paraloc_info(procdefinition);
+             procdefinition.has_paraloc_info:=true;
+           end;
+
          { deallocate the registers used for the current procedure's regvars }
          { deallocate the registers used for the current procedure's regvars }
          if assigned(current_procinfo.procdef.regvarinfo) then
          if assigned(current_procinfo.procdef.regvarinfo) then
            begin
            begin
@@ -1531,7 +1561,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.95  2003-06-17 16:34:44  jonas
+  Revision 1.96  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.95  2003/06/17 16:34:44  jonas
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * renamed all_intregisters to volatile_intregisters and made it
     * renamed all_intregisters to volatile_intregisters and made it
       processor dependent
       processor dependent

+ 6 - 2
compiler/ncgmat.pas

@@ -208,7 +208,7 @@ implementation
           LOC_CFPUREGISTER:
           LOC_CFPUREGISTER:
             begin
             begin
                location.register:=rg.getregisterfpu(exprasmlist,location.size);
                location.register:=rg.getregisterfpu(exprasmlist,location.size);
-               cg.a_loadfpu_reg_reg(exprasmlist,left.location.register,location.register);
+               cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,location.register);
                emit_float_sign_change(location.register,def_cgsize(left.resulttype.def));
                emit_float_sign_change(location.register,def_cgsize(left.resulttype.def));
             end;
             end;
           else
           else
@@ -514,7 +514,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2003-06-07 18:57:04  jonas
+  Revision 1.15  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.14  2003/06/07 18:57:04  jonas
     + added freeintparaloc
     + added freeintparaloc
     * ppc get/freeintparaloc now check whether the parameter regs are
     * ppc get/freeintparaloc now check whether the parameter regs are
       properly allocated/deallocated (and get an extra list para)
       properly allocated/deallocated (and get an extra list para)

+ 61 - 83
compiler/ncgutil.pas

@@ -820,12 +820,12 @@ implementation
                               para_offset:longint;alignment : longint;
                               para_offset:longint;alignment : longint;
                               const locpara : tparalocation);
                               const locpara : tparalocation);
       var
       var
-        tempreference : treference;
         href : treference;
         href : treference;
 {$ifdef i386}
 {$ifdef i386}
+        tempreference : treference;
         hreg : tregister;
         hreg : tregister;
+        sizetopush : longint;
 {$endif i386}
 {$endif i386}
-        sizetopush,
         size : longint;
         size : longint;
         cgsize : tcgsize;
         cgsize : tcgsize;
       begin
       begin
@@ -840,43 +840,40 @@ implementation
         { Handle Floating point types differently }
         { Handle Floating point types differently }
         if p.resulttype.def.deftype=floatdef then
         if p.resulttype.def.deftype=floatdef then
          begin
          begin
-           case p.location.loc of
-             LOC_FPUREGISTER,
-             LOC_CFPUREGISTER:
-               begin
+           if calloption=pocall_inline then
+             begin
+               size:=align(tfloatdef(p.resulttype.def).size,alignment);
+               inc(pushedparasize,size);
+               reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
+               case p.location.loc of
+                 LOC_FPUREGISTER,
+                 LOC_CFPUREGISTER:
+                   cg.a_loadfpu_reg_ref(list,def_cgsize(p.resulttype.def),p.location.register,href);
+                 LOC_REFERENCE,
+                 LOC_CREFERENCE :
+                   cg.g_concatcopy(list,p.location.reference,href,size,false,false);
+                 else
+                   internalerror(200204243);
+               end;
+             end
+           else
+             begin
 {$ifdef i386}
 {$ifdef i386}
-                  size:=align(tfloatdef(p.resulttype.def).size,alignment);
-                  inc(pushedparasize,size);
-
-                  if calloption<>pocall_inline then
-                   cg.g_stackpointer_alloc(list,size);
-{$ifdef GDB}
-                  if (cs_debuginfo in aktmoduleswitches) and
-                     (list.first=list.last) then
-                    list.concat(Tai_force_line.Create);
-{$endif GDB}
-
-                  { this is the easiest case for inlined !! }
-                  hreg.enum:=R_INTREGISTER;
-                  hreg.number:=NR_STACK_POINTER_REG;
-                  if calloption=pocall_inline then
-                   reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize)
-                  else
-                   reference_reset_base(href,hreg,0);
-
-                  cg.a_loadfpu_reg_ref(list,
-                    def_cgsize(p.resulttype.def),p.location.register,href);
-{$else i386}
-                  cg.a_paramfpu_reg(list,def_cgsize(p.resulttype.def),p.location.register,locpara);
-{$endif i386}
+               case p.location.loc of
+                 LOC_FPUREGISTER,
+                 LOC_CFPUREGISTER:
+                   begin
+                      size:=align(tfloatdef(p.resulttype.def).size,alignment);
+                      inc(pushedparasize,size);
+                      cg.g_stackpointer_alloc(list,size);
+                      hreg.enum:=R_INTREGISTER;
+                      hreg.number:=NR_STACK_POINTER_REG;
+                      reference_reset_base(href,hreg,0);
+                      cg.a_loadfpu_reg_ref(list,def_cgsize(p.resulttype.def),p.location.register,href);
 
 
-               end;
-             LOC_REFERENCE,
-             LOC_CREFERENCE :
-               begin
-                 if locpara.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER] then
-                   cg.a_paramfpu_ref(list,def_cgsize(p.resulttype.def),p.location.reference,locpara)
-                 else
+                   end;
+                 LOC_REFERENCE,
+                 LOC_CREFERENCE :
                    begin
                    begin
                      sizetopush:=align(p.resulttype.def.size,alignment);
                      sizetopush:=align(p.resulttype.def.size,alignment);
                      tempreference:=p.location.reference;
                      tempreference:=p.location.reference;
@@ -897,19 +894,25 @@ implementation
                            dec(tempreference.offset,2);
                            dec(tempreference.offset,2);
                            dec(sizetopush,2);
                            dec(sizetopush,2);
                          end;
                          end;
-                        if calloption=pocall_inline then
-                         begin
-                           reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
-                           cg.a_load_ref_ref(list,cgsize,cgsize,tempreference,href);
-                         end
-                        else
-                         cg.a_param_ref(list,cgsize,tempreference,locpara);
-                     end;
-                  end;
+                        cg.a_param_ref(list,cgsize,tempreference,locpara);
+                      end;
+                   end;
+                 else
+                   internalerror(200204243);
                end;
                end;
-             else
-               internalerror(200204243);
-           end;
+{$else i386}
+               case p.location.loc of
+                 LOC_FPUREGISTER,
+                 LOC_CFPUREGISTER:
+                   cg.a_paramfpu_reg(list,def_cgsize(p.resulttype.def),p.location.register,locpara);
+                 LOC_REFERENCE,
+                 LOC_CREFERENCE :
+                   cg.a_paramfpu_ref(list,def_cgsize(p.resulttype.def),p.location.reference,locpara)
+                 else
+                   internalerror(200204243);
+               end;
+{$endif i386}
+             end;
            location_release(list,p.location);
            location_release(list,p.location);
          end
          end
         else
         else
@@ -1565,44 +1568,15 @@ implementation
                      if Tvarsym(hp.parasym).reg.enum>R_INTREGISTER then
                      if Tvarsym(hp.parasym).reg.enum>R_INTREGISTER then
                        internalerror(200301081);
                        internalerror(200301081);
                      if (tvarsym(hp.parasym).reg.enum<>R_NO) then
                      if (tvarsym(hp.parasym).reg.enum<>R_NO) then
-                       case hp.paraloc.loc of
-                         LOC_CREGISTER,
-                         LOC_REGISTER:
-                         if not(hp.paraloc.size in [OS_S64,OS_64]) then
-                           cg.a_load_reg_reg(list,hp.paraloc.size,hp.paraloc.size,hp.paraloc.register,tvarsym(hp.parasym).reg)
-                         else
-                           internalerror(2003053011);
-//                           cg64.a_load64_reg_reg(list,hp.paraloc.register64,tvarsym(hp.parasym).reg);
-                         LOC_CFPUREGISTER,
-                         LOC_FPUREGISTER:
-                           cg.a_loadfpu_reg_reg(list,hp.paraloc.register,tvarsym(hp.parasym).reg);
-                         LOC_REFERENCE,
-                         LOC_CREFERENCE:
-                           begin
-                             reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
-                             cg.a_load_ref_reg(list,hp.paraloc.size,hp.paraloc.size,href,tvarsym(hp.parasym).reg);
-                           end;
-                         else
-                           internalerror(2003053010);
+                       begin
+                         cg.a_load_param_reg(list,hp.calleeparaloc,tvarsym(hp.parasym).reg);
                        end
                        end
-                     else if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
+                     else if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                                                  LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
                                                  LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
                              (tvarsym(hp.parasym).reg.enum=R_NO) then
                              (tvarsym(hp.parasym).reg.enum=R_NO) then
                        begin
                        begin
                          reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
                          reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
-                         case hp.paraloc.loc of
-                           LOC_CREGISTER,
-                           LOC_REGISTER:
-                            if not(hp.paraloc.size in [OS_S64,OS_64]) then
-                               cg.a_load_reg_ref(list,hp.paraloc.size,hp.paraloc.size,hp.paraloc.register,href)
-                            else
-                               cg64.a_load64_reg_ref(list,hp.paraloc.register64,href);
-                           LOC_FPUREGISTER,
-                           LOC_CFPUREGISTER:
-                             cg.a_loadfpu_reg_ref(list,hp.paraloc.size,hp.paraloc.register,href);
-                           else
-                             internalerror(2002081302);
-                         end;
+                         cg.a_load_param_ref(list,hp.calleeparaloc,href);
                        end;
                        end;
                      hp:=tparaitem(hp.next);
                      hp:=tparaitem(hp.next);
                    end;
                    end;
@@ -2002,7 +1976,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.127  2003-06-17 18:13:51  jonas
+  Revision 1.128  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.127  2003/06/17 18:13:51  jonas
     * fixed -dnewra compilation problems
     * fixed -dnewra compilation problems
 
 
   Revision 1.126  2003/06/17 16:32:44  peter
   Revision 1.126  2003/06/17 16:32:44  peter

+ 42 - 25
compiler/paramgr.pas

@@ -80,7 +80,7 @@ unit paramgr;
           procedure freeintparaloc(list: taasmoutput; nr : longint); virtual; abstract;
           procedure freeintparaloc(list: taasmoutput; nr : longint); virtual; abstract;
 
 
 
 
-          {# allocate a parameter location created with create_param_loc_info
+          {# allocate a parameter location created with create_paraloc_info
 
 
             @param(list Current assembler list)
             @param(list Current assembler list)
             @param(loc Parameter location)
             @param(loc Parameter location)
@@ -94,19 +94,10 @@ unit paramgr;
           }
           }
           procedure freeparaloc(list: taasmoutput; const loc: tparalocation); virtual;
           procedure freeparaloc(list: taasmoutput; const loc: tparalocation); virtual;
 
 
-          {# free all parameters allocated with allocparaloc for a procedure
-
-            @param(list Current assembler list)
-            @param(paraitem First paraitem of the procedure)
-          }
-          procedure freeparalocs(list: taasmoutput; paraitem: tparaitem);
-
-
-
           {# This is used to populate the location information on all parameters
           {# This is used to populate the location information on all parameters
              for the routine. This is used for normal call resolution.
              for the routine. This is used for normal call resolution.
           }
           }
-          procedure create_param_loc_info(p : tabstractprocdef);virtual;abstract;
+          procedure create_paraloc_info(p : tabstractprocdef);virtual;abstract;
 
 
           {
           {
             Returns the location where the invisible parameter for structured
             Returns the location where the invisible parameter for structured
@@ -133,7 +124,8 @@ unit paramgr;
 
 
             @param(def The definition of the result type of the function)
             @param(def The definition of the result type of the function)
           }
           }
-          function getfuncresultloc(def : tdef;calloption:tproccalloption): tparalocation; virtual;
+          function getfuncresultloc(def : tdef;calloption:tproccalloption): tparalocation;virtual;
+          procedure splitparaloc64(const locpara:tparalocation;var loclopara,lochipara:tparalocation);virtual;
        end;
        end;
 
 
 
 
@@ -275,7 +267,7 @@ implementation
           LOC_REGISTER, LOC_CREGISTER:
           LOC_REGISTER, LOC_CREGISTER:
             begin
             begin
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
-              if (loc.size in [OS_64,OS_S64]) then
+              if (loc.size in [OS_64,OS_S64,OS_F64]) then
                 begin
                 begin
                   rg.getexplicitregisterint(list,loc.registerhigh.number);
                   rg.getexplicitregisterint(list,loc.registerhigh.number);
                   rg.getexplicitregisterint(list,loc.registerlow.number);
                   rg.getexplicitregisterint(list,loc.registerlow.number);
@@ -300,7 +292,7 @@ implementation
           LOC_REGISTER, LOC_CREGISTER:
           LOC_REGISTER, LOC_CREGISTER:
             begin
             begin
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
-              if (loc.size in [OS_64,OS_S64]) then
+              if (loc.size in [OS_64,OS_S64,OS_F64]) then
                 begin
                 begin
                   rg.ungetregisterint(list,loc.registerhigh);
                   rg.ungetregisterint(list,loc.registerhigh);
                   rg.ungetregisterint(list,loc.registerlow);
                   rg.ungetregisterint(list,loc.registerlow);
@@ -319,16 +311,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tparamanager.freeparalocs(list: taasmoutput; paraitem: tparaitem);
-      begin
-        while assigned(paraitem) do
-          begin
-            freeparaloc(list,paraitem.paraloc);
-            paraitem := tparaitem(paraitem.next);
-          end;
-      end;
-
-
     function tparamanager.getfuncretparaloc(p : tabstractprocdef) : tparalocation;
     function tparamanager.getfuncretparaloc(p : tabstractprocdef) : tparalocation;
       begin
       begin
          result.loc:=LOC_REFERENCE;
          result.loc:=LOC_REFERENCE;
@@ -420,6 +402,37 @@ implementation
       end;
       end;
 
 
 
 
+    procedure tparamanager.splitparaloc64(const locpara:tparalocation;var loclopara,lochipara:tparalocation);
+      begin
+        if not(locpara.size in [OS_64,OS_S64]) then
+          internalerror(200307023);
+        lochipara:=locpara;
+        loclopara:=locpara;
+        if locpara.size=OS_S64 then
+          lochipara.size:=OS_S32
+        else
+          lochipara.size:=OS_32;
+        loclopara.size:=OS_32;
+        case locpara.loc of
+           LOC_REGISTER,LOC_CREGISTER:
+             begin
+               loclopara.register:=locpara.registerlow;
+               lochipara.register:=locpara.registerhigh;
+             end;
+           LOC_REFERENCE:
+             begin
+               if target_info.endian=endian_big then
+                 inc(loclopara.reference.offset,4)
+               else
+                 inc(lochipara.reference.offset,4);
+             end;
+           else
+             internalerror(200307024);
+        end;
+      end;
+
+
+
 
 
 initialization
 initialization
   ;
   ;
@@ -429,7 +442,11 @@ end.
 
 
 {
 {
    $Log$
    $Log$
-   Revision 1.46  2003-06-17 16:32:03  peter
+   Revision 1.47  2003-07-02 22:18:04  peter
+     * paraloc splitted in callerparaloc,calleeparaloc
+     * sparc calling convention updates
+
+   Revision 1.46  2003/06/17 16:32:03  peter
      * allocpara/freepara 64bit support
      * allocpara/freepara 64bit support
 
 
    Revision 1.45  2003/06/13 21:19:30  peter
    Revision 1.45  2003/06/13 21:19:30  peter

+ 5 - 3
compiler/pdecl.pas

@@ -219,7 +219,6 @@ implementation
                        end;
                        end;
                       { add default calling convention }
                       { add default calling convention }
                       handle_calling_convention(tabstractprocdef(tt.def));
                       handle_calling_convention(tabstractprocdef(tt.def));
-                      paramanager.create_param_loc_info(tabstractprocdef(tt.def));
                     end;
                     end;
                    if not skipequal then
                    if not skipequal then
                     begin
                     begin
@@ -492,7 +491,6 @@ implementation
                         consume(_SEMICOLON);
                         consume(_SEMICOLON);
                        parse_var_proc_directives(tsym(newtype));
                        parse_var_proc_directives(tsym(newtype));
                      end;
                      end;
-                    paramanager.create_param_loc_info(tabstractprocdef(tt.def));
                   end;
                   end;
                 objectdef,
                 objectdef,
                 recorddef :
                 recorddef :
@@ -633,7 +631,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.67  2003-04-27 11:21:33  peter
+  Revision 1.68  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.67  2003/04/27 11:21:33  peter
     * aktprocdef renamed to current_procdef
     * aktprocdef renamed to current_procdef
     * procinfo renamed to current_procinfo
     * procinfo renamed to current_procinfo
     * procinfo will now be stored in current_module so it can be
     * procinfo will now be stored in current_module so it can be

+ 5 - 5
compiler/pdecsub.pas

@@ -2161,17 +2161,17 @@ const
            inc(aprocsym.overloadcount);
            inc(aprocsym.overloadcount);
          end;
          end;
 
 
-        { recalculate the parameter info as the procdef
-          can be updated }
-        paramanager.create_param_loc_info(pd);
-
         proc_add_definition:=forwardfound;
         proc_add_definition:=forwardfound;
       end;
       end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.128  2003-06-13 21:19:31  peter
+  Revision 1.129  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.128  2003/06/13 21:19:31  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.127  2003/06/05 20:04:43  peter
   Revision 1.127  2003/06/05 20:04:43  peter

+ 5 - 2
compiler/pdecvar.pas

@@ -346,7 +346,6 @@ implementation
                begin
                begin
                   newtype:=ttypesym.create('unnamed',tt);
                   newtype:=ttypesym.create('unnamed',tt);
                   parse_var_proc_directives(tsym(newtype));
                   parse_var_proc_directives(tsym(newtype));
-                  paramanager.create_param_loc_info(tabstractprocdef(tt.def));
                   newtype.restype.def:=nil;
                   newtype.restype.def:=nil;
                   tt.def.typesym:=nil;
                   tt.def.typesym:=nil;
                   newtype.free;
                   newtype.free;
@@ -602,7 +601,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2003-05-09 17:47:03  peter
+  Revision 1.48  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.47  2003/05/09 17:47:03  peter
     * self moved to hidden parameter
     * self moved to hidden parameter
     * removed hdisposen,hnewn,selfn
     * removed hdisposen,hnewn,selfn
 
 

+ 61 - 57
compiler/powerpc/cgcpu.pas

@@ -63,7 +63,7 @@ unit cgcpu;
         procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
         procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
 
 
         { fpu move instructions }
         { fpu move instructions }
-        procedure a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister); override;
+        procedure a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister); override;
         procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
         procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
         procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
         procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
 
 
@@ -205,7 +205,7 @@ const
 {$ifndef newra}
 {$ifndef newra}
                free_scratch_reg(list,tmpreg);
                free_scratch_reg(list,tmpreg);
 {$else newra}
 {$else newra}
-               rg.ungetregisterint(list,tmpreg); 
+               rg.ungetregisterint(list,tmpreg);
 {$endif newra}
 {$endif newra}
             end;
             end;
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
@@ -297,9 +297,9 @@ const
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
 {$ifndef newra}
 {$ifndef newra}
             free_scratch_reg(list,tmpreg);
             free_scratch_reg(list,tmpreg);
-{$else newra}            
+{$else newra}
             rg.ungetregisterint(list,tmpreg);
             rg.ungetregisterint(list,tmpreg);
-{$endif newra}            
+{$endif newra}
           end
           end
         else
         else
           list.concat(taicpu.op_reg(A_MTCTR,reg));
           list.concat(taicpu.op_reg(A_MTCTR,reg));
@@ -323,9 +323,9 @@ const
       begin
       begin
 {$ifndef newra}
 {$ifndef newra}
         tmpreg := get_scratch_reg_int(list,OS_ADDR);
         tmpreg := get_scratch_reg_int(list,OS_ADDR);
-{$else newra}            
+{$else newra}
         tmpreg := rg.getregisterint(list,OS_ADDR);
         tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}            
+{$endif newra}
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         if target_info.system=system_powerpc_macos then
         if target_info.system=system_powerpc_macos then
           begin
           begin
@@ -343,7 +343,7 @@ const
         free_scratch_reg(list,tmpreg);
         free_scratch_reg(list,tmpreg);
 {$else newra}
 {$else newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-{$endif newra} 
+{$endif newra}
         list.concat(taicpu.op_none(A_BCTRL));
         list.concat(taicpu.op_none(A_BCTRL));
         //if target_info.system=system_powerpc_macos then
         //if target_info.system=system_powerpc_macos then
         //  //NOP is not needed here.
         //  //NOP is not needed here.
@@ -482,7 +482,7 @@ const
        end;
        end;
 
 
 
 
-     procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister);
+     procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister);
 
 
        begin
        begin
          list.concat(taicpu.op_reg_reg(A_FMR,reg2,reg1));
          list.concat(taicpu.op_reg_reg(A_FMR,reg2,reg1));
@@ -810,14 +810,14 @@ const
 {$ifndef newra}
 {$ifndef newra}
                 scratch_register := get_scratch_reg_int(list,OS_INT);
                 scratch_register := get_scratch_reg_int(list,OS_INT);
 {$else newra}
 {$else newra}
-                scratch_register := rg.getregisterint(list,OS_INT);        
+                scratch_register := rg.getregisterint(list,OS_INT);
 {$endif newra}
 {$endif newra}
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
 {$ifndef newra}
 {$ifndef newra}
                 free_scratch_reg(list,scratch_register);
                 free_scratch_reg(list,scratch_register);
 {$else newra}
 {$else newra}
-                rg.ungetregisterint(list,scratch_register);        
+                rg.ungetregisterint(list,scratch_register);
 {$endif newra}
 {$endif newra}
               end
               end
           else
           else
@@ -1235,11 +1235,11 @@ const
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 while assigned(hp) do
                 while assigned(hp) do
                   begin
                   begin
-                    if (hp.paraloc.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
+                    if (hp.calleeparaloc.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                       begin
                       begin
                         reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
                         reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
-                        reference_reset_base(href2,r,hp.paraloc.reference.offset);
-                        cg.a_load_ref_ref(list,hp.paraloc.size,hp.paraloc.size,href2,href);
+                        reference_reset_base(href2,r,hp.calleeparaloc.reference.offset);
+                        cg.a_load_ref_ref(list,hp.calleeparaloc.size,hp.calleeparaloc.size,href2,href);
                       end;
                       end;
                     hp := tparaitem(hp.next);
                     hp := tparaitem(hp.next);
                   end;
                   end;
@@ -1853,9 +1853,9 @@ const
          if freereg then
          if freereg then
 {$ifndef newra}
 {$ifndef newra}
            cg.free_scratch_reg(list,ref2.base);
            cg.free_scratch_reg(list,ref2.base);
-{$else newra}                         
+{$else newra}
            rg.ungetregisterint(list,ref2.base);
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}                         
+{$endif newra}
        end;
        end;
 
 
 { ************* concatcopy ************ }
 { ************* concatcopy ************ }
@@ -1959,9 +1959,9 @@ const
           begin
           begin
 {$ifndef newra}
 {$ifndef newra}
             dst.base := get_scratch_reg_address(list);
             dst.base := get_scratch_reg_address(list);
-{$else newra}                                                
+{$else newra}
             dst.base := rg.getregisterint(list,OS_ADDR);
             dst.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}      
+{$endif newra}
             a_loadaddr_ref_reg(list,dest,dst.base);
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
             orgdst := false;
           end
           end
@@ -1985,9 +1985,9 @@ const
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
 {$ifndef newra}
 {$ifndef newra}
             countreg := get_scratch_reg_int(list,OS_INT);
             countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}                                                
-            countreg := rg.getregisterint(list,OS_INT);                         
-{$endif newra}                                                
+{$else newra}
+            countreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
@@ -2002,9 +2002,9 @@ const
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
 {$ifndef newra}
 {$ifndef newra}
             free_scratch_reg(list,countreg);
             free_scratch_reg(list,countreg);
-{$else newra}                                                
-           rg.ungetregisterint(list,countreg);                         
-{$endif newra}                                                
+{$else newra}
+           rg.ungetregisterint(list,countreg);
+{$endif newra}
             a_reg_dealloc(list,r);
             a_reg_dealloc(list,r);
             len := len mod 8;
             len := len mod 8;
           end;
           end;
@@ -2051,9 +2051,9 @@ const
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
 {$ifndef newra}
 {$ifndef newra}
             countreg := get_scratch_reg_int(list,OS_INT);
             countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}                                                
-            countreg := rg.getregisterint(list,OS_INT);                         
-{$endif newra}                                                
+{$else newra}
+            countreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
@@ -2068,9 +2068,9 @@ const
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
 {$ifndef newra}
 {$ifndef newra}
             free_scratch_reg(list,countreg);
             free_scratch_reg(list,countreg);
-{$else newra}                                                
-           rg.ungetregisterint(list,countreg);                         
-{$endif newra}                                                
+{$else newra}
+           rg.ungetregisterint(list,countreg);
+{$endif newra}
             a_reg_dealloc(list,r);
             a_reg_dealloc(list,r);
             len := len mod 4;
             len := len mod 4;
           end;
           end;
@@ -2122,15 +2122,15 @@ const
        else
        else
 {$ifndef newra}
 {$ifndef newra}
          free_scratch_reg(list,src.base);
          free_scratch_reg(list,src.base);
-{$else newra}                                                
-         rg.ungetregisterint(list,src.base);                         
-{$endif newra}                                                
+{$else newra}
+         rg.ungetregisterint(list,src.base);
+{$endif newra}
        if not orgdst then
        if not orgdst then
 {$ifndef newra}
 {$ifndef newra}
          free_scratch_reg(list,dst.base);
          free_scratch_reg(list,dst.base);
-{$else newra}                                                
-         rg.ungetregisterint(list,dest.base);                         
-{$endif newra}                                                
+{$else newra}
+         rg.ungetregisterint(list,dest.base);
+{$endif newra}
        if delsource then
        if delsource then
          tg.ungetiftemp(list,source);
          tg.ungetiftemp(list,source);
       end;
       end;
@@ -2320,9 +2320,9 @@ const
                  result := true;
                  result := true;
 {$ifndef newra}
 {$ifndef newra}
                  tmpreg := cg.get_scratch_reg_int(list,OS_INT);
                  tmpreg := cg.get_scratch_reg_int(list,OS_INT);
-{$else newra}                                                
-                 tmpreg := rg.getregisterint(list,OS_INT);                         
-{$endif newra}                                                
+{$else newra}
+                 tmpreg := rg.getregisterint(list,OS_INT);
+{$endif newra}
                  if not assigned(ref.symbol) and
                  if not assigned(ref.symbol) and
                     (cardinal(ref.offset-low(smallint)) <=
                     (cardinal(ref.offset-low(smallint)) <=
                       high(smallint)-low(smallint)) then
                       high(smallint)-low(smallint)) then
@@ -2445,9 +2445,9 @@ const
 
 
 {$ifndef newra}
 {$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
-{$else newra}                                                
-                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
-{$endif newra}                                                
+{$else newra}
+                        tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := ref.offset;
                         tmpref.offset := ref.offset;
@@ -2464,9 +2464,9 @@ const
                       begin
                       begin
 {$ifndef newra}
 {$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
-{$else newra}                                                
-                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
-{$endif newra}                                                
+{$else newra}
+                        tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := 0;
                         tmpref.offset := 0;
@@ -2503,9 +2503,9 @@ const
                       begin
                       begin
 {$ifndef newra}
 {$ifndef newra}
                         tmpreg := get_scratch_reg_address(list);
                         tmpreg := get_scratch_reg_address(list);
-{$else newra}                                                
-                        tmpreg := rg.getregisterint(list,OS_ADDR);                         
-{$endif newra}                                                
+{$else newra}
+                        tmpreg := rg.getregisterint(list,OS_ADDR);
+{$endif newra}
                         reference_reset(tmpref);
                         reference_reset(tmpref);
                         tmpref.symbol := ref.symbol;
                         tmpref.symbol := ref.symbol;
                         tmpref.offset := 0;
                         tmpref.offset := 0;
@@ -2550,9 +2550,9 @@ const
         if (tmpreg.number <> NR_NO) then
         if (tmpreg.number <> NR_NO) then
 {$ifndef newra}
 {$ifndef newra}
           free_scratch_reg(list,tmpreg);
           free_scratch_reg(list,tmpreg);
-{$else newra}                                                                   
+{$else newra}
           rg.ungetregisterint(list,tmpreg);
           rg.ungetregisterint(list,tmpreg);
-{$endif newra}                                                                  
+{$endif newra}
       end;
       end;
 
 
 
 
@@ -2649,17 +2649,17 @@ const
                     begin
                     begin
 {$ifndef newra}
 {$ifndef newra}
                       tmpreg := cg.get_scratch_reg_int(list,OS_32);
                       tmpreg := cg.get_scratch_reg_int(list,OS_32);
-{$else newra}                                                                   
+{$else newra}
                       tmpreg := rg.getregisterint(list,OS_32);
                       tmpreg := rg.getregisterint(list,OS_32);
-{$endif newra}                                                                  
+{$endif newra}
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                         regdst.reglo,regsrc.reglo,tmpreg));
                         regdst.reglo,regsrc.reglo,tmpreg));
 {$ifndef newra}
 {$ifndef newra}
                       cg.free_scratch_reg(list,tmpreg);
                       cg.free_scratch_reg(list,tmpreg);
-{$else newra}                                                                   
+{$else newra}
                       rg.ungetregisterint(list,tmpreg);
                       rg.ungetregisterint(list,tmpreg);
-{$endif newra}                                                                  
+{$endif newra}
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                         regdst.reghi,regsrc.reghi));
                         regdst.reghi,regsrc.reghi));
                     end
                     end
@@ -2668,10 +2668,10 @@ const
 {$ifndef newra}
 {$ifndef newra}
                       tmpreg64.reglo := cg.get_scratch_reg_int(list,OS_32);
                       tmpreg64.reglo := cg.get_scratch_reg_int(list,OS_32);
                       tmpreg64.reghi := cg.get_scratch_reg_int(list,OS_32);
                       tmpreg64.reghi := cg.get_scratch_reg_int(list,OS_32);
-{$else newra}                                                                   
+{$else newra}
                       tmpreg64.reglo := rg.getregisterint(list,OS_32);
                       tmpreg64.reglo := rg.getregisterint(list,OS_32);
                       tmpreg64.reghi := rg.getregisterint(list,OS_32);
                       tmpreg64.reghi := rg.getregisterint(list,OS_32);
-{$endif newra}                                                                  
+{$endif newra}
                       a_load64_const_reg(list,value,tmpreg64);
                       a_load64_const_reg(list,value,tmpreg64);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
 {$ifndef newra}
 {$ifndef newra}
@@ -2679,7 +2679,7 @@ const
                       cg.free_scratch_reg(list,tmpreg64.reglo);
                       cg.free_scratch_reg(list,tmpreg64.reglo);
 {$else newra}
 {$else newra}
                       rg.ungetregisterint(list,tmpreg64.reglo);
                       rg.ungetregisterint(list,tmpreg64.reglo);
-                      rg.ungetregisterint(list,tmpreg64.reghi);  
+                      rg.ungetregisterint(list,tmpreg64.reghi);
 {$endif newra}
 {$endif newra}
                     end
                     end
                 end
                 end
@@ -2702,7 +2702,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.110  2003-06-18 10:12:36  olle
+  Revision 1.111  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.110  2003/06/18 10:12:36  olle
     * macos: fixes of loading-code
     * macos: fixes of loading-code
 
 
   Revision 1.109  2003/06/14 22:32:43  jonas
   Revision 1.109  2003/06/14 22:32:43  jonas

+ 37 - 30
compiler/powerpc/cpupara.pas

@@ -38,7 +38,7 @@ unit cpupara;
           function push_addr_param(def : tdef;calloption : tproccalloption) : boolean;override;
           function push_addr_param(def : tdef;calloption : tproccalloption) : boolean;override;
           function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
           function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
           procedure freeintparaloc(list: taasmoutput; nr : longint); override;
           procedure freeintparaloc(list: taasmoutput; nr : longint); override;
-          procedure create_param_loc_info(p : tabstractprocdef);override;
+          procedure create_paraloc_info(p : tabstractprocdef);override;
           function getfuncretparaloc(p : tabstractprocdef) : tparalocation;override;
           function getfuncretparaloc(p : tabstractprocdef) : tparalocation;override;
        end;
        end;
 
 
@@ -167,11 +167,12 @@ unit cpupara;
         end;
         end;
       end;
       end;
 
 
-    procedure tppcparamanager.create_param_loc_info(p : tabstractprocdef);
+    procedure tppcparamanager.create_paraloc_info(p : tabstractprocdef);
 
 
       var
       var
          nextintreg,nextfloatreg,nextmmreg : tregister;
          nextintreg,nextfloatreg,nextmmreg : tregister;
          paradef : tdef;
          paradef : tdef;
+         paraloc : tparalocation;
          stack_offset : aword;
          stack_offset : aword;
          hp : tparaitem;
          hp : tparaitem;
          loc : tcgloc;
          loc : tcgloc;
@@ -182,18 +183,18 @@ unit cpupara;
         begin
         begin
            if nextintreg.number<=NR_R10 then
            if nextintreg.number<=NR_R10 then
              begin
              begin
-                hp.paraloc.loc:=LOC_REGISTER;
-                hp.paraloc.register:=nextintreg;
+                paraloc.loc:=LOC_REGISTER;
+                paraloc.register:=nextintreg;
                 inc(nextintreg.number,NR_R1-NR_R0);
                 inc(nextintreg.number,NR_R1-NR_R0);
                 if target_info.abi=abi_powerpc_aix then
                 if target_info.abi=abi_powerpc_aix then
                   inc(stack_offset,4);
                   inc(stack_offset,4);
              end
              end
            else
            else
               begin
               begin
-                 hp.paraloc.loc:=LOC_REFERENCE;
-                 hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                 hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                 hp.paraloc.reference.offset:=stack_offset;
+                 paraloc.loc:=LOC_REFERENCE;
+                 paraloc.reference.index.enum:=R_INTREGISTER;
+                 paraloc.reference.index.number:=NR_STACK_POINTER_REG;
+                 paraloc.reference.offset:=stack_offset;
                  inc(stack_offset,4);
                  inc(stack_offset,4);
              end;
              end;
         end;
         end;
@@ -229,28 +230,28 @@ unit cpupara;
                 paradef := hp.paratype.def;
                 paradef := hp.paratype.def;
               loc:=getparaloc(paradef);
               loc:=getparaloc(paradef);
               { make sure all alignment bytes are 0 as well }
               { make sure all alignment bytes are 0 as well }
-              fillchar(hp.paraloc,sizeof(hp.paraloc),0);
+              fillchar(paraloc,sizeof(paraloc),0);
               case loc of
               case loc of
                  LOC_REGISTER:
                  LOC_REGISTER:
                    begin
                    begin
-                      hp.paraloc.size := def_cgsize(paradef);
+                      paraloc.size := def_cgsize(paradef);
                       { for things like formaldef }
                       { for things like formaldef }
-                      if hp.paraloc.size = OS_NO then
-                        hp.paraloc.size := OS_ADDR;
-                      is_64bit := hp.paraloc.size in [OS_64,OS_S64];
+                      if paraloc.size = OS_NO then
+                        paraloc.size := OS_ADDR;
+                      is_64bit := paraloc.size in [OS_64,OS_S64];
                       if nextintreg.number<=(NR_R10-ord(is_64bit)*(NR_R1-NR_R0))  then
                       if nextintreg.number<=(NR_R10-ord(is_64bit)*(NR_R1-NR_R0))  then
                         begin
                         begin
-                           hp.paraloc.loc:=LOC_REGISTER;
+                           paraloc.loc:=LOC_REGISTER;
 		           if is_64bit then
 		           if is_64bit then
                              begin
                              begin
 			       if odd((nextintreg.number-NR_R3) shr 8) and (target_info.abi=abi_powerpc_sysv) Then
 			       if odd((nextintreg.number-NR_R3) shr 8) and (target_info.abi=abi_powerpc_sysv) Then
                                 inc(nextintreg.number,NR_R1-NR_R0);
                                 inc(nextintreg.number,NR_R1-NR_R0);
-                               hp.paraloc.registerhigh:=nextintreg;
+                               paraloc.registerhigh:=nextintreg;
                                inc(nextintreg.number,NR_R1-NR_R0);
                                inc(nextintreg.number,NR_R1-NR_R0);
                                if target_info.abi=abi_powerpc_aix then
                                if target_info.abi=abi_powerpc_aix then
                                  inc(stack_offset,4);
                                  inc(stack_offset,4);
                              end;
                              end;
-                           hp.paraloc.registerlow:=nextintreg;
+                           paraloc.registerlow:=nextintreg;
                            inc(nextintreg.number,NR_R1-NR_R0);
                            inc(nextintreg.number,NR_R1-NR_R0);
                            if target_info.abi=abi_powerpc_aix then
                            if target_info.abi=abi_powerpc_aix then
                              inc(stack_offset,4);
                              inc(stack_offset,4);
@@ -259,10 +260,10 @@ unit cpupara;
                       else
                       else
                          begin
                          begin
                             nextintreg.number := NR_R11;
                             nextintreg.number := NR_R11;
-                            hp.paraloc.loc:=LOC_REFERENCE;
-                            hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                            hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                            hp.paraloc.reference.offset:=stack_offset;
+                            paraloc.loc:=LOC_REFERENCE;
+                            paraloc.reference.index.enum:=R_INTREGISTER;
+                            paraloc.reference.index.number:=NR_STACK_POINTER_REG;
+                            paraloc.reference.offset:=stack_offset;
                             if not is_64bit then
                             if not is_64bit then
                               inc(stack_offset,4)
                               inc(stack_offset,4)
                             else
                             else
@@ -271,11 +272,11 @@ unit cpupara;
                    end;
                    end;
                  LOC_FPUREGISTER:
                  LOC_FPUREGISTER:
                    begin
                    begin
-                      hp.paraloc.size:=def_cgsize(paradef);
+                      paraloc.size:=def_cgsize(paradef);
                       if nextfloatreg.enum<=R_F10 then
                       if nextfloatreg.enum<=R_F10 then
                         begin
                         begin
-                           hp.paraloc.loc:=LOC_FPUREGISTER;
-                           hp.paraloc.register:=nextfloatreg;
+                           paraloc.loc:=LOC_FPUREGISTER;
+                           paraloc.register:=nextfloatreg;
                            inc(nextfloatreg.enum);
                            inc(nextfloatreg.enum);
                            if target_info.abi=abi_powerpc_aix then
                            if target_info.abi=abi_powerpc_aix then
                              inc(stack_offset,8);
                              inc(stack_offset,8);
@@ -283,29 +284,31 @@ unit cpupara;
                       else
                       else
                          begin
                          begin
                             {!!!!!!!}
                             {!!!!!!!}
-                            hp.paraloc.size:=def_cgsize(paradef);
+                            paraloc.size:=def_cgsize(paradef);
                             internalerror(2002071004);
                             internalerror(2002071004);
                         end;
                         end;
                    end;
                    end;
                  LOC_REFERENCE:
                  LOC_REFERENCE:
                    begin
                    begin
-                      hp.paraloc.size:=OS_ADDR;
+                      paraloc.size:=OS_ADDR;
                       if push_addr_param(paradef,p.proccalloption) or
                       if push_addr_param(paradef,p.proccalloption) or
                         is_open_array(paradef) or
                         is_open_array(paradef) or
                         is_array_of_const(paradef) then
                         is_array_of_const(paradef) then
                         assignintreg
                         assignintreg
                       else
                       else
                         begin
                         begin
-                           hp.paraloc.loc:=LOC_REFERENCE;
-                           hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                           hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                           hp.paraloc.reference.offset:=stack_offset;
+                           paraloc.loc:=LOC_REFERENCE;
+                           paraloc.reference.index.enum:=R_INTREGISTER;
+                           paraloc.reference.index.number:=NR_STACK_POINTER_REG;
+                           paraloc.reference.offset:=stack_offset;
                            inc(stack_offset,hp.paratype.def.size);
                            inc(stack_offset,hp.paratype.def.size);
                         end;
                         end;
                    end;
                    end;
                  else
                  else
                    internalerror(2002071002);
                    internalerror(2002071002);
               end;
               end;
+              hp.callerparaloc:=paraloc;
+              hp.calleeparaloc:=paraloc;
               hp:=tparaitem(hp.next);
               hp:=tparaitem(hp.next);
            end;
            end;
       end;
       end;
@@ -371,7 +374,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2003-06-17 17:27:08  jonas
+  Revision 1.40  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.39  2003/06/17 17:27:08  jonas
     - removed allocparaloc/freeparaloc, generic ones are ok now
     - removed allocparaloc/freeparaloc, generic ones are ok now
 
 
   Revision 1.38  2003/06/17 16:34:44  jonas
   Revision 1.38  2003/06/17 16:34:44  jonas

+ 11 - 7
compiler/regvars.pas

@@ -183,15 +183,15 @@ implementation
                   hp:=tparaitem(current_procinfo.procdef.para.first);
                   hp:=tparaitem(current_procinfo.procdef.para.first);
                   while assigned(hp) do
                   while assigned(hp) do
                     begin
                     begin
-                      if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,
+                      if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,
                             LOC_CREGISTER,LOC_CFPUREGISTER]) and
                             LOC_CREGISTER,LOC_CFPUREGISTER]) and
-                         (TCGSize2Size[hp.paraloc.size] <= sizeof(aword)) then
+                         (TCGSize2Size[hp.calleeparaloc.size] <= sizeof(aword)) then
                         begin
                         begin
-                          tvarsym(hp.parasym).reg := hp.paraloc.register;
-                          if (hp.paraloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
-                            rg.makeregvarint(hp.paraloc.register.number shr 8)
+                          tvarsym(hp.parasym).reg := hp.calleeparaloc.register;
+                          if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+                            rg.makeregvarint(hp.calleeparaloc.register.number shr 8)
                           else
                           else
-                            rg.makeregvarother(hp.paraloc.register);
+                            rg.makeregvarother(hp.calleeparaloc.register);
                         end
                         end
                       else
                       else
                         begin
                         begin
@@ -616,7 +616,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2003-06-13 21:19:31  peter
+  Revision 1.58  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.57  2003/06/13 21:19:31  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.56  2003/06/07 18:57:04  jonas
   Revision 1.56  2003/06/07 18:57:04  jonas

+ 5 - 2
compiler/rgobj.pas

@@ -17,7 +17,6 @@
     You should have received a copy of the GNU General Public License
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
  ****************************************************************************
  ****************************************************************************
 }
 }
 
 
@@ -2456,7 +2455,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.56  2003-06-17 16:34:44  jonas
+  Revision 1.57  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.56  2003/06/17 16:34:44  jonas
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * renamed all_intregisters to volatile_intregisters and made it
     * renamed all_intregisters to volatile_intregisters and made it
       processor dependent
       processor dependent

+ 118 - 32
compiler/sparc/cgcpu.pas

@@ -44,6 +44,10 @@ interface
         procedure a_param_const(list:TAasmOutput;size:tcgsize;a:aword;const LocPara:TParaLocation);override;
         procedure a_param_const(list:TAasmOutput;size:tcgsize;a:aword;const LocPara:TParaLocation);override;
         procedure a_param_ref(list:TAasmOutput;sz:tcgsize;const r:TReference;const LocPara:TParaLocation);override;
         procedure a_param_ref(list:TAasmOutput;sz:tcgsize;const r:TReference;const LocPara:TParaLocation);override;
         procedure a_paramaddr_ref(list:TAasmOutput;const r:TReference;const LocPara:TParaLocation);override;
         procedure a_paramaddr_ref(list:TAasmOutput;const r:TReference;const LocPara:TParaLocation);override;
+        procedure a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);override;
+        procedure a_paramfpu_ref(list : taasmoutput;size : tcgsize;const ref : treference;const locpara : tparalocation);override;
+        procedure a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);override;
+        procedure a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);override;
         procedure a_call_name(list:TAasmOutput;const s:string);override;
         procedure a_call_name(list:TAasmOutput;const s:string);override;
         procedure a_call_reg(list:TAasmOutput;Reg:TRegister);override;
         procedure a_call_reg(list:TAasmOutput;Reg:TRegister);override;
         { General purpose instructions }
         { General purpose instructions }
@@ -59,7 +63,7 @@ interface
         procedure a_load_reg_reg(list:TAasmOutput;FromSize,ToSize:TCgSize;reg1,reg2:tregister);override;
         procedure a_load_reg_reg(list:TAasmOutput;FromSize,ToSize:TCgSize;reg1,reg2:tregister);override;
         procedure a_loadaddr_ref_reg(list:TAasmOutput;const ref:TReference;r:tregister);override;
         procedure a_loadaddr_ref_reg(list:TAasmOutput;const ref:TReference;r:tregister);override;
         { fpu move instructions }
         { fpu move instructions }
-        procedure a_loadfpu_reg_reg(list:TAasmOutput;reg1, reg2:tregister);override;
+        procedure a_loadfpu_reg_reg(list:TAasmOutput;size:tcgsize;reg1, reg2:tregister);override;
         procedure a_loadfpu_ref_reg(list:TAasmOutput;size:tcgsize;const ref:TReference;reg:tregister);override;
         procedure a_loadfpu_ref_reg(list:TAasmOutput;size:tcgsize;const ref:TReference;reg:tregister);override;
         procedure a_loadfpu_reg_ref(list:TAasmOutput;size:tcgsize;reg:tregister;const ref:TReference);override;
         procedure a_loadfpu_reg_ref(list:TAasmOutput;size:tcgsize;reg:tregister;const ref:TReference);override;
         { comparison operations }
         { comparison operations }
@@ -253,16 +257,15 @@ implementation
             a_load_const_reg(list,size,a,locpara.register);
             a_load_const_reg(list,size,a,locpara.register);
           LOC_REFERENCE:
           LOC_REFERENCE:
             begin
             begin
-              reference_reset(ref);
-              ref.base:=locpara.reference.index;
-              ref.offset:=locpara.reference.offset;
+              { Code conventions need the parameters being allocated in %o6+92 }
+              if locpara.reference.offset<92 then
+                InternalError(2002081104);
+              reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
               a_load_const_ref(list,size,a,ref);
               a_load_const_ref(list,size,a,ref);
             end;
             end;
           else
           else
             InternalError(2002122200);
             InternalError(2002122200);
         end;
         end;
-        if locpara.sp_fixup<>0 then
-          InternalError(2002122201);
       end;
       end;
 
 
 
 
@@ -273,17 +276,14 @@ implementation
       begin
       begin
         with LocPara do
         with LocPara do
           case loc of
           case loc of
-            LOC_REGISTER,LOC_CREGISTER:
+            LOC_REGISTER,LOC_CREGISTER :
               a_load_ref_reg(list,sz,sz,r,Register);
               a_load_ref_reg(list,sz,sz,r,Register);
             LOC_REFERENCE:
             LOC_REFERENCE:
               begin
               begin
-                { Code conventions need the parameters being allocated in %o6+92. See
-                  comment on g_stack_frame }
-                if locpara.sp_fixup<92 then
+                { Code conventions need the parameters being allocated in %o6+92 }
+                if locpara.reference.offset<92 then
                   InternalError(2002081104);
                   InternalError(2002081104);
-                reference_reset(ref);
-                ref.base:=locpara.reference.index;
-                ref.offset:=locpara.reference.offset;
+                reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
 {$ifdef newra}
 {$ifdef newra}
                 tmpreg:=rg.getregisterint(list,OS_INT);
                 tmpreg:=rg.getregisterint(list,OS_INT);
 {$else}
 {$else}
@@ -297,17 +297,6 @@ implementation
                 free_scratch_reg(list,tmpreg);
                 free_scratch_reg(list,tmpreg);
 {$endif}
 {$endif}
               end;
               end;
-            LOC_FPUREGISTER,LOC_CFPUREGISTER:
-              begin
-                case sz of
-                  OS_32:
-                    a_loadfpu_ref_reg(list,OS_F32,r,locpara.register);
-                  OS_64:
-                    a_loadfpu_ref_reg(list,OS_F64,r,locpara.register);
-                else
-                  internalerror(2002072801);
-                end;
-              end;
             else
             else
               internalerror(2002081103);
               internalerror(2002081103);
           end;
           end;
@@ -346,6 +335,89 @@ implementation
       end;
       end;
 
 
 
 
+    procedure tcgsparc.a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);
+      var
+        href : treference;
+      begin
+        tg.GetTemp(list,TCGSize2Size[size],tt_normal,href);
+        a_loadfpu_reg_ref(list,size,r,href);
+        a_paramfpu_ref(list,size,href,locpara);
+        tg.Ungettemp(list,href);
+      end;
+
+
+    procedure tcgsparc.a_paramfpu_ref(list : taasmoutput;size : tcgsize;const ref : treference;const locpara : tparalocation);
+      var
+        templocpara : tparalocation;
+      begin
+        { floats are pushed in the int registers }
+        templocpara:=locpara;
+        case locpara.size of
+          OS_F32 :
+            begin
+              templocpara.size:=OS_32;
+              a_param_ref(list,OS_32,ref,templocpara);
+            end;
+          OS_F64 :
+            begin
+              templocpara.size:=OS_64;
+              cg64.a_param64_ref(list,ref,templocpara);
+            end;
+          else
+            internalerror(200307021);
+        end;
+      end;
+
+
+    procedure tcgsparc.a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);
+      var
+        href,
+        tempref : treference;
+        templocpara : tparalocation;
+      begin
+        { Load floats like ints }
+        templocpara:=locpara;
+        case locpara.size of
+          OS_F32 :
+            templocpara.size:=OS_32;
+          OS_F64 :
+            templocpara.size:=OS_64;
+        end;
+        { Word 0 is in register, word 1 is in reference }
+        if (templocpara.loc=LOC_REFERENCE) and (templocpara.low_in_reg) then
+          begin
+            tempref:=ref;
+            cg.a_load_reg_ref(list,OS_INT,OS_INT,templocpara.register,tempref);
+            inc(tempref.offset,4);
+            reference_reset_base(href,templocpara.reference.index,templocpara.reference.offset);
+            cg.a_load_ref_ref(list,OS_INT,OS_INT,href,tempref);
+          end
+        else
+          inherited a_load_param_ref(list,templocpara,ref);
+      end;
+
+
+    procedure tcgsparc.a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);
+      var
+        href : treference;
+      begin
+        { Word 0 is in register, word 1 is in reference, not
+          possible to load it in 1 register }
+        if (locpara.loc=LOC_REFERENCE) and (locpara.low_in_reg) then
+          internalerror(200307011);
+        { Float load use a temp reference }
+        if locpara.size in [OS_F32,OS_F64] then
+          begin
+            tg.GetTemp(list,TCGSize2Size[locpara.size],tt_normal,href);
+            a_load_param_ref(list,locpara,href);
+            a_loadfpu_ref_reg(list,locpara.size,href,reg);
+            tg.Ungettemp(list,href);
+          end
+        else
+          inherited a_load_param_reg(list,locpara,reg);
+      end;
+
+
     procedure TCgSparc.a_call_name(list:TAasmOutput;const s:string);
     procedure TCgSparc.a_call_name(list:TAasmOutput;const s:string);
       begin
       begin
         list.concat(taicpu.op_sym(A_CALL,objectlibrary.newasmsymbol(s)));
         list.concat(taicpu.op_sym(A_CALL,objectlibrary.newasmsymbol(s)));
@@ -559,9 +631,18 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TCgSparc.a_loadfpu_reg_reg(list:TAasmOutput;reg1, reg2:tregister);
+    procedure TCgSparc.a_loadfpu_reg_reg(list:TAasmOutput;size:tcgsize;reg1, reg2:tregister);
       begin
       begin
-        list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
+        if reg1.enum<>reg2.enum then
+          begin
+            list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
+            if size=OS_F64 then
+              begin
+                reg1.enum:=succ(reg1.enum);
+                reg2.enum:=succ(reg2.enum);
+                list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
+              end;
+          end;
       end;
       end;
 
 
 
 
@@ -702,7 +783,7 @@ implementation
       var
       var
         ai:TAiCpu;
         ai:TAiCpu;
       begin
       begin
-        ai:=TAiCpu.Op_sym(A_BA,l);
+        ai:=TAiCpu.Op_sym(A_Bxx,l);
         ai.SetCondition(TOpCmp2AsmCond[cond]);
         ai.SetCondition(TOpCmp2AsmCond[cond]);
         list.Concat(ai);
         list.Concat(ai);
         list.Concat(TAiCpu.Op_none(A_NOP));
         list.Concat(TAiCpu.Op_none(A_NOP));
@@ -713,7 +794,7 @@ implementation
       var
       var
         ai:taicpu;
         ai:taicpu;
       begin
       begin
-        ai := Taicpu.op_sym(A_BA,l);
+        ai := Taicpu.op_sym(A_Bxx,l);
         ai.SetCondition(flags_to_cond(f));
         ai.SetCondition(flags_to_cond(f));
         list.Concat(ai);
         list.Concat(ai);
         list.Concat(TAiCpu.Op_none(A_NOP));
         list.Concat(TAiCpu.Op_none(A_NOP));
@@ -727,7 +808,8 @@ implementation
       begin
       begin
         r.enum:=R_PSR;
         r.enum:=R_PSR;
         ai:=Taicpu.Op_reg_reg(A_RDPSR,r,reg);
         ai:=Taicpu.Op_reg_reg(A_RDPSR,r,reg);
-        ai.SetCondition(flags_to_cond(f));
+{$warning Need to retrieve the correct flag setting in reg}
+//        ai.SetCondition(flags_to_cond(f));
         list.Concat(ai);
         list.Concat(ai);
         list.Concat(TAiCpu.Op_none(A_NOP));
         list.Concat(TAiCpu.Op_none(A_NOP));
       end;
       end;
@@ -746,7 +828,7 @@ implementation
           begin
           begin
             //r.enum:=R_CR7;
             //r.enum:=R_CR7;
             //list.concat(taicpu.op_reg(A_MCRXR,r));
             //list.concat(taicpu.op_reg(A_MCRXR,r));
-            //a_jmp_cond(list,A_BA,C_OV,hl)
+            //a_jmp_cond(list,A_Bxx,C_OV,hl)
             a_jmp_always(list,hl)
             a_jmp_always(list,hl)
           end
           end
         else
         else
@@ -1130,7 +1212,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2003-06-17 16:35:56  peter
+  Revision 1.61  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.60  2003/06/17 16:35:56  peter
     * a_loadaddr_ref_reg fixed
     * a_loadaddr_ref_reg fixed
 
 
   Revision 1.59  2003/06/13 21:19:32  peter
   Revision 1.59  2003/06/13 21:19:32  peter
@@ -1301,7 +1387,7 @@ end.
   word alignement modified in g_stack_frame
   word alignement modified in g_stack_frame
 
 
   Revision 1.10  2002/10/04 21:57:42  mazen
   Revision 1.10  2002/10/04 21:57:42  mazen
-  * register allocation for parameters now done in cpupara, but InternalError(200109223) in cgcpu.pas:1053 is still not fixed du to location_force problem in ncgutils.pas:419
+  * register allocation for parameters now done in cpupara
 
 
   Revision 1.9  2002/10/02 22:20:28  mazen
   Revision 1.9  2002/10/02 22:20:28  mazen
   + out registers allocator for the first 6 scalar parameters which must be passed into %o0..%o5
   + out registers allocator for the first 6 scalar parameters which must be passed into %o0..%o5

+ 16 - 12
compiler/sparc/cpubase.pas

@@ -530,9 +530,9 @@ uses
 
 
     const
     const
       cond2str:array[TAsmCond] of string[3]=('',
       cond2str:array[TAsmCond] of string[3]=('',
-        'a','ae','b','be','c','e','g','ge','l','le','na','nae',
-        'nb','nbe','nc','ne','ng','nge','nl','nle','no','np',
-        'ns','nz','o','p','pe','po','s','z'
+        'gu','cc','cs','leu','cs','e','g','ge','l','le','leu','cs',
+        'cc','gu','cc','ne','le','l','ge','g','vc','XX',
+        'pos','ne','vs','XX','XX','XX','vs','e'
       );
       );
 
 
       inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
       inverse_cond:array[TAsmCond] of TAsmCond=(C_None,
@@ -542,12 +542,12 @@ uses
       );
       );
 
 
     const
     const
-      CondAsmOps=3;
+      CondAsmOps=1;
       CondAsmOp:array[0..CondAsmOps-1] of TAsmOp=(
       CondAsmOp:array[0..CondAsmOps-1] of TAsmOp=(
-        A_FCMPd, A_JMPL, A_FCMPs
+        A_Bxx
       );
       );
       CondAsmOpStr:array[0..CondAsmOps-1] of string[7]=(
       CondAsmOpStr:array[0..CondAsmOps-1] of string[7]=(
-        'FCMPd','JMPL','FCMPs'
+        'B'
       );
       );
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -676,7 +676,7 @@ type
          }
          }
          sp_fixup : longint;
          sp_fixup : longint;
          case TCGLoc of
          case TCGLoc of
-            LOC_REFERENCE : (reference : tparareference);
+            LOC_REFERENCE : (reference : tparareference; low_in_reg: boolean; lowreg : tregister);
             LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
             LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
               LOC_REGISTER,LOC_CREGISTER : (
               LOC_REGISTER,LOC_CREGISTER : (
               case longint of
               case longint of
@@ -767,8 +767,8 @@ type
 
 
       maxintregs = 8;
       maxintregs = 8;
       intregs = [R_G0..R_I7];
       intregs = [R_G0..R_I7];
-      usableregsint = [RS_O0..RS_I7];
-      c_countusableregsint = 24;
+      usableregsint = [RS_L0..RS_L7];
+      c_countusableregsint = 8;
 
 
       maxfpuregs = 8;
       maxfpuregs = 8;
       fpuregs=[R_F0..R_F31];
       fpuregs=[R_F0..R_F31];
@@ -785,8 +785,8 @@ type
       usableregsaddr = [];
       usableregsaddr = [];
       c_countusableregsaddr = 0;
       c_countusableregsaddr = 0;
 
 
-      firstsaveintreg = RS_O0;
-      lastsaveintreg = RS_I7;
+      firstsaveintreg = RS_G0; { L0..L7 are already saved, I0..O7 are parameter }
+      lastsaveintreg = RS_G7;
       firstsavefpureg = R_F0;
       firstsavefpureg = R_F0;
       lastsavefpureg = R_F31;
       lastsavefpureg = R_F31;
       firstsavemmreg = R_NO;
       firstsavemmreg = R_NO;
@@ -1051,7 +1051,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2003-06-17 16:34:44  jonas
+  Revision 1.44  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.43  2003/06/17 16:34:44  jonas
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * lots of newra fixes (need getfuncretparaloc implementation for i386)!
     * renamed all_intregisters to volatile_intregisters and made it
     * renamed all_intregisters to volatile_intregisters and made it
       processor dependent
       processor dependent

+ 6 - 5
compiler/sparc/cpugas.pas

@@ -161,10 +161,7 @@ unit cpugas;
         op:=taicpu(hp).opcode;
         op:=taicpu(hp).opcode;
         { call maybe not translated to call }
         { call maybe not translated to call }
         s:=#9+std_op2str[op]+cond2str[taicpu(hp).condition];
         s:=#9+std_op2str[op]+cond2str[taicpu(hp).condition];
-        { process operands }
-        s:=#9+std_op2str[op];
-        if taicpu(hp).ops>0
-        then
+        if taicpu(hp).ops>0 then
           begin
           begin
             s:=s+#9+getopstr(taicpu(hp).oper[0]);
             s:=s+#9+getopstr(taicpu(hp).oper[0]);
             for i:=1 to taicpu(hp).ops-1 do
             for i:=1 to taicpu(hp).ops-1 do
@@ -207,7 +204,11 @@ begin
 end.
 end.
 {
 {
     $Log$
     $Log$
-    Revision 1.19  2003-06-01 21:38:06  peter
+    Revision 1.20  2003-07-02 22:18:04  peter
+      * paraloc splitted in callerparaloc,calleeparaloc
+      * sparc calling convention updates
+
+    Revision 1.19  2003/06/01 21:38:06  peter
       * getregisterfpu size parameter added
       * getregisterfpu size parameter added
       * op_const_reg size parameter added
       * op_const_reg size parameter added
       * sparc updates
       * sparc updates

+ 113 - 170
compiler/sparc/cpupara.pas

@@ -37,10 +37,13 @@ interface
         function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
         function getintparaloc(list: taasmoutput; nr : longint) : tparalocation;override;
         procedure freeintparaloc(list: taasmoutput; nr : longint); override;
         procedure freeintparaloc(list: taasmoutput; nr : longint); override;
         {Creates location information related to the parameter of the function}
         {Creates location information related to the parameter of the function}
-        procedure create_param_loc_info(p:TAbstractProcDef);override;
+        procedure allocparaloc(list: taasmoutput; const loc: tparalocation);override;
+        procedure freeparaloc(list: taasmoutput; const loc: tparalocation);override;
+        procedure create_paraloc_info(p:TAbstractProcDef);override;
         {Returns the location where the invisible parameter for structured function
         {Returns the location where the invisible parameter for structured function
         results will be passed.}
         results will be passed.}
         function GetFuncRetParaLoc(p:TAbstractProcDef):TParaLocation;override;
         function GetFuncRetParaLoc(p:TAbstractProcDef):TParaLocation;override;
+        procedure splitparaloc64(const locpara:tparalocation;var loclopara,lochipara:tparalocation);override;
       end;
       end;
 
 
 
 
@@ -64,16 +67,16 @@ implementation
             begin
             begin
               loc:=LOC_REGISTER;
               loc:=LOC_REGISTER;
               register.enum:=R_INTREGISTER;
               register.enum:=R_INTREGISTER;
-              register.number:=(RS_I0+nr) shl 8;
+              register.number:=(RS_O0+nr) shl 8;
               rg.getexplicitregisterint(list,register.number);
               rg.getexplicitregisterint(list,register.number);
             end
             end
            else
            else
-           { The other parameters are passed into the frame }
+           { The other parameters are passed on the stack }
             begin
             begin
               loc:=LOC_REFERENCE;
               loc:=LOC_REFERENCE;
               reference.index.enum:=R_INTREGISTER;
               reference.index.enum:=R_INTREGISTER;
-              reference.index.number:=NR_FRAME_POINTER_REG;
-              reference.offset:=-68-nr*4;
+              reference.index.number:=NR_STACK_POINTER_REG;
+              reference.offset:=92+(nr-6)*4;
             end;
             end;
            size:=OS_INT;
            size:=OS_INT;
          end;
          end;
@@ -91,75 +94,39 @@ implementation
         Dec(nr);
         Dec(nr);
         if nr<6 then
         if nr<6 then
           begin
           begin
-            r.enum := R_INTREGISTER;
-            r.number:=(RS_I0+nr) shl 8;
+            r.enum:=R_INTREGISTER;
+            r.number:=(RS_O0+nr) shl 8;
             rg.ungetregisterint(list,r);
             rg.ungetregisterint(list,r);
           end;
           end;
       end;
       end;
 
 
 
 
-    function GetParaLoc(p:TDef):TCGLoc;
+    procedure tsparcparamanager.allocparaloc(list: taasmoutput; const loc: tparalocation);
       begin
       begin
-        { Later, the LOC_REFERENCE is in most cases changed into
-          LOC_REGISTER if push_addr_param for the def is true}
-        case p.DefType of
-          OrdDef:
-            GetParaLoc:=LOC_REGISTER;
-          FloatDef:
-            GetParaLoc:=LOC_FPUREGISTER;
-          enumdef:
-            getparaloc:=LOC_REGISTER;
-          pointerdef:
-            getparaloc:=LOC_REGISTER;
-          formaldef:
-            getparaloc:=LOC_REGISTER;
-          classrefdef:
-            getparaloc:=LOC_REGISTER;
-          recorddef:
-            getparaloc:=LOC_REFERENCE;
-          objectdef:
-            if is_object(p) then
-              getparaloc:=LOC_REFERENCE
-            else
-              getparaloc:=LOC_REGISTER;
-          stringdef:
-            if is_shortstring(p) or is_longstring(p) then
-              getparaloc:=LOC_REFERENCE
-            else
-              getparaloc:=LOC_REGISTER;
-          procvardef:
-            if (po_methodpointer in tprocvardef(p).procoptions) then
-              getparaloc:=LOC_REFERENCE
-            else
-              getparaloc:=LOC_REGISTER;
-          filedef:
-            getparaloc:=LOC_REGISTER;
-          arraydef:
-            getparaloc:=LOC_REFERENCE;
-          setdef:
-            if is_smallset(p) then
-              getparaloc:=LOC_REGISTER
-            else
-              getparaloc:=LOC_REFERENCE;
-          variantdef:
-            getparaloc:=LOC_REFERENCE;
-          { avoid problems with errornous definitions }
-          errordef:
-            getparaloc:=LOC_REGISTER;
-          else
-            internalerror(2002071001);
-        end;
+        if (loc.loc=LOC_REFERENCE) and
+           (loc.low_in_reg) then
+          rg.getexplicitregisterint(list,loc.lowreg.number);
+        inherited allocparaloc(list,loc);
+      end;
+
+
+    procedure tsparcparamanager.freeparaloc(list: taasmoutput; const loc: tparalocation);
+      begin
+        if (loc.loc=LOC_REFERENCE) and
+           (loc.low_in_reg) then
+          rg.ungetregisterint(list,loc.lowreg);
+        inherited freeparaloc(list,loc);
       end;
       end;
 
 
 
 
-    procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
+    procedure TSparcParaManager.create_paraloc_info(p:TAbstractProcDef);
       var
       var
         nextintreg : tsuperregister;
         nextintreg : tsuperregister;
         nextfloatreg : toldregister;
         nextfloatreg : toldregister;
         stack_offset : longint;
         stack_offset : longint;
         hp : tparaitem;
         hp : tparaitem;
-        loc : tcgloc;
         is_64bit : boolean;
         is_64bit : boolean;
+        paraloc : tparalocation;
       begin
       begin
         nextintreg:=RS_O0;
         nextintreg:=RS_O0;
         nextfloatreg:=R_F0;
         nextfloatreg:=R_F0;
@@ -167,116 +134,65 @@ implementation
         hp:=TParaItem(p.para.First);
         hp:=TParaItem(p.para.First);
         while assigned(hp) do
         while assigned(hp) do
           begin
           begin
-            loc:=GetParaLoc(hp.paratype.def);
-            case loc of
-              LOC_REGISTER:
-                begin
-                  hp.paraloc.size:=def_cgSize(hp.paratype.def);
-                  if hp.paraloc.size=OS_NO then
-                    hp.paraloc.size:=OS_ADDR;
-                  is_64bit:=(hp.paraloc.size in [OS_64,OS_S64]);
-                  if NextIntReg<=RS_I5-ord(is_64bit) then
-                    begin
-                      hp.paraloc.loc:=LOC_REGISTER;
-                      hp.paraloc.registerlow.enum:=R_INTREGISTER;
-                      hp.paraloc.registerlow.number:=NextIntReg shl 8;
-                      inc(NextIntReg);
-                      if is_64bit then
-                        begin
-                          hp.paraloc.registerhigh.enum:=R_INTREGISTER;
-                          hp.paraloc.registerhigh.number:=nextintreg shl 8;
-                          inc(nextintreg);
-                        end;
-                    end
-                  else
-                    begin
-                      nextintreg:=RS_I6;
-                      hp.paraloc.loc:=LOC_REFERENCE;
-                      hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                      hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                      hp.paraloc.reference.offset:=stack_offset;
-                      if not is_64bit then
-                        inc(stack_offset,4)
-                      else
-                        inc(stack_offset,8);
-                    end;
-                end;
-
-              LOC_FPUREGISTER:
-                begin
-                  if hp.paratyp in [vs_var,vs_out] then
-                    begin
-                      if NextIntReg<=RS_O5 then
-                        begin
-                          hp.paraloc.size:=OS_ADDR;
-                          hp.paraloc.loc:=LOC_REGISTER;
-                          hp.paraloc.register.enum:=R_INTREGISTER;
-                          hp.paraloc.register.number:=nextintreg shl 8;
-                          inc(nextintreg);
-                        end
-                      else
-                        begin
-                          {!!!!!!!}
-                          hp.paraloc.size:=def_cgsize(hp.paratype.def);
-                          internalerror(2002071006);
-                        end;
-                    end
-                  else if nextfloatreg<=R_F10 then
-                    begin
-                      hp.paraloc.size:=def_cgsize(hp.paratype.def);
-                      hp.paraloc.loc:=LOC_FPUREGISTER;
-                      { Doubles use 2 FPU regs, align on even register }
-                      if (hp.paraloc.size<>OS_F32) and
-                         odd(ord(nextfloatreg)-ord(R_F0)) then
-                        inc(nextfloatreg);
-                      hp.paraloc.register.enum:=nextfloatreg;
-                      inc(nextfloatreg);
-                      { Doubles use 2 FPU regs }
-                      if hp.paraloc.size<>OS_F32 then
-                        inc(nextfloatreg);
-                    end
-                  else
-                    begin
-                      {!!!!!!!}
-                      hp.paraloc.size:=def_cgsize(hp.paratype.def);
-                      internalerror(2002071004);
-                    end;
-                end;
-
-              LOC_REFERENCE:
-                begin
-                   hp.paraloc.size:=OS_ADDR;
-                   if push_addr_param(hp.paratype.def,p.proccalloption) or (hp.paratyp in [vs_var,vs_out]) then
-                     begin
-                        if nextintreg<=RS_O5 then
-                          begin
-                             hp.paraloc.loc:=LOC_REGISTER;
-                             hp.paraloc.register.enum:=R_INTREGISTER;
-                             hp.paraloc.register.number:=nextintreg shl 8;
-                             inc(nextintreg);
-                          end
-                        else
-                           begin
-                              hp.paraloc.loc:=LOC_REFERENCE;
-                              hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                              hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                              hp.paraloc.reference.offset:=stack_offset;
-                              inc(stack_offset,4);
-                          end;
-                     end
-                   else
-                     begin
-                        hp.paraloc.loc:=LOC_REFERENCE;
-                        hp.paraloc.reference.index.enum:=R_INTREGISTER;
-                        hp.paraloc.reference.index.number:=NR_STACK_POINTER_REG;
-                        hp.paraloc.reference.offset:=stack_offset;
-                        inc(stack_offset,hp.paratype.def.size);
-                     end;
-                end;
-
-              else
-                internalerror(2002071002);
-            end;
+            fillchar(paraloc,sizeof(tparalocation),0);
+            if push_addr_param(hp.paratype.def,p.proccalloption) or (hp.paratyp in [vs_var,vs_out]) then
+              paraloc.size:=OS_ADDR
+            else
+              begin
+                paraloc.size:=def_cgSize(hp.paratype.def);
+                if paraloc.size=OS_NO then
+                  paraloc.size:=OS_ADDR;
+              end;
+            is_64bit:=(paraloc.size in [OS_64,OS_S64,OS_F64]);
+            if NextIntReg<=RS_O5-ord(is_64bit) then
+              begin
+                paraloc.loc:=LOC_REGISTER;
+                paraloc.registerlow.enum:=R_INTREGISTER;
+                paraloc.registerlow.number:=NextIntReg shl 8;
+                inc(NextIntReg);
+                if is_64bit then
+                  begin
+                    paraloc.registerhigh.enum:=R_INTREGISTER;
+                    paraloc.registerhigh.number:=nextintreg shl 8;
+                    inc(nextintreg);
+                  end;
+              end
+            else
+              begin
+                paraloc.loc:=LOC_REFERENCE;
+                { Low part need to be in O5 if still available }
+                if NextIntReg<=RS_O5 then
+                  begin
+                    paraloc.low_in_reg:=true;
+                    paraloc.lowreg.enum:=R_INTREGISTER;
+                    paraloc.lowreg.number:=nextintreg shl 8;
+                  end;
+                nextintreg:=RS_O6;
+                paraloc.reference.index.enum:=R_INTREGISTER;
+                paraloc.reference.index.number:=NR_STACK_POINTER_REG;
+                paraloc.reference.offset:=stack_offset;
+                if is_64bit and
+                   (not paraloc.low_in_reg) then
+                  inc(stack_offset,8)
+                else
+                  inc(stack_offset,4);
+              end;
+            hp.callerparaloc:=paraloc;
+            { update callee paraloc and use Ix registers instead
+              of Ox registers }
+            hp.calleeparaloc:=paraloc;
+            if hp.calleeparaloc.loc=LOC_REGISTER then
+              begin
+                inc(hp.calleeparaloc.registerlow.number,(RS_I0-RS_O0) shl 8);
+                if is_64bit then
+                  inc(hp.calleeparaloc.registerhigh.number,(RS_I0-RS_O0) shl 8);
+              end
+            else
+              begin
+                if hp.calleeparaloc.low_in_reg then
+                  inc(hp.calleeparaloc.lowreg.number,(RS_I0-RS_O0) shl 8);
+                inc(hp.calleeparaloc.reference.index.number,(RS_I0-RS_O0) shl 8);
+              end;
             hp:=TParaItem(hp.Next);
             hp:=TParaItem(hp.Next);
           end;
           end;
       end;
       end;
@@ -327,12 +243,39 @@ implementation
          end;
          end;
       end;
       end;
 
 
+
+    procedure tsparcparamanager.splitparaloc64(const locpara:tparalocation;var loclopara,lochipara:tparalocation);
+      begin
+        { Word 0 is in register, word 1 is in reference }
+        if (locpara.loc=LOC_REFERENCE) and locpara.low_in_reg then
+          begin
+            { high }
+            lochipara:=locpara;
+            if locpara.size=OS_S64 then
+              lochipara.size:=OS_S32
+            else
+              lochipara.size:=OS_32;
+            lochipara.low_in_reg:=false;
+            { low }
+            loclopara:=locpara;
+            loclopara.size:=OS_32;
+            loclopara.loc:=LOC_REGISTER;
+            loclopara.register:=locpara.lowreg;
+          end
+        else
+          inherited splitparaloc64(locpara,loclopara,lochipara);
+      end;
+
 begin
 begin
    ParaManager:=TSparcParaManager.create;
    ParaManager:=TSparcParaManager.create;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2003-06-17 16:36:59  peter
+  Revision 1.22  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.21  2003/06/17 16:36:59  peter
     * freeintparaloc
     * freeintparaloc
 
 
   Revision 1.20  2003/06/09 21:44:14  mazen
   Revision 1.20  2003/06/09 21:44:14  mazen

+ 7 - 3
compiler/sparc/opcode.inc

@@ -8,8 +8,7 @@ A_AND,A_ANDcc,A_ANDN,A_ADDNcc,
 {Branching instructions}
 {Branching instructions}
 A_JMPL,
 A_JMPL,
 A_CALL,
 A_CALL,
-A_BN,A_BNE,A_BE,A_BG,A_BLE,A_BGE,A_BL,A_BGU,A_BLEU,A_BCC,
-A_BCS,A_BPOS,A_NEG,A_BVC,A_BVS,A_BA,
+A_BA,A_Bxx,
 A_FBN,A_FBU,A_FBG,A_FBUG,A_FBL,A_FBUL,A_FBLG,A_FBNE,
 A_FBN,A_FBU,A_FBG,A_FBUG,A_FBL,A_FBUL,A_FBLG,A_FBNE,
 A_FBE,A_FBUE,A_FBGE,A_FBUGE,A_FBLE,A_FBULE,A_FBO,A_FBA,
 A_FBE,A_FBUE,A_FBGE,A_FBUGE,A_FBLE,A_FBULE,A_FBO,A_FBA,
 A_CBccc,
 A_CBccc,
@@ -63,13 +62,18 @@ A_cmp,
 A_dec,A_deccc,
 A_dec,A_deccc,
 A_inc,A_inccc,
 A_inc,A_inccc,
 A_MOV,
 A_MOV,
+A_NEG,
 A_not,
 A_not,
 A_set,
 A_set,
 A_skipz,A_skipnz,
 A_skipz,A_skipnz,
 A_tst
 A_tst
 {
 {
         $Log$
         $Log$
-        Revision 1.8  2003-06-01 21:38:07  peter
+        Revision 1.9  2003-07-02 22:18:04  peter
+          * paraloc splitted in callerparaloc,calleeparaloc
+          * sparc calling convention updates
+
+        Revision 1.8  2003/06/01 21:38:07  peter
           * getregisterfpu size parameter added
           * getregisterfpu size parameter added
           * op_const_reg size parameter added
           * op_const_reg size parameter added
           * sparc updates
           * sparc updates

+ 7 - 5
compiler/sparc/rgcpu.pas

@@ -54,8 +54,7 @@ implementation
 
 
     function TRgCpu.GetExplicitRegisterInt(list:TAasmOutput;reg:TNewRegister):TRegister;
     function TRgCpu.GetExplicitRegisterInt(list:TAasmOutput;reg:TNewRegister):TRegister;
       begin
       begin
-        if ((reg shr 8) in [RS_O0..RS_O7,RS_I7]) and
-           not((reg shr 8) in is_reg_var_int) then
+        if ((reg shr 8) in [RS_O0..RS_O7,RS_I0..RS_I7]) then
           begin
           begin
             if (reg shr 8) in UsedParaRegs then
             if (reg shr 8) in UsedParaRegs then
               InternalError(2003060701)
               InternalError(2003060701)
@@ -74,8 +73,7 @@ implementation
       begin
       begin
         if reg.enum<>R_INTREGISTER then
         if reg.enum<>R_INTREGISTER then
           internalerror(200302191);
           internalerror(200302191);
-        if ((reg.number shr 8) in [RS_O0..RS_O7,RS_I7]) and
-           not((reg.number shr 8) in is_reg_var_int) then
+        if ((reg.number shr 8) in [RS_O0..RS_O7,RS_I0..RS_I7]) then
           begin
           begin
             if not((reg.number shr 8) in usedpararegs) then
             if not((reg.number shr 8) in usedpararegs) then
               internalerror(2003060702)
               internalerror(2003060702)
@@ -154,7 +152,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2003-06-17 16:36:11  peter
+  Revision 1.15  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.14  2003/06/17 16:36:11  peter
     * freeintparaloc added
     * freeintparaloc added
 
 
   Revision 1.13  2003/06/12 22:47:52  mazen
   Revision 1.13  2003/06/12 22:47:52  mazen

+ 7 - 3
compiler/sparc/strinst.inc

@@ -7,8 +7,7 @@
           'and','andcc','andn','addncc',
           'and','andcc','andn','addncc',
           'jmpl',
           'jmpl',
           'call',
           'call',
-          'bn','bne','be','bg','ble','bge','bl','bgu','bleu','bcc',
-          'bcs','bpos','neg','bvc','bvs','ba',
+          'ba','b',
           'fbn','fbu','fbg','fbug','fbl','fbul','fblg','fbne',
           'fbn','fbu','fbg','fbug','fbl','fbul','fblg','fbne',
           'fbe','fbue','fbge','fbuge','fble','fbule','fbo','fba',
           'fbe','fbue','fbge','fbuge','fble','fbule','fbo','fba',
           'cbccc',
           'cbccc',
@@ -61,13 +60,18 @@
           'dec','deccc',
           'dec','deccc',
           'inc','inccc',
           'inc','inccc',
           'mov',
           'mov',
+          'neg',
           'not',
           'not',
           'set',
           'set',
           'skipz','skipnz',
           'skipz','skipnz',
           'tst'
           'tst'
 {
 {
         $Log$
         $Log$
-        Revision 1.7  2003-06-01 21:38:07  peter
+        Revision 1.8  2003-07-02 22:18:04  peter
+          * paraloc splitted in callerparaloc,calleeparaloc
+          * sparc calling convention updates
+
+        Revision 1.7  2003/06/01 21:38:07  peter
           * getregisterfpu size parameter added
           * getregisterfpu size parameter added
           * op_const_reg size parameter added
           * op_const_reg size parameter added
           * sparc updates
           * sparc updates

+ 13 - 15
compiler/symdef.pas

@@ -106,11 +106,12 @@ interface
           parasymderef : tderef;
           parasymderef : tderef;
           defaultvalue : tsym; { tconstsym }
           defaultvalue : tsym; { tconstsym }
           defaultvaluederef : tderef;
           defaultvaluederef : tderef;
-          paratyp      : tvarspez; { required for procvar }
-          paraloc      : tparalocation;
-          is_hidden    : boolean; { is this a hidden (implicit) parameter }
+          paratyp       : tvarspez; { required for procvar }
+          calleeparaloc,
+          callerparaloc : tparalocation;
+          is_hidden     : boolean; { is this a hidden (implicit) parameter }
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
-          eqval        : tequaltype;
+          eqval         : tequaltype;
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
        end;
        end;
 
 
@@ -428,6 +429,7 @@ interface
           maxparacount,
           maxparacount,
           minparacount    : byte;
           minparacount    : byte;
           fpu_used        : byte;    { how many stack fpu must be empty }
           fpu_used        : byte;    { how many stack fpu must be empty }
+          has_paraloc_info : boolean; { paraloc info is available }
           constructor create(level:byte);
           constructor create(level:byte);
           constructor ppuload(ppufile:tcompilerppufile);
           constructor ppuload(ppufile:tcompilerppufile);
           destructor destroy;override;
           destructor destroy;override;
@@ -3072,6 +3074,7 @@ implementation
          rettype:=voidtype;
          rettype:=voidtype;
          fpu_used:=0;
          fpu_used:=0;
          savesize:=POINTER_SIZE;
          savesize:=POINTER_SIZE;
+         has_paraloc_info:=false;
       end;
       end;
 
 
 
 
@@ -3201,7 +3204,6 @@ implementation
       var
       var
          hp : TParaItem;
          hp : TParaItem;
          count,i : word;
          count,i : word;
-         paraloclen : byte;
       begin
       begin
          inherited ppuloaddef(ppufile);
          inherited ppuloaddef(ppufile);
          parast:=nil;
          parast:=nil;
@@ -3216,6 +3218,7 @@ implementation
          { get the number of parameters }
          { get the number of parameters }
          count:=ppufile.getbyte;
          count:=ppufile.getbyte;
          savesize:=POINTER_SIZE;
          savesize:=POINTER_SIZE;
+         has_paraloc_info:=false;
          for i:=1 to count do
          for i:=1 to count do
           begin
           begin
             hp:=TParaItem.Create;
             hp:=TParaItem.Create;
@@ -3226,11 +3229,6 @@ implementation
             ppufile.getderef(hp.parasymderef);
             ppufile.getderef(hp.parasymderef);
             hp.parasym:=nil;
             hp.parasym:=nil;
             hp.is_hidden:=boolean(ppufile.getbyte);
             hp.is_hidden:=boolean(ppufile.getbyte);
-            { later, we'll gerate this on the fly (FK) }
-            paraloclen:=ppufile.getbyte;
-            if paraloclen<>sizeof(tparalocation) then
-              internalerror(200304261);
-            ppufile.getdata(hp.paraloc,sizeof(tparalocation));
             { Don't count hidden parameters }
             { Don't count hidden parameters }
             if (not hp.is_hidden) then
             if (not hp.is_hidden) then
              begin
              begin
@@ -3270,10 +3268,6 @@ implementation
             ppufile.putderef(hp.defaultvalue,hp.defaultvaluederef);
             ppufile.putderef(hp.defaultvalue,hp.defaultvaluederef);
             ppufile.putderef(hp.parasym,hp.parasymderef);
             ppufile.putderef(hp.parasym,hp.parasymderef);
             ppufile.putbyte(byte(hp.is_hidden));
             ppufile.putbyte(byte(hp.is_hidden));
-            { write the length of tparalocation so ppudump can
-              parse the .ppu without knowing the tparalocation size }
-            ppufile.putbyte(sizeof(tparalocation));
-            ppufile.putdata(hp.paraloc,sizeof(tparalocation));
             hp:=TParaItem(hp.next);
             hp:=TParaItem(hp.next);
           end;
           end;
       end;
       end;
@@ -5844,7 +5838,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.153  2003-06-25 18:31:23  peter
+  Revision 1.154  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.153  2003/06/25 18:31:23  peter
     * sym,def resolving partly rewritten to support also parent objects
     * sym,def resolving partly rewritten to support also parent objects
       not directly available through the uses clause
       not directly available through the uses clause
 
 

+ 5 - 7
compiler/utils/ppudump.pp

@@ -741,8 +741,6 @@ var
   procoptions     : tprocoptions;
   procoptions     : tprocoptions;
   i,params : longint;
   i,params : longint;
   first    : boolean;
   first    : boolean;
-  paraloclen : byte;
-  paraloc  : array[0..127] of byte;
 begin
 begin
   write(space,'      Return type : ');
   write(space,'      Return type : ');
   readtype;
   readtype;
@@ -795,10 +793,6 @@ begin
      write  (space,'     Symbol : ');
      write  (space,'     Symbol : ');
      readderef;
      readderef;
      writeln(space,'  Is Hidden : ',(ppufile.getbyte<>0));
      writeln(space,'  Is Hidden : ',(ppufile.getbyte<>0));
-     write  (space,'   Location : ');
-     writeln('<not yet implemented>');
-     paraloclen:=ppufile.getbyte;
-     ppufile.getdata(paraloc,paraloclen);
    end;
    end;
 end;
 end;
 
 
@@ -1951,7 +1945,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  2003-06-25 18:31:23  peter
+  Revision 1.46  2003-07-02 22:18:04  peter
+    * paraloc splitted in callerparaloc,calleeparaloc
+    * sparc calling convention updates
+
+  Revision 1.45  2003/06/25 18:31:23  peter
     * sym,def resolving partly rewritten to support also parent objects
     * sym,def resolving partly rewritten to support also parent objects
       not directly available through the uses clause
       not directly available through the uses clause