mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 16:29:14 +02:00
* add "doregister" parameter to torddef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions, or in the code generator for range checking git-svn-id: trunk@32046 -
This commit is contained in:
parent
91be1d0f2d
commit
2778bf55c7
@ -931,7 +931,7 @@ unit cg64f32;
|
|||||||
{ if the high dword = 0, the low dword can be considered a }
|
{ if the high dword = 0, the low dword can be considered a }
|
||||||
{ simple cardinal }
|
{ simple cardinal }
|
||||||
cg.a_label(list,poslabel);
|
cg.a_label(list,poslabel);
|
||||||
hdef:=corddef.create(u32bit,0,$ffffffff);
|
hdef:=corddef.create(u32bit,0,$ffffffff,false);
|
||||||
|
|
||||||
location_copy(temploc,l);
|
location_copy(temploc,l);
|
||||||
temploc.size:=OS_32;
|
temploc.size:=OS_32;
|
||||||
@ -944,7 +944,7 @@ unit cg64f32;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
hlcg.g_rangecheck(list,temploc,hdef,todef);
|
hlcg.g_rangecheck(list,temploc,hdef,todef);
|
||||||
hdef.owner.deletedef(hdef);
|
hdef.free;
|
||||||
|
|
||||||
if from_signed and to_signed then
|
if from_signed and to_signed then
|
||||||
begin
|
begin
|
||||||
@ -971,11 +971,11 @@ unit cg64f32;
|
|||||||
{ if we get here, the 64bit value lies between }
|
{ if we get here, the 64bit value lies between }
|
||||||
{ longint($80000000) and -1 (JM) }
|
{ longint($80000000) and -1 (JM) }
|
||||||
cg.a_label(list,neglabel);
|
cg.a_label(list,neglabel);
|
||||||
hdef:=corddef.create(s32bit,int64(longint($80000000)),int64(-1));
|
hdef:=corddef.create(s32bit,int64(longint($80000000)),int64(-1),false);
|
||||||
location_copy(temploc,l);
|
location_copy(temploc,l);
|
||||||
temploc.size:=OS_32;
|
temploc.size:=OS_32;
|
||||||
hlcg.g_rangecheck(list,temploc,hdef,todef);
|
hlcg.g_rangecheck(list,temploc,hdef,todef);
|
||||||
hdef.owner.deletedef(hdef);
|
hdef.free;
|
||||||
cg.a_label(list,endlabel);
|
cg.a_label(list,endlabel);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
@ -3399,7 +3399,8 @@ implementation
|
|||||||
s32bit,
|
s32bit,
|
||||||
{$endif cpu64bitaddr}
|
{$endif cpu64bitaddr}
|
||||||
get_min_value(resultdef),
|
get_min_value(resultdef),
|
||||||
get_max_value(resultdef)))
|
get_max_value(resultdef),
|
||||||
|
true))
|
||||||
else
|
else
|
||||||
inserttypeconv(hp,resultdef);
|
inserttypeconv(hp,resultdef);
|
||||||
|
|
||||||
@ -3858,7 +3859,8 @@ implementation
|
|||||||
s32bit,
|
s32bit,
|
||||||
{$endif cpu64bitaddr}
|
{$endif cpu64bitaddr}
|
||||||
get_min_value(resultnode.resultdef),
|
get_min_value(resultnode.resultdef),
|
||||||
get_max_value(resultnode.resultdef)))
|
get_max_value(resultnode.resultdef),
|
||||||
|
true))
|
||||||
else
|
else
|
||||||
inserttypeconv(hpp,resultnode.resultdef);
|
inserttypeconv(hpp,resultnode.resultdef);
|
||||||
|
|
||||||
@ -4274,7 +4276,9 @@ implementation
|
|||||||
temprangedef:=nil;
|
temprangedef:=nil;
|
||||||
getrange(unpackednode.resultdef,ulorange,uhirange);
|
getrange(unpackednode.resultdef,ulorange,uhirange);
|
||||||
getrange(packednode.resultdef,plorange,phirange);
|
getrange(packednode.resultdef,plorange,phirange);
|
||||||
temprangedef:=corddef.create(torddef(sinttype).ordtype,ulorange,uhirange);
|
{ does not really need to be registered, but then we would have to
|
||||||
|
record it elsewhere so it still can be freed }
|
||||||
|
temprangedef:=corddef.create(torddef(sinttype).ordtype,ulorange,uhirange,true);
|
||||||
sourcevecindex := ctemprefnode.create(loopvar);
|
sourcevecindex := ctemprefnode.create(loopvar);
|
||||||
targetvecindex := ctypeconvnode.create_internal(index.getcopy,sinttype);
|
targetvecindex := ctypeconvnode.create_internal(index.getcopy,sinttype);
|
||||||
targetvecindex := caddnode.create(subn,targetvecindex,cordconstnode.create(plorange,sinttype,true));
|
targetvecindex := caddnode.create(subn,targetvecindex,cordconstnode.create(plorange,sinttype,true));
|
||||||
|
@ -961,7 +961,8 @@ implementation
|
|||||||
newordtyp:=torddef(ptrsinttype).ordtype;
|
newordtyp:=torddef(ptrsinttype).ordtype;
|
||||||
inserttypeconv(right,corddef.create(newordtyp,
|
inserttypeconv(right,corddef.create(newordtyp,
|
||||||
int64(Tarraydef(left.resultdef).lowrange),
|
int64(Tarraydef(left.resultdef).lowrange),
|
||||||
int64(Tarraydef(left.resultdef).highrange)
|
int64(Tarraydef(left.resultdef).highrange),
|
||||||
|
true
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -972,7 +973,7 @@ implementation
|
|||||||
inserttypeconv(right,u8inttype)
|
inserttypeconv(right,u8inttype)
|
||||||
else if is_shortstring(left.resultdef) then
|
else if is_shortstring(left.resultdef) then
|
||||||
{Convert shortstring indexes to 0..length.}
|
{Convert shortstring indexes to 0..length.}
|
||||||
inserttypeconv(right,corddef.create(u8bit,0,int64(Tstringdef(left.resultdef).len)))
|
inserttypeconv(right,corddef.create(u8bit,0,int64(Tstringdef(left.resultdef).len),true))
|
||||||
else
|
else
|
||||||
{Convert indexes into dynamically allocated strings to aword.}
|
{Convert indexes into dynamically allocated strings to aword.}
|
||||||
inserttypeconv(right,uinttype);
|
inserttypeconv(right,uinttype);
|
||||||
|
@ -205,26 +205,26 @@ implementation
|
|||||||
cundefinedtype:=cundefineddef.create(true);
|
cundefinedtype:=cundefineddef.create(true);
|
||||||
cformaltype:=cformaldef.create(false);
|
cformaltype:=cformaldef.create(false);
|
||||||
ctypedformaltype:=cformaldef.create(true);
|
ctypedformaltype:=cformaldef.create(true);
|
||||||
voidtype:=corddef.create(uvoid,0,0);
|
voidtype:=corddef.create(uvoid,0,0,true);
|
||||||
voidpointertype:=cpointerdef.create(voidtype);
|
voidpointertype:=cpointerdef.create(voidtype);
|
||||||
u8inttype:=corddef.create(u8bit,0,255);
|
u8inttype:=corddef.create(u8bit,0,255,true);
|
||||||
s8inttype:=corddef.create(s8bit,int64(-128),127);
|
s8inttype:=corddef.create(s8bit,int64(-128),127,true);
|
||||||
u16inttype:=corddef.create(u16bit,0,65535);
|
u16inttype:=corddef.create(u16bit,0,65535,true);
|
||||||
s16inttype:=corddef.create(s16bit,int64(-32768),32767);
|
s16inttype:=corddef.create(s16bit,int64(-32768),32767,true);
|
||||||
u32inttype:=corddef.create(u32bit,0,high(longword));
|
u32inttype:=corddef.create(u32bit,0,high(longword),true);
|
||||||
s32inttype:=corddef.create(s32bit,int64(low(longint)),int64(high(longint)));
|
s32inttype:=corddef.create(s32bit,int64(low(longint)),int64(high(longint)),true);
|
||||||
u64inttype:=corddef.create(u64bit,low(qword),high(qword));
|
u64inttype:=corddef.create(u64bit,low(qword),high(qword),true);
|
||||||
s64inttype:=corddef.create(s64bit,low(int64),high(int64));
|
s64inttype:=corddef.create(s64bit,low(int64),high(int64),true);
|
||||||
pasbool8type:=corddef.create(pasbool8,0,1);
|
pasbool8type:=corddef.create(pasbool8,0,1,true);
|
||||||
pasbool16type:=corddef.create(pasbool16,0,1);
|
pasbool16type:=corddef.create(pasbool16,0,1,true);
|
||||||
pasbool32type:=corddef.create(pasbool32,0,1);
|
pasbool32type:=corddef.create(pasbool32,0,1,true);
|
||||||
pasbool64type:=corddef.create(pasbool64,0,1);
|
pasbool64type:=corddef.create(pasbool64,0,1,true);
|
||||||
bool8type:=corddef.create(bool8bit,low(int64),high(int64));
|
bool8type:=corddef.create(bool8bit,low(int64),high(int64),true);
|
||||||
bool16type:=corddef.create(bool16bit,low(int64),high(int64));
|
bool16type:=corddef.create(bool16bit,low(int64),high(int64),true);
|
||||||
bool32type:=corddef.create(bool32bit,low(int64),high(int64));
|
bool32type:=corddef.create(bool32bit,low(int64),high(int64),true);
|
||||||
bool64type:=corddef.create(bool64bit,low(int64),high(int64));
|
bool64type:=corddef.create(bool64bit,low(int64),high(int64),true);
|
||||||
cansichartype:=corddef.create(uchar,0,255);
|
cansichartype:=corddef.create(uchar,0,255,true);
|
||||||
cwidechartype:=corddef.create(uwidechar,0,65535);
|
cwidechartype:=corddef.create(uwidechar,0,65535,true);
|
||||||
cshortstringtype:=cstringdef.createshort(255);
|
cshortstringtype:=cstringdef.createshort(255);
|
||||||
{ should we give a length to the default long and ansi string definition ?? }
|
{ should we give a length to the default long and ansi string definition ?? }
|
||||||
clongstringtype:=cstringdef.createlong(-1);
|
clongstringtype:=cstringdef.createlong(-1);
|
||||||
@ -241,7 +241,7 @@ implementation
|
|||||||
{$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
|
{$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
|
||||||
if target_info.system=system_x86_64_win64 then
|
if target_info.system=system_x86_64_win64 then
|
||||||
begin
|
begin
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
pbestrealtype:=@s64floattype;
|
pbestrealtype:=@s64floattype;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -250,42 +250,42 @@ implementation
|
|||||||
{$endif x86}
|
{$endif x86}
|
||||||
{$ifdef powerpc}
|
{$ifdef powerpc}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif powerpc}
|
{$endif powerpc}
|
||||||
{$ifdef POWERPC64}
|
{$ifdef POWERPC64}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif POWERPC64}
|
{$endif POWERPC64}
|
||||||
{$ifdef sparc}
|
{$ifdef sparc}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif sparc}
|
{$endif sparc}
|
||||||
{$ifdef m68k}
|
{$ifdef m68k}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif}
|
{$endif}
|
||||||
{$ifdef arm}
|
{$ifdef arm}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif arm}
|
{$endif arm}
|
||||||
{$ifdef aarch64}
|
{$ifdef aarch64}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif aarch64}
|
{$endif aarch64}
|
||||||
{$ifdef avr}
|
{$ifdef avr}
|
||||||
s32floattype:=cfloatdef.create(s32real);
|
s32floattype:=cfloatdef.create(s32real);
|
||||||
s64floattype:=cfloatdef.create(s64real);
|
s64floattype:=cfloatdef.create(s64real);
|
||||||
s80floattype:=cfloatdef.create(s80real);
|
s80floattype:=cfloatdef.create(s80real);
|
||||||
sc80floattype:=cfloatdef.create(sc80real);
|
sc80floattype:=cfloatdef.create(sc80real);
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif avr}
|
{$endif avr}
|
||||||
{$ifdef mips}
|
{$ifdef mips}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif mips}
|
{$endif mips}
|
||||||
{$ifdef jvm}
|
{$ifdef jvm}
|
||||||
create_fpu_types;
|
create_fpu_types;
|
||||||
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
|
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
|
||||||
{$endif jvm}
|
{$endif jvm}
|
||||||
set_default_int_types;
|
set_default_int_types;
|
||||||
{ some other definitions }
|
{ some other definitions }
|
||||||
|
@ -1061,14 +1061,14 @@ implementation
|
|||||||
orddef :
|
orddef :
|
||||||
begin
|
begin
|
||||||
if is_char(pt1.resultdef) then
|
if is_char(pt1.resultdef) then
|
||||||
def:=corddef.create(uchar,lv,hv)
|
def:=corddef.create(uchar,lv,hv,true)
|
||||||
else
|
else
|
||||||
if is_boolean(pt1.resultdef) then
|
if is_boolean(pt1.resultdef) then
|
||||||
def:=corddef.create(pasbool8,lv,hv)
|
def:=corddef.create(pasbool8,lv,hv,true)
|
||||||
else if is_signed(pt1.resultdef) then
|
else if is_signed(pt1.resultdef) then
|
||||||
def:=corddef.create(range_to_basetype(lv,hv),lv,hv)
|
def:=corddef.create(range_to_basetype(lv,hv),lv,hv,true)
|
||||||
else
|
else
|
||||||
def:=corddef.create(range_to_basetype(lv,hv),lv,hv);
|
def:=corddef.create(range_to_basetype(lv,hv),lv,hv,true);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -918,9 +918,9 @@ type
|
|||||||
variables are initialised. Since these types are only used for
|
variables are initialised. Since these types are only used for
|
||||||
compile-time evaluation of conditional expressions, it doesn't matter
|
compile-time evaluation of conditional expressions, it doesn't matter
|
||||||
that we use the base types instead of the cpu-specific ones. }
|
that we use the base types instead of the cpu-specific ones. }
|
||||||
sintdef:=torddef.create(s64bit,low(int64),high(int64));
|
sintdef:=torddef.create(s64bit,low(int64),high(int64),false);
|
||||||
uintdef:=torddef.create(u64bit,low(qword),high(qword));
|
uintdef:=torddef.create(u64bit,low(qword),high(qword),false);
|
||||||
booldef:=torddef.create(pasbool8,0,1);
|
booldef:=torddef.create(pasbool8,0,1,false);
|
||||||
strdef:=tstringdef.createansi(0);
|
strdef:=tstringdef.createansi(0);
|
||||||
setdef:=tsetdef.create(sintdef,0,255);
|
setdef:=tsetdef.create(sintdef,0,255);
|
||||||
realdef:=tfloatdef.create(s80real);
|
realdef:=tfloatdef.create(s80real);
|
||||||
|
@ -518,7 +518,7 @@ interface
|
|||||||
torddef = class(tstoreddef)
|
torddef = class(tstoreddef)
|
||||||
low,high : TConstExprInt;
|
low,high : TConstExprInt;
|
||||||
ordtype : tordtype;
|
ordtype : tordtype;
|
||||||
constructor create(t : tordtype;v,b : TConstExprInt);virtual;
|
constructor create(t : tordtype;v,b : TConstExprInt; doregister: boolean);virtual;
|
||||||
constructor ppuload(ppufile:tcompilerppufile);
|
constructor ppuload(ppufile:tcompilerppufile);
|
||||||
function getcopy : tstoreddef;override;
|
function getcopy : tstoreddef;override;
|
||||||
{ do not override this routine in platform-specific subclasses,
|
{ do not override this routine in platform-specific subclasses,
|
||||||
@ -2636,9 +2636,9 @@ implementation
|
|||||||
TORDDEF
|
TORDDEF
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
constructor torddef.create(t : tordtype;v,b : TConstExprInt);
|
constructor torddef.create(t : tordtype;v,b : TConstExprInt; doregister: boolean);
|
||||||
begin
|
begin
|
||||||
inherited create(orddef,true);
|
inherited create(orddef,doregister);
|
||||||
low:=v;
|
low:=v;
|
||||||
high:=b;
|
high:=b;
|
||||||
ordtype:=t;
|
ordtype:=t;
|
||||||
@ -2659,7 +2659,7 @@ implementation
|
|||||||
|
|
||||||
function torddef.getcopy : tstoreddef;
|
function torddef.getcopy : tstoreddef;
|
||||||
begin
|
begin
|
||||||
result:=corddef.create(ordtype,low,high);
|
result:=corddef.create(ordtype,low,high,true);
|
||||||
result.typ:=orddef;
|
result.typ:=orddef;
|
||||||
torddef(result).low:=low;
|
torddef(result).low:=low;
|
||||||
torddef(result).high:=high;
|
torddef(result).high:=high;
|
||||||
|
Loading…
Reference in New Issue
Block a user