فهرست منبع

* pass proccalloption to ret_in_xxx and push_xxx functions

peter 23 سال پیش
والد
کامیت
a496dbe1ff

+ 5 - 2
compiler/aoptobj.pas

@@ -708,7 +708,7 @@ Begin
             new_one.next := foll;
             new_one.next := foll;
             prev.next := new_one;
             prev.next := new_one;
             foll.previous := new_one;
             foll.previous := new_one;
-            Tai(new_one).fileinfo := Tai(foll).fileinfo
+            Tailineinfo(new_one).fileinfo := Tailineinfo(foll).fileinfo
           End
           End
       End
       End
     Else AsmL.Concat(new_one)
     Else AsmL.Concat(new_one)
@@ -788,7 +788,10 @@ End.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.7  2002-08-18 18:16:55  florian
+ Revision 1.8  2002-11-18 17:31:54  peter
+   * pass proccalloption to ret_in_xxx and push_xxx functions
+
+ Revision 1.7  2002/08/18 18:16:55  florian
    * fixed compilation error
    * fixed compilation error
 
 
  Revision 1.6  2002/07/07 09:52:32  florian
  Revision 1.6  2002/07/07 09:52:32  florian

+ 9 - 6
compiler/cgbase.pas

@@ -421,7 +421,7 @@ implementation
          { because we don't know yet where the address is }
          { because we don't know yet where the address is }
          if not is_void(aktprocdef.rettype.def) then
          if not is_void(aktprocdef.rettype.def) then
            begin
            begin
-              if paramanager.ret_in_reg(aktprocdef.rettype.def) then
+              if paramanager.ret_in_reg(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                 begin
                 begin
                    { the space has been set in the local symtable }
                    { the space has been set in the local symtable }
                    procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address;
                    procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address;
@@ -430,7 +430,7 @@ implementation
                      otsym.address:=tfuncretsym(aktprocdef.funcretsym).address;
                      otsym.address:=tfuncretsym(aktprocdef.funcretsym).address;
 
 
                    rg.usedinproc := rg.usedinproc +
                    rg.usedinproc := rg.usedinproc +
-                      getfuncretusedregisters(aktprocdef.rettype.def);
+                      getfuncretusedregisters(aktprocdef.rettype.def,aktprocdef.proccalloption);
                 end;
                 end;
            end;
            end;
       end;
       end;
@@ -438,16 +438,16 @@ implementation
     { updates usedinproc depending on the resulttype }
     { updates usedinproc depending on the resulttype }
     procedure tprocinfo.update_usedinproc_result;
     procedure tprocinfo.update_usedinproc_result;
       begin
       begin
-         if paramanager.ret_in_reg(procdef.rettype.def) then
+         if paramanager.ret_in_reg(procdef.rettype.def,procdef.proccalloption) then
            begin
            begin
               rg.usedinproc := rg.usedinproc +
               rg.usedinproc := rg.usedinproc +
-              getfuncretusedregisters(procdef.rettype.def);
+              getfuncretusedregisters(procdef.rettype.def,procdef.proccalloption);
            end;
            end;
       end;
       end;
 
 
     procedure tprocinfo.set_result_offset;
     procedure tprocinfo.set_result_offset;
       begin
       begin
-         if paramanager.ret_in_reg(aktprocdef) then
+         if paramanager.ret_in_reg(aktprocdef,procdef.proccalloption) then
            procinfo.return_offset:=-tfuncretsym(procdef.funcretsym).address;
            procinfo.return_offset:=-tfuncretsym(procdef.funcretsym).address;
       end;
       end;
 
 
@@ -658,7 +658,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.32  2002-10-05 12:43:23  carl
+  Revision 1.33  2002-11-18 17:31:54  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.32  2002/10/05 12:43:23  carl
     * fixes for Delphi 6 compilation
     * fixes for Delphi 6 compilation
      (warning : Some features do not work under Delphi)
      (warning : Some features do not work under Delphi)
 
 

+ 15 - 11
compiler/i386/cpupara.pas

@@ -30,6 +30,7 @@ unit cpupara;
 
 
     uses
     uses
        cpubase,
        cpubase,
+       globtype,
        symtype,symdef,paramgr;
        symtype,symdef,paramgr;
 
 
     type
     type
@@ -39,8 +40,8 @@ unit cpupara;
          rtl are used.
          rtl are used.
        }
        }
        ti386paramanager = class(tparamanager)
        ti386paramanager = class(tparamanager)
-          function ret_in_acc(def : tdef) : boolean;override;
-          function ret_in_param(def : tdef) : boolean;override;
+          function ret_in_acc(def : tdef;calloption : tproccalloption) : boolean;override;
+          function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;override;
           function getintparaloc(nr : longint) : tparalocation;override;
           function getintparaloc(nr : longint) : tparalocation;override;
           procedure create_param_loc_info(p : tabstractprocdef);override;
           procedure create_param_loc_info(p : tabstractprocdef);override;
           function getselflocation(p : tabstractprocdef) : tparalocation;override;
           function getselflocation(p : tabstractprocdef) : tparalocation;override;
@@ -49,30 +50,30 @@ unit cpupara;
   implementation
   implementation
 
 
     uses
     uses
+       systems,
+       symconst,
        verbose;
        verbose;
 
 
-    function ti386paramanager.ret_in_acc(def : tdef) : boolean;
+    function ti386paramanager.ret_in_acc(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
-{$ifdef TEST_WIN32_RECORDS}
         { Win32 returns small records in the accumulator }
         { Win32 returns small records in the accumulator }
         if ((target_info.system=system_i386_win32) and
         if ((target_info.system=system_i386_win32) and
+            (calloption=pocall_stdcall) and
             (def.deftype=recorddef) and (def.size<=8)) then
             (def.deftype=recorddef) and (def.size<=8)) then
           result:=true
           result:=true
         else
         else
-{$endif TEST_WIN32_RECORDS}
-          result:=inherited ret_in_acc(def);
+          result:=inherited ret_in_acc(def,calloption);
       end;
       end;
 
 
-    function ti386paramanager.ret_in_param(def : tdef) : boolean;
+    function ti386paramanager.ret_in_param(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
-{$ifdef TEST_WIN32_RECORDS}
         { Win32 returns small records in the accumulator }
         { Win32 returns small records in the accumulator }
         if ((target_info.system=system_i386_win32) and
         if ((target_info.system=system_i386_win32) and
+            (calloption=pocall_stdcall) and
             (def.deftype=recorddef) and (def.size<=8)) then
             (def.deftype=recorddef) and (def.size<=8)) then
           result:=false
           result:=false
         else
         else
-{$endif TEST_WIN32_RECORDS}
-          result:=inherited ret_in_param(def);
+          result:=inherited ret_in_param(def,calloption);
       end;
       end;
 
 
     function ti386paramanager.getintparaloc(nr : longint) : tparalocation;
     function ti386paramanager.getintparaloc(nr : longint) : tparalocation;
@@ -99,7 +100,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-11-15 01:58:56  peter
+  Revision 1.5  2002-11-18 17:32:00  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.4  2002/11/15 01:58:56  peter
     * merged changes from 1.0.7 up to 04-11
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - -V option for generating bug report tracing
       - more tracing for option parsing
       - more tracing for option parsing

+ 29 - 26
compiler/i386/n386cal.pas

@@ -29,13 +29,15 @@ interface
 { $define AnsiStrRef}
 { $define AnsiStrRef}
 
 
     uses
     uses
-      symdef,node,ncal,ncgcal;
+      globtype,
+      symdef,
+      node,ncal,ncgcal;
 
 
     type
     type
        ti386callparanode = class(tcallparanode)
        ti386callparanode = class(tcallparanode)
           procedure secondcallparan(defcoll : TParaItem;
           procedure secondcallparan(defcoll : TParaItem;
-                   push_from_left_to_right,inlined,is_cdecl : boolean;
-                   para_alignment,para_offset : longint);override;
+                push_from_left_to_right:boolean;calloption:tproccalloption;
+                para_alignment,para_offset : longint);override;
        end;
        end;
 
 
        ti386callnode = class(tcgcallnode)
        ti386callnode = class(tcgcallnode)
@@ -46,7 +48,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      systems,
       cutils,verbose,globals,
       cutils,verbose,globals,
       symconst,symbase,symsym,symtable,defbase,
       symconst,symbase,symsym,symtable,defbase,
 {$ifdef GDB}
 {$ifdef GDB}
@@ -68,7 +70,7 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
     procedure ti386callparanode.secondcallparan(defcoll : TParaItem;
     procedure ti386callparanode.secondcallparan(defcoll : TParaItem;
-                push_from_left_to_right,inlined,is_cdecl : boolean;para_alignment,para_offset : longint);
+                push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
 
 
       procedure maybe_push_high;
       procedure maybe_push_high;
         begin
         begin
@@ -79,7 +81,7 @@ implementation
             begin
             begin
               secondpass(hightree);
               secondpass(hightree);
               { this is a longint anyway ! }
               { this is a longint anyway ! }
-              push_value_para(hightree,inlined,false,para_offset,4,paralocdummy);
+              push_value_para(hightree,calloption,para_offset,4,paralocdummy);
             end;
             end;
         end;
         end;
 
 
@@ -100,10 +102,10 @@ implementation
           begin
           begin
             if (nf_varargs_para in flags) then
             if (nf_varargs_para in flags) then
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset)
+                                                   calloption,para_alignment,para_offset)
             else
             else
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset);
+                                                   calloption,para_alignment,para_offset);
           end;
           end;
 
 
          otlabel:=truelabel;
          otlabel:=truelabel;
@@ -114,14 +116,14 @@ implementation
          { 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,is_cdecl) then
+             if paramanager.push_addr_param(left.resulttype.def,calloption) then
                begin
                begin
                  inc(pushedparasize,4);
                  inc(pushedparasize,4);
                  cg.a_paramaddr_ref(exprasmlist,left.location.reference,paralocdummy);
                  cg.a_paramaddr_ref(exprasmlist,left.location.reference,paralocdummy);
                  location_release(exprasmlist,left.location);
                  location_release(exprasmlist,left.location);
                end
                end
              else
              else
-               push_value_para(left,inlined,is_cdecl,para_offset,para_alignment,paralocdummy);
+               push_value_para(left,calloption,para_offset,para_alignment,paralocdummy);
            end
            end
          { filter array constructor with c styled args }
          { filter array constructor with c styled args }
          else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
          else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
@@ -142,7 +144,7 @@ implementation
               if (left.nodetype=addrn) and
               if (left.nodetype=addrn) and
                  (not(nf_procvarload in left.flags)) then
                  (not(nf_procvarload in left.flags)) then
                 begin
                 begin
-                  if inlined then
+                  if calloption=pocall_inline then
                     begin
                     begin
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_loc_ref(exprasmlist,left.location,href);
                        cg.a_load_loc_ref(exprasmlist,left.location,href);
@@ -157,7 +159,7 @@ implementation
                      CGMessage(type_e_mismatch)
                      CGMessage(type_e_mismatch)
                    else
                    else
                      begin
                      begin
-                       if inlined then
+                       if calloption=pocall_inline then
                          begin
                          begin
                            tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                            tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                            cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                            cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -190,7 +192,7 @@ implementation
                  defcoll.paratype.def.needs_inittable then
                  defcoll.paratype.def.needs_inittable then
                 cg.g_finalize(exprasmlist,defcoll.paratype.def,left.location.reference,false);
                 cg.g_finalize(exprasmlist,defcoll.paratype.def,left.location.reference,false);
               inc(pushedparasize,4);
               inc(pushedparasize,4);
