Skip to content

Commit

Permalink
flambda-backend: Rename float32 round_half_to_even to round_current (o…
Browse files Browse the repository at this point in the history
…caml-flambda#2913)

update names
  • Loading branch information
TheNumbat authored Aug 10, 2024
1 parent a3b26bf commit 0be6167
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions otherlibs/stdlib_beta/amd64/float32.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ let[@inline] min_max_num (x : t) (y : t) =
else if y > x || ((not (sign_bit y)) && sign_bit x) then (x, y)
else (y, x)

external iround_half_to_even : t -> int64
external iround_current : t -> int64
= "caml_sse_cast_float32_int64_bytecode" "caml_sse_cast_float32_int64"
[@@noalloc] [@@unboxed] [@@builtin]

Expand All @@ -290,7 +290,7 @@ let round_neg_inf = 0x9
let round_pos_inf = 0xA
let round_zero = 0xB
let round_current_mode = 0xC
let[@inline] round_half_to_even x = round_intrinsic round_current_mode x
let[@inline] round_current x = round_intrinsic round_current_mode x
let[@inline] round_down x = round_intrinsic round_neg_inf x
let[@inline] round_up x = round_intrinsic round_pos_inf x
let[@inline] round_towards_zero x = round_intrinsic round_zero x
Expand Down
15 changes: 8 additions & 7 deletions otherlibs/stdlib_beta/amd64/float32.mli
Original file line number Diff line number Diff line change
Expand Up @@ -494,20 +494,21 @@ val min_max_num : t -> t -> t * t
efficient. Note that in particular [min_max_num x nan = (x, x)]
and [min_max_num nan y = (y, y)]. *)

external iround_half_to_even : t -> int64
external iround_current : t -> int64
= "caml_sse_cast_float32_int64_bytecode" "caml_sse_cast_float32_int64"
[@@noalloc] [@@unboxed] [@@builtin]
(** Rounds a [float32] to an [int64] using the current rounding mode. The default
rounding mode is "round half to even", and we expect that no program will
change the rounding mode.
rounding mode on amd64 is "round half to even", and we expect that no
program will change the mode. The default mode may differ on other platforms.
If the argument is NaN or infinite or if the rounded value cannot be
represented, then the result is unspecified.
The amd64 flambda-backend compiler translates this call to CVTSS2SI. *)

val round_half_to_even : t -> t
(** Rounds a [float32] to an integer [float32] using the current rounding
mode. The default rounding mode is "round half to even", and we
expect that no program will change the rounding mode.
val round_current : t -> t
(** Rounds a [float32] to an integer [float32] using the current rounding mode.
The default rounding mode on amd64 is "round half to even", and we
expect that no program will change the mode. The default mode may differ
on other platforms.
The amd64 flambda-backend compiler translates this call to ROUNDSS. *)

val round_down : t -> t
Expand Down
10 changes: 5 additions & 5 deletions otherlibs/stdlib_beta/amd64/float32_u.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ let[@inline always] min_num x y = of_float32 (Float32.min_num (to_float32 x) (to

let[@inline always] max_num x y = of_float32 (Float32.max_num (to_float32 x) (to_float32 y))

let iround_half_to_even x = unbox_int64 (Float32.iround_half_to_even (to_float32 x))
let[@inline always] iround_current x = unbox_int64 (Float32.iround_current (to_float32 x))

let round_half_to_even x = of_float32 (Float32.round_half_to_even (to_float32 x))
let[@inline always] round_current x = of_float32 (Float32.round_current (to_float32 x))

let round_down x = of_float32 (Float32.round_down (to_float32 x))
let[@inline always] round_down x = of_float32 (Float32.round_down (to_float32 x))

let round_up x = of_float32 (Float32.round_up (to_float32 x))
let[@inline always] round_up x = of_float32 (Float32.round_up (to_float32 x))

let round_towards_zero x = of_float32 (Float32.round_towards_zero (to_float32 x))
let[@inline always] round_towards_zero x = of_float32 (Float32.round_towards_zero (to_float32 x))

module Bytes = struct
let get bytes ~pos = of_float32 (Float32.Bytes.get bytes ~pos)
Expand Down
15 changes: 8 additions & 7 deletions otherlibs/stdlib_beta/amd64/float32_u.mli
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,19 @@ val max_num : t -> t -> t
missing values. If both [x] and [y] are [nan] [nan] is returned.
Moreover [max_num #-0.s #+0.s = #+0.s] *)

val iround_half_to_even : t -> int64#
val iround_current : t -> int64#
(** Rounds a [float32#] to an [int64#] using the current rounding mode. The default
rounding mode is "round half to even", and we expect that no program will
change the rounding mode.
rounding mode on amd64 is "round half to even", and we expect that no
program will change the mode. The default mode may differ on other platforms.
If the argument is NaN or infinite or if the rounded value cannot be
represented, then the result is unspecified.
The amd64 flambda-backend compiler translates this call to CVTSS2SI. *)

val round_half_to_even : t -> t
(** Rounds a [float32#] to an integer [float32#] using the current rounding
mode. The default rounding mode is "round half to even", and we
expect that no program will change the rounding mode.
val round_current : t -> t
(** Rounds a [float32#] to an integer [float32#] using the current rounding mode.
The default rounding mode on amd64 is "round half to even", and we
expect that no program will change the mode. The default mode may differ
on other platforms.
The amd64 flambda-backend compiler translates this call to ROUNDSS. *)

val round_down : t -> t
Expand Down

0 comments on commit 0be6167

Please sign in to comment.