فهرست منبع

+ added another helper for register pairs: register_in

git-svn-id: trunk@45150 -
nickysn 5 سال پیش
والد
کامیت
491462fd02
1فایلهای تغییر یافته به همراه18 افزوده شده و 0 حذف شده
  1. 18 0
      compiler/z80/cpubase.pas

+ 18 - 0
compiler/z80/cpubase.pas

@@ -279,6 +279,8 @@ unit cpubase;
     function std_regname(r:Tregister):string;
     function is_regpair(r:Tregister):boolean;
     procedure split_regpair(regpair:Tregister;out reglo,reghi:Tregister);
+    { Checks if sreg is a subset of reg (e.g. NR_H is a subset of NR_HL }
+    function register_in(sreg,reg:Tregister):boolean;
 
     function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
     function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
@@ -434,6 +436,22 @@ unit cpubase;
       end;
 
 
+    function register_in(sreg,reg: Tregister):boolean;
+      var
+        tmpreg1, tmpreg2: Tregister;
+      begin
+        if sreg=reg then
+          result:=true
+        else if is_regpair(reg) then
+          begin
+            split_regpair(reg,tmpreg1,tmpreg2);
+            result:=(sreg=tmpreg1) or (sreg=tmpreg2);
+          end
+        else
+          result:=false;
+      end;
+
+
     function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
       const
         inverse: array[TAsmCond] of TAsmCond=(C_None,