-              if inlined then
+              if calloption=pocall_inline then
                 begin
                 begin
                    tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                    tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -217,7 +219,7 @@ implementation
                    is_array_of_const(defcoll.paratype.def))
                    is_array_of_const(defcoll.paratype.def))
                  ) or
                  ) or
                  (
                  (
-                  paramanager.push_addr_param(resulttype.def,is_cdecl)
+                  paramanager.push_addr_param(resulttype.def,calloption)
                  ) then
                  ) then
                 begin
                 begin
                    if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
                    if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
@@ -239,7 +241,7 @@ implementation
                    if not push_from_left_to_right then
                    if not push_from_left_to_right then
                      maybe_push_high;
                      maybe_push_high;
                    inc(pushedparasize,4);
                    inc(pushedparasize,4);
-                   if inlined then
+                   if calloption=pocall_inline then
                      begin
                      begin
                         tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                         tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -255,7 +257,7 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                   push_value_para(left,inlined,is_cdecl,
+                   push_value_para(left,calloption,
                      para_offset,para_alignment,paralocdummy);
                      para_offset,para_alignment,paralocdummy);
                 end;
                 end;
            end;
            end;
@@ -266,10 +268,10 @@ implementation
           begin
           begin
             if (nf_varargs_para in flags) then
             if (nf_varargs_para in flags) then
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset)
+                                                   calloption,para_alignment,para_offset)
             else
             else
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset);
+                                                   calloption,para_alignment,para_offset);
           end;
           end;
       end;
       end;
 
 
@@ -412,7 +414,7 @@ implementation
                 used for the return value }
                 used for the return value }
               regs_to_push := tprocdef(procdefinition).usedregisters;
               regs_to_push := tprocdef(procdefinition).usedregisters;
               if (not is_void(resulttype.def)) and
               if (not is_void(resulttype.def)) and
-                 (not paramanager.ret_in_param(resulttype.def)) then
+                 (not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption)) then
                begin
                begin
                  include(regs_to_push,accumulator);
                  include(regs_to_push,accumulator);
                  if resulttype.def.size>sizeof(aword) then
                  if resulttype.def.size>sizeof(aword) then
@@ -505,13 +507,11 @@ implementation
               if not(inlined) and
               if not(inlined) and
                  assigned(right) then
                  assigned(right) then
                 tcallparanode(params).secondcallparan(TParaItem(tabstractprocdef(right.resulttype.def).Para.first),
                 tcallparanode(params).secondcallparan(TParaItem(tabstractprocdef(right.resulttype.def).Para.first),
-                  (po_leftright in procdefinition.procoptions),inlined,
-                  (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl]),
+                  (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   para_alignment,para_offset)
                   para_alignment,para_offset)
               else
               else
                 tcallparanode(params).secondcallparan(TParaItem(procdefinition.Para.first),
                 tcallparanode(params).secondcallparan(TParaItem(procdefinition.Para.first),
-                  (po_leftright in procdefinition.procoptions),inlined,
-                  (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl]),
+                  (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   para_alignment,para_offset);
                   para_alignment,para_offset);
            end;
            end;
 
 
@@ -524,7 +524,7 @@ implementation
           end;
           end;
 
 
          { Allocate return value when returned in argument }
          { Allocate return value when returned in argument }
-         if paramanager.ret_in_param(resulttype.def) then
+         if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
            begin
            begin
              if assigned(funcretrefnode) then
              if assigned(funcretrefnode) then
               begin
               begin
@@ -1210,7 +1210,7 @@ implementation
            params.free;
            params.free;
 
 
          { from now on the result can be freed normally }
          { from now on the result can be freed normally }
-         if inlined and paramanager.ret_in_param(resulttype.def) then
+         if inlined and paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
            tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
            tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
 
 
          { if return value is not used }
          { if return value is not used }
@@ -1242,7 +1242,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.74  2002-11-15 01:58:57  peter
+  Revision 1.75  2002-11-18 17:32:00  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.74  2002/11/15 01:58:57  peter
     * merged changes from 1.0.7 up to 04-11
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - -V option for generating bug report tracing
       - more tracing for option parsing
       - more tracing for option parsing

+ 5 - 2
compiler/i386/radirect.pas

@@ -138,7 +138,7 @@ interface
                                  { is the last written character an special }
                                  { is the last written character an special }
                                  { char ?                                   }
                                  { char ?                                   }
                                  if (s[length(s)]='%') and
                                  if (s[length(s)]='%') and
-                                    paramanager.ret_in_acc(aktprocdef.rettype.def) and
+                                    paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) and
                                     ((pos('AX',upper(hs))>0) or
                                     ((pos('AX',upper(hs))>0) or
                                     (pos('AL',upper(hs))>0)) then
                                     (pos('AL',upper(hs))>0)) then
                                    tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
                                    tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
@@ -304,7 +304,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2002-09-03 16:26:28  daniel
+  Revision 1.4  2002-11-18 17:32:00  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.3  2002/09/03 16:26:28  daniel
     * Make Tprocdef.defs protected
     * Make Tprocdef.defs protected
 
 
   Revision 1.2  2002/08/17 09:23:47  florian
   Revision 1.2  2002/08/17 09:23:47  florian

+ 8 - 5
compiler/m68k/cgcpu.pas

@@ -227,15 +227,15 @@ Implementation
         fixref(list,href);
         fixref(list,href);
         list.concat(taicpu.op_ref(A_JSR,S_NO,href));
         list.concat(taicpu.op_ref(A_JSR,S_NO,href));
       end;
       end;
-      
+
     procedure tcg68k.a_call_reg(list : taasmoutput;reg : tregister);
     procedure tcg68k.a_call_reg(list : taasmoutput;reg : tregister);
      var
      var
-       href : treference; 
+       href : treference;
      begin
      begin
        reference_reset_base(href, reg, 0);
        reference_reset_base(href, reg, 0);
        a_call_ref(list,href);
        a_call_ref(list,href);
      end;
      end;
-      
+
 
 
 
 
     procedure tcg68k.a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);
     procedure tcg68k.a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);
@@ -1000,7 +1000,7 @@ Implementation
          if (po_clearstack in aktprocdef.procoptions) then
          if (po_clearstack in aktprocdef.procoptions) then
            begin
            begin
              { complex return values are removed from stack in C code PM }
              { complex return values are removed from stack in C code PM }
-             if paramanager.ret_in_param(aktprocdef.rettype.def) then
+             if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                list.concat(taicpu.op_const(A_RTD,S_NO,4))
                list.concat(taicpu.op_const(A_RTD,S_NO,4))
              else
              else
                list.concat(taicpu.op_none(A_RTS,S_NO));
                list.concat(taicpu.op_none(A_RTS,S_NO));
@@ -1250,7 +1250,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2002-09-22 14:15:31  carl
+  Revision 1.11  2002-11-18 17:32:00  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.10  2002/09/22 14:15:31  carl
     + a_call_reg
     + a_call_reg
 
 
   Revision 1.9  2002/09/17 18:54:05  jonas
   Revision 1.9  2002/09/17 18:54:05  jonas

+ 20 - 24
compiler/ncal.pas

@@ -28,13 +28,8 @@ unit ncal;
 
 
 interface
 interface
 
 
-{$ifdef DEBUG}
- {$ifdef i386}
-  {$define TEST_WIN32_RECORDS}
- {$endif i386}
-{$endif DEBUG}
-
     uses
     uses
+       globtype,
        node,
        node,
        {$ifdef state_tracking}
        {$ifdef state_tracking}
        nstate,
        nstate,
@@ -115,9 +110,9 @@ interface
           procedure insert_typeconv(defcoll : tparaitem;do_count : boolean);
           procedure insert_typeconv(defcoll : tparaitem;do_count : boolean);
           procedure det_registers;
           procedure det_registers;
           procedure firstcallparan(defcoll : tparaitem;do_count : boolean);
           procedure firstcallparan(defcoll : tparaitem;do_count : boolean);
-          procedure secondcallparan(defcoll : tparaitem;
-                   push_from_left_to_right,inlined,is_cdecl : boolean;
-                   para_alignment,para_offset : longint);virtual;abstract;
+          procedure secondcallparan(defcoll : TParaItem;
+                push_from_left_to_right:boolean;calloption:tproccalloption;
+                para_alignment,para_offset : longint);virtual;abstract;
           function docompare(p: tnode): boolean; override;
           function docompare(p: tnode): boolean; override;
        end;
        end;
        tcallparanodeclass = class of tcallparanode;
        tcallparanodeclass = class of tcallparanode;
@@ -150,7 +145,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      cutils,globtype,systems,
+      cutils,systems,
       verbose,globals,
       verbose,globals,
       symconst,paramgr,defbase,
       symconst,paramgr,defbase,
       htypechk,pass_1,cpuinfo,cpubase,
       htypechk,pass_1,cpuinfo,cpubase,
@@ -457,7 +452,7 @@ implementation
          if not(assigned(aktcallprocdef) and
          if not(assigned(aktcallprocdef) and
                 (aktcallprocdef.proccalloption in [pocall_cppdecl,pocall_cdecl]) and
                 (aktcallprocdef.proccalloption in [pocall_cppdecl,pocall_cdecl]) and
                 (po_external in aktcallprocdef.procoptions)) and
                 (po_external in aktcallprocdef.procoptions)) and
-            paramanager.push_high_param(defcoll.paratype.def) then
+            paramanager.push_high_param(defcoll.paratype.def,aktcallprocdef.proccalloption) then
            gen_high_tree(is_open_string(defcoll.paratype.def));
            gen_high_tree(is_open_string(defcoll.paratype.def));
 
 
          { test conversions }
          { test conversions }
@@ -472,7 +467,7 @@ implementation
                        left.resulttype.def.typename,defcoll.paratype.def.typename);
                        left.resulttype.def.typename,defcoll.paratype.def.typename);
                   end;
                   end;
               { Process open parameters }
               { Process open parameters }
-              if paramanager.push_high_param(defcoll.paratype.def) then
+              if paramanager.push_high_param(defcoll.paratype.def,aktcallprocdef.proccalloption) then
                begin
                begin
                  { insert type conv but hold the ranges of the array }
                  { insert type conv but hold the ranges of the array }
                  oldtype:=left.resulttype;
                  oldtype:=left.resulttype;
@@ -739,7 +734,8 @@ implementation
         restypeset := true;
         restypeset := true;
         { both the normal and specified resulttype either have to be returned via a }
         { both the normal and specified resulttype either have to be returned via a }
         { parameter or not, but no mixing (JM)                                      }
         { parameter or not, but no mixing (JM)                                      }
-        if paramanager.ret_in_param(restype.def) xor paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def) then
+        if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
+           paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
           internalerror(200108291);
           internalerror(200108291);
       end;
       end;
 
 
@@ -748,7 +744,7 @@ implementation
       begin
       begin
         self.createintern(name,params);
         self.createintern(name,params);
         funcretrefnode:=returnnode;
         funcretrefnode:=returnnode;
-        if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def) then
+        if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
           internalerror(200204247);
           internalerror(200204247);
       end;
       end;
 
 
