Pārlūkot izejas kodu

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

git-svn-id: trunk@29605 -
Károly Balogh 10 gadi atpakaļ
vecāks
revīzija
9d6f763d4f
1 mainītis faili ar 23 papildinājumiem un 0 dzēšanām
  1. 23 0
      compiler/m68k/cpubase.pas

+ 23 - 0
compiler/m68k/cpubase.pas

@@ -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.