mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 10:45:08 +02:00
* fixed longint -> real, was broken in 6153
git-svn-id: trunk@6257 -
This commit is contained in:
parent
31636e3887
commit
0fd3498892
@ -122,47 +122,57 @@ implementation
|
||||
l1,l2 : tasmlabel;
|
||||
hregister : tregister;
|
||||
begin
|
||||
current_asmdata.getdatalabel(l1);
|
||||
current_asmdata.getjumplabel(l2);
|
||||
reference_reset_symbol(href,l1,0);
|
||||
|
||||
{ convert first to double to avoid precision loss }
|
||||
location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
|
||||
location_force_reg(current_asmdata.CurrAsmList,left.location,OS_32,true);
|
||||
location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
|
||||
instr:=taicpu.op_reg_reg(A_FLT,location.register,left.location.register);
|
||||
instr.oppostfix:=PF_D;
|
||||
current_asmdata.CurrAsmList.concat(instr);
|
||||
|
||||
current_asmdata.CurrAsmList.concat(Taicpu.op_reg_const(A_CMP,left.location.register,0));
|
||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_GE,l2);
|
||||
|
||||
case tfloatdef(resultdef).floattype of
|
||||
{ converting dword to s64real first and cut off at the end avoids precision loss }
|
||||
s32real,
|
||||
s64real:
|
||||
begin
|
||||
hregister:=cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
|
||||
current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(8)));
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
|
||||
{ I got this constant from a test program (FK) }
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($41f00000));
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(0));
|
||||
|
||||
cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,OS_F64,OS_F64,href,hregister);
|
||||
current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ADF,location.register,hregister,location.register),PF_D));
|
||||
cg.a_label(current_asmdata.CurrAsmList,l2);
|
||||
|
||||
{ cut off if we should convert to single }
|
||||
if tfloatdef(resultdef).floattype=s32real then
|
||||
if is_signed(left.resultdef) then
|
||||
begin
|
||||
instr.oppostfix:=cgsize2fpuoppostfix[def_cgsize(resultdef)];;
|
||||
current_asmdata.CurrAsmList.concat(instr);
|
||||
end
|
||||
else
|
||||
begin
|
||||
{ flt does a signed load, fix this }
|
||||
case tfloatdef(resultdef).floattype of
|
||||
s32real,
|
||||
s64real:
|
||||
begin
|
||||
hregister:=location.register;
|
||||
location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
|
||||
current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_MVF,location.register,hregister),PF_S));
|
||||
{ converting dword to s64real first and cut off at the end avoids precision loss }
|
||||
instr.oppostfix:=PF_D;
|
||||
current_asmdata.CurrAsmList.concat(instr);
|
||||
|
||||
current_asmdata.getdatalabel(l1);
|
||||
current_asmdata.getjumplabel(l2);
|
||||
reference_reset_symbol(href,l1,0);
|
||||
|
||||
current_asmdata.CurrAsmList.concat(Taicpu.op_reg_const(A_CMP,left.location.register,0));
|
||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_GE,l2);
|
||||
|
||||
hregister:=cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
|
||||
current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(8)));
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
|
||||
{ I got this constant from a test program (FK) }
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($41f00000));
|
||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(0));
|
||||
|
||||
cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,OS_F64,OS_F64,href,hregister);
|
||||
current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ADF,location.register,hregister,location.register),PF_D));
|
||||
cg.a_label(current_asmdata.CurrAsmList,l2);
|
||||
|
||||
{ cut off if we should convert to single }
|
||||
if tfloatdef(resultdef).floattype=s32real then
|
||||
begin
|
||||
hregister:=location.register;
|
||||
location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
|
||||
current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_MVF,location.register,hregister),PF_S));
|
||||
end;
|
||||
end;
|
||||
else
|
||||
internalerror(200410031);
|
||||
end;
|
||||
else
|
||||
internalerror(200410031);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user