Browse Source

m68k: implemented a simple a_cmp_const_ref_label. uses TST instruction to test ref contents against zero

git-svn-id: trunk@28053 -
Károly Balogh 11 years ago
parent
commit
531ac093ed
1 changed files with 22 additions and 0 deletions
  1. 22 0
      compiler/m68k/cgcpu.pas

+ 22 - 0
compiler/m68k/cgcpu.pas

@@ -72,6 +72,7 @@ unit cgcpu;
         procedure a_op_reg_ref(list : TAsmList; Op: TOpCG; size: TCGSize; reg: TRegister; const ref: TReference); override;
 
         procedure a_cmp_const_reg_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;a : tcgint;reg : tregister; l : tasmlabel);override;
+        procedure a_cmp_const_ref_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;a : tcgint;const ref : treference; l : tasmlabel); override;
         procedure a_cmp_reg_reg_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
         procedure a_jmp_name(list : TAsmList;const s : string); override;
         procedure a_jmp_always(list : TAsmList;l: tasmlabel); override;
@@ -1442,6 +1443,27 @@ unit cgcpu;
          a_jmp_cond(list,cmp_op,l);
       end;
 
+    procedure tcg68k.a_cmp_const_ref_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;a : tcgint;const ref : treference; l : tasmlabel);
+      var
+        tmpref: treference;
+      begin
+        { optimize for usage of TST here, so ref compares against zero, which is the 
+          most common case by far in the RTL code at least (KB) }
+        if (a = 0) then
+          begin
+            //list.concat(tai_comment.create(strpnew('a_cmp_const_ref_label with TST')));
+            tmpref:=ref;
+            fixref(list,tmpref);
+            list.concat(taicpu.op_ref(A_TST,tcgsize2opsize[size],tmpref));
+            a_jmp_cond(list,cmp_op,l);
+          end
+        else
+          begin
+            //list.concat(tai_comment.create(strpnew('a_cmp_const_ref_label inherited')));
+            inherited;
+          end;
+      end;
+
     procedure tcg68k.a_cmp_reg_reg_label(list : TAsmList;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
       begin
          list.concat(taicpu.op_reg_reg(A_CMP,tcgsize2opsize[size],reg1,reg2));