Browse Source

* factored out tx86typeconvnode.int_to_real_mm_location

florian 3 years ago
parent
commit
7ff393085e
1 changed files with 23 additions and 16 deletions
  1. 23 16
      compiler/x86/nx86cnv.pas

+ 23 - 16
compiler/x86/nx86cnv.pas

@@ -30,6 +30,8 @@ interface
 
     type
        tx86typeconvnode = class(tcgtypeconvnode)
+       private
+         function int_to_real_mm_location: boolean;
        protected
          function first_real_to_real : tnode;override;
          { procedure second_int_to_int;override; }
@@ -223,6 +225,25 @@ implementation
        end;
 
 
+    function tx86typeconvnode.int_to_real_mm_location : boolean;
+      begin
+        result:=use_vectorfpu(resultdef) and
+{$ifdef cpu64bitalu}
+           ((torddef(left.resultdef).ordtype in [s32bit,s64bit]) or
+            ((torddef(left.resultdef).ordtype in [u32bit,u64bit]) and
+             (FPUX86_HAS_AVX512F in fpu_capabilities[current_settings.fputype]))
+           );
+{$else cpu64bitalu}
+           ((torddef(left.resultdef).ordtype=s32bit)
+{$ifdef i386}
+            or ((torddef(left.resultdef).ordtype=u32bit) and
+             (FPUX86_HAS_AVX512F in fpu_capabilities[current_settings.fputype]))
+{$endif i386}
+           );
+{$endif cpu64bitalu}
+      end;
+
+
     function tx86typeconvnode.first_int_to_real : tnode;
 
       begin
@@ -233,8 +254,7 @@ implementation
             firstpass(left)
           end;
 
-        if use_vectorfpu(resultdef) and
-           (torddef(left.resultdef).ordtype = s32bit) then
+        if int_to_real_mm_location then
           expectloc:=LOC_MMREGISTER
         else
           expectloc:=LOC_FPUREGISTER;
@@ -259,20 +279,7 @@ implementation
 {$endif i8086}
         if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE]) then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
-        if use_vectorfpu(resultdef) and
-{$ifdef cpu64bitalu}
-           ((torddef(left.resultdef).ordtype in [s32bit,s64bit]) or
-            ((torddef(left.resultdef).ordtype in [u32bit,u64bit]) and
-             (FPUX86_HAS_AVX512F in fpu_capabilities[current_settings.fputype]))
-           ) then
-{$else cpu64bitalu}
-           ((torddef(left.resultdef).ordtype=s32bit)
-{$ifdef i386}
-            or ((torddef(left.resultdef).ordtype=u32bit) and
-             (FPUX86_HAS_AVX512F in fpu_capabilities[current_settings.fputype]))
-{$endif i386}
-           ) then
-{$endif cpu64bitalu}
+        if int_to_real_mm_location then
           begin
             location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
             location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);