@@ -2212,7 +2208,7 @@ implementation
          { modify the exit code, in case of special cases }
          { modify the exit code, in case of special cases }
          if (not is_void(resulttype.def)) then
          if (not is_void(resulttype.def)) then
           begin
           begin
-            if paramanager.ret_in_reg(resulttype.def) then
+            if paramanager.ret_in_reg(resulttype.def,procdefinition.proccalloption) then
              begin
              begin
                { wide- and ansistrings are returned in EAX    }
                { wide- and ansistrings are returned in EAX    }
                { but they are imm. moved to a memory location }
                { but they are imm. moved to a memory location }
@@ -2350,17 +2346,14 @@ implementation
          { get a register for the return value }
          { get a register for the return value }
          if (not is_void(resulttype.def)) then
          if (not is_void(resulttype.def)) then
            begin
            begin
-{$ifdef TEST_WIN32_RECORDS}
-             if (target_info.system=system_i386_win32) and
-                (resulttype.def.deftype=recorddef) then
+             { for win32 records returned in EDX:EAX, we
+               move them to memory after ... }
+             if (resulttype.def.deftype=recorddef) then
               begin
               begin
-                { for win32 records returned in EDX:EAX, we
-                  move them to memory after ... }
                 location.loc:=LOC_CREFERENCE;
                 location.loc:=LOC_CREFERENCE;
               end
               end
              else
              else
-{$endif TEST_WIN32_RECORDS}
-              if paramanager.ret_in_param(resulttype.def) then
+              if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
                begin
                begin
                  location.loc:=LOC_CREFERENCE;
                  location.loc:=LOC_CREFERENCE;
                end
                end
@@ -2629,7 +2622,7 @@ implementation
          retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
          retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
          para_offset:=0;
          para_offset:=0;
          para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
          para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
-         if paramanager.ret_in_param(inlineprocdef.rettype.def) then
+         if paramanager.ret_in_param(inlineprocdef.rettype.def,inlineprocdef.proccalloption) then
            inc(para_size,POINTER_SIZE);
            inc(para_size,POINTER_SIZE);
          result:=nil;
          result:=nil;
       end;
       end;
@@ -2662,7 +2655,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.107  2002-11-15 01:58:50  peter
+  Revision 1.108  2002-11-18 17:31:54  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.107  2002/11/15 01:58:50  peter
     * merged changes from 1.0.7 up to 04-11
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - -V option for generating bug report tracing
       - more tracing for option parsing
       - more tracing for option parsing

+ 28 - 26
compiler/ncgcal.pas

@@ -30,13 +30,14 @@ interface
 
 
     uses
     uses
       cpubase,
       cpubase,
+      globtype,
       symdef,node,ncal;
       symdef,node,ncal;
 
 
     type
     type
        tcgcallparanode = class(tcallparanode)
        tcgcallparanode = class(tcallparanode)
           procedure secondcallparan(defcoll : TParaItem;
           procedure secondcallparan(defcoll : TParaItem;
-                   push_from_left_to_right,inlined,is_cdecl : boolean;
-                   para_alignment,para_offset : longint);override;
+                push_from_left_to_right:boolean;calloption:tproccalloption;
+                para_alignment,para_offset : longint);override;
        end;
        end;
 
 
        tcgcallnode = class(tcallnode)
        tcgcallnode = class(tcallnode)
@@ -58,7 +59,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      systems,
       cutils,verbose,globals,
       cutils,verbose,globals,
       symconst,symbase,symsym,symtable,defbase,paramgr,
       symconst,symbase,symsym,symtable,defbase,paramgr,
 {$ifdef GDB}
 {$ifdef GDB}
@@ -82,7 +83,7 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
     procedure tcgcallparanode.secondcallparan(defcoll : TParaItem;
     procedure tcgcallparanode.secondcallparan(defcoll : TParaItem;
-                push_from_left_to_right,inlined,is_cdecl : boolean;para_alignment,para_offset : longint);
+                push_from_left_to_right:boolean;calloption:tproccalloption;para_alignment,para_offset : longint);
 
 
       { goes to pass 1 }
       { goes to pass 1 }
       procedure maybe_push_high;
       procedure maybe_push_high;
@@ -94,7 +95,7 @@ implementation
             begin
             begin
               secondpass(hightree);
               secondpass(hightree);
               { this is a longint anyway ! }
               { this is a longint anyway ! }
-              push_value_para(hightree,inlined,false,para_offset,4,defcoll.paraloc);
+              push_value_para(hightree,calloption,para_offset,4,defcoll.paraloc);
             end;
             end;
         end;
         end;
 
 
@@ -112,10 +113,10 @@ implementation
           begin
           begin
             if (nf_varargs_para in flags) then
             if (nf_varargs_para in flags) then
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset)
+                                                   calloption,para_alignment,para_offset)
             else
             else
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset);
+                                                   calloption,para_alignment,para_offset);
           end;
           end;
 
 
          otlabel:=truelabel;
          otlabel:=truelabel;
@@ -126,14 +127,14 @@ implementation
          { 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,is_cdecl) then
+             if paramanager.push_addr_param(left.resulttype.def,calloption) then
                begin
                begin
                  inc(pushedparasize,4);
                  inc(pushedparasize,4);
                  cg.a_paramaddr_ref(exprasmlist,left.location.reference,defcoll.paraloc);
                  cg.a_paramaddr_ref(exprasmlist,left.location.reference,defcoll.paraloc);
                  location_release(exprasmlist,left.location);
                  location_release(exprasmlist,left.location);
                end
                end
              else
              else
-               push_value_para(left,inlined,is_cdecl,para_offset,para_alignment,defcoll.paraloc);
+               push_value_para(left,calloption,para_offset,para_alignment,defcoll.paraloc);
            end
            end
          { filter array constructor with c styled args }
          { filter array constructor with c styled args }
          else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
          else if is_array_constructor(left.resulttype.def) and (nf_cargs in left.flags) then
@@ -154,7 +155,7 @@ implementation
               if (left.nodetype=addrn) and
               if (left.nodetype=addrn) and
                  (not(nf_procvarload in left.flags)) then
                  (not(nf_procvarload in left.flags)) then
                 begin
                 begin
-                  if inlined then
+                  if calloption=pocall_inline then
                     begin
                     begin
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_loc_ref(exprasmlist,left.location,href);
                        cg.a_load_loc_ref(exprasmlist,left.location,href);
@@ -171,7 +172,7 @@ implementation
                      end
                      end
                    else
                    else
                      begin
                      begin
-                       if inlined then
+                       if calloption=pocall_inline then
                          begin
                          begin
                            tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                            tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                            cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                            cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -204,7 +205,7 @@ implementation
                  defcoll.paratype.def.needs_inittable then
                  defcoll.paratype.def.needs_inittable then
                 cg.g_finalize(exprasmlist,defcoll.paratype.def,left.location.reference,false);
                 cg.g_finalize(exprasmlist,defcoll.paratype.def,left.location.reference,false);
               inc(pushedparasize,4);
               inc(pushedparasize,4);
-              if inlined then
+              if calloption=pocall_inline then
                 begin
                 begin
                    tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                    tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -231,7 +232,7 @@ implementation
                    is_array_of_const(defcoll.paratype.def))
                    is_array_of_const(defcoll.paratype.def))
                  ) or
                  ) or
                  (
                  (
-                  paramanager.push_addr_param(resulttype.def,is_cdecl)
+                  paramanager.push_addr_param(resulttype.def,calloption)
                  ) then
                  ) then
                 begin
                 begin
                    if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
                    if not(left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
@@ -258,7 +259,7 @@ implementation
                    if not push_from_left_to_right then
                    if not push_from_left_to_right then
                      maybe_push_high;
                      maybe_push_high;
                    inc(pushedparasize,4);
                    inc(pushedparasize,4);
-                   if inlined then
+                   if calloption=pocall_inline then
                      begin
                      begin
                         tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                         tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
@@ -274,7 +275,7 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                   push_value_para(left,inlined,is_cdecl,
+                   push_value_para(left,calloption,
                      para_offset,para_alignment,defcoll.paraloc);
                      para_offset,para_alignment,defcoll.paraloc);
                 end;
                 end;
            end;
            end;
@@ -285,10 +286,10 @@ implementation
           begin
           begin
             if (nf_varargs_para in flags) then
             if (nf_varargs_para in flags) then
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
               tcallparanode(right).secondcallparan(defcoll,push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset)
+                                                   calloption,para_alignment,para_offset)
             else
             else
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
               tcallparanode(right).secondcallparan(TParaItem(defcoll.next),push_from_left_to_right,
-                                                   inlined,is_cdecl,para_alignment,para_offset);
+                                                   calloption,para_alignment,para_offset);
           end;
           end;
       end;
       end;
 
 
@@ -316,7 +317,7 @@ implementation
       begin
       begin
         { structured results are easy to handle.... }
         { structured results are easy to handle.... }
         { needed also when result_no_used !! }
         { needed also when result_no_used !! }
-        if paramanager.ret_in_param(resulttype.def) then
+        if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
          begin
          begin
            location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
            location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
            location.reference.symbol:=nil;
            location.reference.symbol:=nil;
@@ -557,7 +558,7 @@ implementation
                 used for the return value }
                 used for the return value }
               regs_to_push := tprocdef(procdefinition).usedregisters;
               regs_to_push := tprocdef(procdefinition).usedregisters;
               if (not is_void(resulttype.def)) and
               if (not is_void(resulttype.def)) and
-                 (not paramanager.ret_in_param(resulttype.def)) then
+                 (not paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption)) then
                begin
                begin
                  include(regs_to_push,accumulator);
                  include(regs_to_push,accumulator);
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
@@ -656,13 +657,11 @@ implementation
               if not(inlined) and
               if not(inlined) and
                  assigned(right) then
                  assigned(right) then
                 tcallparanode(params).secondcallparan(TParaItem(tabstractprocdef(right.resulttype.def).Para.first),
                 tcallparanode(params).secondcallparan(TParaItem(tabstractprocdef(right.resulttype.def).Para.first),
-                  (po_leftright in procdefinition.procoptions),inlined,
-                  (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl]),
+                  (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   para_alignment,para_offset)
                   para_alignment,para_offset)
               else
               else
                 tcallparanode(params).secondcallparan(TParaItem(procdefinition.Para.first),
                 tcallparanode(params).secondcallparan(TParaItem(procdefinition.Para.first),
-                  (po_leftright in procdefinition.procoptions),inlined,
-                  (procdefinition.proccalloption in [pocall_cdecl,pocall_cppdecl]),
+                  (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   para_alignment,para_offset);
                   para_alignment,para_offset);
            end;
            end;
 
 
@@ -675,7 +674,7 @@ implementation
            end;
            end;
 
 
          { Allocate return value when returned in argument }
          { Allocate return value when returned in argument }
-         if paramanager.ret_in_param(resulttype.def) then
+         if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
            begin
            begin
              if assigned(funcretrefnode) then
              if assigned(funcretrefnode) then
               begin
               begin
@@ -1328,7 +1327,7 @@ implementation
            params.free;
            params.free;
 
 
          { from now on the result can be freed normally }
          { from now on the result can be freed normally }
-         if inlined and paramanager.ret_in_param(resulttype.def) then
+         if inlined and paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
            tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
            tg.ChangeTempType(exprasmlist,funcretref,tt_normal);
 
 
          { if return value is not used }
          { if return value is not used }
@@ -1542,7 +1541,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2002-11-16 15:34:30  florian
+  Revision 1.28  2002-11-18 17:31:54  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.27  2002/11/16 15:34:30  florian
     * generic location for float results
     * generic location for float results
 
 
   Revision 1.26  2002/11/15 01:58:51  peter
   Revision 1.26  2002/11/15 01:58:51  peter

+ 8 - 5
compiler/ncgld.pas

@@ -276,8 +276,7 @@ implementation
                       if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
                       if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
                          is_open_array(tvarsym(symtableentry).vartype.def) or
                          is_open_array(tvarsym(symtableentry).vartype.def) or
                          is_array_of_const(tvarsym(symtableentry).vartype.def) or
                          is_array_of_const(tvarsym(symtableentry).vartype.def) or
-                         paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,
-                             (tprocdef(symtable.defowner).proccalloption in [pocall_cdecl,pocall_cppdecl])) then
+                         paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,tprocdef(symtable.defowner).proccalloption) then
                         begin
                         begin
                            if hregister=R_NO then
                            if hregister=R_NO then
                              hregister:=rg.getaddressregister(exprasmlist);
                              hregister:=rg.getaddressregister(exprasmlist);
