Explorar o código

* moved setting the call result to a separate method, so it can still be
used across multiple levels of inheritance such as on MIPS (and the code
has to be reusable for a_call_ref/reeg in the future anyway)

git-svn-id: trunk@21906 -

Jonas Maebe %!s(int64=13) %!d(string=hai) anos
pai
achega
7717e43929
Modificáronse 4 ficheiros con 19 adicións e 19 borrados
  1. 2 2
      compiler/hlcg2ll.pas
  2. 14 14
      compiler/hlcgobj.pas
  3. 1 1
      compiler/jvm/hlcgcpu.pas
  4. 2 2
      compiler/mips/hlcgcpu.pas

+ 2 - 2
compiler/hlcg2ll.pas

@@ -459,7 +459,7 @@ implementation
   function thlcg2ll.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara;
     begin
       cg.a_call_name(list,s,weak);
-      result:=inherited;
+      result:=get_call_result_cgpara(pd,forceresdef);
     end;
 
   procedure thlcg2ll.a_call_reg(list: TAsmList; pd: tabstractprocdef; reg: tregister);
@@ -475,7 +475,7 @@ implementation
   function thlcg2ll.a_call_name_static(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef): tcgpara;
     begin
       cg.a_call_name_static(list,s);
-      result:=inherited a_call_name(list,pd,s,forceresdef,false);
+      result:=get_call_result_cgpara(pd,forceresdef);
     end;
 
   procedure thlcg2ll.a_load_const_reg(list: TAsmList; tosize: tdef; a: aint; register: tregister);

+ 14 - 14
compiler/hlcgobj.pas

@@ -194,7 +194,7 @@ unit hlcgobj;
              Returns the function result location.
              This routine must be overridden for each new target cpu.
           }
-          function a_call_name(list : TAsmList;pd : tprocdef;const s : TSymStr; forceresdef: tdef; weak: boolean): tcgpara;virtual;
+          function a_call_name(list : TAsmList;pd : tprocdef;const s : TSymStr; forceresdef: tdef; weak: boolean): tcgpara;virtual;abstract;
           procedure a_call_reg(list : TAsmList;pd : tabstractprocdef;reg : tregister);virtual;abstract;
           procedure a_call_ref(list : TAsmList;pd : tabstractprocdef;const ref : treference);virtual;
           { same as a_call_name, might be overridden on certain architectures to emit
@@ -261,6 +261,7 @@ unit hlcgobj;
           procedure a_bit_set_const_loc(list: TAsmList; doset: boolean; tosize: tdef; bitnumber: aint; const loc: tlocation);virtual;
 
          protected
+           function  get_call_result_cgpara(pd: tprocdef; forceresdef: tdef): tcgpara;
            procedure get_subsetref_load_info(const sref: tsubsetreference; out loadsize: torddef; out extra_load: boolean);
            procedure a_load_subsetref_regs_noindex(list: TAsmList; subsetsize: tdef; loadbitsize: byte; const sref: tsubsetreference; valuereg, extra_value_reg: tregister); virtual;
            procedure a_load_subsetref_regs_index(list: TAsmList; subsetsize: tdef; loadbitsize: byte; const sref: tsubsetreference; valuereg: tregister); virtual;
@@ -873,19 +874,6 @@ implementation
          end;
     end;
 
-  function thlcgobj.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara;
-    begin
-      { this is incomplete, it only sets the default function result location;
-        for use by descendants }
-      if not assigned(forceresdef) then
-        begin
-          pd.init_paraloc_info(callerside);
-          result:=pd.funcretloc[callerside];
-        end
-      else
-        result:=paramanager.get_funcretloc(pd,callerside,forceresdef);
-    end;
-
   procedure thlcgobj.a_call_ref(list: TAsmList; pd: tabstractprocdef; const ref: treference);
     var
       reg: tregister;
@@ -1586,6 +1574,18 @@ implementation
     end;
 
 
+  function thlcgobj.get_call_result_cgpara(pd: tprocdef; forceresdef: tdef): tcgpara;
+    begin
+      if not assigned(forceresdef) then
+        begin
+          pd.init_paraloc_info(callerside);
+          result:=pd.funcretloc[callerside];
+        end
+      else
+        result:=paramanager.get_funcretloc(pd,callerside,forceresdef);
+    end;
+
+
   (*
     Subsetrefs are used for (bit)packed arrays and (bit)packed records stored
     in memory. They are like a regular reference, but contain an extra bit

+ 1 - 1
compiler/jvm/hlcgcpu.pas

@@ -2343,7 +2343,7 @@ implementation
           pd.init_paraloc_info(calleeside);
           list.concat(taicpu.op_sym_const(opc,current_asmdata.RefAsmSymbol(s),pd.calleeargareasize));
         end;
-      result:=inherited a_call_name(list,pd,s,forceresdef,false);
+      result:=get_call_result_cgpara(pd,forceresdef);
     end;
 
   procedure create_hlcodegen;

+ 2 - 2
compiler/mips/hlcgcpu.pas

@@ -73,8 +73,8 @@ implementation
         end
       else
         cg.a_call_name(list,s,weak);
-      { the default implementation only determines the result location }
-      result:=inherited;
+      { set the result location }
+      result:=get_call_result_cgpara(pd,forceresdef);
     end;
 
   procedure thlcgmips.a_call_reg(list: TAsmList; pd: tabstractprocdef; reg: tregister);