12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485(** The are two version of [count_leading_zeros], [count_set_bits] each, which differ in
their native code implementation. The first version takes as input a tagged integer
and the second version takes as input an untagged integer. Generally, the first
version (that operates on a tagged integer) is faster, but if the integer is already
untagged, it may be faster to use the second version.
*)moduleStubs=structletavailable=Common.available(** [count_leading_zeros n] returns the number of most-significant
zero bits before the most significant set bit in [n].
If [n] is 0, the result is the number of bits in [n],
that is 31 or 63, depending on the target. *)externalcount_leading_zeros:int->(int[@untagged])="caml_int_clz""caml_int_clz_tagged_to_untagged"[@@noalloc][@@builtin][@@no_effects][@@no_coeffects]externalcount_leading_zeros2:int->int="caml_int_clz""caml_int_clz_untagged_to_untagged"[@@untagged][@@noalloc][@@builtin][@@no_effects][@@no_coeffects](** [count_set_bits n] returns the number of bits that are 1 in [n]. *)externalcount_set_bits:int->(int[@untagged])="caml_int_popcnt""caml_int_popcnt_tagged_to_untagged"[@@noalloc][@@builtin][@@no_effects][@@no_coeffects]externalcount_set_bits2:int->int="caml_int_popcnt""caml_int_popcnt_untagged_to_untagged"[@@untagged][@@noalloc][@@builtin][@@no_effects][@@no_coeffects](** [count_trailing_zeros n] returns the number of least-significant
zero bits before the least significant set bit in [n].
If [n] is 0, the result is the number of bits in [n],
that is 31 or 63, depending on the target. *)externalcount_trailing_zeros:int->int="caml_int_ctz""caml_int_ctz_untagged_to_untagged"[@@untagged][@@noalloc][@@builtin][@@no_effects][@@no_coeffects]endmoduleNaive=Naive_ints.Make(structincludeStdlib.Intletbitwidth=Sys.int_sizeend)let[@inlinealways]count_leading_zerosn=matchStubs.availablewith|true->Stubs.count_leading_zerosn|false->Naive.count_leading_zerosn;;let[@inlinealways]count_leading_zeros2n=matchStubs.availablewith|true->Stubs.count_leading_zeros2n|false->Naive.count_leading_zerosn;;let[@inlinealways]count_set_bits2n=matchStubs.availablewith|true->Stubs.count_set_bits2n|false->Naive.count_set_bitsn;;let[@inlinealways]count_trailing_zerosn=matchStubs.availablewith|true->Stubs.count_trailing_zerosn|false->Naive.count_trailing_zerosn;;let[@inlinealways]count_set_bitsn=matchStubs.availablewith|true->Stubs.count_set_bitsn|false->Naive.count_set_bitsn;;