Browse Source

+ CMOVSupport function

florian 2 years ago
parent
commit
12aa48602b
3 changed files with 32 additions and 0 deletions
  1. 10 0
      rtl/i386/cpu.pp
  2. 7 0
      rtl/x86_64/cpu.pp
  3. 15 0
      tests/test/units/cpu/tcpu1.pp

+ 10 - 0
rtl/i386/cpu.pp

@@ -31,6 +31,7 @@ unit cpu;
     { returns the contents of the cr0 register }
     { returns the contents of the cr0 register }
     function cr0 : longint;
     function cr0 : longint;
 
 
+    function CMOVSupport : boolean;inline;
     function InterlockedCompareExchange128Support : boolean;
     function InterlockedCompareExchange128Support : boolean;
     function AESSupport : boolean;inline;
     function AESSupport : boolean;inline;
     function AVXSupport: boolean;inline;
     function AVXSupport: boolean;inline;
@@ -73,6 +74,7 @@ unit cpu;
 
 
 {$ASMMODE INTEL}
 {$ASMMODE INTEL}
     var
     var
+      _CMOVSupport,
       _AESSupport,
       _AESSupport,
       _AVXSupport,
       _AVXSupport,
       _AVX2Support,
       _AVX2Support,
@@ -219,9 +221,11 @@ unit cpu;
                  pushl %ebx
                  pushl %ebx
                  movl $1,%eax
                  movl $1,%eax
                  cpuid
                  cpuid
+                 movl %edx,_edx
                  movl %ecx,_ecx
                  movl %ecx,_ecx
                  popl %ebx
                  popl %ebx
               end;
               end;
+              _CMOVSupport:=(_edx and $8000)<>0;
               _AESSupport:=(_ecx and $2000000)<>0;
               _AESSupport:=(_ecx and $2000000)<>0;
               _POPCNTSupport:=(_ecx and $800000)<>0;
               _POPCNTSupport:=(_ecx and $800000)<>0;
               _SSE41Support:=(_ecx and $80000)<>0;
               _SSE41Support:=(_ecx and $80000)<>0;
@@ -299,6 +303,12 @@ unit cpu;
       end;
       end;
 
 
 
 
+    function CMOVSupport : boolean;
+      begin
+        result:=_CMOVSupport;
+      end;
+
+
     function AESSupport : boolean;
     function AESSupport : boolean;
       begin
       begin
         result:=_AESSupport;
         result:=_AESSupport;

+ 7 - 0
rtl/x86_64/cpu.pp

@@ -29,6 +29,7 @@ unit cpu;
       sysutils;
       sysutils;
 
 
     function InterlockedCompareExchange128Support : boolean;inline;
     function InterlockedCompareExchange128Support : boolean;inline;
+    function CMOVSupport : boolean;inline;
     function AESSupport : boolean;inline;
     function AESSupport : boolean;inline;
     function AVXSupport : boolean;inline;
     function AVXSupport : boolean;inline;
     function AVX2Support: boolean;inline;
     function AVX2Support: boolean;inline;
@@ -270,6 +271,12 @@ unit cpu;
       end;
       end;
 
 
 
 
+    function CMOVSupport : boolean;
+      begin
+        result:=true;
+      end;
+
+
     function AESSupport : boolean;inline;
     function AESSupport : boolean;inline;
       begin
       begin
         result:=_AESSupport;
         result:=_AESSupport;

+ 15 - 0
tests/test/units/cpu/tcpu1.pp

@@ -4,6 +4,21 @@ uses
   cpu;
   cpu;
 
 
 begin
 begin
+  write('CMOV support: ');
+  if CMOVSupport then
+    begin
+      writeln('yes');
+      asm
+        cmov %eax,%eax
+        fldz
+        fldz
+        fcmovb %st(1)
+        fstpl %st(0)
+        fstpl %st(0)
+      end;
+    end
+  else
+    writeln('no');
   write('AES support: ');
   write('AES support: ');
   if AESSupport then
   if AESSupport then
     begin
     begin