Function shuffleVectorIndex [src]
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
Prototype
pub fn shuffleVectorIndex(comptime this_index: c_int, comptime source_vector_len: usize) i32
Parameters
this_index: c_int
source_vector_len: usize
Source
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));
}