@@ -738,7 +737,8 @@ implementation
              location.reference.base:=procinfo.framepointer;
              location.reference.base:=procinfo.framepointer;
              location.reference.offset:=procinfo.return_offset;
              location.reference.offset:=procinfo.return_offset;
            end;
            end;
-         if paramanager.ret_in_param(funcretsym.returntype.def) then
+         if paramanager.ret_in_param(funcretsym.returntype.def,
+                                     tprocdef(funcretsym.owner.defowner).proccalloption) then
            begin
            begin
               { the parameter is actual a pointer to the value }
               { the parameter is actual a pointer to the value }
               if not hr_valid then
               if not hr_valid then
@@ -915,7 +915,7 @@ implementation
                      end
                      end
                     else
                     else
                       if vtype in [vtInt64,vtQword,vtExtended] then
                       if vtype in [vtInt64,vtQword,vtExtended] then
-                        push_value_para(hp.left,false,true,0,4,paralocdummy)
+                        push_value_para(hp.left,pocall_cdecl,0,4,paralocdummy)
                     else
                     else
                       begin
                       begin
                         cg.a_param_loc(exprasmlist,hp.left.location,paralocdummy);
                         cg.a_param_loc(exprasmlist,hp.left.location,paralocdummy);
@@ -989,7 +989,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.37  2002-11-15 21:16:39  jonas
+  Revision 1.38  2002-11-18 17:31:54  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.37  2002/11/15 21:16:39  jonas
     * proper fix for tw2110, also fixes tb0416 (funcretnode of parent
     * proper fix for tw2110, also fixes tb0416 (funcretnode of parent
       function was handled wrong inside nested functions/procedures)
       function was handled wrong inside nested functions/procedures)
 
 

+ 26 - 22
compiler/ncgutil.pas

@@ -28,6 +28,7 @@ interface
 
 
     uses
     uses
       node,cpuinfo,
       node,cpuinfo,
+      globtype,
       cpubase,cpupara,
       cpubase,cpupara,
       aasmbase,aasmtai,aasmcpu,
       aasmbase,aasmtai,aasmcpu,
       cginfo,symbase,symdef,symtype,
       cginfo,symbase,symdef,symtype,
@@ -55,7 +56,7 @@ interface
     procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
     procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
 
 
-    procedure push_value_para(p:tnode;inlined,is_cdecl:boolean;
+    procedure push_value_para(p:tnode;calloption:tproccalloption;
                               para_offset:longint;alignment : longint;
                               para_offset:longint;alignment : longint;
                               const locpara : tparalocation);
                               const locpara : tparalocation);
 
 
@@ -96,7 +97,8 @@ implementation
 {$else}
 {$else}
     strings,
     strings,
 {$endif}
 {$endif}
-    cutils,cclasses,globtype,globals,systems,verbose,
+    cutils,cclasses,
+    globals,systems,verbose,
     symconst,symsym,symtable,defbase,paramgr,
     symconst,symsym,symtable,defbase,paramgr,
     fmodule,
     fmodule,
     cgbase,regvars,
     cgbase,regvars,
@@ -688,7 +690,7 @@ implementation
                                 Push Value Para
                                 Push Value Para
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure push_value_para(p:tnode;inlined,is_cdecl:boolean;
+    procedure push_value_para(p:tnode;calloption:tproccalloption;
                               para_offset:longint;alignment : longint;
                               para_offset:longint;alignment : longint;
                               const locpara : tparalocation);
                               const locpara : tparalocation);
       var
       var
@@ -716,7 +718,7 @@ implementation
                begin
                begin
                   size:=align(tfloatdef(p.resulttype.def).size,alignment);
                   size:=align(tfloatdef(p.resulttype.def).size,alignment);
                   inc(pushedparasize,size);
                   inc(pushedparasize,size);
-                  if not inlined then
+                  if calloption<>pocall_inline then
                    cg.a_op_const_reg(exprasmlist,OP_SUB,size,STACK_POINTER_REG);
                    cg.a_op_const_reg(exprasmlist,OP_SUB,size,STACK_POINTER_REG);
 {$ifdef GDB}
 {$ifdef GDB}
                   if (cs_debuginfo in aktmoduleswitches) and
                   if (cs_debuginfo in aktmoduleswitches) and
@@ -725,7 +727,7 @@ implementation
 {$endif GDB}
 {$endif GDB}
 
 
                   { this is the easiest case for inlined !! }
                   { this is the easiest case for inlined !! }
-                  if inlined then
+                  if calloption=pocall_inline then
                    reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize)
                    reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize)
                   else
                   else
                    reference_reset_base(href,stack_pointer_reg,0);
                    reference_reset_base(href,stack_pointer_reg,0);
@@ -755,7 +757,7 @@ implementation
                        dec(tempreference.offset,2);
                        dec(tempreference.offset,2);
                        dec(sizetopush,2);
                        dec(sizetopush,2);
                      end;
                      end;
-                    if inlined then
+                    if calloption=pocall_inline then
                      begin
                      begin
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_ref_ref(exprasmlist,cgsize,tempreference,href);
                        cg.a_load_ref_ref(exprasmlist,cgsize,tempreference,href);
@@ -771,8 +773,8 @@ implementation
         else
         else
          begin
          begin
            { call by value open array ? }
            { call by value open array ? }
-           if is_cdecl and
-              paramanager.push_addr_param(p.resulttype.def,false) then
+           if (calloption in [pocall_cdecl,pocall_cppdecl]) and
+              paramanager.push_addr_param(p.resulttype.def,calloption) then
             begin
             begin
               if not (p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
               if not (p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                 internalerror(200204241);
                 internalerror(200204241);
@@ -796,7 +798,7 @@ implementation
                     if cgsize in [OS_64,OS_S64] then
                     if cgsize in [OS_64,OS_S64] then
                      begin
                      begin
                        inc(pushedparasize,8);
                        inc(pushedparasize,8);
-                       if inlined then
+                       if calloption=pocall_inline then
                         begin
                         begin
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
                           if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
@@ -833,7 +835,7 @@ implementation
                           p.location.register:=rg.makeregsize(p.location.register,cgsize);
                           p.location.register:=rg.makeregsize(p.location.register,cgsize);
                         end;
                         end;
                        inc(pushedparasize,alignment);
                        inc(pushedparasize,alignment);
-                       if inlined then
+                       if calloption=pocall_inline then
                         begin
                         begin
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
                           if p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
@@ -857,7 +859,7 @@ implementation
                 LOC_CMMXREGISTER:
                 LOC_CMMXREGISTER:
                   begin
                   begin
                      inc(pushedparasize,8);
                      inc(pushedparasize,8);
-                     if inlined then
+                     if calloption=pocall_inline then
                        begin
                        begin
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize);
                           cg.a_loadmm_reg_ref(exprasmlist,p.location.register,href);
                           cg.a_loadmm_reg_ref(exprasmlist,p.location.register,href);
@@ -886,7 +888,7 @@ implementation
         list:=taasmoutput(arg);
         list:=taasmoutput(arg);
         if (tsym(p).typ=varsym) and
         if (tsym(p).typ=varsym) and
            (tvarsym(p).varspez=vs_value) and
            (tvarsym(p).varspez=vs_value) and
-           (paramanager.push_addr_param(tvarsym(p).vartype.def,false)) then
+           (paramanager.push_addr_param(tvarsym(p).vartype.def,procinfo.procdef.proccalloption)) then
          begin
          begin
            reference_reset_base(href1,procinfo.framepointer,tvarsym(p).address+procinfo.para_offset);
            reference_reset_base(href1,procinfo.framepointer,tvarsym(p).address+procinfo.para_offset);
            if is_open_array(tvarsym(p).vartype.def) or
            if is_open_array(tvarsym(p).vartype.def) or
@@ -914,7 +916,7 @@ implementation
            (tvarsym(p).varspez=vs_value) and
            (tvarsym(p).varspez=vs_value) and
            (is_open_array(tvarsym(p).vartype.def) or
            (is_open_array(tvarsym(p).vartype.def) or
             is_array_of_const(tvarsym(p).vartype.def)) and
             is_array_of_const(tvarsym(p).vartype.def)) and
-           (paramanager.push_addr_param(tvarsym(p).vartype.def,false)) then
+           (paramanager.push_addr_param(tvarsym(p).vartype.def,procinfo.procdef.proccalloption)) then
          begin
          begin
            reference_reset_base(href1,procinfo.framepointer,tvarsym(p).address+procinfo.para_offset);
            reference_reset_base(href1,procinfo.framepointer,tvarsym(p).address+procinfo.para_offset);
            cg.g_removevaluepara_openarray(list,href1,tarraydef(tvarsym(p).vartype.def).elesize);
            cg.g_removevaluepara_openarray(list,href1,tarraydef(tvarsym(p).vartype.def).elesize);
@@ -1151,7 +1153,7 @@ function returns in a register and the caller receives it in an other one}
                end;
                end;
              else
              else
                begin
                begin
-                 if paramanager.ret_in_acc(aktprocdef.rettype.def) then
+                 if paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                   begin
                   begin
                     uses_acc:=true;
                     uses_acc:=true;
                     cg.a_reg_alloc(list,accumulator);
                     cg.a_reg_alloc(list,accumulator);
@@ -1203,7 +1205,7 @@ function returns in a register and the caller receives it in an other one}
                end;
                end;
              else
              else
                begin
                begin
-                 if paramanager.ret_in_acc(aktprocdef.rettype.def) then
+                 if paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                   cg.a_load_reg_ref(list,cgsize,accumulator,href);
                   cg.a_load_reg_ref(list,cgsize,accumulator,href);
                end;
                end;
            end;
            end;
@@ -1219,7 +1221,6 @@ function returns in a register and the caller receives it in an other one}
       var
       var
         hs : string;
         hs : string;
         href : treference;
         href : treference;
-        p : tsymtable;
         stackalloclist : taasmoutput;
         stackalloclist : taasmoutput;
         hp : tparaitem;
         hp : tparaitem;
         paraloc : tparalocation;
         paraloc : tparalocation;
