Changing "target" parameter via attribute
Manu
turkeyman at gmail.com
Mon May 27 01:15:35 PDT 2013
So we talked about this at DConf.
Working on std.simd, I need to be able to change the target parameter on a
per-function basis.
GCC supports this via: __attribute__((target("sse2"))) for instance.
I need the ability to set this from D, but the trick is, I need to be able
to set the target string according to a template arg.
Eg:
enum Targets { SSE2, SSE3 };
enum targets[] = [ "sse2", "sse3" ];
@attribute("target", targets[T]) // <- attribute needs to refer to the
template arg T
void func(Targets T)();
{
// this way, it is possibly to produce dynamic selection of code paths
optimised for different CPU features (a task which is usually very tedious
in C/C++)
func!(Targets.SSE2)();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20130527/63bb46be/attachment.html>
More information about the D.gnu
mailing list