Browse Source

* moved ARM/x86 ifdef'ed code from ncgcal to virtual methods

git-svn-id: trunk@24179 -
Jonas Maebe 12 years ago
parent
commit
8b8a786823
3 changed files with 40 additions and 42 deletions
  1. 9 2
      compiler/arm/narmcal.pas
  2. 15 39
      compiler/ncgcal.pas
  3. 16 1
      compiler/x86/nx86cal.pas

+ 9 - 2
compiler/arm/narmcal.pas

@@ -38,8 +38,8 @@ implementation
   uses
   uses
     verbose,globtype,globals,aasmdata,
     verbose,globtype,globals,aasmdata,
     symconst,
     symconst,
-    cgbase,cpuinfo,
-    ncgutil,
+    cgbase,cgutils,cpuinfo,
+    ncgutil,tgobj,
     systems;
     systems;
 
 
   procedure tarmcallnode.set_result_location(realresdef: tstoreddef);
   procedure tarmcallnode.set_result_location(realresdef: tstoreddef);
@@ -64,6 +64,13 @@ implementation
               internalerror(2010053008);
               internalerror(2010053008);
           end
           end
         end
         end
+      else if (resultdef.typ=floatdef) and
+         (location.loc=LOC_REGISTER) and
+         (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then
+        begin
+          location_reset_ref(location,LOC_REFERENCE,location.size,resultdef.alignment);
+          tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference);
+        end
       else
       else
         inherited;
         inherited;
     end;
     end;

+ 15 - 39
compiler/ncgcal.pas

@@ -103,9 +103,6 @@ implementation
       cgbase,pass_2,
       cgbase,pass_2,
       aasmbase,aasmtai,aasmdata,
       aasmbase,aasmtai,aasmdata,
       nbas,nmem,nld,ncnv,nutils,
       nbas,nmem,nld,ncnv,nutils,
-{$ifdef x86}
-      cga,cgx86,aasmcpu,
-{$endif x86}
       ncgutil,
       ncgutil,
       cgobj,tgobj,hlcgobj,
       cgobj,tgobj,hlcgobj,
       procinfo,
       procinfo,
@@ -477,42 +474,21 @@ implementation
         else
         else
           realresdef:=tstoreddef(typedef);
           realresdef:=tstoreddef(typedef);
 
 
-{$ifdef x86}
-        if (retloc.location^.loc=LOC_FPUREGISTER) then
-          begin
-            tcgx86(cg).inc_fpu_stack;
-            location_reset(location,LOC_FPUREGISTER,retloc.location^.size);
-            location.register:=retloc.location^.register;
-          end
-        else
-{$endif x86}
-          begin
-            { get a tlocation that can hold the return value that's currently in
-            the the return value's tcgpara }
-            set_result_location(realresdef);
-
-            { Do not move the physical register to a virtual one in case
-              the return value is not used, because if the virtual one is
-              then mapped to the same register as the physical one, we will
-              end up with two deallocs of this register (one inserted here,
-              one inserted by the register allocator), which unbalances the
-              register allocation information.  The return register(s) will
-              be freed by location_free() in release_unused_return_value
-              (mantis #13536).  }
-            if (cnf_return_value_used in callnodeflags) or
-               assigned(funcretnode) then
-              begin
-                hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,realresdef,retloc,location,false);
-{$ifdef arm}
-                if (resultdef.typ=floatdef) and
-                   (location.loc=LOC_REGISTER) and
-                   (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) then
-                  begin
-                    hlcg.location_force_mem(current_asmdata.CurrAsmList,location,resultdef);
-                  end;
-{$endif arm}
-              end;
-          end;
+          { get a tlocation that can hold the return value that's currently in
+            the return value's tcgpara }
+          set_result_location(realresdef);
+
+          { Do not move the physical register to a virtual one in case
+            the return value is not used, because if the virtual one is
+            then mapped to the same register as the physical one, we will
+            end up with two deallocs of this register (one inserted here,
+            one inserted by the register allocator), which unbalances the
+            register allocation information.  The return register(s) will
+            be freed by location_free() in release_unused_return_value
+            (mantis #13536).  }
+          if (cnf_return_value_used in callnodeflags) or
+             assigned(funcretnode) then
+            hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,realresdef,retloc,location,false);
 
 
         { copy value to the final location if this was already provided to the
         { copy value to the final location if this was already provided to the
           callnode. This must be done after the call node, because the location can
           callnode. This must be done after the call node, because the location can

+ 16 - 1
compiler/x86/nx86cal.pas

@@ -28,6 +28,7 @@ interface
 { $define AnsiStrRef}
 { $define AnsiStrRef}
 
 
     uses
     uses
+      symdef,
       ncgcal;
       ncgcal;
 
 
     type
     type
@@ -37,6 +38,7 @@ interface
        tx86callnode = class(tcgcallnode)
        tx86callnode = class(tcgcallnode)
         protected
         protected
          procedure do_release_unused_return_value;override;
          procedure do_release_unused_return_value;override;
+         procedure set_result_location(realresdef: tstoreddef);override;
        end;
        end;
 
 
 
 
@@ -44,7 +46,7 @@ implementation
 
 
     uses
     uses
       cgobj,
       cgobj,
-      cgbase,cpubase,cgx86,cga;
+      cgbase,cgutils,cpubase,cgx86,cga;
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -66,4 +68,17 @@ implementation
       end;
       end;
 
 
 
 
+  procedure tx86callnode.set_result_location(realresdef: tstoreddef);
+    begin
+      if (retloc.location^.loc=LOC_FPUREGISTER) then
+        begin
+          tcgx86(cg).inc_fpu_stack;
+          location_reset(location,LOC_FPUREGISTER,retloc.location^.size);
+          location.register:=retloc.location^.register;
+        end
+      else
+        inherited set_result_location(realresdef);
+    end;
+
+
 end.
 end.