diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td | 19 |
2 files changed, 16 insertions, 12 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp index b4143240c99..4cb3a3138e8 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp @@ -120,10 +120,13 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering( ISD::SETULT, ISD::SETULE, ISD::SETUGT, ISD::SETUGE}) setCondCodeAction(CC, T, Expand); // Expand floating-point library function operators. - for (auto Op : {ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOWI, ISD::FPOW, - ISD::FLOG, ISD::FLOG2, ISD::FLOG10, ISD::FEXP, ISD::FEXP2, - ISD::FMINNAN, ISD::FMAXNAN}) + for (auto Op : {ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOWI, ISD::FPOW}) setOperationAction(Op, T, Expand); + // Note supported floating-point library function operators that otherwise + // default to expand. + for (auto Op : {ISD::FCEIL, ISD::FFLOOR, ISD::FTRUNC, ISD::FNEARBYINT, + ISD::FRINT}) + setOperationAction(Op, T, Legal); } for (auto T : {MVT::i32, MVT::i64}) { diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td index 87d1a98b98e..69db7e71ae1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td @@ -16,17 +16,20 @@ defm FADD : BinaryFP<fadd>; defm FSUB : BinaryFP<fsub>; defm FMUL : BinaryFP<fmul>; defm FDIV : BinaryFP<fdiv>; +defm SQRT : UnaryFP<fsqrt>; + defm FABS : UnaryFP<fabs>; defm FNEG : UnaryFP<fneg>; defm COPYSIGN : BinaryFP<fcopysign>; -/* - * TODO(jfb): add and test these: - * defm CEIL : UnaryFP<fceil>; - * defm FLOOR : UnaryFP<ffloor>; - * defm TRUNC : UnaryFP<ftrunc>; - * defm NEARESTINT : UnaryFP<fnearbyint>; - */ +defm CEIL : UnaryFP<fceil>; +defm FLOOR : UnaryFP<ffloor>; +defm TRUNC : UnaryFP<ftrunc>; +defm NEARESTINT : UnaryFP<fnearbyint>; + +// WebAssembly doesn't expose inexact exceptions, so map frint to fnearbyint. +def : Pat<(frint f32:$src), (NEARESTINT_F32 f32:$src)>; +def : Pat<(frint f64:$src), (NEARESTINT_F64 f64:$src)>; defm EQ : ComparisonFP<SETOEQ>; defm NE : ComparisonFP<SETUNE>; @@ -49,8 +52,6 @@ def : Pat<(setle f64:$lhs, f64:$rhs), (LE_F64 f64:$lhs, f64:$rhs)>; def : Pat<(setgt f64:$lhs, f64:$rhs), (GT_F64 f64:$lhs, f64:$rhs)>; def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>; -defm SQRT : UnaryFP<fsqrt>; - /* * TODO(jfb): Add the following for 32-bit and 64-bit. * |