diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-09-19 11:14:42 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-19 11:14:42 -0400 |
| commit | 28c7fe60b6de6e3c32e082a0abfb5a7bac8fc45a (patch) | |
| tree | b03cf7256bc6c77b79bffecbe83cd384b5e9db91 | |
| parent | 005a54a853a77b9c28551490fc08dc37cd7d7715 (diff) | |
| download | zig-28c7fe60b6de6e3c32e082a0abfb5a7bac8fc45a.tar.gz zig-28c7fe60b6de6e3c32e082a0abfb5a7bac8fc45a.zip | |
add docs for `@splat`
| -rw-r--r-- | doc/langref.html.in | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index 61fc06fd02..1158135dab 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -5864,7 +5864,7 @@ volatile ( : [number] "{rax}" (number), [arg1] "{rdi}" (arg1) // Next is the list of clobbers. These declare a set of registers whose -// values will not be preserved by the execution of this assembly code. +// values will not be preserved by the execution of this assembly code. // These do not include output or input registers. The special clobber // value of "memory" means that the assembly writes to arbitrary undeclared // memory locations - not only the memory pointed to by a declared indirect @@ -5885,7 +5885,7 @@ volatile ( </p> {#header_open|Output Constraints#} <p> - Output constraints are still considered to be unstable in Zig, and + Output constraints are still considered to be unstable in Zig, and so <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> and @@ -5900,7 +5900,7 @@ volatile ( {#header_open|Input Constraints#} <p> - Input constraints are still considered to be unstable in Zig, and + Input constraints are still considered to be unstable in Zig, and so <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> and @@ -5919,7 +5919,7 @@ volatile ( the assembly code. These do not include output or input registers. The special clobber value of {#syntax#}"memory"{#endsyntax#} means that the assembly causes writes to arbitrary undeclared memory locations - not only the memory pointed to by a declared - indirect output. + indirect output. </p> <p> Failure to declare the full set of clobbers for a given inline assembly @@ -7746,6 +7746,30 @@ test "@setRuntimeSafety" { </p> {#header_close#} + {#header_open|@splat#} + <pre>{#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @typeOf(scalar)){#endsyntax#}</pre> + <p> + Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value + {#syntax#}scalar{#endsyntax#}: + </p> + {#code_begin|test#} +const std = @import("std"); +const assert = std.debug.assert; + +test "vector @splat" { + const scalar: u32 = 5; + const result = @splat(4, scalar); + comptime assert(@typeOf(result) == @Vector(4, u32)); + assert(std.mem.eql(u32, ([4]u32)(result), [_]u32{ 5, 5, 5, 5 })); +} + {#code_end#} + <p> + {#syntax#}scalar{#endsyntax#} must be an {#link|integer|Integers#}, {#link|bool|Primitive Types#}, + {#link|float|Floats#}, or {#link|pointer|Pointers#}. + </p> + {#see_also|Vectors|@shuffle#} + {#header_close#} + {#header_open|@sqrt#} <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre> <p> @@ -9456,8 +9480,8 @@ const c = @cImport({ <li>Does not support Zig-only pointer attributes such as alignment. Use normal {#link|Pointers#} please!</li> </ul> - <p>When a C pointer is pointing to a single struct (not an array), deference the C pointer to - access to the struct's fields or member data. That syntax looks like + <p>When a C pointer is pointing to a single struct (not an array), deference the C pointer to + access to the struct's fields or member data. That syntax looks like this: </p> <p>{#syntax#}ptr_to_struct.*.struct_member{#endsyntax#}</p> <p>This is comparable to doing {#syntax#}->{#endsyntax#} in C.</p> |
