On Thu, 6 Jul 2006 12:52:29 +0200 "Diego 'Flameeyes' Pettenò" <[EMAIL PROTECTED]> wrote:
> So, I've been drafting this up in my blog[1], and it is a simple way
> to replace the CPU feature useflags.
>[...]
To paraphrase the idea - use the compiler's knowledge of the target
processor to select cpu-specific code.
I like the idea a lot. To my mind, the sse/sse2/3dnow etc should be
derived from the target arch, which is what you're doing with the
compiler's macro definitions. This could easily be done by configure
scripts; perhaps it would be a good idea to look into writing some
autoconf macros.
re. hardened - all we ever need, is to be able to force a package to
fall back to it's portable C implementation when the asm code breaks
PIC (which is independent of whether it uses mmx, sse etc) or
generates code at runtime. I think most packages provide this, as it's
useful to the developer to compare the C implementation with
accelerated asm versions easily.
re. Donnie's point about non-gcc compilers - handling these can be
hidden in the has_cpuset() function. They can always be determined
from the target arch (combination of ARCH and -march or equivalent
CFLAGS). The suggested code already does the worst-case fall-back, as
it responds 'no' if the compiler doesn't support -dM or doesn't define
the relevant macro.
echo | $(tc-getCC) ${CFLAGS} -dM -E - 2>/dev/null | grep -q ${def} ||
hasfeat="no"
The '2>/dev/null' is the critical element for that.
--
Kevin F. Quinn
signature.asc
Description: PGP signature
