+ get_max_value in defutil

* use a linear cmp list instead of subtractions on ppc if low >=
    low(smallint) and high <= high(word), because a compare does not
    introduce any dependencies (and in those cases using subtractions
    does not save any instructions or bytes either)

git-svn-id: trunk@3065 -
This commit is contained in:
Jonas Maebe 2006-03-28 11:49:16 +00:00
parent 7a34d58a15
commit 6c62d6a647
2 changed files with 23 additions and 0 deletions

View File

@ -46,6 +46,9 @@ interface
{# Returns the minimal integer value of the type }
function get_min_value(def : tdef) : TConstExprInt;
{# Returns the maximal integer value of the type }
function get_max_value(def : tdef) : TConstExprInt;
{# Returns basetype of the specified integer range }
function range_to_basetype(l,h:TConstExprInt):tbasetype;
@ -349,6 +352,20 @@ implementation
end;
{ returns the max. value of the type }
function get_max_value(def : tdef) : TConstExprInt;
begin
case def.deftype of
orddef:
get_max_value:=torddef(def).high;
enumdef:
get_max_value:=tenumdef(def).max;
else
get_max_value:=0;
end;
end;
{ true if p is an integer }
function is_integer(def : tdef) : boolean;
begin

View File

@ -144,6 +144,12 @@ implementation
end;
begin
if (get_min_value(left.resulttype.def) >= low(smallint)) and
(get_max_value(left.resulttype.def) <= high(word)) then
begin
genlinearcmplist(hp);
exit;
end;
if assigned(t^.less) then
genitem(t^.less);
{ need we to test the first value }