Browse Source

+ 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

mazen 23 years ago
parent
commit
41153e2b1a

+ 12 - 1
compiler/alpha/cpubase.pas

@@ -132,6 +132,14 @@ unit cpubase;
        frame_pointer_reg = R_15;
        frame_pointer_reg = R_15;
        self_pointer_reg = R_16;
        self_pointer_reg = R_16;
        accumulator   = R_0;
        accumulator   = R_0;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
        fpu_result_reg = R_F0;
        fpu_result_reg = R_F0;
        global_pointer = R_29;
        global_pointer = R_29;
        return_pointer = R_26;
        return_pointer = R_26;
@@ -450,7 +458,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-29 23:54:12  florian
+  Revision 1.5  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
+
+  Revision 1.4  2002/09/29 23:54:12  florian
     * alpha compiles again, changes to common code not yet commited
     * alpha compiles again, changes to common code not yet commited
 
 
   Revision 1.3  2002/09/29 23:42:45  florian
   Revision 1.3  2002/09/29 23:42:45  florian

+ 12 - 1
compiler/i386/cpubase.pas

@@ -445,6 +445,14 @@ uses
       pic_offset_reg = R_EBX;
       pic_offset_reg = R_EBX;
       {# Results are returned in this register (32-bit values) }
       {# Results are returned in this register (32-bit values) }
       accumulator   = R_EAX;
       accumulator   = R_EAX;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
       {# Hi-Results are returned in this register (64-bit value high register) }
       {# Hi-Results are returned in this register (64-bit value high register) }
       accumulatorhigh = R_EDX;
       accumulatorhigh = R_EDX;
       { WARNING: don't change to R_ST0!! See comments above implementation of }
       { WARNING: don't change to R_ST0!! See comments above implementation of }
@@ -525,7 +533,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.32  2002-10-05 12:43:29  carl
+  Revision 1.33  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
+
+  Revision 1.32  2002/10/05 12:43:29  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)
 
 

+ 12 - 1
compiler/ia64/cpubase.pas

@@ -92,6 +92,14 @@ Const
   frame_pointer_reg = R_15;
   frame_pointer_reg = R_15;
   self_pointer_reg  = R_16;
   self_pointer_reg  = R_16;
   accumulator   = R_0;
   accumulator   = R_0;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
   global_pointer = R_29;
   global_pointer = R_29;
   return_pointer = R_26;
   return_pointer = R_26;
 
 
@@ -275,7 +283,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-07 15:25:11  peter
+  Revision 1.5  2002-11-17 17:49:09  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
+
+  Revision 1.4  2002/09/07 15:25:11  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
   Revision 1.3  2002/04/20 21:38:45  carl
   Revision 1.3  2002/04/20 21:38:45  carl

+ 12 - 1
compiler/m68k/cpubase.pas

@@ -490,6 +490,14 @@ uses
       pic_offset_reg = R_A5;
       pic_offset_reg = R_A5;
       {# Results are returned in this register (32-bit values) }
       {# Results are returned in this register (32-bit values) }
       accumulator   = R_D0;
       accumulator   = R_D0;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
       {# Hi-Results are returned in this register (64-bit value high register) }
       {# Hi-Results are returned in this register (64-bit value high register) }
       accumulatorhigh = R_D1;
       accumulatorhigh = R_D1;
       {# Floating point results will be placed into this register }
       {# Floating point results will be placed into this register }
@@ -584,7 +592,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2002-10-14 16:32:36  carl
+  Revision 1.12  2002-11-17 17:49:09  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
+
+  Revision 1.11  2002/10/14 16:32:36  carl
     + flag_2_cond implemented
     + flag_2_cond implemented
 
 
   Revision 1.10  2002/08/18 09:02:12  florian
   Revision 1.10  2002/08/18 09:02:12  florian

+ 14 - 3
compiler/ncgutil.pas

@@ -1121,7 +1121,11 @@ implementation
              enumdef :
              enumdef :
                begin
                begin
                  uses_acc:=true;
                  uses_acc:=true;
-                 cg.a_reg_alloc(list,accumulator);
+{$WARNING accumulator was replaced by return_result_reg}
+{Here, we return the function result. In most architectures, the value is
+passed into the accumulator, but in a windowed architecure like sparc a
+function returns in a register and the caller receives it in an other one}
+                  cg.a_reg_alloc(list,return_result_reg);
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
                  if cgsize in [OS_64,OS_S64] then
                  if cgsize in [OS_64,OS_S64] then
                   begin
                   begin
@@ -1132,7 +1136,11 @@ implementation
                  else
                  else
 {$endif cpu64bit}
 {$endif cpu64bit}
                   begin
                   begin
-                    hreg:=rg.makeregsize(accumulator,cgsize);
+{$WARNING accumulator was replaced by return_result_reg}
+{Here, we return the function result. In most architectures, the value is
+passed into the accumulator, but in a windowed architecure like sparc a
+function returns in a register and the caller receives it in an other one}
+                    hreg:=rg.makeregsize(return_result_reg,cgsize);
                     cg.a_load_ref_reg(list,cgsize,href,hreg);
                     cg.a_load_ref_reg(list,cgsize,href,hreg);
                   end;
                   end;
                end;
                end;
@@ -1867,7 +1875,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2002-11-17 16:31:56  carl
+  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
+
+  Revision 1.60  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

+ 12 - 1
compiler/powerpc/cpubase.pas

@@ -591,6 +591,14 @@ uses
       pic_offset_reg = R_30;
       pic_offset_reg = R_30;
       {# Results are returned in this register (32-bit values) }
       {# Results are returned in this register (32-bit values) }
       accumulator   = R_3;
       accumulator   = R_3;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
       {# Hi-Results are returned in this register (64-bit value high register) }
       {# Hi-Results are returned in this register (64-bit value high register) }
       accumulatorhigh = R_4;
       accumulatorhigh = R_4;
       { WARNING: don't change to R_ST0!! See comments above implementation of }
       { WARNING: don't change to R_ST0!! See comments above implementation of }
@@ -721,7 +729,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.34  2002-09-17 18:54:06  jonas
+  Revision 1.35  2002-11-17 17:49:09  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
+
+  Revision 1.34  2002/09/17 18:54:06  jonas
     * a_load_reg_reg() now has two size parameters: source and dest. This
     * a_load_reg_reg() now has two size parameters: source and dest. This
       allows some optimizations on architectures that don't encode the
       allows some optimizations on architectures that don't encode the
       register size in the register name.
       register size in the register name.

+ 5 - 2
compiler/sparc/cgcpu.pas

@@ -821,7 +821,7 @@ stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state
 before execution of the SAVE instrucion so it is the caller %i6, when the %i6
 before execution of the SAVE instrucion so it is the caller %i6, when the %i6
 after execution of that instruction is the called function stack pointer}
 after execution of that instruction is the called function stack pointer}
     with list do
     with list do
-      concat(Taicpu.Op_reg_const_reg(A_SAVE,Stack_Pointer_Reg,LocalSize,Stack_Pointer_Reg));
+      concat(Taicpu.Op_reg_const_reg(A_SAVE,Stack_Pointer_Reg,-LocalSize,Stack_Pointer_Reg));
   end;
   end;
 procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput);
 procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput);
   begin
   begin
@@ -1253,7 +1253,10 @@ BEGIN
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2002-11-10 19:07:46  mazen
+  Revision 1.24  2002-11-17 17:49:09  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
+
+  Revision 1.23  2002/11/10 19:07:46  mazen
   * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
   * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
 
 
   Revision 1.22  2002/11/06 11:31:24  mazen
   Revision 1.22  2002/11/06 11:31:24  mazen

+ 10 - 6
compiler/sparc/cpupi.pas

@@ -50,8 +50,6 @@ stack frame.}
   end;
   end;
 implementation
 implementation
 uses
 uses
-	globtype,globals,
-	aasmtai,
 	tgobj;
 	tgobj;
 constructor TSparcprocinfo.create;
 constructor TSparcprocinfo.create;
 	begin
 	begin
@@ -65,7 +63,7 @@ procedure TSparcprocinfo.after_header;
     register overflow/underflow}
     register overflow/underflow}
     {The 17th word is used to save the address of the variable which will
     {The 17th word is used to save the address of the variable which will
     receive the return value of the called function}
     receive the return value of the called function}
-    Return_Offset:=-64;{16*4}
+    Return_Offset:=64;{16*4}
     procdef.parast.address_fixup:=(16+1)*4;
     procdef.parast.address_fixup:=(16+1)*4;
   	{Reserve the stack for copying parameters passed into registers. By default
   	{Reserve the stack for copying parameters passed into registers. By default
     we reserve space for the 6 input registers even if the function had less
     we reserve space for the 6 input registers even if the function had less
@@ -83,8 +81,11 @@ procedure TSparcProcInfo.after_pass1;
 	      WriteLn('Parameter copies start at: %i6+'+tostr(parast.address_fixup));
 	      WriteLn('Parameter copies start at: %i6+'+tostr(parast.address_fixup));
     		WriteLn('Locals start at: %o6+'+tostr(localst.address_fixup));
     		WriteLn('Locals start at: %o6+'+tostr(localst.address_fixup));
 	      WriteLn('Temp. space start: %o6+'+tostr(firsttemp_offset));
 	      WriteLn('Temp. space start: %o6+'+tostr(firsttemp_offset));
-    		tg.firsttemp:=procinfo.firsttemp_offset;
-		    tg.lasttemp:=procinfo.firsttemp_offset;
+        with tg do
+          begin
+        		FirstTemp:=firsttemp_offset;
+		        LastTemp:=firsttemp_offset;
+          end;
       end;
       end;
 	end;
 	end;
 begin
 begin
@@ -92,7 +93,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2002-11-14 21:42:08  mazen
+  Revision 1.8  2002-11-17 17:49:09  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
+
+  Revision 1.7  2002/11/14 21:42:08  mazen
   * fixing return value variable address
   * fixing return value variable address
 
 
   Revision 1.6  2002/11/10 19:07:46  mazen
   Revision 1.6  2002/11/10 19:07:46  mazen

+ 7 - 1
compiler/tgobj.pas

@@ -157,6 +157,9 @@ unit tgobj;
 {$else powerpc}
 {$else powerpc}
        direction:=-1;
        direction:=-1;
 {$endif powerpc}
 {$endif powerpc}
+{$IFDEF SPARC}
+        Direction:=1;
+{$ENDIF SPARC}
      end;
      end;
 
 
 
 
@@ -532,7 +535,10 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2002-11-15 01:58:54  peter
+  Revision 1.20  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
+
+  Revision 1.19  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

+ 12 - 1
compiler/vis/cpubase.pas

@@ -437,6 +437,14 @@ uses
       pic_offset_reg = R_R10;
       pic_offset_reg = R_R10;
       {# Results are returned in this register (32-bit values) }
       {# Results are returned in this register (32-bit values) }
       accumulator   = R_R0;
       accumulator   = R_R0;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
       {# Hi-Results are returned in this register (64-bit value high register) }
       {# Hi-Results are returned in this register (64-bit value high register) }
       accumulatorhigh = R_R1;
       accumulatorhigh = R_R1;
       fpu_result_reg = R_FP0;
       fpu_result_reg = R_FP0;
@@ -526,7 +534,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2002-10-14 16:31:52  carl
+  Revision 1.2  2002-11-17 17:49:09  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
+
+  Revision 1.1  2002/10/14 16:31:52  carl
     + first revision of vm
     + first revision of vm
 
 
 }
 }

+ 12 - 1
compiler/x86_64/cpubase.pas

@@ -413,6 +413,14 @@ const
        frame_pointer_reg = R_RBP;
        frame_pointer_reg = R_RBP;
        self_pointer_reg  = R_RSI;
        self_pointer_reg  = R_RSI;
        accumulator   = R_RAX;
        accumulator   = R_RAX;
+  {the return_result_reg, is used inside the called function to store its return
+  value when that is a scalar value otherwise a pointer to the address of the
+  result is placed inside it}
+	return_result_reg		=	accmulator;
+
+  {the function_result_reg contains the function result after a call to a scalar
+  function othewise it contains a pointer to the returned result}
+	function_result_reg	=	accumulator;
        accumulatorhigh = R_RDX;
        accumulatorhigh = R_RDX;
        { the register where the vmt offset is passed to the destructor }
        { the register where the vmt offset is passed to the destructor }
        { helper routine                                                }
        { helper routine                                                }
@@ -491,7 +499,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2002-07-25 22:55:33  florian
+  Revision 1.3  2002-11-17 17:49:09  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
+
+  Revision 1.2  2002/07/25 22:55:33  florian
     * several fixes, small test units can be compiled
     * several fixes, small test units can be compiled
 
 
   Revision 1.1  2002/07/24 22:38:15  florian
   Revision 1.1  2002/07/24 22:38:15  florian