mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 05:40:20 +02:00
* range check error fixes
This commit is contained in:
parent
5373203246
commit
801d6914e8
@ -587,9 +587,9 @@ implementation
|
|||||||
if not(jumptable_no_range) then
|
if not(jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ case expr less than min_ => goto elselabel }
|
{ case expr less than min_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,longint(min_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,aword(min_),hregister,elselabel);
|
||||||
{ case expr greater than max_ => goto elselabel }
|
{ case expr greater than max_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_gt,longint(max_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_gt,aword(max_),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
objectlibrary.getlabel(table);
|
objectlibrary.getlabel(table);
|
||||||
{ make it a 32bit register }
|
{ make it a 32bit register }
|
||||||
@ -624,7 +624,7 @@ implementation
|
|||||||
{ need we to test the first value }
|
{ need we to test the first value }
|
||||||
if first and (t^._low>get_min_value(left.resulttype.def)) then
|
if first and (t^._low>get_min_value(left.resulttype.def)) then
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,longint(t^._low),hregister,elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,aword(t^._low),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
@ -632,7 +632,7 @@ implementation
|
|||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ,0,hregister,t^.statement)
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ,0,hregister,t^.statement)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
cg.a_op_const_reg(exprasmlist, OP_SUB, longint(t^._low-last), hregister);
|
cg.a_op_const_reg(exprasmlist, OP_SUB, aword(t^._low-last), hregister);
|
||||||
emitjmp(C_Z,t^.statement);
|
emitjmp(C_Z,t^.statement);
|
||||||
end;
|
end;
|
||||||
last:=t^._low;
|
last:=t^._low;
|
||||||
@ -706,7 +706,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.43 2002-09-17 18:54:05 jonas
|
Revision 1.44 2002-10-03 21:34:45 carl
|
||||||
|
* range check error fixes
|
||||||
|
|
||||||
|
Revision 1.43 2002/09/17 18:54:05 jonas
|
||||||
* a_load_reg_reg() now has two size parameters: source and dest. This
|
* a_load_reg_reg() now has two size parameters: source and dest. This
|
||||||
allows some optimizations on architectures that don't encode the
|
allows some optimizations on architectures that don't encode the
|
||||||
register size in the register name.
|
register size in the register name.
|
||||||
|
@ -91,7 +91,7 @@ implementation
|
|||||||
paramgr,
|
paramgr,
|
||||||
pass_2,
|
pass_2,
|
||||||
ncon,
|
ncon,
|
||||||
tgobj,ncgutil,regvars,rgobj;
|
tgobj,ncgutil,regvars,rgobj,cpuinfo;
|
||||||
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
@ -632,7 +632,7 @@ implementation
|
|||||||
{ need we to test the first value }
|
{ need we to test the first value }
|
||||||
if first and (t^._low>get_min_value(left.resulttype.def)) then
|
if first and (t^._low>get_min_value(left.resulttype.def)) then
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,longint(t^._low),hregister,elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,jmp_lt,aword(t^._low),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
@ -641,7 +641,7 @@ implementation
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
gensub(longint(t^._low-last));
|
gensub(longint(t^._low-last));
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ,longint(t^._low-last),scratch_reg,t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ,aword(t^._low-last),scratch_reg,t^.statement);
|
||||||
end;
|
end;
|
||||||
last:=t^._low;
|
last:=t^._low;
|
||||||
end
|
end
|
||||||
@ -662,10 +662,10 @@ implementation
|
|||||||
{ present label then the lower limit can be checked }
|
{ present label then the lower limit can be checked }
|
||||||
{ immediately. else check the range in between: }
|
{ immediately. else check the range in between: }
|
||||||
gensub(longint(t^._low-last));
|
gensub(longint(t^._low-last));
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT,jmp_lt,longint(t^._low-last),scratch_reg,elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT,jmp_lt,aword(t^._low-last),scratch_reg,elselabel);
|
||||||
end;
|
end;
|
||||||
gensub(longint(t^._high-t^._low));
|
gensub(longint(t^._high-t^._low));
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT,jmp_le,longint(t^._high-t^._low),scratch_reg,t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT,jmp_le,aword(t^._high-t^._low),scratch_reg,t^.statement);
|
||||||
last:=t^._high;
|
last:=t^._high;
|
||||||
end;
|
end;
|
||||||
first:=false;
|
first:=false;
|
||||||
@ -708,13 +708,13 @@ implementation
|
|||||||
if opsize in [OS_S64,OS_64] then
|
if opsize in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
objectlibrary.getlabel(l1);
|
objectlibrary.getlabel(l1);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_NE, longint(hi(int64(t^._low))),hregister2,l1);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_NE, aword(hi(int64(t^._low))),hregister2,l1);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ, longint(lo(int64(t^._low))),hregister, t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ, aword(lo(int64(t^._low))),hregister, t^.statement);
|
||||||
cg.a_label(exprasmlist,l1);
|
cg.a_label(exprasmlist,l1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ, longint(t^._low),hregister, t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_EQ, aword(t^._low),hregister, t^.statement);
|
||||||
last:=t^._low;
|
last:=t^._low;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
@ -728,17 +728,17 @@ implementation
|
|||||||
if opsize in [OS_64,OS_S64] then
|
if opsize in [OS_64,OS_S64] then
|
||||||
begin
|
begin
|
||||||
objectlibrary.getlabel(l1);
|
objectlibrary.getlabel(l1);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, longint(hi(int64(t^._low))),
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, aword(hi(int64(t^._low))),
|
||||||
hregister2, elselabel);
|
hregister2, elselabel);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_gt, longint(hi(int64(t^._low))),
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_gt, aword(hi(int64(t^._low))),
|
||||||
hregister2, l1);
|
hregister2, l1);
|
||||||
{ the comparisation of the low dword must be always unsigned! }
|
{ the comparisation of the low dword must be always unsigned! }
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_B, longint(lo(int64(t^._low))), hregister, elselabel);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_B, aword(lo(int64(t^._low))), hregister, elselabel);
|
||||||
cg.a_label(exprasmlist,l1);
|
cg.a_label(exprasmlist,l1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, longint(t^._low), hregister,
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, aword(t^._low), hregister,
|
||||||
elselabel);
|
elselabel);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -746,16 +746,16 @@ implementation
|
|||||||
if opsize in [OS_S64,OS_64] then
|
if opsize in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
objectlibrary.getlabel(l1);
|
objectlibrary.getlabel(l1);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, longint(hi(int64(t^._high))), hregister2,
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_lt, aword(hi(int64(t^._high))), hregister2,
|
||||||
t^.statement);
|
t^.statement);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_gt, longint(hi(int64(t^._high))), hregister2,
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_gt, aword(hi(int64(t^._high))), hregister2,
|
||||||
l1);
|
l1);
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_BE, longint(lo(int64(t^._high))), hregister, t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, OC_BE, aword(lo(int64(t^._high))), hregister, t^.statement);
|
||||||
cg.a_label(exprasmlist,l1);
|
cg.a_label(exprasmlist,l1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_le, longint(t^._high), hregister, t^.statement);
|
cg.a_cmp_const_reg_label(exprasmlist, OS_INT, jmp_le, aword(t^._high), hregister, t^.statement);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
last:=t^._high;
|
last:=t^._high;
|
||||||
@ -993,7 +993,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.20 2002-09-17 18:54:03 jonas
|
Revision 1.21 2002-10-03 21:31:10 carl
|
||||||
|
* range check error fixes
|
||||||
|
|
||||||
|
Revision 1.20 2002/09/17 18:54:03 jonas
|
||||||
* a_load_reg_reg() now has two size parameters: source and dest. This
|
* a_load_reg_reg() now has two size parameters: source and dest. This
|
||||||
allows some optimizations on architectures that don't encode the
|
allows some optimizations on architectures that don't encode the
|
||||||
register size in the register name.
|
register size in the register name.
|
||||||
|
Loading…
Reference in New Issue
Block a user