authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-19 11:14:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-19 11:14:42-04:00
log28c7fe60b6de6e3c32e082a0abfb5a7bac8fc45a
treeb03cf7256bc6c77b79bffecbe83cd384b5e9db91
parent005a54a853a77b9c28551490fc08dc37cd7d7715
signaturelock-open Commit is signed but in an unrecognized format.

add docs for `@splat`


1 files changed, 30 insertions(+), 6 deletions(-)

doc/langref.html.in+30-6
......@@ -5864,7 +5864,7 @@ volatile (
58645864 : [number] "{rax}" (number),
58655865 [arg1] "{rdi}" (arg1)
58665866// Next is the list of clobbers. These declare a set of registers whose
5867// values will not be preserved by the execution of this assembly code.
5867// values will not be preserved by the execution of this assembly code.
58685868// These do not include output or input registers. The special clobber
58695869// value of "memory" means that the assembly writes to arbitrary undeclared
58705870// memory locations - not only the memory pointed to by a declared indirect
......@@ -5885,7 +5885,7 @@ volatile (
58855885 </p>
58865886 {#header_open|Output Constraints#}
58875887 <p>
5888 Output constraints are still considered to be unstable in Zig, and
5888 Output constraints are still considered to be unstable in Zig, and
58895889 so
58905890 <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a>
58915891 and
......@@ -5900,7 +5900,7 @@ volatile (
59005900
59015901 {#header_open|Input Constraints#}
59025902 <p>
5903 Input constraints are still considered to be unstable in Zig, and
5903 Input constraints are still considered to be unstable in Zig, and
59045904 so
59055905 <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a>
59065906 and
......@@ -5919,7 +5919,7 @@ volatile (
59195919 the assembly code. These do not include output or input registers. The special clobber
59205920 value of {#syntax#}"memory"{#endsyntax#} means that the assembly causes writes to
59215921 arbitrary undeclared memory locations - not only the memory pointed to by a declared
5922 indirect output.
5922 indirect output.
59235923 </p>
59245924 <p>
59255925 Failure to declare the full set of clobbers for a given inline assembly
......@@ -7746,6 +7746,30 @@ test "@setRuntimeSafety" {
77467746 </p>
77477747 {#header_close#}
77487748
7749 {#header_open|@splat#}
7750 <pre>{#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @typeOf(scalar)){#endsyntax#}</pre>
7751 <p>
7752 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
7753 {#syntax#}scalar{#endsyntax#}:
7754 </p>
7755 {#code_begin|test#}
7756const std = @import("std");
7757const assert = std.debug.assert;
7758
7759test "vector @splat" {
7760 const scalar: u32 = 5;
7761 const result = @splat(4, scalar);
7762 comptime assert(@typeOf(result) == @Vector(4, u32));
7763 assert(std.mem.eql(u32, ([4]u32)(result), [_]u32{ 5, 5, 5, 5 }));
7764}
7765 {#code_end#}
7766 <p>
7767 {#syntax#}scalar{#endsyntax#} must be an {#link|integer|Integers#}, {#link|bool|Primitive Types#},
7768 {#link|float|Floats#}, or {#link|pointer|Pointers#}.
7769 </p>
7770 {#see_also|Vectors|@shuffle#}
7771 {#header_close#}
7772
77497773 {#header_open|@sqrt#}
77507774 <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre>
77517775 <p>
......@@ -9456,8 +9480,8 @@ const c = @cImport({
94569480 <li>Does not support Zig-only pointer attributes such as alignment. Use normal {#link|Pointers#}
94579481 please!</li>
94589482 </ul>
9459 <p>When a C pointer is pointing to a single struct (not an array), deference the C pointer to
9460 access to the struct's fields or member data. That syntax looks like
9483 <p>When a C pointer is pointing to a single struct (not an array), deference the C pointer to
9484 access to the struct's fields or member data. That syntax looks like
94619485 this: </p>
94629486 <p>{#syntax#}ptr_to_struct.*.struct_member{#endsyntax#}</p>
94639487 <p>This is comparable to doing {#syntax#}->{#endsyntax#} in C.</p>