@@ -1271,7 +1272,7 @@ function returns in a register and the caller receives it in an other one}
         if not is_void(aktprocdef.rettype.def) then
         if not is_void(aktprocdef.rettype.def) then
           begin
           begin
              { for now the pointer to the result can't be a register }
              { for now the pointer to the result can't be a register }
-             if not(paramanager.ret_in_reg(aktprocdef.rettype.def)) then
+             if not(paramanager.ret_in_reg(aktprocdef.rettype.def,aktprocdef.proccalloption)) then
                begin
                begin
                   paraloc:=paramanager.getfuncretparaloc(aktprocdef);
                   paraloc:=paramanager.getfuncretparaloc(aktprocdef);
                   reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
                   reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
@@ -1297,7 +1298,7 @@ function returns in a register and the caller receives it in an other one}
                   if (cs_implicit_exceptions in aktmoduleswitches) then
                   if (cs_implicit_exceptions in aktmoduleswitches) then
                     procinfo.flags:=procinfo.flags or pi_needs_implicit_finally;
                     procinfo.flags:=procinfo.flags or pi_needs_implicit_finally;
                   reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
                   reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
-                  cg.g_initialize(list,aktprocdef.rettype.def,href,paramanager.ret_in_param(aktprocdef.rettype.def));
+                  cg.g_initialize(list,aktprocdef.rettype.def,href,paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption));
                end;
                end;
           end;
           end;
 
 
@@ -1629,7 +1630,7 @@ function returns in a register and the caller receives it in an other one}
                     not is_class(aktprocdef.rettype.def)) then
                     not is_class(aktprocdef.rettype.def)) then
                   begin
                   begin
                      reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
                      reference_reset_base(href,procinfo.framepointer,procinfo.return_offset);
-                     cg.g_finalize(list,aktprocdef.rettype.def,href,paramanager.ret_in_param(aktprocdef.rettype.def));
+                     cg.g_finalize(list,aktprocdef.rettype.def,href,paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption));
                   end;
                   end;
               end;
               end;
 
 
@@ -1784,7 +1785,7 @@ function returns in a register and the caller receives it in an other one}
 
 
             if (not is_void(aktprocdef.rettype.def)) then
             if (not is_void(aktprocdef.rettype.def)) then
               begin
               begin
-                if paramanager.ret_in_param(aktprocdef.rettype.def) then
+                if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                   list.concat(Tai_stabs.Create(strpnew(
                   list.concat(Tai_stabs.Create(strpnew(
                    '"'+aktprocsym.name+':X*'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                    '"'+aktprocsym.name+':X*'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                    tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))))
                    tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))))
@@ -1793,7 +1794,7 @@ function returns in a register and the caller receives it in an other one}
                    '"'+aktprocsym.name+':X'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                    '"'+aktprocsym.name+':X'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                    tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))));
                    tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))));
                 if (m_result in aktmodeswitches) then
                 if (m_result in aktmodeswitches) then
-                  if paramanager.ret_in_param(aktprocdef.rettype.def) then
+                  if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                     list.concat(Tai_stabs.Create(strpnew(
                     list.concat(Tai_stabs.Create(strpnew(
                      '"RESULT:X*'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                      '"RESULT:X*'+tstoreddef(aktprocdef.rettype.def).numberstring+'",'+
                      tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))))
                      tostr(N_tsym)+',0,0,'+tostr(procinfo.return_offset))))
@@ -1875,7 +1876,10 @@ function returns in a register and the caller receives it in an other one}
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2002-11-17 17:49:08  mazen
+  Revision 1.62  2002-11-18 17:31:55  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.61  2002/11/17 17:49:08  mazen
   + return_result_reg and function_result_reg are now used, in all plateforms, to pass functions result between called function and its caller. See the explanation of each one
   + return_result_reg and function_result_reg are now used, in all plateforms, to pass functions result between called function and its caller. See the explanation of each one
 
 
   Revision 1.60  2002/11/17 16:31:56  carl
   Revision 1.60  2002/11/17 16:31:56  carl

+ 5 - 2
compiler/nflw.pas

@@ -826,7 +826,7 @@ implementation
            if assigned(left) then
            if assigned(left) then
             begin
             begin
               inserttypeconv(left,aktprocdef.rettype);
               inserttypeconv(left,aktprocdef.rettype);
-              if paramanager.ret_in_param(aktprocdef.rettype.def) or
+              if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) or
                  (procinfo.no_fast_exit) or
                  (procinfo.no_fast_exit) or
                  ((procinfo.flags and pi_uses_exceptions)<>0) then
                  ((procinfo.flags and pi_uses_exceptions)<>0) then
                begin
                begin
@@ -1412,7 +1412,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.54  2002-10-20 15:31:49  peter
+  Revision 1.55  2002-11-18 17:31:56  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.54  2002/10/20 15:31:49  peter
     * set funcret state for exit(0)
     * set funcret state for exit(0)
 
 
   Revision 1.53  2002/10/05 12:43:25  carl
   Revision 1.53  2002/10/05 12:43:25  carl

+ 5 - 2
compiler/ninl.pas

@@ -2022,7 +2022,7 @@ implementation
             end;
             end;
           in_sizeof_x:
           in_sizeof_x:
             begin
             begin
-              if paramanager.push_high_param(left.resulttype.def) then
+              if paramanager.push_high_param(left.resulttype.def,aktprocdef.proccalloption) then
                begin
                begin
                  srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+tvarsym(tloadnode(left).symtableentry).name);
                  srsym:=searchsymonlyin(tloadnode(left).symtable,'high'+tvarsym(tloadnode(left).symtableentry).name);
                  hp:=caddnode.create(addn,cloadnode.create(srsym,tloadnode(left).symtable),
                  hp:=caddnode.create(addn,cloadnode.create(srsym,tloadnode(left).symtable),
@@ -2401,7 +2401,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.95  2002-11-16 17:59:31  peter
+  Revision 1.96  2002-11-18 17:31:57  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.95  2002/11/16 17:59:31  peter
     * load threadvar input/output variable in temp
     * load threadvar input/output variable in temp
 
 
   Revision 1.94  2002/11/15 01:58:52  peter
   Revision 1.94  2002/11/15 01:58:52  peter

+ 6 - 3
compiler/nld.pas

@@ -412,7 +412,7 @@ implementation
                    { we need a register for call by reference parameters }
                    { we need a register for call by reference parameters }
                    if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
                    if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
                       ((tvarsym(symtableentry).varspez=vs_const) and
                       ((tvarsym(symtableentry).varspez=vs_const) and
-                      paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,false)) or
+                      paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,pocall_none)) or
                       { call by value open arrays are also indirect addressed }
                       { call by value open arrays are also indirect addressed }
                       is_open_array(tvarsym(symtableentry).vartype.def) then
                       is_open_array(tvarsym(symtableentry).vartype.def) then
                      registers32:=1;
                      registers32:=1;
@@ -778,7 +778,7 @@ implementation
       begin
       begin
          result:=nil;
          result:=nil;
          location.loc:=LOC_REFERENCE;
          location.loc:=LOC_REFERENCE;
-         if paramanager.ret_in_param(resulttype.def) or
+         if paramanager.ret_in_param(resulttype.def,tprocdef(funcretsym.owner.defowner).proccalloption) or
             (lexlevel<>funcretsym.owner.symtablelevel) then
             (lexlevel<>funcretsym.owner.symtablelevel) then
            registers32:=1;
            registers32:=1;
       end;
       end;
@@ -1181,7 +1181,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2002-11-15 01:58:52  peter
+  Revision 1.65  2002-11-18 17:31:57  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.64  2002/11/15 01:58:52  peter
     * merged changes from 1.0.7 up to 04-11
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - -V option for generating bug report tracing
       - more tracing for option parsing
       - more tracing for option parsing

+ 29 - 25
compiler/paramgr.pas

@@ -30,6 +30,7 @@ unit paramgr;
 
 
     uses
     uses
        cpubase,
        cpubase,
+       globtype,
        symtype,symdef;
        symtype,symdef;
 
 
     type
     type
@@ -38,25 +39,25 @@ unit paramgr;
        }
        }
        tparamanager = class
        tparamanager = class
           {# Returns true if the return value can be put in accumulator }
           {# Returns true if the return value can be put in accumulator }
-          function ret_in_acc(def : tdef) : boolean;virtual;
+          function ret_in_acc(def : tdef;calloption : tproccalloption) : boolean;virtual;
           {# Returns true if the return value is put in a register
           {# Returns true if the return value is put in a register
 
 
              Either a floating point register, or a general purpose
              Either a floating point register, or a general purpose
              register.
              register.
           }
           }
-          function ret_in_reg(def : tdef) : boolean;virtual;
+          function ret_in_reg(def : tdef;calloption : tproccalloption) : boolean;virtual;
 
 
           {# Returns true if the return value is actually a parameter
           {# Returns true if the return value is actually a parameter
              pointer.
              pointer.
           }
           }
-          function ret_in_param(def : tdef) : boolean;virtual;
+          function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
 
 
-          function push_high_param(def : tdef) : boolean;virtual;
+          function push_high_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
 
 
           {# Returns true if a parameter is too large to copy and only
           {# Returns true if a parameter is too large to copy and only
             the address is pushed
             the address is pushed
           }
           }
-          function push_addr_param(def : tdef;is_cdecl:boolean) : boolean;virtual;
+          function push_addr_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
           {# Returns a structure giving the information on
           {# Returns a structure giving the information on
              the storage of the parameter (which must be
              the storage of the parameter (which must be
              an integer parameter)
              an integer parameter)
@@ -91,11 +92,11 @@ 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): tparalocation; virtual;
+          function getfuncresultloc(def : tdef;calloption:tproccalloption): tparalocation; virtual;
        end;
        end;
 
 
     procedure setparalocs(p : tprocdef);
     procedure setparalocs(p : tprocdef);
-    function getfuncretusedregisters(def : tdef): tregisterset;
+    function getfuncretusedregisters(def : tdef;calloption:tproccalloption): tregisterset;
 
 
     var
     var
        paralocdummy : tparalocation;
        paralocdummy : tparalocation;
@@ -104,13 +105,13 @@ unit paramgr;
   implementation
   implementation
 
 
     uses
     uses
-       cpuinfo,globals,globtype,systems,
+       cpuinfo,globals,systems,
        symconst,symbase,symsym,
        symconst,symbase,symsym,
        rgobj,
        rgobj,
        defbase,cgbase,cginfo,verbose;
        defbase,cgbase,cginfo,verbose;
 
 
     { true if the return value is in accumulator (EAX for i386), D0 for 68k }
     { true if the return value is in accumulator (EAX for i386), D0 for 68k }
-    function tparamanager.ret_in_acc(def : tdef) : boolean;
+    function tparamanager.ret_in_acc(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
          ret_in_acc:=(def.deftype in [orddef,pointerdef,enumdef,classrefdef]) or
          ret_in_acc:=(def.deftype in [orddef,pointerdef,enumdef,classrefdef]) or
                      ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_ansistring,st_widestring])) or
                      ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_ansistring,st_widestring])) or
@@ -119,13 +120,13 @@ unit paramgr;
                      ((def.deftype=setdef) and (tsetdef(def).settype=smallset));
                      ((def.deftype=setdef) and (tsetdef(def).settype=smallset));
       end;
       end;
 
 
