* 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:
Jonas Maebe 2015-10-13 15:59:06 +00:00
parent 91be1d0f2d
commit 2778bf55c7
7 changed files with 54 additions and 49 deletions

View File

@ -931,7 +931,7 @@ unit cg64f32;
{ if the high dword = 0, the low dword can be considered a }
{ simple cardinal }
cg.a_label(list,poslabel);
hdef:=corddef.create(u32bit,0,$ffffffff);
hdef:=corddef.create(u32bit,0,$ffffffff,false);
location_copy(temploc,l);
temploc.size:=OS_32;
@ -944,7 +944,7 @@ unit cg64f32;
end;
hlcg.g_rangecheck(list,temploc,hdef,todef);
hdef.owner.deletedef(hdef);
hdef.free;
if from_signed and to_signed then
begin
@ -971,11 +971,11 @@ unit cg64f32;
{ if we get here, the 64bit value lies between }
{ longint($80000000) and -1 (JM) }
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);
temploc.size:=OS_32;
hlcg.g_rangecheck(list,temploc,hdef,todef);
hdef.owner.deletedef(hdef);
hdef.free;
cg.a_label(list,endlabel);
end;
end

View File

@ -3399,7 +3399,8 @@ implementation
s32bit,
{$endif cpu64bitaddr}
get_min_value(resultdef),
get_max_value(resultdef)))
get_max_value(resultdef),
true))
else
inserttypeconv(hp,resultdef);
@ -3858,7 +3859,8 @@ implementation
s32bit,
{$endif cpu64bitaddr}
get_min_value(resultnode.resultdef),
get_max_value(resultnode.resultdef)))
get_max_value(resultnode.resultdef),
true))
else
inserttypeconv(hpp,resultnode.resultdef);
@ -4274,7 +4276,9 @@ implementation
temprangedef:=nil;
getrange(unpackednode.resultdef,ulorange,uhirange);
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);
targetvecindex := ctypeconvnode.create_internal(index.getcopy,sinttype);
targetvecindex := caddnode.create(subn,targetvecindex,cordconstnode.create(plorange,sinttype,true));

View File

@ -961,7 +961,8 @@ implementation
newordtyp:=torddef(ptrsinttype).ordtype;
inserttypeconv(right,corddef.create(newordtyp,
int64(Tarraydef(left.resultdef).lowrange),
int64(Tarraydef(left.resultdef).highrange)
int64(Tarraydef(left.resultdef).highrange),
true
))
end
else
@ -972,7 +973,7 @@ implementation
inserttypeconv(right,u8inttype)
else if is_shortstring(left.resultdef) then
{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
{Convert indexes into dynamically allocated strings to aword.}
inserttypeconv(right,uinttype);

View File

@ -205,26 +205,26 @@ implementation
cundefinedtype:=cundefineddef.create(true);
cformaltype:=cformaldef.create(false);
ctypedformaltype:=cformaldef.create(true);
voidtype:=corddef.create(uvoid,0,0);
voidtype:=corddef.create(uvoid,0,0,true);
voidpointertype:=cpointerdef.create(voidtype);
u8inttype:=corddef.create(u8bit,0,255);
s8inttype:=corddef.create(s8bit,int64(-128),127);
u16inttype:=corddef.create(u16bit,0,65535);
s16inttype:=corddef.create(s16bit,int64(-32768),32767);
u32inttype:=corddef.create(u32bit,0,high(longword));
s32inttype:=corddef.create(s32bit,int64(low(longint)),int64(high(longint)));
u64inttype:=corddef.create(u64bit,low(qword),high(qword));
s64inttype:=corddef.create(s64bit,low(int64),high(int64));
pasbool8type:=corddef.create(pasbool8,0,1);
pasbool16type:=corddef.create(pasbool16,0,1);
pasbool32type:=corddef.create(pasbool32,0,1);
pasbool64type:=corddef.create(pasbool64,0,1);
bool8type:=corddef.create(bool8bit,low(int64),high(int64));
bool16type:=corddef.create(bool16bit,low(int64),high(int64));
bool32type:=corddef.create(bool32bit,low(int64),high(int64));
bool64type:=corddef.create(bool64bit,low(int64),high(int64));
cansichartype:=corddef.create(uchar,0,255);
cwidechartype:=corddef.create(uwidechar,0,65535);
u8inttype:=corddef.create(u8bit,0,255,true);
s8inttype:=corddef.create(s8bit,int64(-128),127,true);
u16inttype:=corddef.create(u16bit,0,65535,true);
s16inttype:=corddef.create(s16bit,int64(-32768),32767,true);
u32inttype:=corddef.create(u32bit,0,high(longword),true);
s32inttype:=corddef.create(s32bit,int64(low(longint)),int64(high(longint)),true);
u64inttype:=corddef.create(u64bit,low(qword),high(qword),true);
s64inttype:=corddef.create(s64bit,low(int64),high(int64),true);
pasbool8type:=corddef.create(pasbool8,0,1,true);
pasbool16type:=corddef.create(pasbool16,0,1,true);
pasbool32type:=corddef.create(pasbool32,0,1,true);
pasbool64type:=corddef.create(pasbool64,0,1,true);
bool8type:=corddef.create(bool8bit,low(int64),high(int64),true);
bool16type:=corddef.create(bool16bit,low(int64),high(int64),true);
bool32type:=corddef.create(bool32bit,low(int64),high(int64),true);
bool64type:=corddef.create(bool64bit,low(int64),high(int64),true);
cansichartype:=corddef.create(uchar,0,255,true);
cwidechartype:=corddef.create(uwidechar,0,65535,true);
cshortstringtype:=cstringdef.createshort(255);
{ should we give a length to the default long and ansi string definition ?? }
clongstringtype:=cstringdef.createlong(-1);
@ -241,7 +241,7 @@ implementation
{$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
if target_info.system=system_x86_64_win64 then
begin
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
pbestrealtype:=@s64floattype;
end
else
@ -250,42 +250,42 @@ implementation
{$endif x86}
{$ifdef powerpc}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif powerpc}
{$ifdef POWERPC64}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif POWERPC64}
{$ifdef sparc}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif sparc}
{$ifdef m68k}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif}
{$ifdef arm}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif arm}
{$ifdef aarch64}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif aarch64}
{$ifdef avr}
s32floattype:=cfloatdef.create(s32real);
s64floattype:=cfloatdef.create(s64real);
s80floattype:=cfloatdef.create(s80real);
sc80floattype:=cfloatdef.create(sc80real);
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif avr}
{$ifdef mips}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif mips}
{$ifdef jvm}
create_fpu_types;
s64currencytype:=corddef.create(scurrency,low(int64),high(int64));
s64currencytype:=corddef.create(scurrency,low(int64),high(int64),true);
{$endif jvm}
set_default_int_types;
{ some other definitions }

