* define FPC_DOUBLE_HILO_SWAPPED for ARM CPU if needed to properly handle doubles in RTL.

git-svn-id: trunk@5439 -
This commit is contained in:
yury 2006-11-21 21:24:01 +00:00
parent 5ceef96cf3
commit 61f0f0b793
3 changed files with 18 additions and 11 deletions

View File

@ -2210,6 +2210,13 @@ begin
system_m68k_linux] then
include(init_settings.moduleswitches,cs_fp_emulation);
{$ifdef ARM}
{ define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }
if (init_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
not(cs_fp_emulation in init_settings.moduleswitches) then
def_system_macro('FPC_DOUBLE_HILO_SWAPPED');
{$endif ARM}
{ Section smartlinking conflicts with import sections on Windows }
if GenerateImportSection and
(target_info.system in [system_i386_win32,system_x86_64_win64]) then

View File

@ -294,9 +294,9 @@ type
function fpc_trunc_real(d : ValReal) : int64;compilerproc;
var
{$ifdef cpuarm}
{$ifdef FPC_DOUBLE_HILO_SWAPPED}
l: longint;
{$endif cpuarm}
{$endif FPC_DOUBLE_HILO_SWAPPED}
f32 : float32;
f64 : float64;
Begin
@ -308,12 +308,12 @@ type
if sizeof(D)=8 then
begin
move(d,f64,sizeof(f64));
{$ifdef cpuarm}
{$ifdef FPC_DOUBLE_HILO_SWAPPED}
{ the arm fpu has a strange opinion how a double has to be stored }
l:=f64.low;
f64.low:=f64.high;
f64.high:=l;
{$endif cpuarm}
{$endif FPC_DOUBLE_HILO_SWAPPED}
result:=float64_to_int64_round_to_zero(f64);
end
else
@ -339,12 +339,12 @@ type
f64 : float64;
begin
f64:=float64(d);
{$ifdef cpuarm}
{$ifdef FPC_DOUBLE_HILO_SWAPPED}
{ the arm fpu has a strange opinion how a double has to be stored }
i0:=f64.low;
f64.low:=f64.high;
f64.high:=i0;
{$endif cpuarm}
{$endif FPC_DOUBLE_HILO_SWAPPED}
i0 := f64.high;
i1 := cardinal(f64.low);
sx := i0 and $80000000;
@ -374,12 +374,12 @@ type
f64.high := i0;
f64.low := longint(i1 and not(cardinal($ffffffff) shr (j0 - 20)));
end;
{$ifdef cpuarm}
{$ifdef FPC_DOUBLE_HILO_SWAPPED}
{ the arm fpu has a strange opinion how a double has to be stored }
i0:=f64.low;
f64.low:=f64.high;
f64.high:=i0;
{$endif cpuarm}
{$endif FPC_DOUBLE_HILO_SWAPPED}
result:=double(f64);
end;

View File

@ -261,20 +261,20 @@ begin
((TSplitExtended(d).cards[1] and $7fffffff) = 0);
{$else SUPPORT_EXTENDED}
{$ifdef SUPPORT_DOUBLE}
{$ifdef CPUARM}
{$ifdef FPC_DOUBLE_HILO_SWAPPED}
{ double, format (MSB): 1 Sign bit, 11 bit exponent, 52 bit mantissa }
{ high and low dword are swapped when using the arm fpa }
sign := ((TSplitDouble(d).cards[0] shr 20) and $800) <> 0;
expMaximal := ((TSplitDouble(d).cards[0] shr 20) and $7ff) = 2047;
fraczero:= (TSplitDouble(d).cards[0] and $fffff = 0) and
(TSplitDouble(d).cards[1] = 0);
{$else CPUARM}
{$else FPC_DOUBLE_HILO_SWAPPED}
{ double, format (MSB): 1 Sign bit, 11 bit exponent, 52 bit mantissa }
sign := ((TSplitDouble(d).cards[1] shr 20) and $800) <> 0;
expMaximal := ((TSplitDouble(d).cards[1] shr 20) and $7ff) = 2047;
fraczero := (TSplitDouble(d).cards[1] and $fffff = 0) and
(TSplitDouble(d).cards[0] = 0);
{$endif CPUARM}
{$endif FPC_DOUBLE_HILO_SWAPPED}
{$else SUPPORT_DOUBLE}
{$ifdef SUPPORT_SINGLE}
{ single, format (MSB): 1 Sign bit, 8 bit exponent, 23 bit mantissa }