1/**********************************************
2To provide access to features that would be otherwise counterproductive or
3difficult to implement, compilers provide an interface consisting of a set
4of builtins (also called intrinsics) which can be called like normal functions.
5
6This module exposes builtins both common to all D compilers
7(those provided by the frontend) and specific to the host compiler i.e. those
8specific to either LLVM or GCC (`ldc.intrinsics` and `gcc.builtins` are publicly imported, respectively).
9Host-specific intrinsics cannot be reliably listed here, however listings can be found
10at the documentation for the relevant backends, i.e.
11$(LINK2 https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html, GCC) and
12$(LINK2 https://llvm.org/docs/LangRef.html, LLVM). It should be noted that not all
13builtins listed are necessarily supported by the host compiler, please file a bug
14if this is the case for your workload.
15
16Use of this module reduces the amount of conditional compilation needed
17to use a given builtin. For example, to write a target independent function
18that uses prefetching we can write the following:
19---
20float usePrefetch(float[] x)
21{
22    // There is only one import statement required rather than two (versioned) imports
23    import core.builtins;
24    version (GNU)
25        __builtin_prefetch(x.ptr);
26    version (LDC)
27        /+
28            For the curious: 0, 3, 1 mean `x` will only be read-from (0), it will be used
29            very often (3), and it should be fetched to the data-cache (1).
30        +/
31        llvm_prefetch(x.ptr, 0, 3, 1);
32    const doMath = blahBlahBlah;
33    return doMath;
34}
35---
36
37
38Copyright: Copyright �� 2021, The D Language Foundation
39License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
40Authors:   Walter Bright
41Source:    $(DRUNTIMESRC core/builtins.d)
42*/
43
44module core.builtins;
45
46version (GNU)
47    public import gcc.builtins;
48
49version (LDC)
50    public import ldc.intrinsics;
51
52/// Writes `s` to `stderr` during CTFE (does nothing at runtime).
53void __ctfeWrite(scope const(char)[] s) @nogc @safe pure nothrow {}
54