September 11, 2017
On Monday, 11 September 2017 at 11:55:45 UTC, Igor wrote:
>
> In the meantime can anyone tell me how to add an attribute to a function only if something is defined, since this doesn't work:
>
> version(USE_SIMD_WITH_LDC) {
>   import ldc.attributes;
>   @target("ssse3")
> } void funcThatUsesSIMD() {
>   ...
>   version(LDC) {
>     import ldc.gccbuiltins_x86;
>     c = __builtin_ia32_pshufb128(c, *simdMasks);
>   } else {
>     c = __simd(XMM.PSHUFB, c, *simdMasks);
>   }
>   ...
> }

Regarding the crash in debug mode the problem was that my masks variable wasn't properly aligned and I guess the best I can do with the attribute is this:

version(LDC) import ldc.attributes;
else private struct target { string specifier; }
@target("ssse3")
void funcThatUsesSIMD() {...}
1 2
Next ›   Last »