Procházet zdrojové kódy

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 před 10 roky
rodič
revize
9d6f763d4f
1 změnil soubory, kde provedl 23 přidání a 0 odebrání
  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 conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
     function dwarf_reg(r:tregister):shortint;
     function dwarf_reg(r:tregister):shortint;
 
 
+    function isvalue8bit(val: tcgint): boolean;
+    function isvalue16bit(val: tcgint): boolean;
+    function isvalueforaddqsubq(val: tcgint): boolean;
+
 implementation
 implementation
 
 
     uses
     uses
@@ -542,4 +546,23 @@ implementation
           internalerror(200603251);
           internalerror(200603251);
       end;
       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.
 end.