package ocaml_intrinsics

  1. Overview
  2. Docs

Source file int64.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(** [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 64. *)
external count_leading_zeros
  :  (int64[@unboxed])
  -> (int[@untagged])
  = "caml_int64_clz" "caml_int64_clz_unboxed_to_untagged"
  [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects]

(** Same as [count_leading_zeros] except if the argument is zero,
    then the result is undefined. Emits more efficient code. *)
external count_leading_zeros_nonzero_arg
  :  (int64[@unboxed])
  -> (int[@untagged])
  = "caml_int64_clz" "caml_int64_clz_nonzero_unboxed_to_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 64. *)
external count_trailing_zeros
  :  (int64[@unboxed])
  -> (int[@untagged])
  = "caml_int64_ctz" "caml_int64_ctz_unboxed_to_untagged"
  [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects]

(** Same as [count_trailing_zeros] except if the argument is zero,
    then the result is undefined. Emits more efficient code. *)
external count_trailing_zeros_nonzero_arg
  :  (int64[@unboxed])
  -> (int[@untagged])
  = "caml_int64_ctz" "caml_int64_ctz_nonzero_unboxed_to_untagged"
  [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects]

(** [count_set_bits n] returns the number of bits that are 1 in [n]. *)
external count_set_bits
  :  (int64[@unboxed])
  -> (int[@untagged])
  = "caml_int64_popcnt" "caml_int64_popcnt_unboxed_to_untagged"
  [@@noalloc] [@@builtin] [@@no_effects] [@@no_coeffects]

(** [deposit_bits a mask]: Deposit contiguous low bits from unsigned 64-bit
    integer a to dst at the corresponding bit locations specified by mask;
    all other bits in dst are set to zero. See [_pdep_u64]. *)
external deposit_bits
  :  int64
  -> int64
  -> int64
  = "caml_bmi2_int64_deposit_bits_bytecode" "caml_bmi2_int64_deposit_bits"
  [@@noalloc] [@@unboxed] [@@builtin] [@@no_effects] [@@no_coeffects]

(** [extract_bits a mask]: Extract bits from unsigned 64-bit integer a at the
    corresponding bit locations specified by mask to contiguous low bits in dst;
    the remaining upper bits in dst are set to zero. See [_pext_u64]. *)
external extract_bits
  :  int64
  -> int64
  -> int64
  = "caml_bmi2_int64_extract_bits_bytecode" "caml_bmi2_int64_extract_bits"
  [@@noalloc] [@@unboxed] [@@builtin] [@@no_effects] [@@no_coeffects]
OCaml

Innovation. Community. Security.