mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 01:09:13 +02:00
* move x86_64 specific int_to_real conversion to nx64cnv
* fix x86_64 code for none loc_register/loc_reference location git-svn-id: trunk@8844 -
This commit is contained in:
parent
c39b663201
commit
ad944fd198
@ -189,104 +189,12 @@ implementation
|
|||||||
|
|
||||||
var
|
var
|
||||||
href : treference;
|
href : treference;
|
||||||
hregister : tregister;
|
|
||||||
l1,l2 : tasmlabel;
|
l1,l2 : tasmlabel;
|
||||||
signtested : boolean;
|
signtested : boolean;
|
||||||
hreg : tregister;
|
|
||||||
op : tasmop;
|
|
||||||
begin
|
begin
|
||||||
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,true);
|
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,true);
|
||||||
|
|
||||||
{$ifdef x86_64}
|
|
||||||
if use_sse(resultdef) then
|
|
||||||
begin
|
|
||||||
{ We can only directly convert s32bit and s64bit,u64bit values, for other
|
|
||||||
values convert first to s64bit }
|
|
||||||
if not(torddef(left.resultdef).ordtype in [s32bit,s64bit,u64bit]) then
|
|
||||||
begin
|
|
||||||
hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_S64);
|
|
||||||
location_force_reg(current_asmdata.CurrAsmList,left.location,OS_S64,false);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if is_double(resultdef) then
|
|
||||||
op:=A_CVTSI2SD
|
|
||||||
else if is_single(resultdef) then
|
|
||||||
op:=A_CVTSI2SS
|
|
||||||
else
|
|
||||||
internalerror(200506061);
|
|
||||||
|
|
||||||
location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
|
|
||||||
location.register:=cg.getmmregister(current_asmdata.CurrAsmList,def_cgsize(resultdef));
|
|
||||||
|
|
||||||
case torddef(left.resultdef).ordtype of
|
|
||||||
u64bit:
|
|
||||||
begin
|
|
||||||
{ unsigned 64 bit ints are harder to handle:
|
|
||||||
we load bits 0..62 and then check bit 63:
|
|
||||||
if it is 1 then we add $80000000 000000000
|
|
||||||
as double }
|
|
||||||
current_asmdata.getdatalabel(l1);
|
|
||||||
current_asmdata.getjumplabel(l2);
|
|
||||||
|
|
||||||
{ Get sign bit }
|
|
||||||
if (left.location.loc=LOC_REGISTER) then
|
|
||||||
begin
|
|
||||||
emit_const_reg(A_BT,S_Q,63,left.location.register);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,S_Q,left.location.register,location.register));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
inc(left.location.reference.offset,4);
|
|
||||||
emit_const_ref(A_BT,S_L,31,left.location.reference);
|
|
||||||
dec(left.location.reference.offset,4);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,S_Q,left.location.reference,location.register));
|
|
||||||
end;
|
|
||||||
|
|
||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NC,l2);
|
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
|
|
||||||
reference_reset_symbol(href,l1,0);
|
|
||||||
|
|
||||||
{ I got these constant from a test program (FK) }
|
|
||||||
if is_double(resultdef) then
|
|
||||||
begin
|
|
||||||
{ double (2^64) }
|
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(0));
|
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($43f00000));
|
|
||||||
{ simplify for PIC }
|
|
||||||
tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,href);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(A_ADDSD,S_NO,href,location.register));
|
|
||||||
end
|
|
||||||
else if is_single(resultdef) then
|
|
||||||
begin
|
|
||||||
{ single(2^64) }
|
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($5f800000));
|
|
||||||
{ simplify for PIC }
|
|
||||||
tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,href);
|
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(A_ADDSS,S_NO,href,location.register));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
internalerror(200506071);
|
|
||||||
cg.a_label(current_asmdata.CurrAsmList,l2);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
case left.location.loc of
|
|
||||||
LOC_CREFERENCE,
|
|
||||||
LOC_REFERENCE :
|
|
||||||
current_asmdata.CurrAsmList.concat(Taicpu.op_ref_reg(op,tcgsize2opsize[left.location.size],left.location.reference,location.register));
|
|
||||||
LOC_CREGISTER,
|
|
||||||
LOC_REGISTER :
|
|
||||||
current_asmdata.CurrAsmList.concat(Taicpu.op_reg_reg(op,tcgsize2opsize[left.location.size],left.location.register,location.register));
|
|
||||||
else
|
|
||||||
internalerror(200506072);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
{$endif x86_64}
|
|
||||||
begin
|
|
||||||
location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
|
location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
|
||||||
if (left.location.loc=LOC_REGISTER) and (torddef(left.resultdef).ordtype=u64bit) then
|
if (left.location.loc=LOC_REGISTER) and (torddef(left.resultdef).ordtype=u64bit) then
|
||||||
begin
|
begin
|
||||||
@ -367,7 +275,6 @@ implementation
|
|||||||
tcgx86(cg).inc_fpu_stack;
|
tcgx86(cg).inc_fpu_stack;
|
||||||
location.register:=NR_ST;
|
location.register:=NR_ST;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ctypeconvnode:=tx86typeconvnode
|
ctypeconvnode:=tx86typeconvnode
|
||||||
|
@ -41,7 +41,7 @@ interface
|
|||||||
{ procedure second_chararray_to_string;override; }
|
{ procedure second_chararray_to_string;override; }
|
||||||
{ procedure second_char_to_string;override; }
|
{ procedure second_char_to_string;override; }
|
||||||
{ function first_int_to_real: tnode; override; }
|
{ function first_int_to_real: tnode; override; }
|
||||||
{ procedure second_int_to_real;override; }
|
procedure second_int_to_real;override;
|
||||||
{ procedure second_real_to_real;override; }
|
{ procedure second_real_to_real;override; }
|
||||||
{ procedure second_cord_to_pointer;override; }
|
{ procedure second_cord_to_pointer;override; }
|
||||||
{ procedure second_proc_to_procvar;override; }
|
{ procedure second_proc_to_procvar;override; }
|
||||||
@ -58,7 +58,115 @@ interface
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ncnv;
|
verbose,systems,globals,globtype,
|
||||||
|
aasmbase,aasmtai,aasmdata,aasmcpu,
|
||||||
|
symconst,symdef,
|
||||||
|
cgbase,cga,procinfo,pass_2,
|
||||||
|
ncon,ncal,ncnv,
|
||||||
|
cpubase,
|
||||||
|
cgutils,cgobj,cgx86,ncgutil,
|
||||||
|
tgobj;
|
||||||
|
|
||||||
|
|
||||||
|
procedure tx8664typeconvnode.second_int_to_real;
|
||||||
|
var
|
||||||
|
href : treference;
|
||||||
|
l1,l2 : tasmlabel;
|
||||||
|
op : tasmop;
|
||||||
|
begin
|
||||||
|
if use_sse(resultdef) then
|
||||||
|
begin
|
||||||
|
{ We can only directly convert s32bit and s64bit,u64bit values, for other
|
||||||
|
values convert first to s64bit }
|
||||||
|
if not(torddef(left.resultdef).ordtype in [s32bit,s64bit,u64bit]) then
|
||||||
|
location_force_reg(current_asmdata.CurrAsmList,left.location,OS_S64,false);
|
||||||
|
|
||||||
|
if is_double(resultdef) then
|
||||||
|
op:=A_CVTSI2SD
|
||||||
|
else if is_single(resultdef) then
|
||||||
|
op:=A_CVTSI2SS
|
||||||
|
else
|
||||||
|
internalerror(200506061);
|
||||||
|
|
||||||
|
location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
|
||||||
|
location.register:=cg.getmmregister(current_asmdata.CurrAsmList,def_cgsize(resultdef));
|
||||||
|
|
||||||
|
case torddef(left.resultdef).ordtype of
|
||||||
|
u64bit:
|
||||||
|
begin
|
||||||
|
{ unsigned 64 bit ints are harder to handle:
|
||||||
|
we load bits 0..62 and then check bit 63:
|
||||||
|
if it is 1 then we add $80000000 000000000
|
||||||
|
as double }
|
||||||
|
current_asmdata.getdatalabel(l1);
|
||||||
|
current_asmdata.getjumplabel(l2);
|
||||||
|
|
||||||
|
{ Get sign bit }
|
||||||
|
if not(left.location.loc in [LOC_REGISTER,LOC_REFERENCE]) then
|
||||||
|
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,false);
|
||||||
|
case left.location.loc of
|
||||||
|
LOC_REGISTER :
|
||||||
|
begin
|
||||||
|
emit_const_reg(A_BT,S_Q,63,left.location.register);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,S_Q,left.location.register,location.register));
|
||||||
|
end;
|
||||||
|
LOC_REFERENCE :
|
||||||
|
begin
|
||||||
|
inc(left.location.reference.offset,4);
|
||||||
|
emit_const_ref(A_BT,S_L,31,left.location.reference);
|
||||||
|
dec(left.location.reference.offset,4);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,S_Q,left.location.reference,location.register));
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
internalerror(200710181);
|
||||||
|
end;
|
||||||
|
|
||||||
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NC,l2);
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
|
||||||
|
reference_reset_symbol(href,l1,0);
|
||||||
|
|
||||||
|
{ I got these constant from a test program (FK) }
|
||||||
|
if is_double(resultdef) then
|
||||||
|
begin
|
||||||
|
{ double (2^64) }
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(0));
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($43f00000));
|
||||||
|
{ simplify for PIC }
|
||||||
|
tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,href);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(A_ADDSD,S_NO,href,location.register));
|
||||||
|
end
|
||||||
|
else if is_single(resultdef) then
|
||||||
|
begin
|
||||||
|
{ single(2^64) }
|
||||||
|
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($5f800000));
|
||||||
|
{ simplify for PIC }
|
||||||
|
tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,href);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(A_ADDSS,S_NO,href,location.register));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
internalerror(200506071);
|
||||||
|
cg.a_label(current_asmdata.CurrAsmList,l2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE]) then
|
||||||
|
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,false);
|
||||||
|
case left.location.loc of
|
||||||
|
LOC_CREFERENCE,
|
||||||
|
LOC_REFERENCE :
|
||||||
|
current_asmdata.CurrAsmList.concat(Taicpu.op_ref_reg(op,tcgsize2opsize[left.location.size],left.location.reference,location.register));
|
||||||
|
LOC_CREGISTER,
|
||||||
|
LOC_REGISTER :
|
||||||
|
current_asmdata.CurrAsmList.concat(Taicpu.op_reg_reg(op,tcgsize2opsize[left.location.size],left.location.register,location.register));
|
||||||
|
else
|
||||||
|
internalerror(200506072);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inherited second_int_to_real;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user