m68k: small helpers to determine a given int value fits into a certain size or instruction argument

git-svn-id: trunk@29605 -
This commit is contained in:
Károly Balogh 2015-02-02 08:25:01 +00:00
parent f0c5074e34
commit 9d6f763d4f

View File

@ -360,6 +360,10 @@ unit cpubase;
function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
function dwarf_reg(r:tregister):shortint;
function isvalue8bit(val: tcgint): boolean;
function isvalue16bit(val: tcgint): boolean;
function isvalueforaddqsubq(val: tcgint): boolean;
implementation
uses
@ -542,4 +546,23 @@ implementation
internalerror(200603251);
end;
{ returns true if given value fits to an 8bit signed integer }
function isvalue8bit(val: tcgint): boolean;
begin
isvalue8bit := (val >= low(shortint)) and (val <= high(shortint));
end;
{ returns true if given value fits to a 16bit signed integer }
function isvalue16bit(val: tcgint): boolean;
begin
isvalue16bit := (val >= low(smallint)) and (val <= high(smallint));
end;
{ returns true if given value fits addq/subq argument, so in 1 - 8 range }
function isvalueforaddqsubq(val: tcgint): boolean;
begin
isvalueforaddqsubq := (val >= 1) and (val <= 8);
end;
end.