View File

@ -1061,14 +1061,14 @@ implementation
orddef :
begin
if is_char(pt1.resultdef) then
def:=corddef.create(uchar,lv,hv)
def:=corddef.create(uchar,lv,hv,true)
else
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
def:=corddef.create(range_to_basetype(lv,hv),lv,hv)
def:=corddef.create(range_to_basetype(lv,hv),lv,hv,true)
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;

View File

@ -918,9 +918,9 @@ type
variables are initialised. Since these types are only used for
compile-time evaluation of conditional expressions, it doesn't matter
that we use the base types instead of the cpu-specific ones. }
sintdef:=torddef.create(s64bit,low(int64),high(int64));
uintdef:=torddef.create(u64bit,low(qword),high(qword));
booldef:=torddef.create(pasbool8,0,1);
sintdef:=torddef.create(s64bit,low(int64),high(int64),false);
uintdef:=torddef.create(u64bit,low(qword),high(qword),false);
booldef:=torddef.create(pasbool8,0,1,false);
strdef:=tstringdef.createansi(0);
setdef:=tsetdef.create(sintdef,0,255);
realdef:=tfloatdef.create(s80real);

View File

@ -518,7 +518,7 @@ interface
torddef = class(tstoreddef)
low,high : TConstExprInt;
ordtype : tordtype;
constructor create(t : tordtype;v,b : TConstExprInt);virtual;
constructor create(t : tordtype;v,b : TConstExprInt; doregister: boolean);virtual;
constructor ppuload(ppufile:tcompilerppufile);
function getcopy : tstoreddef;override;
{ do not override this routine in platform-specific subclasses,
@ -2636,9 +2636,9 @@ implementation
TORDDEF
****************************************************************************}
constructor torddef.create(t : tordtype;v,b : TConstExprInt);
constructor torddef.create(t : tordtype;v,b : TConstExprInt; doregister: boolean);
begin
inherited create(orddef,true);
inherited create(orddef,doregister);
low:=v;
high:=b;
ordtype:=t;
@ -2659,7 +2659,7 @@ implementation
function torddef.getcopy : tstoreddef;
begin
result:=corddef.create(ordtype,low,high);
result:=corddef.create(ordtype,low,high,true);
result.typ:=orddef;
torddef(result).low:=low;
torddef(result).high:=high;