+ CPU units: check for SHA support

This commit is contained in:
florian 2021-10-09 16:23:11 +02:00
parent 6c7e6191f6
commit bff09e8e9e
3 changed files with 30 additions and 2 deletions
rtl
i386
x86_64
tests/test/units/cpu

View File

@ -43,6 +43,7 @@ unit cpu;
function AVX512CDSupport: boolean;inline;
function AVX512BWSupport: boolean;inline;
function AVX512VLSupport: boolean;inline;
function SHASupport: boolean;inline;
function FMASupport: boolean;inline;
function POPCNTSupport: boolean;inline;
function SSE41Support: boolean;inline;
@ -63,6 +64,7 @@ unit cpu;
{$ASMMODE INTEL}
var
_AESSupport,
_AVXSupport,
_AVX2Support,
_AVX512FSupport,
@ -73,7 +75,7 @@ unit cpu;
_AVX512CDSupport,
_AVX512BWSupport,
_AVX512VLSupport,
_AESSupport,
_SHASupport,
_FMASupport,
_POPCNTSupport,
_SSE41Support,
@ -240,6 +242,7 @@ unit cpu;
_AVX512ERSupport:=(_ebx and $8000000)<>0;
_AVX512CDSupport:=(_ebx and $10000000)<>0;
_AVX512BWSupport:=(_ebx and $40000000)<>0;
_SHASupport:=(_ebx and $20000000)<>0;
_AVX512VLSupport:=(_ebx and $80000000)<>0;
_BMI1Support:=(_ebx and $8)<>0;
_BMI2Support:=(_ebx and $100)<>0;
@ -323,7 +326,13 @@ unit cpu;
end;
function FMASupport: boolean;inline;
function SHASupport: boolean;inline;
begin
result:=_SHASupport;
end;
function FMASupport: boolean;inline;
begin
result:=_FMASupport;
end;

View File

@ -40,6 +40,7 @@ unit cpu;
function AVX512CDSupport: boolean;inline;
function AVX512BWSupport: boolean;inline;
function AVX512VLSupport: boolean;inline;
function SHASupport: boolean;inline;
function FMASupport: boolean;inline;
function POPCNTSupport: boolean;inline;
function SSE41Support: boolean;inline;
@ -73,6 +74,7 @@ unit cpu;
_AVX512CDSupport,
_AVX512BWSupport,
_AVX512VLSupport,
_SHASupport,
_FMASupport,
_POPCNTSupport,
_SSE41Support,
@ -215,6 +217,7 @@ unit cpu;
_AVX512PFSupport:=(_ebx and $4000000)<>0;
_AVX512ERSupport:=(_ebx and $8000000)<>0;
_AVX512CDSupport:=(_ebx and $10000000)<>0;
_SHASupport:=(_ebx and $20000000)<>0;
_AVX512BWSupport:=(_ebx and $40000000)<>0;
_AVX512VLSupport:=(_ebx and $80000000)<>0;
_BMI1Support:=(_ebx and $8)<>0;
@ -296,6 +299,12 @@ unit cpu;
end;
function SHASupport: boolean;inline;
begin
result:=_SHASupport;
end;
function FMASupport: boolean;inline;
begin
result:=_FMASupport;

View File

@ -35,5 +35,15 @@ begin
end
else
writeln('no');
write('SHA support: ');
if SHASupport then
begin
writeln('yes');
asm
sha256rnds2 %xmm0,%xmm0
end;
end
else
writeln('no');
end.