mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-06 19:38:33 +02:00
+ Xtensa: implemented tcputypeconvnode.second_int_to_bool
git-svn-id: trunk@44384 -
This commit is contained in:
parent
8fd53df3cd
commit
d1bbfe4cf7
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
Copyright (c) 1998-2002 by Florian Klaempfl
|
Copyright (c) 1998-2019 by Florian Klaempfl
|
||||||
|
|
||||||
Generate Xtensa assembler for type converting nodes
|
Generate Xtensa assembler for type converting nodes
|
||||||
|
|
||||||
@ -67,128 +67,98 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
FirstTypeConv
|
tcputypeconvnode
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
procedure tcputypeconvnode.second_int_to_bool;
|
procedure tcputypeconvnode.second_int_to_bool;
|
||||||
var
|
var
|
||||||
hreg1,
|
hreg1, onereg: tregister;
|
||||||
hregister : tregister;
|
|
||||||
href : treference;
|
href : treference;
|
||||||
hlabel : tasmlabel;
|
hlabel : tasmlabel;
|
||||||
newsize : tcgsize;
|
newsize : tcgsize;
|
||||||
begin
|
begin
|
||||||
secondpass(left);
|
secondpass(left);
|
||||||
if codegenerror then
|
if codegenerror then
|
||||||
exit;
|
exit;
|
||||||
//
|
|
||||||
// { Explicit typecasts from any ordinal type to a boolean type }
|
{ Explicit typecasts from any ordinal type to a boolean type
|
||||||
// { must not change the ordinal value }
|
must not change the ordinal value }
|
||||||
// if (nf_explicit in flags) and
|
if (nf_explicit in flags) and
|
||||||
// not(left.location.loc in [LOC_FLAGS,LOC_JUMP]) then
|
not(left.location.loc in [LOC_JUMP]) then
|
||||||
// begin
|
begin
|
||||||
// location_copy(location,left.location);
|
location_copy(location,left.location);
|
||||||
// newsize:=def_cgsize(resultdef);
|
newsize:=def_cgsize(resultdef);
|
||||||
// { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
|
{ change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
|
||||||
// if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
|
if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
|
||||||
// ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
|
((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
|
||||||
// hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
|
||||||
// else
|
else
|
||||||
// location.size:=newsize;
|
location.size:=newsize;
|
||||||
// exit;
|
exit;
|
||||||
// end;
|
end;
|
||||||
//
|
|
||||||
// { Load left node into flag F_NE/F_E }
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
// resflags:=F_NE;
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
//
|
|
||||||
// if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
||||||
// hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
|
||||||
//
|
onereg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||||
// case left.location.loc of
|
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,1,onereg);
|
||||||
// LOC_CREFERENCE,
|
hreg1:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
||||||
// LOC_REFERENCE :
|
case left.location.loc of
|
||||||
// begin
|
LOC_CREFERENCE,
|
||||||
// if left.location.size in [OS_64,OS_S64] then
|
LOC_REFERENCE :
|
||||||
// begin
|
begin
|
||||||
// hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
if left.location.size in [OS_64,OS_S64] then
|
||||||
// cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hregister);
|
begin
|
||||||
// href:=left.location.reference;
|
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hreg1);
|
||||||
// inc(href.offset,4);
|
href:=left.location.reference;
|
||||||
// tbasecgarm(cg).cgsetflags:=true;
|
inc(href.offset,4);
|
||||||
// cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,href,hregister);
|
cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,href,hreg1);
|
||||||
// tbasecgarm(cg).cgsetflags:=false;
|
end
|
||||||
// end
|
else
|
||||||
// else
|
cg.a_load_ref_reg(current_asmdata.CurrAsmList,left.location.size,OS_32,left.location.reference,hreg1);
|
||||||
// begin
|
current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_MOVNEZ,hreg1,onereg,hreg1));
|
||||||
// hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
end;
|
||||||
// tbasecgarm(cg).cgsetflags:=true;
|
LOC_REGISTER,LOC_CREGISTER :
|
||||||
// cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
|
begin
|
||||||
// tbasecgarm(cg).cgsetflags:=false;
|
if left.location.size in [OS_64,OS_S64] then
|
||||||
// end;
|
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,hreg1)
|
||||||
// end;
|
else
|
||||||
// LOC_FLAGS :
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList,left.location.size,OS_32,left.location.register,hreg1);
|
||||||
// begin
|
current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg_reg(A_MOVNEZ,hreg1,onereg,hreg1));
|
||||||
// resflags:=left.location.resflags;
|
end;
|
||||||
// end;
|
LOC_JUMP :
|
||||||
// LOC_REGISTER,LOC_CREGISTER :
|
begin
|
||||||
// begin
|
current_asmdata.getjumplabel(hlabel);
|
||||||
// if left.location.size in [OS_64,OS_S64] then
|
cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
|
||||||
// begin
|
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1);
|
||||||
// hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
|
||||||
// cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.register64.reglo,hregister);
|
cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
|
||||||
// tbasecgarm(cg).cgsetflags:=true;
|
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hreg1);
|
||||||
// cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reghi,hregister);
|
cg.a_label(current_asmdata.CurrAsmList,hlabel);
|
||||||
// tbasecgarm(cg).cgsetflags:=false;
|
end;
|
||||||
// end
|
else
|
||||||
// else
|
internalerror(2020031504);
|
||||||
// begin
|
end;
|
||||||
// tbasecgarm(cg).cgsetflags:=true;
|
if (is_cbool(resultdef)) then
|
||||||
// cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
|
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,hreg1,hreg1);
|
||||||
// tbasecgarm(cg).cgsetflags:=false;
|
|
||||||
// end;
|
{$ifndef cpu64bitalu}
|
||||||
// end;
|
if (location.size in [OS_64,OS_S64]) then
|
||||||
// LOC_JUMP :
|
begin
|
||||||
// begin
|
location.register64.reglo:=hreg1;
|
||||||
// hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
location.register64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||||
// current_asmdata.getjumplabel(hlabel);
|
if (is_cbool(resultdef)) then
|
||||||
// cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
|
{ reglo is either 0 or -1 -> reghi has to become the same }
|
||||||
// cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hregister);
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,location.register64.reglo,location.register64.reghi)
|
||||||
// cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
|
else
|
||||||
// cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
|
{ unsigned }
|
||||||
// cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
|
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reghi);
|
||||||
// cg.a_label(current_asmdata.CurrAsmList,hlabel);
|
end
|
||||||
// tbasecgarm(cg).cgsetflags:=true;
|
else
|
||||||
// cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_INT,hregister,hregister);
|
{$endif cpu64bitalu}
|
||||||
// tbasecgarm(cg).cgsetflags:=false;
|
location.register:=hreg1;
|
||||||
// end;
|
|
||||||
// else
|
|
||||||
// internalerror(200311301);
|
|
||||||
// end;
|
|
||||||
// { load flags to register }
|
|
||||||
// location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
|
||||||
// hreg1:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
|
||||||
// cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,hreg1);
|
|
||||||
// cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
|
||||||
// if (is_cbool(resultdef)) then
|
|
||||||
// cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,hreg1,hreg1);
|
|
||||||
//
|
|
||||||
//{$ifndef cpu64bitalu}
|
|
||||||
// if (location.size in [OS_64,OS_S64]) then
|
|
||||||
// begin
|
|
||||||
// location.register64.reglo:=hreg1;
|
|
||||||
// location.register64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
|
||||||
// if (is_cbool(resultdef)) then
|
|
||||||
// { reglo is either 0 or -1 -> reghi has to become the same }
|
|
||||||
// cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,location.register64.reglo,location.register64.reghi)
|
|
||||||
// else
|
|
||||||
// { unsigned }
|
|
||||||
// cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reghi);
|
|
||||||
// end
|
|
||||||
// else
|
|
||||||
//{$endif cpu64bitalu}
|
|
||||||
// location.register:=hreg1;
|
|
||||||
location_copy(location,left.location);
|
|
||||||
current_asmdata.CurrAsmList.Concat(taicpu.op_none(A_NOP));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
'j',
|
'j',
|
||||||
'mov',
|
'mov',
|
||||||
'mov.s',
|
'mov.s',
|
||||||
|
'movnez',
|
||||||
'movi',
|
'movi',
|
||||||
'mull',
|
'mull',
|
||||||
'neg',
|
'neg',
|
||||||
|
@ -26,6 +26,7 @@ A_LSI,
|
|||||||
A_J,
|
A_J,
|
||||||
A_MOV,
|
A_MOV,
|
||||||
A_MOV_S,
|
A_MOV_S,
|
||||||
|
A_MOVNEZ,
|
||||||
A_MOVI,
|
A_MOVI,
|
||||||
A_MULL,
|
A_MULL,
|
||||||
A_NEG,
|
A_NEG,
|
||||||
|
Loading…
Reference in New Issue
Block a user