@@ -8674,6 +8674,50 @@ test "@wasmMemoryGrow" {
8674
8674
{#see_also|@ctz|@clz#}
8675
8675
{#header_close#}
8676
8676
8677
+ {#header_open|@prefetch#}
8678
+ <pre>{#syntax#}@prefetch(ptr: anytype, comptime options: std.builtin.PrefetchOptions){#endsyntax#}</pre>
8679
+ <p>
8680
+ This builtin tells the compiler to emit a prefetch instruction if supported by the
8681
+ target CPU. If the target CPU does not support the requested prefetch instruction,
8682
+ this builtin is a noop. This function has no effect on the behavior of the program,
8683
+ only on the performance characteristics.
8684
+ </p>
8685
+ <p>
8686
+ The {#syntax#}ptr{#endsyntax#} argument may be any pointer type and determines the memory
8687
+ address to prefetch. This function does not dereference the pointer, it is perfectly legal
8688
+ to pass a pointer to invalid memory to this function and no illegal behavior will result.
8689
+ </p>
8690
+ <p>
8691
+ The {#syntax#}options{#endsyntax#} argument is the following struct:
8692
+ </p>
8693
+ {#code_begin|syntax|builtin#}
8694
+ /// This data structure is used by the Zig language code generation and
8695
+ /// therefore must be kept in sync with the compiler implementation.
8696
+ pub const PrefetchOptions = struct {
8697
+ /// Whether the prefetch should prepare for a read or a write.
8698
+ rw: Rw = .read,
8699
+ /// 0 means no temporal locality. That is, the data can be immediately
8700
+ /// dropped from the cache after it is accessed.
8701
+ ///
8702
+ /// 3 means high temporal locality. That is, the data should be kept in
8703
+ /// the cache as it is likely to be accessed again soon.
8704
+ locality: u2 = 3,
8705
+ /// The cache that the prefetch should be preformed on.
8706
+ cache: Cache = .data,
8707
+
8708
+ pub const Rw = enum {
8709
+ read,
8710
+ write,
8711
+ };
8712
+
8713
+ pub const Cache = enum {
8714
+ instruction,
8715
+ data,
8716
+ };
8717
+ };
8718
+ {#code_end#}
8719
+ {#header_close#}
8720
+
8677
8721
{#header_open|@ptrCast#}
8678
8722
<pre>{#syntax#}@ptrCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
8679
8723
<p>
0 commit comments