mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-08 09:23:48 +02:00
* use vmov.xx to load float constants if possible
git-svn-id: trunk@39298 -
This commit is contained in:
parent
4f5f3c4a09
commit
4aa0ad6735
@ -26,10 +26,11 @@ unit narmcon;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ncgcon,cpubase;
|
node,ncgcon,cpubase;
|
||||||
|
|
||||||
type
|
type
|
||||||
tarmrealconstnode = class(tcgrealconstnode)
|
tarmrealconstnode = class(tcgrealconstnode)
|
||||||
|
function pass_1 : tnode;override;
|
||||||
procedure pass_generate_code;override;
|
procedure pass_generate_code;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -39,9 +40,10 @@ interface
|
|||||||
verbose,
|
verbose,
|
||||||
globtype,globals,
|
globtype,globals,
|
||||||
cpuinfo,
|
cpuinfo,
|
||||||
aasmbase,aasmtai,aasmdata,symdef,
|
aasmbase,aasmtai,aasmdata,aasmcpu,
|
||||||
|
symdef,
|
||||||
defutil,
|
defutil,
|
||||||
cgbase,cgutils,
|
cgbase,cgutils,cgobj,
|
||||||
procinfo,
|
procinfo,
|
||||||
ncon;
|
ncon;
|
||||||
|
|
||||||
@ -49,6 +51,17 @@ interface
|
|||||||
TARMREALCONSTNODE
|
TARMREALCONSTNODE
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
|
function tarmrealconstnode.pass_1 : tnode;
|
||||||
|
begin
|
||||||
|
result:=nil;
|
||||||
|
if (current_settings.fputype in [fpu_vfpv3,fpu_vfpv4,fpu_vfpv3_d16,fpu_fpv4_s16]) and
|
||||||
|
IsVFPFloatImmediate(tfloatdef(resultdef).floattype,value_real) then
|
||||||
|
expectloc:=LOC_MMREGISTER
|
||||||
|
else
|
||||||
|
expectloc:=LOC_CREFERENCE;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tarmrealconstnode.pass_generate_code;
|
procedure tarmrealconstnode.pass_generate_code;
|
||||||
{ I suppose the parser/pass_1 must make sure the generated real }
|
{ I suppose the parser/pass_1 must make sure the generated real }
|
||||||
{ constants are actually supported by the target processor? (JM) }
|
{ constants are actually supported by the target processor? (JM) }
|
||||||
@ -59,75 +72,91 @@ interface
|
|||||||
lastlabel : tasmlabel;
|
lastlabel : tasmlabel;
|
||||||
realait : tairealconsttype;
|
realait : tairealconsttype;
|
||||||
hiloswapped : boolean;
|
hiloswapped : boolean;
|
||||||
|
pf : TOpPostfix;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
location_reset_ref(location,LOC_CREFERENCE,def_cgsize(resultdef),4,[]);
|
if (current_settings.fputype in [fpu_vfpv3,fpu_vfpv4,fpu_vfpv3_d16,fpu_fpv4_s16]) and
|
||||||
lastlabel:=nil;
|
IsVFPFloatImmediate(tfloatdef(resultdef).floattype,value_real) then
|
||||||
realait:=floattype2ait[tfloatdef(resultdef).floattype];
|
|
||||||
hiloswapped:=is_double_hilo_swapped;
|
|
||||||
{ const already used ? }
|
|
||||||
if not assigned(lab_real) then
|
|
||||||
begin
|
begin
|
||||||
current_asmdata.getjumplabel(lastlabel);
|
location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
|
||||||
lab_real:=lastlabel;
|
location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
|
||||||
current_procinfo.aktlocaldata.concat(Tai_label.Create(lastlabel));
|
if tfloatdef(resultdef).floattype=s32real then
|
||||||
location.reference.symboldata:=current_procinfo.aktlocaldata.last;
|
pf:=PF_F32
|
||||||
case realait of
|
else
|
||||||
aitrealconst_s32bit :
|
pf:=PF_F64;
|
||||||
begin
|
current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_realconst(A_VMOV,
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s32real(ts32real(value_real)));
|
location.register,value_real),pf));
|
||||||
{ range checking? }
|
end
|
||||||
if floating_point_range_check_error and
|
else
|
||||||
(tai_realconst(current_procinfo.aktlocaldata.last).value.s32val=MathInf.Value) then
|
begin
|
||||||
Message(parser_e_range_check_error);
|
location_reset_ref(location,LOC_CREFERENCE,def_cgsize(resultdef),4,[]);
|
||||||
end;
|
lastlabel:=nil;
|
||||||
|
realait:=floattype2ait[tfloatdef(resultdef).floattype];
|
||||||
|
hiloswapped:=is_double_hilo_swapped;
|
||||||
|
{ const already used ? }
|
||||||
|
if not assigned(lab_real) then
|
||||||
|
begin
|
||||||
|
current_asmdata.getjumplabel(lastlabel);
|
||||||
|
lab_real:=lastlabel;
|
||||||
|
current_procinfo.aktlocaldata.concat(Tai_label.Create(lastlabel));
|
||||||
|
location.reference.symboldata:=current_procinfo.aktlocaldata.last;
|
||||||
|
case realait of
|
||||||
|
aitrealconst_s32bit :
|
||||||
|
begin
|
||||||
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s32real(ts32real(value_real)));
|
||||||
|
{ range checking? }
|
||||||
|
if floating_point_range_check_error and
|
||||||
|
(tai_realconst(current_procinfo.aktlocaldata.last).value.s32val=MathInf.Value) then
|
||||||
|
Message(parser_e_range_check_error);
|
||||||
|
end;
|
||||||
|
|
||||||
aitrealconst_s64bit :
|
aitrealconst_s64bit :
|
||||||
begin
|
begin
|
||||||
if hiloswapped then
|
if hiloswapped then
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real_hiloswapped(ts64real(value_real)))
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real_hiloswapped(ts64real(value_real)))
|
||||||
else
|
else
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real(ts64real(value_real)));
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64real(ts64real(value_real)));
|
||||||
|
|
||||||
{ range checking? }
|
{ range checking? }
|
||||||
if floating_point_range_check_error and
|
if floating_point_range_check_error and
|
||||||
(tai_realconst(current_procinfo.aktlocaldata.last).value.s64val=MathInf.Value) then
|
(tai_realconst(current_procinfo.aktlocaldata.last).value.s64val=MathInf.Value) then
|
||||||
Message(parser_e_range_check_error);
|
Message(parser_e_range_check_error);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
aitrealconst_s80bit :
|
aitrealconst_s80bit :
|
||||||
begin
|
begin
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size));
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size));
|
||||||
|
|
||||||
{ range checking? }
|
{ range checking? }
|
||||||
if floating_point_range_check_error and
|
if floating_point_range_check_error and
|
||||||
(tai_realconst(current_procinfo.aktlocaldata.last).value.s80val=MathInf.Value) then
|
(tai_realconst(current_procinfo.aktlocaldata.last).value.s80val=MathInf.Value) then
|
||||||
Message(parser_e_range_check_error);
|
Message(parser_e_range_check_error);
|
||||||
end;
|
end;
|
||||||
{$ifdef cpufloat128}
|
{$ifdef cpufloat128}
|
||||||
aitrealconst_s128bit :
|
aitrealconst_s128bit :
|
||||||
begin
|
begin
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s128real(value_real));
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s128real(value_real));
|
||||||
|
|
||||||
{ range checking? }
|
{ range checking? }
|
||||||
if floating_point_range_check_error and
|
if floating_point_range_check_error and
|
||||||
(tai_realconst(current_procinfo.aktlocaldata.last).value.s128val=MathInf.Value) then
|
(tai_realconst(current_procinfo.aktlocaldata.last).value.s128val=MathInf.Value) then
|
||||||
Message(parser_e_range_check_error);
|
Message(parser_e_range_check_error);
|
||||||
end;
|
end;
|
||||||
{$endif cpufloat128}
|
{$endif cpufloat128}
|
||||||
|
|
||||||
{ the round is necessary for native compilers where comp isn't a float }
|
{ the round is necessary for native compilers where comp isn't a float }
|
||||||
aitrealconst_s64comp :
|
aitrealconst_s64comp :
|
||||||
if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
|
if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
|
||||||
message(parser_e_range_check_error)
|
message(parser_e_range_check_error)
|
||||||
|
else
|
||||||
|
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64compreal(round(value_real)));
|
||||||
else
|
else
|
||||||
current_procinfo.aktlocaldata.concat(tai_realconst.create_s64compreal(round(value_real)));
|
internalerror(2005092401);
|
||||||
else
|
end;
|
||||||
internalerror(2005092401);
|
end;
|
||||||
end;
|
location.reference.symbol:=lab_real;
|
||||||
|
location.reference.base:=NR_R15;
|
||||||
end;
|
end;
|
||||||
location.reference.symbol:=lab_real;
|
|
||||||
location.reference.base:=NR_R15;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user