Add simd_reverse

This commit is contained in:
gingerBill
2022-05-26 11:14:22 +01:00
parent 0fd43c1a0b
commit 7ec0236fbf
6 changed files with 39 additions and 0 deletions
+16
View File
@@ -1338,6 +1338,22 @@ lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAndValue const
return res;
}
case BuiltinProc_simd_reverse:
{
i64 count = get_array_type_count(arg0.type);
LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, count);
LLVMTypeRef llvm_u32 = lb_type(m, t_u32);
for (i64 i = 0; i < count; i++) {
values[i] = LLVMConstInt(llvm_u32, count-1-i, false);
}
LLVMValueRef mask = LLVMConstVector(values, cast(unsigned)count);
LLVMValueRef v = arg0.value;
res.value = LLVMBuildShuffleVector(p->builder, v, v, mask, "");
return res;
}
}
GB_PANIC("Unhandled simd intrinsic: '%.*s'", LIT(builtin_procs[builtin_id].name));