Jelajahi Sumber

* Moved handling of emulated floating point negation into new virtual method tcgunaryminusnode.second_float_emulated. Also changed it into simple flipping of the sign bit, which is how it is defined by IEEE 754, and already done for ARM targets. Relevant ARM-specific parts can now be removed, and m68k code gets significantly better without further efforts.

git-svn-id: trunk@28528 -
sergei 11 tahun lalu
induk
melakukan
5f2821ee5f
2 mengubah file dengan 26 tambahan dan 21 penghapusan
  1. 24 1
      compiler/ncgmat.pas
  2. 2 20
      compiler/nmat.pas

+ 24 - 1
compiler/ncgmat.pas

@@ -50,6 +50,7 @@ interface
 {$endif not cpu64bitalu}
          procedure second_integer;virtual;
          procedure second_float;virtual;
+         procedure second_float_emulated;virtual;
       public
          procedure pass_generate_code;override;
       end;
@@ -206,6 +207,23 @@ implementation
       end;
 {$endif not cpu64bitalu}
 
+
+    procedure tcgunaryminusnode.second_float_emulated;
+      begin
+        secondpass(left);
+        hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
+        location:=left.location;
+        case location.size of
+          OS_32:
+            cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_XOR,OS_32,tcgint($80000000),location.register);
+          OS_64:
+            cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_XOR,OS_32,tcgint($80000000),location.registerhi);
+        else
+          internalerror(2014033101);
+        end;
+      end;
+
+
     procedure tcgunaryminusnode.second_float;
       begin
         secondpass(left);
@@ -282,7 +300,12 @@ implementation
          else
 {$endif SUPPORT_MMX}
            if (left.resultdef.typ=floatdef) then
-             second_float
+             begin
+               if (cs_fp_emulation in current_settings.moduleswitches) then
+                 second_float_emulated
+               else
+                 second_float;
+             end
          else
            second_integer;
       end;

+ 2 - 20
compiler/nmat.pas

@@ -931,26 +931,8 @@ implementation
           begin
             if not(target_info.system in systems_wince) then
               begin
-                case tfloatdef(resultdef).floattype of
-                  s32real:
-                    begin
-                      procname:='float32_sub';
-                      fdef:=search_system_type('FLOAT32REC').typedef;
-                    end;
-                  s64real:
-                    begin
-                      procname:='float64_sub';
-                      fdef:=search_system_type('FLOAT64').typedef;
-                    end;
-                  {!!! not yet implemented
-                  s128real:
-                  }
-                  else
-                    internalerror(2005082801);
-                end;
-                result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
-                  ctypeconvnode.create_internal(left,fDef),
-                  ccallparanode.create(ctypeconvnode.create_internal(crealconstnode.create(0,resultdef),fdef),nil))),resultdef);
+                expectloc:=LOC_REGISTER;
+                exit;
               end
             else
               begin