瀏覽代碼

+ added a new x86-specific compiler option 'enablecld', which controls whether
the compiler should emit a CLD before using the x86 string instructions.

git-svn-id: trunk@25590 -

nickysn 12 年之前
父節點
當前提交
52fcc0a407
共有 5 個文件被更改,包括 23 次插入5 次删除
  1. 13 0
      compiler/globals.pas
  2. 2 1
      compiler/i386/cgcpu.pas
  3. 2 1
      compiler/i8086/cgcpu.pas
  4. 4 0
      compiler/options.pas
  5. 2 3
      compiler/x86/cgx86.pas

+ 13 - 0
compiler/globals.pas

@@ -154,6 +154,12 @@ interface
 
          disabledircache : boolean;
 
+{$if defined(x86)}
+         { setting this to true causes the compiler to emit a CLD instruction
+           before using the x86 string instructions. }
+         enablecld       : boolean;
+{$endif defined(x86)}
+
 {$if defined(i8086)}
          x86memorymodel  : tx86memorymodel;
 {$endif defined(i8086)}
@@ -485,6 +491,13 @@ interface
         minfpconstprec : s32real;
 
         disabledircache : false;
+{$if defined(i8086)}
+        enablecld      : true;
+{$elseif defined(i386)}
+        enablecld      : true;
+{$elseif defined(x86_64)}
+        enablecld      : false;
+{$endif}
 {$if defined(i8086)}
         x86memorymodel : mm_small;
 {$endif defined(i8086)}

+ 2 - 1
compiler/i386/cgcpu.pas

@@ -485,7 +485,8 @@ unit cgcpu;
             else
               list.concat(Taicpu.op_const_reg(A_IMUL,S_L,len,NR_ECX));
           end;
-        list.concat(Taicpu.op_none(A_CLD,S_NO));
+        if current_settings.enablecld then
+          list.concat(Taicpu.op_none(A_CLD,S_NO));
         list.concat(Taicpu.op_none(A_REP,S_NO));
         case opsize of
           S_B : list.concat(Taicpu.Op_none(A_MOVSB,S_NO));

+ 2 - 1
compiler/i8086/cgcpu.pas

@@ -1504,7 +1504,8 @@ unit cgcpu;
             else
               list.concat(Taicpu.op_const_reg(A_IMUL,S_W,len,NR_CX));
           end;
-        list.concat(Taicpu.op_none(A_CLD,S_NO));
+        if current_settings.enablecld then
+          list.concat(Taicpu.op_none(A_CLD,S_NO));
         list.concat(Taicpu.op_none(A_REP,S_NO));
         case opsize of
           S_B : list.concat(Taicpu.Op_none(A_MOVSB,S_NO));

+ 4 - 0
compiler/options.pas

@@ -3475,6 +3475,10 @@ if (target_info.abi = abi_eabihf) then
     mm_huge:    def_system_macro('FPC_MM_HUGE');
   end;
 {$endif}
+{$if defined(x86)}
+  if current_settings.enablecld then
+    def_system_macro('FPC_ENABLED_CLD');
+{$endif}
 
 
   { Section smartlinking conflicts with import sections on Windows }

+ 2 - 3
compiler/x86/cgx86.pas

@@ -2233,9 +2233,8 @@ unit cgx86;
               end;
 
             getcpuregister(list,REGCX);
-{$if defined(i8086) or defined(i386)}
-           list.concat(Taicpu.op_none(A_CLD,S_NO));
-{$endif i8086 or i386}
+            if current_settings.enablecld then
+              list.concat(Taicpu.op_none(A_CLD,S_NO));
             if (cs_opt_size in current_settings.optimizerswitches) and
                (len>sizeof(aint)+(sizeof(aint) div 2)) then
               begin