From 11f076f0e7b29bc71e6ff5866a954315098d9142 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 28 Feb 2024 22:18:05 +0100 Subject: [PATCH] + CMPXCHG16BSupport --- rtl/x86_64/cpu.pp | 9 +++++++++ tests/test/units/cpu/tcpu1.pp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/rtl/x86_64/cpu.pp b/rtl/x86_64/cpu.pp index 8d35af8612..b4fd5e554d 100644 --- a/rtl/x86_64/cpu.pp +++ b/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; diff --git a/tests/test/units/cpu/tcpu1.pp b/tests/test/units/cpu/tcpu1.pp index d13d332062..914a6c124e 100644 --- a/tests/test/units/cpu/tcpu1.pp +++ b/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.