From 88c2c77319b86b4c9a9352afd879bcb0edfb7a95 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 20 Aug 2011 12:01:48 +0000 Subject: [PATCH] + is_sse3_cpu, put into cpu unit, so x86-64 and i386 can share source code git-svn-id: trunk@18785 - --- rtl/i386/cpu.pp | 26 ++++++++++++++++++++++++++ rtl/i386/mmx.pp | 6 ++---- rtl/x86_64/cpu.pp | 12 ++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/rtl/i386/cpu.pp b/rtl/i386/cpu.pp index 1159e4a3b7..c4775ecd14 100644 --- a/rtl/i386/cpu.pp +++ b/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. diff --git a/rtl/i386/mmx.pp b/rtl/i386/mmx.pp index 305e5bbadd..1a6576f81a 100644 --- a/rtl/i386/mmx.pp +++ b/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 diff --git a/rtl/x86_64/cpu.pp b/rtl/x86_64/cpu.pp index e6f6c5f1fe..1fd3623ce4 100644 --- a/rtl/x86_64/cpu.pp +++ b/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.