mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-05 10:14:05 +00:00
Added simd_extract_msbs intrinsic.
This commit is contained in:
@@ -1564,6 +1564,30 @@ gb_internal lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAn
|
||||
return res;
|
||||
}
|
||||
|
||||
case BuiltinProc_simd_extract_msbs:
|
||||
{
|
||||
Type *vt = arg0.type;
|
||||
GB_ASSERT(vt->kind == Type_SimdVector);
|
||||
|
||||
i64 elem_bits = 8*type_size_of(elem);
|
||||
i64 num_elems = get_array_type_count(vt);
|
||||
|
||||
LLVMTypeRef word_type = lb_type(m, elem);
|
||||
LLVMValueRef shift_value = llvm_splat_int(num_elems, word_type, elem_bits - 1);
|
||||
LLVMValueRef broadcast_value = LLVMBuildAShr(p->builder, arg0.value, shift_value, "");
|
||||
|
||||
LLVMTypeRef bitvec_type = LLVMVectorType(LLVMInt1TypeInContext(m->ctx), (unsigned)num_elems);
|
||||
LLVMValueRef bitvec_value = LLVMBuildTrunc(p->builder, broadcast_value, bitvec_type, "");
|
||||
|
||||
LLVMTypeRef mask_type = LLVMIntTypeInContext(m->ctx, (unsigned)num_elems);
|
||||
LLVMValueRef mask_value = LLVMBuildBitCast(p->builder, bitvec_value, mask_type, "");
|
||||
|
||||
LLVMTypeRef result_type = lb_type(m, res.type);
|
||||
res.value = LLVMBuildZExtOrBitCast(p->builder, mask_value, result_type, "");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
case BuiltinProc_simd_shuffle:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user