Browse Source

* CPUs not having CMOV apparently do not support the newly introduced Multibyte NOPs (Agner, Optimizing subroutines in assembly
language, An optimization guide for x86 platforms, Page 87), so restored the 32 Bit part of the old alignment
bytes for use on those old CPUs and use it depending on the CPU switches

git-svn-id: trunk@29777 -

florian 10 years ago
parent
commit
5946328ed6
1 changed files with 26 additions and 7 deletions
  1. 26 7
      compiler/x86/aasmcpu.pas

+ 26 - 7
compiler/x86/aasmcpu.pas

@@ -639,7 +639,7 @@ implementation
           Intel 64 and IA-32 Architectures Software Developer’s Manual
           Intel 64 and IA-32 Architectures Software Developer’s Manual
             Volume 2B: Instruction Set Reference, N-Z, January 2015
             Volume 2B: Instruction Set Reference, N-Z, January 2015
         }
         }
-        alignarray:array[0..10] of string[11]=(
+        alignarray_cmovcpus:array[0..10] of string[11]=(
           #$66#$66#$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
           #$66#$66#$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
           #$66#$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
           #$66#$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
           #$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
           #$66#$0F#$1F#$84#$00#$00#$00#$00#$00,
@@ -651,6 +651,13 @@ implementation
           #$0F#$1F#$00,
           #$0F#$1F#$00,
           #$66#$90,
           #$66#$90,
           #$90);
           #$90);
+        alignarray:array[0..5] of string[8]=(
+          #$8D#$B4#$26#$00#$00#$00#$00,
+          #$8D#$B6#$00#$00#$00#$00,
+          #$8D#$74#$26#$00,
+          #$8D#$76#$00,
+          #$89#$F6,
+          #$90);
       var
       var
         bufptr : pchar;
         bufptr : pchar;
         j : longint;
         j : longint;
@@ -665,12 +672,24 @@ implementation
            localsize:=fillsize;
            localsize:=fillsize;
            while (localsize>0) do
            while (localsize>0) do
             begin
             begin
-              for j:=low(alignarray) to high(alignarray) do
-               if (localsize>=length(alignarray[j])) then
-                break;
-              move(alignarray[j][1],bufptr^,length(alignarray[j]));
-              inc(bufptr,length(alignarray[j]));
-              dec(localsize,length(alignarray[j]));
+              if CPUX86_HAS_CMOV in cpu_capabilities[current_settings.cputype] then
+                begin
+                  for j:=low(alignarray_cmovcpus) to high(alignarray_cmovcpus) do
+                   if (localsize>=length(alignarray_cmovcpus[j])) then
+                    break;
+                  move(alignarray_cmovcpus[j][1],bufptr^,length(alignarray_cmovcpus[j]));
+                  inc(bufptr,length(alignarray_cmovcpus[j]));
+                  dec(localsize,length(alignarray_cmovcpus[j]));
+                end
+              else
+                begin
+                  for j:=low(alignarray) to high(alignarray) do
+                   if (localsize>=length(alignarray[j])) then
+                    break;
+                  move(alignarray[j][1],bufptr^,length(alignarray[j]));
+                  inc(bufptr,length(alignarray[j]));
+                  dec(localsize,length(alignarray[j]));
+                end
             end;
             end;
          end;
          end;
         calculatefillbuf:=pchar(@buf);
         calculatefillbuf:=pchar(@buf);