Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

core.builtins

To provide access to features that would be otherwise counterproductive ordifficult to implement, compilers provide an interface consisting of a setof builtins (also called intrinsics) which can be called like normal functions.
This module exposes builtins both common to all D compilers(those provided by the frontend) and specific to the host compiler i.e. thosespecific to either LLVM or GCC (ldc.intrinsics andgcc.builtins are publicly imported, respectively).Host-specific intrinsics cannot be reliably listed here, however listings can be foundat the documentation for the relevant backends, i.e.GCC andLLVM. It should be noted that not allbuiltins listed are necessarily supported by the host compiler, please file a bugif this is the case for your workload.
Use of this module reduces the amount of conditional compilation neededto use a given builtin. For example, to write a target independent functionthat uses prefetching we can write the following:
float usePrefetch(float[] x){// There is only one import statement required rather than two (versioned) importsimport core.builtins;version (GNU)        __builtin_prefetch(x.ptr);version (LDC)/+            For the curious: 0, 3, 1 mean `x` will only be read-from (0), it will be used            very often (3), and it should be fetched to the data-cache (1).        +/        llvm_prefetch(x.ptr, 0, 3, 1);const doMath = blahBlahBlah;return doMath;}
License:
Boost License 1.0
Authors:
Walter Bright

Sourcecore/builtins.d

pure nothrow @nogc @safe void__ctfeWrite(scope const(char)[]s);
Writess tostderr during CTFE (does nothing at runtime).
voidtrap();
Execute target dependent trap instruction, if supported.Otherwise, abort execution.
boollikely()(boolb);

boolunlikely()(boolb);
Provide static branch and value hints for the LDC/GDC compilers.DMD ignores these hints.
Examples:
int x = 12;expect(x, 12);if (likely(x > 0)){// ...}elseif (unlikely(x ==int.min)){// ...}
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 00:53:01 2026

[8]ページ先頭

©2009-2026 Movatter.jp