perf: annotate types in monomorphic/float/int to help specialize builtins

close #245
This commit is contained in:
Simon Cruanes 2019-01-30 21:16:13 -06:00
parent 052e607c5c
commit b60fe99365
3 changed files with 57 additions and 21 deletions

View file

@ -10,17 +10,17 @@ type fpclass = Pervasives.fpclass =
| FP_nan
module Infix = struct
let (=) = Pervasives.(=)
let (<>) = Pervasives.(<>)
let (<) = Pervasives.(<)
let (>) = Pervasives.(>)
let (<=) = Pervasives.(<=)
let (>=) = Pervasives.(>=)
let (~-) = Pervasives.(~-.)
let (+) = Pervasives.(+.)
let (-) = Pervasives.(-.)
let ( * ) = Pervasives.( *. )
let (/) = Pervasives.(/.)
let (=) : t -> t -> bool = Pervasives.(=)
let (<>) : t -> t -> bool = Pervasives.(<>)
let (<) : t -> t -> bool = Pervasives.(<)
let (>) : t -> t -> bool = Pervasives.(>)
let (<=) : t -> t -> bool = Pervasives.(<=)
let (>=) : t -> t -> bool = Pervasives.(>=)
let (~-) : t -> t = Pervasives.(~-.)
let (+) : t -> t -> t = Pervasives.(+.)
let (-) : t -> t -> t = Pervasives.(-.)
let ( * ) : t -> t -> t = Pervasives.( *. )
let (/) : t -> t -> t = Pervasives.(/.)
end
include Infix
@ -36,7 +36,7 @@ let max_finite_value = Pervasives.max_float
let epsilon = Pervasives.epsilon_float
let is_nan x = Pervasives.classify_float x = Pervasives.FP_nan
let is_nan x = Pervasives.(classify_float x = Pervasives.FP_nan)
let add = (+.)
let sub = (-.)

View file

@ -2,6 +2,7 @@
(* This file is free software, part of containers. See file "license" for more details. *)
type t = int
type 'a sequence = ('a -> unit) -> unit
let equal (a:int) b = Pervasives.(=) a b
@ -70,7 +71,30 @@ let pow a b =
pow 0 1 = 0
*)
module Infix = struct
module Infix : sig
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (<) : t -> t -> bool
val (>) : t -> t -> bool
val (<=) : t -> t -> bool
val (>=) : t -> t -> bool
val (--) : t -> t -> t sequence
val (--^) : t -> t -> t sequence
val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val ( * ) : t -> t -> t
val (/) : t -> t -> t
val ( ** ) : t -> t -> t
val (mod) : t -> t -> t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val lnot : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
end = struct
include Pervasives
let (--) = range
let (--^) = range'
@ -78,6 +102,9 @@ module Infix = struct
end
include Infix
let min : t -> t -> t = Pervasives.min
let max : t -> t -> t = Pervasives.max
let floor_div a n =
if a < 0 && n >= 0 then
(a + 1) / n - 1
@ -159,7 +186,6 @@ let rem a n =
type 'a printer = Format.formatter -> 'a -> unit
type 'a random_gen = Random.State.t -> 'a
type 'a sequence = ('a -> unit) -> unit
let random n st = Random.State.int st n
let random_small = random 100

View file

@ -1,14 +1,24 @@
(* This file is free software, part of containers. See file "license" for more details. *)
include Pervasives
let (=) : int -> int -> bool = Pervasives.(=)
let (<>) : int -> int -> bool = Pervasives.(<>)
let (<) : int -> int -> bool = Pervasives.(<)
let (>) : int -> int -> bool = Pervasives.(>)
let (<=) : int -> int -> bool = Pervasives.(<=)
let (>=) : int -> int -> bool = Pervasives.(>=)
let compare : int -> int -> int = Pervasives.compare
let min : int -> int -> int = Pervasives.min
let max : int -> int -> int = Pervasives.max
let (=.) : float -> float -> bool = Pervasives.(=)
let (<>.) : float -> float -> bool = Pervasives.(<>)
let (<.) : float -> float -> bool = Pervasives.(<)
let (>.) : float -> float -> bool = Pervasives.(>)
let (<=.) : float -> float -> bool = Pervasives.(<=)
let (>=.) : float -> float -> bool = Pervasives.(>=)
let (=.) : float -> float -> bool = (=)
let (<>.) : float -> float -> bool = (<>)
let (<.) : float -> float -> bool = (<)
let (>.) : float -> float -> bool = (>)
let (<=.) : float -> float -> bool = (<=)
let (>=.) : float -> float -> bool = (>=)
let (==) = `Consider_using_CCEqual_physical
let (!=) = `Consider_using_CCEqual_physical