On May 3, 2011, at 3:07 AM, Richard Guenther <richard.guent...@gmail.com> wrote:
>> 
>> There is no possibility for a high-level dispatch at the source level.
>> And if I'd have to design one I would use function overloading, like
>> 
>> float compute_sth (float) __attribute__((version("sse4")))
>> {
>>  ... sse4 code ...
>> }
>> 
>> float compute_sth (float)
>> {
>>  ... fallback ...
>> }
>> 
>> float foo (float f)
>> {
>>  return compute_sth (f);
>> }
>> 
>> and if you not only want to dispatch for target features you could
>> specify a selector function and value in the attribute.  You might
>> notice that the above eventually matches the target attribute
>> directly, just the frontends need to be taught to emit dispatch
>> code whenever overload resolution results in ambiguities involving
>> target attribute differences.
> 
> Which also would allow the frontend to directly call the sse4 variant
> if you compile with -msse4, avoiding the need for any fancy processing.

And to go one step further, if we had this, we could use this to define all 
data manipulation machine built-ins as generic functions, available to all 
compiles as normal c code, so portable code could use them everywhere, and on 
platforms that had instructions for any of them, they could define them as 
normal built-ins.
> 

Reply via email to