Browse Source

+ x86: ADXSupport
+ x86: RDSEEDSupport

Florian Klämpfl 3 years ago
parent
commit
4aebfe97a9
3 changed files with 57 additions and 1 deletions
  1. 18 0
      rtl/i386/cpu.pp
  2. 19 1
      rtl/x86_64/cpu.pp
  3. 20 0
      tests/test/units/cpu/tcpu1.pp

+ 18 - 0
rtl/i386/cpu.pp

@@ -43,6 +43,8 @@ unit cpu;
     function AVX512CDSupport: boolean;inline;    
     function AVX512CDSupport: boolean;inline;    
     function AVX512BWSupport: boolean;inline;    
     function AVX512BWSupport: boolean;inline;    
     function AVX512VLSupport: boolean;inline;    
     function AVX512VLSupport: boolean;inline;    
+    function RDSEEDSupport: boolean;inline;
+    function ADXSupport: boolean;inline;
     function SHASupport: boolean;inline;    
     function SHASupport: boolean;inline;    
     function FMASupport: boolean;inline;
     function FMASupport: boolean;inline;
     function POPCNTSupport: boolean;inline;
     function POPCNTSupport: boolean;inline;
@@ -76,6 +78,8 @@ unit cpu;
       _AVX512CDSupport,
       _AVX512CDSupport,
       _AVX512BWSupport,
       _AVX512BWSupport,
       _AVX512VLSupport,
       _AVX512VLSupport,
+      _RDSEEDSupport,
+      _ADXSupport,
       _SHASupport,
       _SHASupport,
       _FMASupport,
       _FMASupport,
       _POPCNTSupport,
       _POPCNTSupport,
@@ -250,6 +254,8 @@ unit cpu;
                   _AVX2Support:=_AVXSupport and ((_ebx and $20)<>0);
                   _AVX2Support:=_AVXSupport and ((_ebx and $20)<>0);
                   _AVX512FSupport:=(_ebx and $10000)<>0;
                   _AVX512FSupport:=(_ebx and $10000)<>0;
                   _AVX512DQSupport:=(_ebx and $20000)<>0;
                   _AVX512DQSupport:=(_ebx and $20000)<>0;
+                  _RDSEEDSupport:=(_ebx and $40000)<>0;
+                  _ADXSupport:=(_ebx and $80000)<>0;
                   _AVX512IFMASupport:=(_ebx and $200000)<>0;
                   _AVX512IFMASupport:=(_ebx and $200000)<>0;
                   _AVX512PFSupport:=(_ebx and $4000000)<>0;
                   _AVX512PFSupport:=(_ebx and $4000000)<>0;
                   _AVX512ERSupport:=(_ebx and $8000000)<>0;
                   _AVX512ERSupport:=(_ebx and $8000000)<>0;
@@ -339,6 +345,18 @@ unit cpu;
       end;
       end;
 
 
 
 
+    function RDSEEDSupport: boolean;inline;
+      begin
+        result:=_RDSEEDSupport;
+      end;
+
+
+    function ADXSupport: boolean;inline;
+      begin
+        result:=_ADXSupport;
+      end;
+
+
      function SHASupport: boolean;inline;    
      function SHASupport: boolean;inline;    
       begin
       begin
         result:=_SHASupport;
         result:=_SHASupport;

+ 19 - 1
rtl/x86_64/cpu.pp

@@ -39,7 +39,9 @@ unit cpu;
     function AVX512ERSupport: boolean;inline;    
     function AVX512ERSupport: boolean;inline;    
     function AVX512CDSupport: boolean;inline;    
     function AVX512CDSupport: boolean;inline;    
     function AVX512BWSupport: boolean;inline;    
     function AVX512BWSupport: boolean;inline;    
-    function AVX512VLSupport: boolean;inline;    
+    function AVX512VLSupport: boolean;inline;
+    function RDSEEDSupport: boolean;inline;
+    function ADXSupport: boolean;inline;
     function SHASupport: boolean;inline;    
     function SHASupport: boolean;inline;    
     function FMASupport: boolean;inline;
     function FMASupport: boolean;inline;
     function POPCNTSupport: boolean;inline;
     function POPCNTSupport: boolean;inline;
@@ -75,6 +77,8 @@ unit cpu;
       _AVX512CDSupport,
       _AVX512CDSupport,
       _AVX512BWSupport,
       _AVX512BWSupport,
       _AVX512VLSupport,
       _AVX512VLSupport,
+      _RDSEEDSupport,
+      _ADXSupport,
       _SHASupport,
       _SHASupport,
       _FMASupport,
       _FMASupport,
       _POPCNTSupport,
       _POPCNTSupport,
@@ -224,6 +228,8 @@ unit cpu;
             _AVX2Support:=_AVXSupport and ((_ebx and $20)<>0);
             _AVX2Support:=_AVXSupport and ((_ebx and $20)<>0);
             _AVX512FSupport:=(_ebx and $10000)<>0;
             _AVX512FSupport:=(_ebx and $10000)<>0;
             _AVX512DQSupport:=(_ebx and $20000)<>0;
             _AVX512DQSupport:=(_ebx and $20000)<>0;
+            _RDSEEDSupport:=(_ebx and $40000)<>0;
+            _ADXSupport:=(_ebx and $80000)<>0;
             _AVX512IFMASupport:=(_ebx and $200000)<>0;
             _AVX512IFMASupport:=(_ebx and $200000)<>0;
             _AVX512PFSupport:=(_ebx and $4000000)<>0;
             _AVX512PFSupport:=(_ebx and $4000000)<>0;
             _AVX512ERSupport:=(_ebx and $8000000)<>0;
             _AVX512ERSupport:=(_ebx and $8000000)<>0;
@@ -310,6 +316,18 @@ unit cpu;
       end;
       end;
 
 
 
 
+    function RDSEEDSupport: boolean;inline;
+      begin
+        result:=_RDSEEDSupport;
+      end;
+
+
+    function ADXSupport: boolean;inline;
+      begin
+        result:=_ADXSupport;
+      end;
+
+
     function SHASupport: boolean;inline;    
     function SHASupport: boolean;inline;    
       begin
       begin
         result:=_SHASupport;
         result:=_SHASupport;

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

@@ -66,5 +66,25 @@ begin
     end
     end
   else
   else
     writeln('no');
     writeln('no');
+  write('ADX support: ');
+  if ADXSupport then
+    begin
+      writeln('yes');
+      asm
+        adcx %eax,%eax
+      end;
+    end
+  else
+    writeln('no');
+  write('RDSEED support: ');
+  if RDSEEDSupport then
+    begin
+      writeln('yes');
+      asm
+        rdseed %eax
+      end;
+    end
+  else
+    writeln('no');
 end.
 end.