Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

shuffleVectorIndex

Convert from clang __builtin_shufflevector index to Zig @shuffle index clang requires __builtin_shufflevector index arguments to be integer constants. negative values for this_index indicate "don't care". clang enforces that this_index is less than the total number of vector elements See https://ziglang.org/documentation/master/#shuffle See https://clang.llvm.org/docs/LanguageExtensions.html#langext-builtin-shufflevector

helpers.shuffleVectorIndex
pub fn shuffleVectorIndex(comptime this_index: c_int, comptime source_vector_len: usize) i32

File

Code

pub fn shuffleVectorIndex(comptime this_index: c_int, comptime source_vector_len: usize) i32 {
    const positive_index = std.math.cast(usize, this_index) orelse return undefined;
    if (positive_index < source_vector_len) return @as(i32, @intCast(this_index));
    const b_index = positive_index - source_vector_len;
    return ~@as(i32, @intCast(b_index));
}