This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
i386 floating point asm in mathinline.h (gcc related)
- To: "GNU C. library Alpha Tester List" <libc-alpha at sourceware dot cygnus dot com>
- Subject: i386 floating point asm in mathinline.h (gcc related)
- From: Andreas Jaeger <aj at suse dot de>
- Date: 19 Oct 1999 16:29:47 +0200
- Cc: Tim Prince <tprince at computer dot org>
Hi,
I need a wee bit of help with understanding floating point asm in
mathinline.h. It might be that glibc has wrong asms - but I don't
know enough to give a definite answer.
Currently we use e.g.
__inline_mathop (log, "fldln2; fxch; fyl2x")
which expands to (I simplified a little bit):
inline double log (double __x)
{
register double __result;
__asm __volatile__ ("fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x))
return __result;
}
We push two elements on the fp stack without telling gcc about it.
What happens if we get a stack overflow? Does the above asm really
handle this problem?
An alternative solution is to use two asm statements and specify
explicitly how we change the stack:
inline double log (double __x)
{
register double __result;
register long double __value;
__asm ("fldln2": "=t" (__value));
__asm ("fyl2x" : "=t" (__value) : "0" (__x), "u" (__value) : "st(1)" );
return __result;
}
I do think [1] that the above is correct - but is it as efficient as
possible?
This has been brought to my attention by Tim Prince
<tprince@computer.org>. The code is from a patch he send me which I'm
currently looking at.
Andreas
Footnotes:
[1] My knowledge of i386 asm in gcc is not good - please double check
everything I say before you believe me ;-)
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.rhein-neckar.de