blob: a24c8bfdef36863848a4cb2371933f5f644254a4 [file] [log] [blame]
JF Bastien5ca0bac2015-07-10 18:23:10 +00001// 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
Dan Gohmanfb3e0592015-11-25 19:36:19 +000015let Defs = [ARGUMENTS] in {
16
Dan Gohman1f29c682015-11-18 16:25:38 +000017defm ADD : BinaryFP<fadd, "add ">;
18defm SUB : BinaryFP<fsub, "sub ">;
19defm MUL : BinaryFP<fmul, "mul ">;
20defm DIV : BinaryFP<fdiv, "div ">;
Dan Gohmanaf29bd42015-11-05 20:42:30 +000021defm SQRT : UnaryFP<fsqrt, "sqrt">;
Dan Gohman896e53f2015-08-24 18:23:13 +000022
Dan Gohman1f29c682015-11-18 16:25:38 +000023defm ABS : UnaryFP<fabs, "abs ">;
24defm NEG : UnaryFP<fneg, "neg ">;
Dan Gohmanaf29bd42015-11-05 20:42:30 +000025defm COPYSIGN : BinaryFP<fcopysign, "copysign">;
JF Bastienef172fc2015-08-11 02:45:15 +000026
Dan Gohman1f29c682015-11-18 16:25:38 +000027defm MIN : BinaryFP<fminnan, "min ">;
28defm MAX : BinaryFP<fmaxnan, "max ">;
Dan Gohmanb84ae9b2015-11-10 21:40:21 +000029
Dan Gohmanaf29bd42015-11-05 20:42:30 +000030defm CEIL : UnaryFP<fceil, "ceil">;
31defm FLOOR : UnaryFP<ffloor, "floor">;
32defm TRUNC : UnaryFP<ftrunc, "trunc">;
33defm NEAREST : UnaryFP<fnearbyint, "nearest">;
Dan Gohman896e53f2015-08-24 18:23:13 +000034
Dan Gohmanfb3e0592015-11-25 19:36:19 +000035} // Defs = [ARGUMENTS]
36
Dan Gohman896e53f2015-08-24 18:23:13 +000037// WebAssembly doesn't expose inexact exceptions, so map frint to fnearbyint.
Dan Gohmand0bf9812015-09-26 01:09:44 +000038def : Pat<(frint f32:$src), (NEAREST_F32 f32:$src)>;
39def : Pat<(frint f64:$src), (NEAREST_F64 f64:$src)>;
JF Bastiend9767a32015-07-14 21:13:29 +000040
Dan Gohmanfb3e0592015-11-25 19:36:19 +000041let Defs = [ARGUMENTS] in {
42
Dan Gohman1f29c682015-11-18 16:25:38 +000043defm EQ : ComparisonFP<SETOEQ, "eq ">;
44defm NE : ComparisonFP<SETUNE, "ne ">;
45defm LT : ComparisonFP<SETOLT, "lt ">;
46defm LE : ComparisonFP<SETOLE, "le ">;
47defm GT : ComparisonFP<SETOGT, "gt ">;
48defm GE : ComparisonFP<SETOGE, "ge ">;
JF Bastiend9767a32015-07-14 21:13:29 +000049
Dan Gohmanfb3e0592015-11-25 19:36:19 +000050} // Defs = [ARGUMENTS]
51
JF Bastien71d29ac2015-08-12 17:53:29 +000052// Don't care floating-point comparisons, supported via other comparisons.
53def : Pat<(seteq f32:$lhs, f32:$rhs), (EQ_F32 f32:$lhs, f32:$rhs)>;
54def : Pat<(setne f32:$lhs, f32:$rhs), (NE_F32 f32:$lhs, f32:$rhs)>;
55def : Pat<(setlt f32:$lhs, f32:$rhs), (LT_F32 f32:$lhs, f32:$rhs)>;
56def : Pat<(setle f32:$lhs, f32:$rhs), (LE_F32 f32:$lhs, f32:$rhs)>;
57def : Pat<(setgt f32:$lhs, f32:$rhs), (GT_F32 f32:$lhs, f32:$rhs)>;
58def : Pat<(setge f32:$lhs, f32:$rhs), (GE_F32 f32:$lhs, f32:$rhs)>;
59def : Pat<(seteq f64:$lhs, f64:$rhs), (EQ_F64 f64:$lhs, f64:$rhs)>;
60def : Pat<(setne f64:$lhs, f64:$rhs), (NE_F64 f64:$lhs, f64:$rhs)>;
61def : Pat<(setlt f64:$lhs, f64:$rhs), (LT_F64 f64:$lhs, f64:$rhs)>;
62def : Pat<(setle f64:$lhs, f64:$rhs), (LE_F64 f64:$lhs, f64:$rhs)>;
63def : Pat<(setgt f64:$lhs, f64:$rhs), (GT_F64 f64:$lhs, f64:$rhs)>;
64def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>;
65
Dan Gohmanfb3e0592015-11-25 19:36:19 +000066let Defs = [ARGUMENTS] in {
67
Derek Schuff6b5c6da2015-11-03 22:40:40 +000068def SELECT_F32 : I<(outs F32:$dst), (ins I32:$cond, F32:$lhs, F32:$rhs),
Dan Gohmanaf29bd42015-11-05 20:42:30 +000069 [(set F32:$dst, (select I32:$cond, F32:$lhs, F32:$rhs))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000070 "f32.select\t$dst, $cond, $lhs, $rhs">;
Derek Schuff6b5c6da2015-11-03 22:40:40 +000071def SELECT_F64 : I<(outs F64:$dst), (ins I32:$cond, F64:$lhs, F64:$rhs),
Dan Gohmanaf29bd42015-11-05 20:42:30 +000072 [(set F64:$dst, (select I32:$cond, F64:$lhs, F64:$rhs))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000073 "f64.select\t$dst, $cond, $lhs, $rhs">;
Dan Gohmanfb3e0592015-11-25 19:36:19 +000074
75} // Defs = [ARGUMENTS]