JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 1 | // WebAssemblyInstrFloat.td-WebAssembly Float codegen support ---*- tablegen -*- |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief WebAssembly Floating-point operand code-gen constructs. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
JF Bastien | d9767a3 | 2015-07-14 21:13:29 +0000 | [diff] [blame] | 15 | defm FADD : BinaryFP<fadd>; |
| 16 | defm FSUB : BinaryFP<fsub>; |
| 17 | defm FMUL : BinaryFP<fmul>; |
| 18 | defm FDIV : BinaryFP<fdiv>; |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 19 | defm SQRT : UnaryFP<fsqrt>; |
| 20 | |
JF Bastien | d9767a3 | 2015-07-14 21:13:29 +0000 | [diff] [blame] | 21 | defm FABS : UnaryFP<fabs>; |
| 22 | defm FNEG : UnaryFP<fneg>; |
| 23 | defm COPYSIGN : BinaryFP<fcopysign>; |
JF Bastien | ef172fc | 2015-08-11 02:45:15 +0000 | [diff] [blame] | 24 | |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 25 | defm CEIL : UnaryFP<fceil>; |
| 26 | defm FLOOR : UnaryFP<ffloor>; |
| 27 | defm TRUNC : UnaryFP<ftrunc>; |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame^] | 28 | defm NEAREST : UnaryFP<fnearbyint>; |
Dan Gohman | 896e53f | 2015-08-24 18:23:13 +0000 | [diff] [blame] | 29 | |
| 30 | // WebAssembly doesn't expose inexact exceptions, so map frint to fnearbyint. |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame^] | 31 | def : Pat<(frint f32:$src), (NEAREST_F32 f32:$src)>; |
| 32 | def : Pat<(frint f64:$src), (NEAREST_F64 f64:$src)>; |
JF Bastien | d9767a3 | 2015-07-14 21:13:29 +0000 | [diff] [blame] | 33 | |
JF Bastien | da06bce | 2015-08-11 21:02:46 +0000 | [diff] [blame] | 34 | defm EQ : ComparisonFP<SETOEQ>; |
| 35 | defm NE : ComparisonFP<SETUNE>; |
| 36 | defm LT : ComparisonFP<SETOLT>; |
| 37 | defm LE : ComparisonFP<SETOLE>; |
| 38 | defm GT : ComparisonFP<SETOGT>; |
| 39 | defm GE : ComparisonFP<SETOGE>; |
JF Bastien | d9767a3 | 2015-07-14 21:13:29 +0000 | [diff] [blame] | 40 | |
JF Bastien | 71d29ac | 2015-08-12 17:53:29 +0000 | [diff] [blame] | 41 | // Don't care floating-point comparisons, supported via other comparisons. |
| 42 | def : Pat<(seteq f32:$lhs, f32:$rhs), (EQ_F32 f32:$lhs, f32:$rhs)>; |
| 43 | def : Pat<(setne f32:$lhs, f32:$rhs), (NE_F32 f32:$lhs, f32:$rhs)>; |
| 44 | def : Pat<(setlt f32:$lhs, f32:$rhs), (LT_F32 f32:$lhs, f32:$rhs)>; |
| 45 | def : Pat<(setle f32:$lhs, f32:$rhs), (LE_F32 f32:$lhs, f32:$rhs)>; |
| 46 | def : Pat<(setgt f32:$lhs, f32:$rhs), (GT_F32 f32:$lhs, f32:$rhs)>; |
| 47 | def : Pat<(setge f32:$lhs, f32:$rhs), (GE_F32 f32:$lhs, f32:$rhs)>; |
| 48 | def : Pat<(seteq f64:$lhs, f64:$rhs), (EQ_F64 f64:$lhs, f64:$rhs)>; |
| 49 | def : Pat<(setne f64:$lhs, f64:$rhs), (NE_F64 f64:$lhs, f64:$rhs)>; |
| 50 | def : Pat<(setlt f64:$lhs, f64:$rhs), (LT_F64 f64:$lhs, f64:$rhs)>; |
| 51 | def : Pat<(setle f64:$lhs, f64:$rhs), (LE_F64 f64:$lhs, f64:$rhs)>; |
| 52 | def : Pat<(setgt f64:$lhs, f64:$rhs), (GT_F64 f64:$lhs, f64:$rhs)>; |
| 53 | def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>; |
| 54 | |
JF Bastien | d9767a3 | 2015-07-14 21:13:29 +0000 | [diff] [blame] | 55 | /* |
| 56 | * TODO(jfb): Add the following for 32-bit and 64-bit. |
| 57 | * |
Dan Gohman | d0bf981 | 2015-09-26 01:09:44 +0000 | [diff] [blame^] | 58 | * f32.min: minimum (binary operator); if either operand is NaN, returns NaN |
| 59 | * f32.max: maximum (binary operator); if either operand is NaN, returns NaN |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 60 | */ |