mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 11:49:23 +02:00
+ generic implementation of tcg.g_flags2ref()
* tcg.flags2xxx() now also needs a size parameter
This commit is contained in:
parent
15429fdd2c
commit
6b83738e7d
@ -237,8 +237,8 @@ unit cgobj;
|
||||
procedure a_jmp_always(list : taasmoutput;l: tasmlabel); virtual; abstract;
|
||||
procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); virtual; abstract;
|
||||
|
||||
procedure g_flags2reg(list: taasmoutput; const f: tresflags; reg: TRegister); virtual; abstract;
|
||||
procedure g_flags2ref(list: taasmoutput; const f: tresflags; const ref:TReference); virtual; abstract;
|
||||
procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister); virtual; abstract;
|
||||
procedure g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref:TReference); virtual;
|
||||
|
||||
{ some processors like the PPC doesn't allow to change the stack in }
|
||||
{ a procedure, so we need to maintain an extra stack for the }
|
||||
@ -1084,8 +1084,7 @@ unit cgobj;
|
||||
(hfrom = high(longint))) or
|
||||
((torddef(fromdef).typ = u32bit) and
|
||||
(lfrom = low(cardinal)) and
|
||||
(hfrom = high(cardinal))))) or
|
||||
is_64bitint(fromdef)) then
|
||||
(hfrom = high(cardinal)))))) then
|
||||
exit;
|
||||
if todef<>fromdef then
|
||||
begin
|
||||
@ -1098,7 +1097,7 @@ unit cgobj;
|
||||
{ store the result }
|
||||
|
||||
{ use the trick that }
|
||||
{ a <= x <= b <=> 0 <= x-a <= b-a <=> cardinal(x-a) <= cardinal(b-a) }
|
||||
{ a <= x <= b <=> 0 <= x-a <= b-a <=> unsigned(x-a) <= unsigned(b-a) }
|
||||
|
||||
{ To be able to do that, we have to make sure however that either }
|
||||
{ fromdef and todef are both signed or unsigned, or that we leave }
|
||||
@ -1143,15 +1142,15 @@ unit cgobj;
|
||||
hreg := get_scratch_reg_int(list);
|
||||
if (p.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
|
||||
a_op_const_reg_reg(list,OP_SUB,def_cgsize(p.resulttype.def),
|
||||
aword(longint(lto and $ffffffff)),p.location.register,hreg)
|
||||
aword(lto),p.location.register,hreg)
|
||||
else
|
||||
begin
|
||||
a_load_ref_reg(list,def_cgsize(p.resulttype.def),
|
||||
p.location.reference,hreg);
|
||||
a_op_const_reg(list,OP_SUB,aword(longint(lto and $ffffffff)),hreg);
|
||||
a_op_const_reg(list,OP_SUB,aword(lto),hreg);
|
||||
end;
|
||||
getlabel(neglabel);
|
||||
a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(longint((hto-lto) and $ffffffff)),hreg,neglabel);
|
||||
a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
|
||||
{ !!! should happen right after the compare (JM) }
|
||||
free_scratch_reg(list,hreg);
|
||||
a_call_name(list,'FPC_RANGEERROR');
|
||||
@ -1167,6 +1166,18 @@ unit cgobj;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcg.g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref:TReference);
|
||||
|
||||
var
|
||||
tmpreg : tregister;
|
||||
begin
|
||||
tmpreg := get_scratch_reg_int(list);
|
||||
g_flags2reg(list,size,f,tmpreg);
|
||||
a_load_reg_ref(list,size,tmpreg,ref);
|
||||
free_scratch_reg(list,tmpreg);
|
||||
end;
|
||||
|
||||
|
||||
procedure tcg.g_maybe_loadself(list : taasmoutput);
|
||||
var
|
||||
hp : treference;
|
||||
@ -1368,7 +1379,11 @@ finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.37 2002-07-20 11:57:53 florian
|
||||
Revision 1.38 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.37 2002/07/20 11:57:53 florian
|
||||
* types.pas renamed to defbase.pas because D6 contains a types
|
||||
unit so this would conflicts if D6 programms are compiled
|
||||
+ Willamette/SSE2 instructions to assembler added
|
||||
|
@ -270,7 +270,7 @@ implementation
|
||||
{ load flags to register }
|
||||
location_reset(location,LOC_REGISTER,def_cgsize(resulttype.def));
|
||||
location.register:=def_getreg(resulttype.def);
|
||||
cg.g_flags2reg(exprasmlist,resflags,location.register);
|
||||
cg.g_flags2reg(exprasmlist,location.size,resflags,location.register);
|
||||
truelabel:=oldtruelabel;
|
||||
falselabel:=oldfalselabel;
|
||||
end;
|
||||
@ -365,7 +365,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.44 2002-07-20 11:58:01 florian
|
||||
Revision 1.45 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.44 2002/07/20 11:58:01 florian
|
||||
* types.pas renamed to defbase.pas because D6 contains a types
|
||||
unit so this would conflicts if D6 programms are compiled
|
||||
+ Willamette/SSE2 instructions to assembler added
|
||||
|
@ -104,10 +104,10 @@ implementation
|
||||
if nf_testatbegin in flags then
|
||||
cg.a_jmp_always(exprasmlist,lcont);
|
||||
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
{ align loop target }
|
||||
exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
|
||||
|
||||
|
||||
cg.a_label(exprasmlist,lloop);
|
||||
|
||||
aktcontinuelabel:=lcont;
|
||||
@ -133,7 +133,7 @@ implementation
|
||||
end;
|
||||
rg.cleartempgen;
|
||||
secondpass(left);
|
||||
|
||||
|
||||
maketojumpbool(exprasmlist,left,lr_load_regvars);
|
||||
cg.a_label(exprasmlist,lbreak);
|
||||
truelabel:=otlabel;
|
||||
@ -363,7 +363,7 @@ implementation
|
||||
hop:=OP_SUB;
|
||||
cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
|
||||
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
{ align loop target }
|
||||
exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
|
||||
cg.a_label(exprasmlist,l3);
|
||||
@ -472,7 +472,7 @@ implementation
|
||||
begin
|
||||
cg.a_reg_alloc(exprasmlist,accumulator);
|
||||
allocated_acc := true;
|
||||
cg.g_flags2reg(exprasmlist,left.location.resflags,accumulator);
|
||||
cg.g_flags2reg(exprasmlist,OS_INT,left.location.resflags,accumulator);
|
||||
goto do_jmp;
|
||||
end;
|
||||
LOC_JUMP :
|
||||
@ -627,7 +627,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.29 2002-07-25 17:56:29 carl
|
||||
Revision 1.30 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.29 2002/07/25 17:56:29 carl
|
||||
+ FPURESULTREG -> FPU_RESULT_REG
|
||||
|
||||
Revision 1.28 2002/07/21 06:58:49 daniel
|
||||
|
@ -633,13 +633,14 @@ implementation
|
||||
end;
|
||||
LOC_FLAGS :
|
||||
begin
|
||||
// this can be a wordbool or longbool too, no?
|
||||
if left.location.loc=LOC_CREGISTER then
|
||||
cg.g_flags2reg(exprasmlist,right.location.resflags,left.location.register)
|
||||
cg.g_flags2reg(exprasmlist,def_cgsize(left.resulttype.def),right.location.resflags,left.location.register)
|
||||
else
|
||||
begin
|
||||
if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
|
||||
if not(left.location.loc = LOC_REFERENCE) then
|
||||
internalerror(200203273);
|
||||
cg.g_flags2ref(exprasmlist,right.location.resflags,left.location.reference);
|
||||
cg.g_flags2ref(exprasmlist,def_cgsize(left.resulttype.def),right.location.resflags,left.location.reference);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -922,7 +923,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.15 2002-07-20 11:57:54 florian
|
||||
Revision 1.16 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.15 2002/07/20 11:57:54 florian
|
||||
* types.pas renamed to defbase.pas because D6 contains a types
|
||||
unit so this would conflicts if D6 programms are compiled
|
||||
+ Willamette/SSE2 instructions to assembler added
|
||||
|
@ -233,7 +233,7 @@ implementation
|
||||
{ load value in low register }
|
||||
case l.loc of
|
||||
LOC_FLAGS :
|
||||
cg.g_flags2reg(list,l.resflags,hregister);
|
||||
cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
|
||||
LOC_JUMP :
|
||||
begin
|
||||
cg.a_label(list,truelabel);
|
||||
@ -321,7 +321,7 @@ implementation
|
||||
{ load value in new register }
|
||||
case l.loc of
|
||||
LOC_FLAGS :
|
||||
cg.g_flags2reg(list,l.resflags,hregister);
|
||||
cg.g_flags2reg(list,dst_size,l.resflags,hregister);
|
||||
LOC_JUMP :
|
||||
begin
|
||||
cg.a_label(list,truelabel);
|
||||
@ -375,7 +375,7 @@ implementation
|
||||
{ load value in low register }
|
||||
case l.loc of
|
||||
LOC_FLAGS :
|
||||
cg.g_flags2reg(list,l.resflags,hregister);
|
||||
cg.g_flags2reg(list,OS_INT,l.resflags,hregister);
|
||||
LOC_JUMP :
|
||||
begin
|
||||
cg.a_label(list,truelabel);
|
||||
@ -413,7 +413,7 @@ implementation
|
||||
{ load value in new register }
|
||||
case l.loc of
|
||||
LOC_FLAGS :
|
||||
cg.g_flags2reg(list,l.resflags,hregister);
|
||||
cg.g_flags2reg(list,dst_size,l.resflags,hregister);
|
||||
LOC_JUMP :
|
||||
begin
|
||||
cg.a_label(list,truelabel);
|
||||
@ -587,15 +587,11 @@ implementation
|
||||
|
||||
function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
|
||||
begin
|
||||
if needed>=maxfpuregs then
|
||||
if (needed>=maxfpuregs) and
|
||||
(l.loc = LOC_FPUREGISTER) then
|
||||
begin
|
||||
if l.loc = LOC_FPUREGISTER then
|
||||
begin
|
||||
location_force_mem(list,l);
|
||||
maybe_pushfpu:=true;
|
||||
end
|
||||
else
|
||||
maybe_pushfpu:=false;
|
||||
location_force_mem(list,l);
|
||||
maybe_pushfpu:=true;
|
||||
end
|
||||
else
|
||||
maybe_pushfpu:=false;
|
||||
@ -1629,7 +1625,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.25 2002-07-26 21:15:38 florian
|
||||
Revision 1.26 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.25 2002/07/26 21:15:38 florian
|
||||
* rewrote the system handling
|
||||
|
||||
Revision 1.24 2002/07/25 17:58:24 carl
|
||||
|
@ -297,7 +297,7 @@ implementation
|
||||
begin
|
||||
hreg1:=rg.getregisterint(exprasmlist);
|
||||
resflags:=left.location.resflags;
|
||||
cg.g_flags2reg(exprasmlist,resflags,hreg1);
|
||||
cg.g_flags2reg(exprasmlist,location.size,resflags,hreg1);
|
||||
end;
|
||||
else
|
||||
internalerror(10062);
|
||||
@ -384,7 +384,11 @@ begin
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002-07-24 14:38:00 florian
|
||||
Revision 1.17 2002-07-27 19:55:15 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.16 2002/07/24 14:38:00 florian
|
||||
* small typo fixed, compiles with 1.0.x again
|
||||
|
||||
Revision 1.15 2002/07/21 16:57:22 jonas
|
||||
|
@ -94,8 +94,8 @@ unit cgx86;
|
||||
procedure a_jmp_always(list : taasmoutput;l: tasmlabel); override;
|
||||
procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
|
||||
|
||||
procedure g_flags2reg(list: taasmoutput; const f: tresflags; reg: TRegister); override;
|
||||
procedure g_flags2ref(list: taasmoutput; const f: tresflags; const ref: TReference); override;
|
||||
procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister); override;
|
||||
procedure g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref: TReference); override;
|
||||
|
||||
procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
|
||||
|
||||
@ -1034,26 +1034,28 @@ unit cgx86;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcgx86.g_flags2reg(list: taasmoutput; const f: tresflags; reg: TRegister);
|
||||
procedure tcgx86.g_flags2reg(list: taasmoutput; size: TCgSize; const f: tresflags; reg: TRegister);
|
||||
|
||||
var
|
||||
ai : taicpu;
|
||||
hreg : tregister;
|
||||
begin
|
||||
if not(size in [OS_8,OS_S8]) then
|
||||
a_load_const_reg(list,size,0,reg);
|
||||
hreg := rg.makeregsize(reg,OS_8);
|
||||
ai:=Taicpu.Op_reg(A_Setcc,S_B,hreg);
|
||||
ai.SetCondition(flags_to_cond(f));
|
||||
list.concat(ai);
|
||||
if hreg<>reg then
|
||||
a_load_reg_reg(list,OS_8,hreg,reg);
|
||||
end;
|
||||
|
||||
|
||||
procedure tcgx86.g_flags2ref(list: taasmoutput; const f: tresflags; const ref: TReference);
|
||||
procedure tcgx86.g_flags2ref(list: taasmoutput; size: TCgSize; const f: tresflags; const ref: TReference);
|
||||
|
||||
var
|
||||
ai : taicpu;
|
||||
begin
|
||||
if not(size in [OS_8,OS_S8]) then
|
||||
a_load_const_ref(list,size,0,ref);
|
||||
ai:=Taicpu.Op_ref(A_Setcc,S_B,ref);
|
||||
ai.SetCondition(flags_to_cond(f));
|
||||
list.concat(ai);
|
||||
@ -1664,7 +1666,11 @@ unit cgx86;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2002-07-26 21:15:46 florian
|
||||
Revision 1.4 2002-07-27 19:53:51 jonas
|
||||
+ generic implementation of tcg.g_flags2ref()
|
||||
* tcg.flags2xxx() now also needs a size parameter
|
||||
|
||||
Revision 1.3 2002/07/26 21:15:46 florian
|
||||
* rewrote the system handling
|
||||
|
||||
Revision 1.2 2002/07/21 16:55:34 jonas
|
||||
|
Loading…
Reference in New Issue
Block a user