From 53b0b4d114b82434e99e88cd7147014c29368d02 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 31 Dec 2009 17:51:27 +0000 Subject: add some asm notes, some more registers back to the clobber list, and memset the fxsave area in FPU::FPU() git-svn-id: svn://localhost/ardour2/branches/3.0@6420 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/fpu.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libs/pbd/fpu.cc') diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc index 0eab7a93cb..12400221cc 100644 --- a/libs/pbd/fpu.cc +++ b/libs/pbd/fpu.cc @@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 600 +#include // for memset #include #include @@ -19,6 +20,12 @@ FPU::FPU () #ifndef ARCH_X86 return; #endif + + /* asm notes: although we explicitly save&restore ebx/rbx (stack pointer), we must tell + gcc that ebx,rbx is clobbered so that it doesn't try to use it as an intermediate + register when storing edx/rdx. gcc 4.3 didn't make this "mistake", but gcc 4.4 + does, at least on x86_64. + */ #ifndef USE_X86_64_ASM asm volatile ( @@ -29,7 +36,7 @@ FPU::FPU () "popl %%ebx\n" : "=r" (cpuflags) : - : "%eax", "%ebx", "%edx" + : "%eax", "%ebx", "%ecx", "%edx" ); #else @@ -42,11 +49,11 @@ FPU::FPU () "popq %%rbx\n" : "=r" (cpuflags) : - : "%rax", "%rbx", "%rdx" + : "%rax", "%rbx", "%rcx", "%rdx" ); #endif /* USE_X86_64_ASM */ - + if (cpuflags & (1<<25)) { _flags = Flags (_flags | (HasSSE|HasFlushToZero)); } @@ -68,6 +75,8 @@ FPU::FPU () error << _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg; } else { + memset (fxbuf, 0, 512); + asm volatile ( "fxsave (%0)" : -- cgit v1.2.3