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