소스 검색

* optimized the code generated by the a_op_const_* and a_op64_const
methods

Jonas Maebe 23 년 전
부모
커밋
36699776ee
1개의 변경된 파일67개의 추가작업 그리고 11개의 파일을 삭제
  1. 67 11
      compiler/i386/cgcpu.pas

+ 67 - 11
compiler/i386/cgcpu.pas

@@ -20,6 +20,7 @@
 
  ****************************************************************************
 }
+
 unit cgcpu;
 
 {$i defines.inc}
@@ -455,6 +456,18 @@ unit cgcpu;
                 exit
               else
                 list.concat(taicpu.op_const_reg(A_MOV,regsize(reg),0,reg))
+            else if (a = high(aword)) and
+                    (op in [OP_AND,OP_OR,OP_XOR]) then
+                   begin
+                     case op of
+                       OP_AND:
+                         exit;
+                       OP_OR:
+                         list.concat(taicpu.op_const_reg(A_MOV,regsize(reg),high(aword),reg));
+                       OP_XOR:
+                         list.concat(taicpu.op_reg(A_NOT,regsize(reg),reg));
+                     end
+                   end
             else
               list.concat(taicpu.op_const_reg(TOpCG2AsmOp[op],regsize(reg),
                 a,reg));
@@ -527,6 +540,18 @@ unit cgcpu;
                 exit
               else
                 a_load_const_ref(list,size,0,ref)
+            else if (a = high(aword)) and
+                    (op in [OP_AND,OP_OR,OP_XOR]) then
+                   begin
+                     case op of
+                       OP_AND:
+                         exit;
+                       OP_OR:
+                         list.concat(taicpu.op_const_ref(A_MOV,TCgSize2OpSize[size],high(aword),ref));
+                       OP_XOR:
+                         list.concat(taicpu.op_ref(A_NOT,TCgSize2OpSize[size],ref));
+                     end
+                   end
             else
               list.concat(taicpu.op_const_ref(TOpCG2AsmOp[op],
                 TCgSize2OpSize[size],a,ref));
@@ -763,8 +788,7 @@ unit cgcpu;
         l : tasmlabel);
 
         begin
-          if (a = 0) and
-             (cmp_op in [OC_EQ,OC_NE]) then
+          if (a = 0) then
             list.concat(taicpu.op_reg_reg(A_TEST,regsize(reg),reg,reg))
           else
             list.concat(taicpu.op_const_reg(A_CMP,regsize(reg),a,reg));
@@ -989,9 +1013,22 @@ unit cgcpu;
       var
         op1,op2 : TAsmOp;
       begin
-        get_64bit_ops(op,op1,op2);
-        list.concat(taicpu.op_const_reg(op1,S_L,valuelosrc,reglodst));
-        list.concat(taicpu.op_const_reg(op2,S_L,valuehisrc,reghidst));
+        case op of
+          OP_AND,OP_OR,OP_XOR:
+            begin
+              a_op_const_reg(list,op,valuelosrc,reglodst);
+              a_op_const_reg(list,op,valuehisrc,reghidst);
+            end;
+          OP_ADD, OP_SUB:
+            begin
+              // can't use a_op_const_ref because this may use dec/inc
+              get_64bit_ops(op,op1,op2);
+              list.concat(taicpu.op_const_reg(op1,S_L,valuelosrc,reglodst));
+              list.concat(taicpu.op_const_reg(op2,S_L,valuehisrc,reghidst));
+            end;
+          else
+            internalerror(200204021);
+        end;
       end;
 
 
@@ -1000,11 +1037,26 @@ unit cgcpu;
         op1,op2 : TAsmOp;
         tempref : treference;
       begin
-        get_64bit_ops(op,op1,op2);
-        list.concat(taicpu.op_const_ref(op1,S_L,valuelosrc,ref));
-        tempref:=ref;
-        inc(tempref.offset,4);
-        list.concat(taicpu.op_const_ref(op2,S_L,valuehisrc,tempref));
+        case op of
+          OP_AND,OP_OR,OP_XOR:
+            begin
+              a_op_const_ref(list,op,OS_32,valuelosrc,ref);
+              tempref:=ref;
+              inc(tempref.offset,4);
+              a_op_const_ref(list,op,OS_32,valuehisrc,tempref);
+            end;
+          OP_ADD, OP_SUB:
+            begin
+              get_64bit_ops(op,op1,op2);
+              // can't use a_op_const_ref because this may use dec/inc
+              list.concat(taicpu.op_const_ref(op1,S_L,valuelosrc,ref));
+              tempref:=ref;
+              inc(tempref.offset,4);
+              list.concat(taicpu.op_const_ref(op2,S_L,valuehisrc,tempref));
+            end;
+          else
+            internalerror(200204022);
+        end;
       end;
 
 
@@ -1159,7 +1211,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.9  2002-04-02 17:11:33  peter
+  Revision 1.10  2002-04-02 20:29:02  jonas
+    * optimized the code generated by the a_op_const_* and a_op64_const
+      methods
+
+  Revision 1.9  2002/04/02 17:11:33  peter
     * tlocation,treference update
     * LOC_CONSTANT added for better constant handling
     * secondadd splitted in multiple routines