Skip to content

Commit

Permalink
Merge pull request #46 from WebAssembly/minmax
Browse files Browse the repository at this point in the history
Add min and max operators.
  • Loading branch information
rossberg committed Sep 3, 2015
2 parents 02668bb + 7455058 commit 5062f47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ml-proto/src/arithmetic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ struct
| Mul -> ( *.)
| Div -> (/.)
| CopySign -> copysign
| Min -> min
| Max -> max
in
fun v1 v2 -> Float.to_value (f (Float.of_value 1 v1) (Float.of_value 2 v2))

Expand Down
2 changes: 1 addition & 1 deletion ml-proto/src/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
module FloatOp () =
struct
type unop = Neg | Abs | Ceil | Floor | Trunc | Nearest | Sqrt
type binop = Add | Sub | Mul | Div | CopySign
type binop = Add | Sub | Mul | Div | CopySign | Min | Max
type relop = Eq | Neq | Lt | Le | Gt | Ge
type cvt = ToInt32S | ToInt32U | ToInt64S | ToInt64U | ToIntCast
| ToFloat32 | ToFloat64
Expand Down
2 changes: 2 additions & 0 deletions ml-proto/src/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ rule token = parse
| "mul."(fxx as t) { BINARY (floatop t F32.Mul F64.Mul) }
| "div."(fxx as t) { BINARY (floatop t F32.Div F64.Div) }
| "copysign."(fxx as t) { BINARY (floatop t F32.CopySign F64.CopySign) }
| "min."(fxx as t) { BINARY (floatop t F32.Min F64.Min) }
| "max."(fxx as t) { BINARY (floatop t F32.Max F64.Max) }

| "eq."(ixx as t) { COMPARE (intop t I32.Eq I64.Eq) }
| "neq."(ixx as t) { COMPARE (intop t I32.Neq I64.Neq) }
Expand Down

0 comments on commit 5062f47

Please sign in to comment.