Query Builtins (The GNU D Compiler)

#### 2.2.2 Querying Available Built-ins ¶

Not all of the functions are supported, and some target-specific functions may only be available when compiling for a particular ISA. One way of finding out what is exposed by the built-ins module is by generating a D interface file. Assuming you have no file `builtins.d`, the command

      echo "module gcc.builtins;" > builtins.d; gdc -H -fsyntax-only builtins.d

will save all built-in declarations to the file `builtins.di`.

Another way to determine whether a specific built-in is available is by using compile-time reflection.

    enum X86_HAVE_SSE3 = __traits(compiles, __builtin_ia32_haddps);
    enum X86_HAVE_SSSE3 = __traits(compiles, __builtin_ia32_pmulhrsw128);
    enum X86_HAVE_SSE41 = __traits(compiles, __builtin_ia32_dpps);
    enum X86_HAVE_SSE42 = __traits(compiles, __builtin_ia32_pcmpgtq);
    enum X86_HAVE_AVX = __traits(compiles, __builtin_ia32_vbroadcastf128_pd256);
    enum X86_HAVE_AVX2 = __traits(compiles, __builtin_ia32_gathersiv2df);
    enum X86_HAVE_BMI2 = __traits(compiles, __builtin_ia32_pext_si);