-    function tparamanager.ret_in_reg(def : tdef) : boolean;
+    function tparamanager.ret_in_reg(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
-        ret_in_reg:=ret_in_acc(def) or (def.deftype=floatdef);
+        ret_in_reg:=ret_in_acc(def,calloption) or (def.deftype=floatdef);
       end;
       end;
 
 
     { true if uses a parameter as return value }
     { true if uses a parameter as return value }
-    function tparamanager.ret_in_param(def : tdef) : boolean;
+    function tparamanager.ret_in_param(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
          ret_in_param:=(def.deftype in [arraydef,recorddef]) or
          ret_in_param:=(def.deftype in [arraydef,recorddef]) or
            ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_shortstring,st_longstring])) or
            ((def.deftype=stringdef) and (tstringdef(def).string_typ in [st_shortstring,st_longstring])) or
@@ -136,7 +137,7 @@ unit paramgr;
       end;
       end;
 
 
 
 
-    function tparamanager.push_high_param(def : tdef) : boolean;
+    function tparamanager.push_high_param(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
          push_high_param:=is_open_array(def) or
          push_high_param:=is_open_array(def) or
                           is_open_string(def) or
                           is_open_string(def) or
@@ -145,7 +146,7 @@ unit paramgr;
 
 
 
 
     { true if a parameter is too large to copy and only the address is pushed }
     { true if a parameter is too large to copy and only the address is pushed }
-    function tparamanager.push_addr_param(def : tdef;is_cdecl:boolean) : boolean;
+    function tparamanager.push_addr_param(def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin
         push_addr_param:=false;
         push_addr_param:=false;
         if never_copy_const_param then
         if never_copy_const_param then
@@ -157,14 +158,14 @@ unit paramgr;
              formaldef :
              formaldef :
                push_addr_param:=true;
                push_addr_param:=true;
              recorddef :
              recorddef :
-               push_addr_param:=(not is_cdecl) and (def.size>pointer_size);
+               push_addr_param:=not(calloption in [pocall_cdecl,pocall_cppdecl]) and (def.size>pointer_size);
              arraydef :
              arraydef :
                push_addr_param:=(
                push_addr_param:=(
                                  (tarraydef(def).highrange>=tarraydef(def).lowrange) and
                                  (tarraydef(def).highrange>=tarraydef(def).lowrange) and
                                   (
                                   (
                                    not(target_info.system=system_i386_win32) or
                                    not(target_info.system=system_i386_win32) or
                                    ((def.size>pointer_size) and
                                    ((def.size>pointer_size) and
-                                    (not is_cdecl))
+                                    not(calloption in [pocall_cdecl,pocall_cppdecl]))
                                   )
                                   )
                                 ) or
                                 ) or
                                 is_open_array(def) or
                                 is_open_array(def) or
@@ -175,9 +176,9 @@ unit paramgr;
              stringdef :
              stringdef :
                push_addr_param:=tstringdef(def).string_typ in [st_shortstring,st_longstring];
                push_addr_param:=tstringdef(def).string_typ in [st_shortstring,st_longstring];
              procvardef :
              procvardef :
-               push_addr_param:=(not is_cdecl) and (po_methodpointer in tprocvardef(def).procoptions);
+               push_addr_param:=not(calloption in [pocall_cdecl,pocall_cppdecl]) and (po_methodpointer in tprocvardef(def).procoptions);
              setdef :
              setdef :
-               push_addr_param:=(not is_cdecl) and (tsetdef(def).settype<>smallset);
+               push_addr_param:=not(calloption in [pocall_cdecl,pocall_cppdecl]) and (tsetdef(def).settype<>smallset);
            end;
            end;
          end;
          end;
       end;
       end;
@@ -203,7 +204,7 @@ unit paramgr;
       end;
       end;
 
 
 
 
-    function tparamanager.getfuncresultloc(def : tdef): tparalocation;
+    function tparamanager.getfuncresultloc(def : tdef;calloption:tproccalloption): tparalocation;
       begin
       begin
          fillchar(result,sizeof(tparalocation),0);
          fillchar(result,sizeof(tparalocation),0);
          if is_void(def) then exit;
          if is_void(def) then exit;
@@ -234,7 +235,7 @@ unit paramgr;
              end;
              end;
           else
           else
              begin
              begin
-                if ret_in_reg(def) then
+                if ret_in_reg(def,calloption) then
                   begin
                   begin
                     result.loc := LOC_REGISTER;
                     result.loc := LOC_REGISTER;
                     result.register := accumulator;
                     result.register := accumulator;
@@ -261,7 +262,7 @@ unit paramgr;
       end;
       end;
 
 
 
 
-    function getfuncretusedregisters(def : tdef): tregisterset;
+    function getfuncretusedregisters(def : tdef;calloption:tproccalloption): tregisterset;
       var
       var
         paramloc : tparalocation;
         paramloc : tparalocation;
         regset : tregisterset;
         regset : tregisterset;
@@ -272,9 +273,9 @@ unit paramgr;
           its useless to continue on in this
           its useless to continue on in this
           routine
           routine
         }
         }
-        if not paramanager.ret_in_reg(def) then
+        if not paramanager.ret_in_reg(def,calloption) then
           exit;
           exit;
-        paramloc := paramanager.getfuncresultloc(def);
+        paramloc := paramanager.getfuncresultloc(def,calloption);
         case paramloc.loc of
         case paramloc.loc of
           LOC_FPUREGISTER,
           LOC_FPUREGISTER,
           LOC_CFPUREGISTER,
           LOC_CFPUREGISTER,
@@ -310,7 +311,7 @@ unit paramgr;
                  (
                  (
                   (vo_regable in tvarsym(hp.parasym).varoptions) or
                   (vo_regable in tvarsym(hp.parasym).varoptions) or
                   (vo_fpuregable in tvarsym(hp.parasym).varoptions) or
                   (vo_fpuregable in tvarsym(hp.parasym).varoptions) or
-                   paramanager.push_addr_param(hp.paratype.def,p.proccalloption in [pocall_cdecl,pocall_cppdecl]) or
+                   paramanager.push_addr_param(hp.paratype.def,p.proccalloption) or
                    (hp.paratyp in [vs_var,vs_out])
                    (hp.paratyp in [vs_var,vs_out])
                  ) then
                  ) then
                 begin
                 begin
@@ -338,7 +339,10 @@ end.
 
 
 {
 {
    $Log$
    $Log$
-   Revision 1.22  2002-11-16 18:00:04  peter
+   Revision 1.23  2002-11-18 17:31:58  peter
+     * pass proccalloption to ret_in_xxx and push_xxx functions
+
+   Revision 1.22  2002/11/16 18:00:04  peter
      * only push small arrays on the stack for win32
      * only push small arrays on the stack for win32
 
 
    Revision 1.21  2002/10/05 12:43:25  carl
    Revision 1.21  2002/10/05 12:43:25  carl

+ 7 - 4
compiler/pdecsub.pas

@@ -332,13 +332,13 @@ implementation
                      vs.vartype:=tt;
                      vs.vartype:=tt;
                      vs.varspez:=varspez;
                      vs.varspez:=varspez;
                      if (varspez in [vs_var,vs_const,vs_out]) and
                      if (varspez in [vs_var,vs_const,vs_out]) and
-                        paramanager.push_addr_param(tt.def,false) then
+                        paramanager.push_addr_param(tt.def,aktprocdef.proccalloption) then
                        include(vs.varoptions,vo_regable);
                        include(vs.varoptions,vo_regable);
 
 
                      { do we need a local copy? Then rename the varsym, do this after the
                      { do we need a local copy? Then rename the varsym, do this after the
                        insert so the dup id checking is done correctly }
                        insert so the dup id checking is done correctly }
                      if (varspez=vs_value) and
                      if (varspez=vs_value) and
-                        paramanager.push_addr_param(tt.def,aktprocdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
+                        paramanager.push_addr_param(tt.def,aktprocdef.proccalloption) and
                         not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
                         not(is_open_array(tt.def) or is_array_of_const(tt.def)) then
                        currparast.rename(vs.name,'val'+vs.name);
                        currparast.rename(vs.name,'val'+vs.name);
 
 
@@ -2027,7 +2027,7 @@ const
          begin
          begin
            if not parse_only then
            if not parse_only then
             begin
             begin
-              if paramanager.ret_in_param(aprocdef.rettype.def) then
+              if paramanager.ret_in_param(aprocdef.rettype.def,aprocdef.proccalloption) then
                begin
                begin
                  aprocdef.parast.insert(otsym);
                  aprocdef.parast.insert(otsym);
                  { this allows to read the funcretoffset }
                  { this allows to read the funcretoffset }
@@ -2054,7 +2054,10 @@ const
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.80  2002-11-17 16:31:56  carl
+  Revision 1.81  2002-11-18 17:31:58  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.80  2002/11/17 16:31:56  carl
     * memory optimization (3-4%) : cleanup of tai fields,
     * memory optimization (3-4%) : cleanup of tai fields,
        cleanup of tdef and tsym fields.
        cleanup of tdef and tsym fields.
     * make it work for m68k
     * make it work for m68k

+ 8 - 1
compiler/pexpr.pas

@@ -611,6 +611,10 @@ implementation
       begin
       begin
          prevafterassn:=afterassignment;
          prevafterassn:=afterassignment;
          afterassignment:=false;
          afterassignment:=false;
+{$ifdef EXTDEBUG}
+         if p1.nodetype<>calln then
+           internalerror(20021118);
+{$endif EXTDEBUG}
          { want we only determine the address of }
          { want we only determine the address of }
          { a subroutine ?                       }
          { a subroutine ?                       }
          if not(getaddr) then
          if not(getaddr) then
@@ -2263,7 +2267,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.86  2002-10-05 00:48:57  peter
+  Revision 1.87  2002-11-18 17:31:58  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.86  2002/10/05 00:48:57  peter
     * support inherited; support for overload as it is handled by
     * support inherited; support for overload as it is handled by
       delphi. This is only for delphi mode as it is working is
       delphi. This is only for delphi mode as it is working is
       undocumented and hard to predict what is done
       undocumented and hard to predict what is done

+ 6 - 3
compiler/powerpc/cpupara.pas

@@ -137,7 +137,7 @@ unit cpupara;
          { pointer for structured results ? }
          { pointer for structured results ? }
          if not is_void(p.rettype.def) then
          if not is_void(p.rettype.def) then
            begin
            begin
-              if not(ret_in_reg(p.rettype.def)) then
+              if not(ret_in_reg(p.rettype.def,p.proccalloption)) then
                 inc(nextintreg);
                 inc(nextintreg);
            end;
            end;
 
 
@@ -216,7 +216,7 @@ unit cpupara;
                  LOC_REFERENCE:
                  LOC_REFERENCE:
                    begin
                    begin
                       hp.paraloc.size:=OS_ADDR;
                       hp.paraloc.size:=OS_ADDR;
-                      if push_addr_param(hp.paratype.def,p.proccalloption in [pocall_cdecl,pocall_cppdecl]) or (hp.paratyp in [vs_var,vs_out]) then
+                      if push_addr_param(hp.paratype.def,p.proccalloption) or (hp.paratyp in [vs_var,vs_out]) then
                         begin
                         begin
                            if nextintreg<=R_10 then
                            if nextintreg<=R_10 then
                              begin
                              begin
@@ -295,7 +295,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2002-10-02 13:33:36  jonas
+  Revision 1.16  2002-11-18 17:32:01  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.15  2002/10/02 13:33:36  jonas
     + set, variant support in getfuncretparaloc
     + set, variant support in getfuncretparaloc
 
 
   Revision 1.14  2002/09/28 21:27:16  florian
   Revision 1.14  2002/09/28 21:27:16  florian

+ 7 - 4
compiler/powerpc/cpupi.pas

@@ -71,7 +71,7 @@ unit cpupi;
               procinfo.framepointer_offset:=procdef.parast.address_fixup;
               procinfo.framepointer_offset:=procdef.parast.address_fixup;
               inc(procdef.parast.address_fixup,4);
               inc(procdef.parast.address_fixup,4);
            end;
            end;
-         if paramanager.ret_in_param(procdef.rettype.def) then
+         if paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption) then
            begin
            begin
               procinfo.return_offset:=procdef.parast.address_fixup;
               procinfo.return_offset:=procdef.parast.address_fixup;
               inc(procdef.parast.address_fixup,4);
               inc(procdef.parast.address_fixup,4);
@@ -84,7 +84,7 @@ unit cpupi;
          { this value is necessary for nested procedures }
          { this value is necessary for nested procedures }
          procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
          procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
          if assigned(aktprocdef.funcretsym) and
          if assigned(aktprocdef.funcretsym) and
-           not(paramanager.ret_in_param(procdef.rettype.def)) then
+           not(paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption)) then
            procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
            procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
      end;
      end;
 
 
@@ -103,7 +103,7 @@ unit cpupi;
          procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
          procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
 
 
          if assigned(aktprocdef.funcretsym) and
          if assigned(aktprocdef.funcretsym) and
-           not(paramanager.ret_in_param(procdef.rettype.def)) then
+           not(paramanager.ret_in_param(procdef.rettype.def,procdef.proccalloption)) then
            procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
            procinfo.return_offset:=tg.direction*tfuncretsym(aktprocdef.funcretsym).address+procdef.localst.address_fixup;
 
 
          if cs_asm_source in aktglobalswitches then
          if cs_asm_source in aktglobalswitches then
@@ -123,7 +123,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-10 20:30:42  florian
+  Revision 1.5  2002-11-18 17:32:01  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.4  2002/09/10 20:30:42  florian
     * fixed offset calculation for symtables etc.
     * fixed offset calculation for symtables etc.
 
 
   Revision 1.3  2002/09/07 17:54:59  florian
   Revision 1.3  2002/09/07 17:54:59  florian

+ 7 - 4
compiler/pstatmnt.pas

@@ -710,7 +710,7 @@ implementation
       var
       var
         asmstat : tasmnode;
         asmstat : tasmnode;
         Marker  : tai;
         Marker  : tai;
-        r,r2    : tregister;
+        r       : tregister;
         found   : boolean;
         found   : boolean;
         hs      : string;
         hs      : string;
       begin
       begin
@@ -1121,7 +1121,7 @@ implementation
             (aktprocdef.owner.symtabletype<>objectsymtable) and
             (aktprocdef.owner.symtabletype<>objectsymtable) and
             (not assigned(aktprocdef.funcretsym) or
             (not assigned(aktprocdef.funcretsym) or
              (tfuncretsym(aktprocdef.funcretsym).refcount<=1)) and
              (tfuncretsym(aktprocdef.funcretsym).refcount<=1)) and
-            not(paramanager.ret_in_param(aktprocdef.rettype.def)) and
+            not(paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption)) and
             (target_cpu in [cpu_i386,cpu_m68k,cpu_vm])
             (target_cpu in [cpu_i386,cpu_m68k,cpu_vm])
 {$ifdef CHECKFORPUSH}
 {$ifdef CHECKFORPUSH}
             and not(UsesPush(tasmnode(p)))
             and not(UsesPush(tasmnode(p)))
