mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
add Num.count*Bits functions
This commit is contained in:
parent
fbaa257cef
commit
785da377c8
11 changed files with 207 additions and 8 deletions
|
@ -848,9 +848,24 @@ pub(crate) fn run_low_level<'a, 'ctx, 'env>(
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
NumAbs | NumNeg | NumRound | NumSqrtUnchecked | NumLogUnchecked | NumSin | NumCos
|
||||
| NumCeiling | NumFloor | NumToFrac | NumIsFinite | NumAtan | NumAcos | NumAsin
|
||||
| NumToIntChecked => {
|
||||
NumAbs
|
||||
| NumNeg
|
||||
| NumRound
|
||||
| NumSqrtUnchecked
|
||||
| NumLogUnchecked
|
||||
| NumSin
|
||||
| NumCos
|
||||
| NumCeiling
|
||||
| NumFloor
|
||||
| NumToFrac
|
||||
| NumIsFinite
|
||||
| NumAtan
|
||||
| NumAcos
|
||||
| NumAsin
|
||||
| NumToIntChecked
|
||||
| NumCountLeadingZeroBits
|
||||
| NumCountTrailingZeroBits
|
||||
| NumCountOneBits => {
|
||||
arguments_with_layouts!((arg, arg_layout));
|
||||
|
||||
match layout_interner.get(arg_layout) {
|
||||
|
@ -2045,6 +2060,19 @@ fn build_int_unary_op<'a, 'ctx, 'env>(
|
|||
complex_bitcast_check_size(env, result, return_type.into(), "cast_bitpacked")
|
||||
}
|
||||
}
|
||||
NumCountLeadingZeroBits => call_bitcode_fn(
|
||||
env,
|
||||
&[arg.into()],
|
||||
&bitcode::NUM_COUNT_LEADING_ZERO_BITS[arg_width],
|
||||
),
|
||||
NumCountTrailingZeroBits => call_bitcode_fn(
|
||||
env,
|
||||
&[arg.into()],
|
||||
&bitcode::NUM_COUNT_TRAILING_ZERO_BITS[arg_width],
|
||||
),
|
||||
NumCountOneBits => {
|
||||
call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_COUNT_ONE_BITS[arg_width])
|
||||
}
|
||||
_ => {
|
||||
unreachable!("Unrecognized int unary operation: {:?}", op);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue