DoxigAlpha

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

Function parameters

Parameters

#
this_index:c_int
source_vector_len:usize

Type definitions in this namespace

Types

#

Given a type and value, cast the value to the type as c would.

Functions

#
cast
Given a type and value, cast the value to the type as c would.
sizeof
Given a value returns its size as C's sizeof operator would.
promoteIntLiteral
Promote the type of an integer literal until it fits as C would.
shuffleVectorIndex
Convert from clang __builtin_shufflevector index to Zig @shuffle index
FlexibleArrayType
Constructs a [*c] pointer with the const and volatile annotations
signedRemainder
C `%` operator for signed integers

Source

Implementation

#
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));
}