@@ -1133,7 +1133,7 @@ implementation
           register.
           register.
         }
         }
         if assigned(aktprocdef.funcretsym) and
         if assigned(aktprocdef.funcretsym) and
-           paramanager.ret_in_reg(aktprocdef.rettype.def) then
+           paramanager.ret_in_reg(aktprocdef.rettype.def,aktprocdef.proccalloption) then
           tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
           tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
 
 
         { because the END is already read we need to get the
         { because the END is already read we need to get the
@@ -1146,7 +1146,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.78  2002-09-07 19:34:08  florian
+  Revision 1.79  2002-11-18 17:31:58  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.78  2002/09/07 19:34:08  florian
     + tcg.direction is used now
     + tcg.direction is used now
 
 
   Revision 1.77  2002/09/07 15:25:07  peter
   Revision 1.77  2002/09/07 15:25:07  peter

+ 5 - 2
compiler/psub.pas

@@ -621,7 +621,7 @@ implementation
 {$endif i386}
 {$endif i386}
 
 
          { pointer to the return value ? }
          { pointer to the return value ? }
-         if paramanager.ret_in_param(aktprocdef.rettype.def)
+         if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption)
 {$ifdef m68k}
 {$ifdef m68k}
             and not (aktprocdef.proccalloption in [pocall_cdecl])
             and not (aktprocdef.proccalloption in [pocall_cdecl])
 {$endif m68k}
 {$endif m68k}
@@ -802,7 +802,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.75  2002-11-17 16:31:57  carl
+  Revision 1.76  2002-11-18 17:31:58  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.75  2002/11/17 16:31:57  carl
     * memory optimization (3-4%) : cleanup of tai fields,
     * memory optimization (3-4%) : cleanup of tai fields,
        cleanup of tdef and tsym fields.
        cleanup of tdef and tsym fields.
     * make it work for m68k
     * make it work for m68k

+ 7 - 4
compiler/rautils.pas

@@ -736,7 +736,7 @@ Begin
   if (not is_void(aktprocdef.rettype.def)) then
   if (not is_void(aktprocdef.rettype.def)) then
    begin
    begin
      if (m_tp7 in aktmodeswitches) and
      if (m_tp7 in aktmodeswitches) and
-        paramanager.ret_in_reg(aktprocdef.rettype.def) then
+        paramanager.ret_in_reg(aktprocdef.rettype.def,aktprocdef.proccalloption) then
        begin
        begin
          Message(asmr_e_cannot_use_RESULT_here);
          Message(asmr_e_cannot_use_RESULT_here);
          exit;
          exit;
@@ -874,7 +874,7 @@ Begin
                 end;
                 end;
               if (tvarsym(sym).varspez=vs_var) or
               if (tvarsym(sym).varspez=vs_var) or
                  ((tvarsym(sym).varspez=vs_const) and
                  ((tvarsym(sym).varspez=vs_const) and
-                  paramanager.push_addr_param(tvarsym(sym).vartype.def,false)) then
+                  paramanager.push_addr_param(tvarsym(sym).vartype.def,aktprocdef.proccalloption)) then
                 SetSize(pointer_size,false);
                 SetSize(pointer_size,false);
             end;
             end;
           localsymtable :
           localsymtable :
@@ -914,7 +914,7 @@ Begin
                 end;
                 end;
               if (tvarsym(sym).varspez in [vs_var,vs_out]) or
               if (tvarsym(sym).varspez in [vs_var,vs_out]) or
                  ((tvarsym(sym).varspez=vs_const) and
                  ((tvarsym(sym).varspez=vs_const) and
-                  paramanager.push_addr_param(tvarsym(sym).vartype.def,false)) then
+                  paramanager.push_addr_param(tvarsym(sym).vartype.def,aktprocdef.proccalloption)) then
                 SetSize(pointer_size,false);
                 SetSize(pointer_size,false);
             end;
             end;
         end;
         end;
@@ -1592,7 +1592,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2002-11-15 16:29:31  peter
+  Revision 1.48  2002-11-18 17:31:59  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.47  2002/11/15 16:29:31  peter
     * made tasmsymbol.refs private (merged)
     * made tasmsymbol.refs private (merged)
 
 
   Revision 1.46  2002/09/03 16:26:27  daniel
   Revision 1.46  2002/09/03 16:26:27  daniel

+ 6 - 3
compiler/regvars.pas

@@ -178,7 +178,7 @@ implementation
                       { call by reference/const ? }
                       { call by reference/const ? }
                       if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
                       if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
                          ((regvarinfo^.regvars[i].varspez=vs_const) and
                          ((regvarinfo^.regvars[i].varspez=vs_const) and
-                           paramanager.push_addr_param(regvarinfo^.regvars[i].vartype.def,false)) then
+                           paramanager.push_addr_param(regvarinfo^.regvars[i].vartype.def,aktprocdef.proccalloption)) then
                         begin
                         begin
                            regvarinfo^.regvars[i].reg:=varregs[i];
                            regvarinfo^.regvars[i].reg:=varregs[i];
                         end
                         end
@@ -316,7 +316,7 @@ implementation
           hr.base:=procinfo.framepointer;
           hr.base:=procinfo.framepointer;
           if (vsym.varspez in [vs_var,vs_out]) or
           if (vsym.varspez in [vs_var,vs_out]) or
              ((vsym.varspez=vs_const) and
              ((vsym.varspez=vs_const) and
-               paramanager.push_addr_param(vsym.vartype.def,false)) then
+               paramanager.push_addr_param(vsym.vartype.def,aktprocdef.proccalloption)) then
             opsize := OS_ADDR
             opsize := OS_ADDR
           else
           else
             opsize := def_cgsize(vsym.vartype.def);
             opsize := def_cgsize(vsym.vartype.def);
@@ -469,7 +469,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.41  2002-08-25 19:25:20  peter
+  Revision 1.42  2002-11-18 17:31:59  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.41  2002/08/25 19:25:20  peter
     * sym.insert_in_data removed
     * sym.insert_in_data removed
     * symtable.insertvardata/insertconstdata added
     * symtable.insertvardata/insertconstdata added
     * removed insert_in_data call from symtable.insert, it needs to be
     * removed insert_in_data call from symtable.insert, it needs to be

+ 7 - 4
compiler/sparc/cpupara.pas

@@ -206,7 +206,7 @@ WriteLn('***********************************************');
                  LOC_REFERENCE:
                  LOC_REFERENCE:
                    begin
                    begin
                       hp.paraloc.size:=OS_ADDR;
                       hp.paraloc.size:=OS_ADDR;
-                      if push_addr_param(hp.paratype.def,p.proccalloption in [pocall_cdecl,pocall_cppdecl]) or (hp.paratyp in [vs_var,vs_out]) then
+                      if push_addr_param(hp.paratype.def,p.proccalloption) or (hp.paratyp in [vs_var,vs_out]) then
                         begin
                         begin
                            if nextintreg<=R_O5 then
                            if nextintreg<=R_O5 then
                              begin
                              begin
@@ -283,7 +283,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2002-11-03 20:22:40  mazen
+  Revision 1.10  2002-11-18 17:32:01  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.9  2002/11/03 20:22:40  mazen
   * parameter handling updated
   * parameter handling updated
 
 
   Revision 1.8  2002/10/13 21:46:07  mazen
   Revision 1.8  2002/10/13 21:46:07  mazen
@@ -297,10 +300,10 @@ end.
 
 
   Revision 1.5  2002/10/09 13:52:19  mazen
   Revision 1.5  2002/10/09 13:52:19  mazen
   just incase some one wolud help me debugging that\!
   just incase some one wolud help me debugging that\!
-  
+
   Revision 1.4  2002/10/08 21:02:22  mazen
   Revision 1.4  2002/10/08 21:02:22  mazen
   * debugging register allocation
   * debugging register allocation
-  
+
   Revision 1.3  2002/10/07 20:33:05  mazen
   Revision 1.3  2002/10/07 20:33:05  mazen
   word alignement modified in g_stack_frame
   word alignement modified in g_stack_frame
 
 

+ 5 - 2
compiler/sparc/radirect.pas

@@ -148,7 +148,7 @@ end;
                                  { is the last written character an special }
                                  { is the last written character an special }
                                  { char ?                                   }
                                  { char ?                                   }
                                  if (s[length(s)]='%') and
                                  if (s[length(s)]='%') and
-                                    paramanager.ret_in_acc(aktprocdef.rettype.def) and
+                                    paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) and
                                     ((pos('AX',upper(hs))>0) or
                                     ((pos('AX',upper(hs))>0) or
                                     (pos('AL',upper(hs))>0)) then
                                     (pos('AL',upper(hs))>0)) then
                                    tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
                                    tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
