Browse Source

+ is_sse3_cpu, put into cpu unit, so x86-64 and i386 can share source code

git-svn-id: trunk@18785 -
florian 14 years ago
parent
commit
88c2c77319
3 changed files with 36 additions and 8 deletions
  1. 26 0
      rtl/i386/cpu.pp
  2. 2 4
      rtl/i386/mmx.pp
  3. 8 4
      rtl/x86_64/cpu.pp

+ 26 - 0
rtl/i386/cpu.pp

@@ -25,6 +25,8 @@ unit cpu;
     { returns the contents of the cr0 register }
     function cr0 : longint;
 
+    var
+      is_sse3_cpu : boolean = false;
 
   implementation
 
@@ -72,4 +74,28 @@ unit cpu;
          floating_point_emulation:=(cr0 and $4)<>0;
       end;
 
+
+{$ASMMODE ATT}
+    function sse3_support : boolean;
+      var
+         _ecx : longint;
+      begin
+         if cpuid_support then
+           begin
+              asm
+                 pushl %ebx
+                 movl $1,%eax
+                 cpuid
+                 movl %ecx,_ecx
+                 popl %ebx
+              end;
+              sse3_support:=(_ecx and $1)<>0;
+           end
+         else
+           { a cpu with without cpuid instruction supports never sse3 }
+           sse3_support:=false;
+      end;
+
+begin
+  is_sse3_cpu:=sse3_support;
 end.

+ 2 - 4
rtl/i386/mmx.pp

@@ -199,10 +199,8 @@ unit mmx;
       end;
 
     function sse2_support : boolean;
-
       var
          _edx : longint;
-
       begin
          if cpuid_support then
            begin
@@ -220,14 +218,14 @@ unit mmx;
            sse2_support:=false;
       end;
 
-    procedure emms;assembler;
 
+    procedure emms;assembler;
       asm
          emms
       end;
 
-    procedure femms;assembler;
 
+    procedure femms;assembler;
       asm
         { femms instruction not supported with older as versions }
         .byte 0x0f, 0x0e

+ 8 - 4
rtl/x86_64/cpu.pp

@@ -22,7 +22,7 @@ unit cpu;
 			           // Unless overridebinutils is defined (for ports usage), use db instead of the instruction
      {$ifndef overridebinutils}
        {$define oldbinutils}
-     {$endif} 
+     {$endif}
   {$endif}
 
     uses
@@ -31,6 +31,9 @@ unit cpu;
     function InterlockedCompareExchange128Support : boolean;inline;
     function AESSupport : boolean;inline;
 
+    var
+      is_sse3_cpu : boolean = false;
+
     function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec;
 
   implementation
@@ -77,7 +80,7 @@ unit cpu;
         movq 8(%r9),%rdx
 
         {$ifdef oldbinutils}
-           .byte 0xF0,0x49,0x0F,0xC7,0x08 
+           .byte 0xF0,0x49,0x0F,0xC7,0x08
         {$else}
         lock cmpxchg16b (%r8)
         {$endif}
@@ -115,6 +118,7 @@ unit cpu;
       end;
     {$endif win64}
 
+
     procedure SetupSupport;
       var
         _ecx : longint;
@@ -127,10 +131,10 @@ unit cpu;
            popq %rbx
         end;
         _InterlockedCompareExchange128Support:=(_ecx and $2000)<>0;
-        _AESSupport:=(_ecx and $2000000)<>0;        
+        _AESSupport:=(_ecx and $2000000)<>0;
+        is_sse3_cpu:=(_ecx and $1)<>0;
       end;
 
-
 begin
   SetupSupport;
 end.