Browse Source

Merged revisions 8013,8015 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r8013 | yury | 2007-07-10 23:31:47 +0300 (Вт, 10 июл 2007) | 1 line

* fixed exp() for hardfloat on arm.
........
r8015 | yury | 2007-07-11 00:05:12 +0300 (Ср, 11 июл 2007) | 1 line

* Completely fixed float constants in softfloat mode when compiler was compiled in hardfloat mode on arm-linux host.
........

git-svn-id: branches/fixes_2_2@8016 -

yury 18 years ago
parent
commit
7c5fd7242e
6 changed files with 36 additions and 14 deletions
  1. 1 5
      compiler/arm/narmcon.pas
  2. 14 0
      compiler/globals.pas
  3. 1 5
      compiler/ncgcon.pas
  4. 1 2
      compiler/ptconst.pas
  5. 1 2
      compiler/rautils.pas
  6. 18 0
      rtl/inc/genmath.inc

+ 1 - 5
compiler/arm/narmcon.pas

@@ -66,11 +66,7 @@ interface
         location_reset(location,LOC_CREFERENCE,def_cgsize(resultdef));
         lastlabel:=nil;
         realait:=floattype2ait[tfloatdef(resultdef).floattype];
-        hiloswapped:=(current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
-          not(cs_fp_emulation in current_settings.moduleswitches);;
-{$ifdef FPC_DOUBLE_HILO_SWAPPED}
-        hiloswapped:=not hiloswapped;
-{$endif FPC_DOUBLE_HILO_SWAPPED}
+        hiloswapped:=is_double_hilo_swapped;
         { const already used ? }
         if not assigned(lab_real) then
           begin

+ 14 - 0
compiler/globals.pas

@@ -348,6 +348,9 @@ interface
     {# Routine to get the required alignment for size of data, which will
        be placed in data/const segment, according to the current alignment requirements }
     function const_align(siz: longint): shortint;
+{$ifdef ARM}
+    function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
+{$endif ARM}
 
 implementation
 
@@ -1013,6 +1016,17 @@ implementation
         const_align := used_align(siz,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
       end;
 
+{$ifdef ARM}
+    function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        result := (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
+          not(cs_fp_emulation in current_settings.moduleswitches);
+{$ifdef FPC_DOUBLE_HILO_SWAPPED}
+        { inverse result if compiler was compiled with swapped hilo already }
+        result := not result;
+{$endif FPC_DOUBLE_HILO_SWAPPED}
+      end;
+{$endif ARM}
 
 {****************************************************************************
                                     Init

+ 1 - 5
compiler/ncgcon.pas

@@ -122,11 +122,7 @@ implementation
         lastlabel:=nil;
         realait:=floattype2ait[tfloatdef(resultdef).floattype];
 {$ifdef ARM}
-        hiloswapped:=(current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
-          not(cs_fp_emulation in current_settings.moduleswitches);
-{$ifdef FPC_DOUBLE_HILO_SWAPPED}
-        hiloswapped:=not hiloswapped;
-{$endif FPC_DOUBLE_HILO_SWAPPED}
+        hiloswapped:=is_double_hilo_swapped;
 {$endif ARM}
         { const already used ? }
         if not assigned(lab_real) then

+ 1 - 2
compiler/ptconst.pas

@@ -283,8 +283,7 @@ implementation
                list.concat(Tai_real_32bit.Create(ts32real(value)));
              s64real :
 {$ifdef ARM}
-               if (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
-                 not(cs_fp_emulation in current_settings.moduleswitches) then
+               if is_double_hilo_swapped then
                  list.concat(Tai_real_64bit.Create_hiloswapped(ts64real(value)))
                else
 {$endif ARM}

+ 1 - 2
compiler/rautils.pas

@@ -1529,8 +1529,7 @@ end;
           s32real : p.concat(Tai_real_32bit.Create(value));
           s64real :
 {$ifdef ARM}
-           if (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
-             not(cs_fp_emulation in current_settings.moduleswitches) then
+           if is_double_hilo_swapped then
              p.concat(Tai_real_64bit.Create_hiloswapped(value))
            else
 {$endif ARM}

+ 18 - 0
rtl/inc/genmath.inc

@@ -753,7 +753,11 @@ invalid:
         hi:=0.0;
         lo:=0.0;
         k:=0;
+{$ifdef FPC_DOUBLE_HILO_SWAPPED}
+        hx:=float64(d).low;
+{$else}
         hx:=float64(d).high;
+{$endif FPC_DOUBLE_HILO_SWAPPED}
         xsb := (hx shr 31) and 1;               { sign bit of d }
         hx := hx and $7fffffff;                 { high word of |d| }
 
@@ -762,7 +766,11 @@ invalid:
           begin                  { if |d|>=709.78... }
             if hx >= $7ff00000 then
               begin
+{$ifdef FPC_DOUBLE_HILO_SWAPPED}
+                lx:=float64(d).high;
+{$else}
                 lx:=float64(d).low;
+{$endif FPC_DOUBLE_HILO_SWAPPED}
                 if ((hx and $fffff) or lx)<>0 then
                   begin
                     result:=d+d; { NaN }
@@ -829,14 +837,24 @@ invalid:
 
         if k >= -1021 then
           begin
+{$ifdef FPC_DOUBLE_HILO_SWAPPED}
+            hy:=float64(y).low;
+            float64(y).low:=longint(hy)+(k shl 20);        { add k to y's exponent }
+{$else}
             hy:=float64(y).high;
             float64(y).high:=longint(hy)+(k shl 20);        { add k to y's exponent }
+{$endif FPC_DOUBLE_HILO_SWAPPED}
             result:=y;
           end
         else
           begin
+{$ifdef FPC_DOUBLE_HILO_SWAPPED}
+            hy:=float64(y).low;
+            float64(y).low:=longint(hy)+((k+1000) shl 20); { add k to y's exponent }
+{$else}
             hy:=float64(y).high;
             float64(y).high:=longint(hy)+((k+1000) shl 20); { add k to y's exponent }
+{$endif FPC_DOUBLE_HILO_SWAPPED}
             result:=y*twom1000;
           end;
       end;