@@ -314,7 +314,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2002-09-19 20:24:47  mazen
+  Revision 1.3  2002-11-18 17:32:01  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.2  2002/09/19 20:24:47  mazen
   + call support
   + call support
 
 
   Revision 1.1  2002/08/23 10:08:28  mazen
   Revision 1.1  2002/08/23 10:08:28  mazen

+ 7 - 6
compiler/symdef.pas

@@ -3143,10 +3143,8 @@ implementation
       var
       var
          pdc : TParaItem;
          pdc : TParaItem;
          l : longint;
          l : longint;
-         is_cdecl : boolean;
       begin
       begin
          l:=0;
          l:=0;
-         is_cdecl:=(proccalloption in [pocall_cdecl,pocall_cppdecl]);
          pdc:=TParaItem(Para.first);
          pdc:=TParaItem(Para.first);
          while assigned(pdc) do
          while assigned(pdc) do
           begin
           begin
@@ -3157,7 +3155,7 @@ implementation
               vs_value,
               vs_value,
               vs_const :
               vs_const :
                 begin
                 begin
-                  if paramanager.push_addr_param(pdc.paratype.def,is_cdecl) then
+                  if paramanager.push_addr_param(pdc.paratype.def,proccalloption) then
                     inc(l,POINTER_SIZE)
                     inc(l,POINTER_SIZE)
                   else
                   else
                     inc(l,pdc.paratype.def.size);
                     inc(l,pdc.paratype.def.size);
@@ -4129,7 +4127,7 @@ implementation
          iidstr:=nil;
          iidstr:=nil;
          if objecttype in [odt_interfacecom,odt_interfacecorba] then
          if objecttype in [odt_interfacecom,odt_interfacecorba] then
            begin
            begin
-              new(iidguid); 
+              new(iidguid);
               ppufile.getguid(iidguid^);
               ppufile.getguid(iidguid^);
               iidstr:=stringdup(ppufile.getstring);
               iidstr:=stringdup(ppufile.getstring);
               lastvtableindex:=ppufile.getlongint;
               lastvtableindex:=ppufile.getlongint;
@@ -4244,7 +4242,7 @@ implementation
            implementedinterfaces.deref;
            implementedinterfaces.deref;
       end;
       end;
 
 
-    
+
     procedure tobjectdef.prepareguid;
     procedure tobjectdef.prepareguid;
       begin
       begin
         { set up guid }
         { set up guid }
@@ -5520,7 +5518,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.105  2002-11-17 16:31:57  carl
+  Revision 1.106  2002-11-18 17:31:59  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.105  2002/11/17 16:31:57  carl
     * memory optimization (3-4%) : cleanup of tai fields,
     * memory optimization (3-4%) : cleanup of tai fields,
        cleanup of tdef and tsym fields.
        cleanup of tdef and tsym fields.
     * make it work for m68k
     * make it work for m68k

+ 10 - 9
compiler/symsym.pas

@@ -29,7 +29,7 @@ interface
        { common }
        { common }
        cutils,
        cutils,
        { target }
        { target }
-       cpuinfo,
+       cpuinfo,globtype,
        { symtable }
        { symtable }
        symconst,symbase,symtype,symdef,
        symconst,symbase,symtype,symdef,
        { ppu }
        { ppu }
@@ -193,7 +193,7 @@ interface
           procedure set_mangledname(const s:string);
           procedure set_mangledname(const s:string);
           function  getsize : longint;
           function  getsize : longint;
           function  getvaluesize : longint;
           function  getvaluesize : longint;
-          function  getpushsize(is_cdecl:boolean): longint;
+          function  getpushsize(calloption:tproccalloption): longint;
 {$ifdef var_notification}
 {$ifdef var_notification}
           function register_notification(flags:Tnotification_flags;
           function register_notification(flags:Tnotification_flags;
                                          callback:Tnotification_callback):cardinal;
                                          callback:Tnotification_callback):cardinal;
@@ -378,7 +378,7 @@ implementation
        strings,
        strings,
 {$endif Delphi}
 {$endif Delphi}
        { global }
        { global }
-       globtype,verbose,
+       verbose,
        { target }
        { target }
        systems,
        systems,
        { symtable }
        { symtable }
@@ -1665,7 +1665,7 @@ implementation
       end;
       end;
 
 
 
 
-    function tvarsym.getpushsize(is_cdecl:boolean) : longint;
+    function tvarsym.getpushsize(calloption:tproccalloption) : longint;
       begin
       begin
          getpushsize:=-1;
          getpushsize:=-1;
          if assigned(vartype.def) then
          if assigned(vartype.def) then
@@ -1677,7 +1677,7 @@ implementation
                 vs_value,
                 vs_value,
                 vs_const :
                 vs_const :
                   begin
                   begin
-                      if paramanager.push_addr_param(vartype.def,is_cdecl) then
+                      if paramanager.push_addr_param(vartype.def,calloption) then
                         getpushsize:=pointer_size
                         getpushsize:=pointer_size
                       else
                       else
                         getpushsize:=vartype.def.size;
                         getpushsize:=vartype.def.size;
@@ -1705,7 +1705,6 @@ implementation
     function tvarsym.stabstring : pchar;
     function tvarsym.stabstring : pchar;
      var
      var
        st : string;
        st : string;
-       is_cdecl : boolean;
      begin
      begin
        st:=tstoreddef(vartype.def).numberstring;
        st:=tstoreddef(vartype.def).numberstring;
        if (owner.symtabletype = objectsymtable) and
        if (owner.symtabletype = objectsymtable) and
@@ -1733,12 +1732,11 @@ implementation
          end
          end
        else if (owner.symtabletype in [parasymtable,inlineparasymtable]) then
        else if (owner.symtabletype in [parasymtable,inlineparasymtable]) then
          begin
          begin
-            is_cdecl:=(tprocdef(owner.defowner).proccalloption in [pocall_cdecl,pocall_cppdecl]);
             case varspez of
             case varspez of
                vs_out,
                vs_out,
                vs_var   : st := 'v'+st;
                vs_var   : st := 'v'+st;
                vs_value,
                vs_value,
-               vs_const : if paramanager.push_addr_param(vartype.def,is_cdecl) then
+               vs_const : if paramanager.push_addr_param(vartype.def,tprocdef(owner.defowner).proccalloption) then
                             st := 'v'+st { should be 'i' but 'i' doesn't work }
                             st := 'v'+st { should be 'i' but 'i' doesn't work }
                           else
                           else
                             st := 'p'+st;
                             st := 'p'+st;
@@ -2506,7 +2504,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.72  2002-11-17 16:31:57  carl
+  Revision 1.73  2002-11-18 17:31:59  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.72  2002/11/17 16:31:57  carl
     * memory optimization (3-4%) : cleanup of tai fields,
     * memory optimization (3-4%) : cleanup of tai fields,
        cleanup of tdef and tsym fields.
        cleanup of tdef and tsym fields.
     * make it work for m68k
     * make it work for m68k

+ 7 - 5
compiler/symtable.pas

@@ -1324,7 +1324,8 @@ implementation
               else
               else
                begin
                begin
                  { allocate space in local if ret in register }
                  { allocate space in local if ret in register }
-                 if paramanager.ret_in_reg(tfuncretsym(sym).returntype.def) then
+                 if paramanager.ret_in_reg(tfuncretsym(sym).returntype.def,
+                                           tprocdef(sym.owner.defowner).proccalloption) then
                   begin
                   begin
                     l:=tfuncretsym(sym).returntype.def.size;
                     l:=tfuncretsym(sym).returntype.def.size;
                     varalign:=size_2_align(l);
                     varalign:=size_2_align(l);
@@ -1432,17 +1433,15 @@ implementation
     procedure tparasymtable.insertvardata(sym : tsymentry);
     procedure tparasymtable.insertvardata(sym : tsymentry);
       var
       var
         l,varalign : longint;
         l,varalign : longint;
-        is_cdecl : boolean;
       begin
       begin
         if sym.typ<>varsym then
         if sym.typ<>varsym then
           internalerror(200208253);
           internalerror(200208253);
         { retrieve cdecl status }
         { retrieve cdecl status }
         if defowner.deftype<>procdef then
         if defowner.deftype<>procdef then
           internalerror(200208256);
           internalerror(200208256);
-        is_cdecl:=(tprocdef(defowner).proccalloption in [pocall_cdecl,pocall_cppdecl]);
         { here we need the size of a push instead of the
         { here we need the size of a push instead of the
           size of the data }
           size of the data }
-        l:=tvarsym(sym).getpushsize(is_cdecl);
+        l:=tvarsym(sym).getpushsize(tprocdef(defowner).proccalloption);
         varalign:=size_2_align(l);
         varalign:=size_2_align(l);
         tvarsym(sym).varstate:=vs_assigned;
         tvarsym(sym).varstate:=vs_assigned;
         { we need the new datasize already aligned so we can't
         { we need the new datasize already aligned so we can't
@@ -2343,7 +2342,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.77  2002-11-15 01:58:54  peter
+  Revision 1.78  2002-11-18 17:32:00  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.77  2002/11/15 01:58:54  peter
     * merged changes from 1.0.7 up to 04-11
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - -V option for generating bug report tracing
       - more tracing for option parsing
       - more tracing for option parsing

+ 5 - 2
compiler/x86/cgx86.pas

@@ -1510,7 +1510,7 @@ unit cgx86;
         if (po_clearstack in aktprocdef.procoptions) then
         if (po_clearstack in aktprocdef.procoptions) then
          begin
          begin
            { complex return values are removed from stack in C code PM }
            { complex return values are removed from stack in C code PM }
-           if paramanager.ret_in_param(aktprocdef.rettype.def) then
+           if paramanager.ret_in_param(aktprocdef.rettype.def,aktprocdef.proccalloption) then
              list.concat(Taicpu.Op_const(A_RET,S_NO,4))
              list.concat(Taicpu.Op_const(A_RET,S_NO,4))
            else
            else
              list.concat(Taicpu.Op_none(A_RET,S_NO));
              list.concat(Taicpu.Op_none(A_RET,S_NO));
@@ -1682,7 +1682,10 @@ unit cgx86;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2002-11-09 21:18:31  carl
+  Revision 1.21  2002-11-18 17:32:01  peter
+    * pass proccalloption to ret_in_xxx and push_xxx functions
+
+  Revision 1.20  2002/11/09 21:18:31  carl
     * flags2reg() was not extending the byte register to the correct result size
     * flags2reg() was not extending the byte register to the correct result size
 
 
   Revision 1.19  2002/10/16 19:01:43  peter
   Revision 1.19  2002/10/16 19:01:43  peter