| ... | @@ -5864,7 +5864,7 @@ volatile ( | ... | @@ -5864,7 +5864,7 @@ volatile ( |
| 5864 | : [number] "{rax}" (number), | 5864 | : [number] "{rax}" (number), |
| 5865 | [arg1] "{rdi}" (arg1) | 5865 | [arg1] "{rdi}" (arg1) |
| 5866 | // Next is the list of clobbers. These declare a set of registers whose | 5866 | // 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. |
| 5868 | // These do not include output or input registers. The special clobber | 5868 | // These do not include output or input registers. The special clobber |
| 5869 | // value of "memory" means that the assembly writes to arbitrary undeclared | 5869 | // value of "memory" means that the assembly writes to arbitrary undeclared |
| 5870 | // memory locations - not only the memory pointed to by a declared indirect | 5870 | // memory locations - not only the memory pointed to by a declared indirect |
| ... | @@ -5885,7 +5885,7 @@ volatile ( | ... | @@ -5885,7 +5885,7 @@ volatile ( |
| 5885 | </p> | 5885 | </p> |
| 5886 | {#header_open|Output Constraints#} | 5886 | {#header_open|Output Constraints#} |
| 5887 | <p> | 5887 | <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 |
| 5889 | so | 5889 | so |
| 5890 | <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> | 5890 | <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> |
| 5891 | and | 5891 | and |
| ... | @@ -5900,7 +5900,7 @@ volatile ( | ... | @@ -5900,7 +5900,7 @@ volatile ( |
| 5900 | | 5900 | |
| 5901 | {#header_open|Input Constraints#} | 5901 | {#header_open|Input Constraints#} |
| 5902 | <p> | 5902 | <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 |
| 5904 | so | 5904 | so |
| 5905 | <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> | 5905 | <a href="http://releases.llvm.org/8.0.0/docs/LangRef.html#inline-asm-constraint-string">LLVM documentation</a> |
| 5906 | and | 5906 | and |
| ... | @@ -5919,7 +5919,7 @@ volatile ( | ... | @@ -5919,7 +5919,7 @@ volatile ( |
| 5919 | the assembly code. These do not include output or input registers. The special clobber | 5919 | the assembly code. These do not include output or input registers. The special clobber |
| 5920 | value of {#syntax#}"memory"{#endsyntax#} means that the assembly causes writes to | 5920 | value of {#syntax#}"memory"{#endsyntax#} means that the assembly causes writes to |
| 5921 | arbitrary undeclared memory locations - not only the memory pointed to by a declared | 5921 | arbitrary undeclared memory locations - not only the memory pointed to by a declared |
| 5922 | indirect output. | 5922 | indirect output. |
| 5923 | </p> | 5923 | </p> |
| 5924 | <p> | 5924 | <p> |
| 5925 | Failure to declare the full set of clobbers for a given inline assembly | 5925 | Failure to declare the full set of clobbers for a given inline assembly |
| ... | @@ -7746,6 +7746,30 @@ test "@setRuntimeSafety" { | ... | @@ -7746,6 +7746,30 @@ test "@setRuntimeSafety" { |
| 7746 | </p> | 7746 | </p> |
| 7747 | {#header_close#} | 7747 | {#header_close#} |
| 7748 | | 7748 | |
| | 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#} |
| | 7756 | const std = @import("std"); |
| | 7757 | const assert = std.debug.assert; |
| | 7758 | |
| | 7759 | test "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 | |
| 7749 | {#header_open|@sqrt#} | 7773 | {#header_open|@sqrt#} |
| 7750 | <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre> | 7774 | <pre>{#syntax#}@sqrt(comptime T: type, value: T) T{#endsyntax#}</pre> |
| 7751 | <p> | 7775 | <p> |
| ... | @@ -9456,8 +9480,8 @@ const c = @cImport({ | ... | @@ -9456,8 +9480,8 @@ const c = @cImport({ |
| 9456 | <li>Does not support Zig-only pointer attributes such as alignment. Use normal {#link|Pointers#} | 9480 | <li>Does not support Zig-only pointer attributes such as alignment. Use normal {#link|Pointers#} |
| 9457 | please!</li> | 9481 | please!</li> |
| 9458 | </ul> | 9482 | </ul> |
| 9459 | <p>When a C pointer is pointing to a single struct (not an array), deference the C pointer to | 9483 | <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 | 9484 | access to the struct's fields or member data. That syntax looks like |
| 9461 | this: </p> | 9485 | this: </p> |
| 9462 | <p>{#syntax#}ptr_to_struct.*.struct_member{#endsyntax#}</p> | 9486 | <p>{#syntax#}ptr_to_struct.*.struct_member{#endsyntax#}</p> |
| 9463 | <p>This is comparable to doing {#syntax#}->{#endsyntax#} in C.</p> | 9487 | <p>This is comparable to doing {#syntax#}->{#endsyntax#} in C.</p> |