Bladeren bron

+ CMPXCHG16BSupport

florian 1 jaar geleden
bovenliggende
commit
11f076f0e7
2 gewijzigde bestanden met toevoegingen van 26 en 0 verwijderingen
  1. 9 0
      rtl/x86_64/cpu.pp
  2. 17 0
      tests/test/units/cpu/tcpu1.pp

+ 9 - 0
rtl/x86_64/cpu.pp

@@ -66,6 +66,7 @@ type
     function ADXSupport: boolean;inline;
     function SHASupport: boolean;inline;    
     function FMASupport: boolean;inline;
+    function CMPXCHG16BSupport: boolean;inline;
     function POPCNTSupport: boolean;inline;
     function LZCNTSupport: boolean;inline;
     function SSE3Support: boolean;inline;
@@ -103,6 +104,7 @@ type
       _AVX512VLSupport,
       _AVX512VBMISupport,
       _AVX512VBMI2Support,
+      _CMPXCHG16BSupport,
       _VAESSupport,
       _VCLMULSupport,
       _AVX512VNNISupport,
@@ -272,6 +274,7 @@ type
         is_sse3_cpu:=(cpuid1.ecx and $1)<>0;
 
         _FMASupport:=_AVXSupport and ((cpuid1.ecx and $1000)<>0);
+        _CMPXCHG16BSupport:=(cpuid1.ecx and $2000)<>0;
 
         _LZCNTSupport:=(CPUID($80000001).ecx and $20)<>0;
 
@@ -442,6 +445,12 @@ type
       end;
 
 
+    function CMPXCHG16BSupport: boolean;inline;
+      begin
+        result:=_CMPXCHG16BSupport;
+      end;
+
+
     function POPCNTSupport: boolean;inline;
       begin
         result:=_POPCNTSupport;

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

@@ -3,6 +3,9 @@
 uses
   cpu;
 
+var
+  dummy16b : array[0..15] of byte;
+  
 begin
   write('CMOV support: ');
   if CMOVSupport then
@@ -193,5 +196,19 @@ begin
     end
   else
     writeln('no');
+  write('CMPXCHG16B support: ');
+  if CMPXCHG16BSupport then
+    begin
+      writeln('yes');
+      asm
+{$ifdef FPC_PIC}
+        cmpxchg16b       Dummy16b@GOTPCREL(%rip)
+{$else FPC_PIC}
+        cmpxchg16b       Dummy16b(%rip)
+{$endif FPC_PIC}
+      end;
+    end
+  else
+    writeln('no');
 end.