mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-01 01:31:49 -07:00
Added simd_extract_lsbs intrinsic as well.
Equivalent to the simd_extract_msbs intrinsic, except it extracts the least significant bit of each element instead.
This commit is contained in:
@@ -1564,6 +1564,7 @@ gb_internal lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAn
|
||||
return res;
|
||||
}
|
||||
|
||||
case BuiltinProc_simd_extract_lsbs:
|
||||
case BuiltinProc_simd_extract_msbs:
|
||||
{
|
||||
Type *vt = arg0.type;
|
||||
@@ -1572,9 +1573,12 @@ gb_internal lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAn
|
||||
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, "");
|
||||
LLVMValueRef broadcast_value = arg0.value;
|
||||
if (builtin_id == BuiltinProc_simd_extract_msbs) {
|
||||
LLVMTypeRef word_type = lb_type(m, elem);
|
||||
LLVMValueRef shift_value = llvm_splat_int(num_elems, word_type, elem_bits - 1);
|
||||
broadcast_value = LLVMBuildAShr(p->builder, broadcast_value, shift_value, "");
|
||||
}
|
||||
|
||||
LLVMTypeRef bitvec_type = LLVMVectorType(LLVMInt1TypeInContext(m->ctx), (unsigned)num_elems);
|
||||
LLVMValueRef bitvec_value = LLVMBuildTrunc(p->builder, broadcast_value, bitvec_type, "");
|
||||
|
||||
Reference in New Issue
Block a user