[WebAssembly] Use a physical register to describe ARGUMENT liveness.
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyInstrFloat.td
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
15 let Defs = [ARGUMENTS] in {
16
17 defm ADD : BinaryFP<fadd, "add ">;
18 defm SUB : BinaryFP<fsub, "sub ">;
19 defm MUL : BinaryFP<fmul, "mul ">;
20 defm DIV : BinaryFP<fdiv, "div ">;
21 defm SQRT : UnaryFP<fsqrt, "sqrt">;
22
23 defm ABS : UnaryFP<fabs, "abs ">;
24 defm NEG : UnaryFP<fneg, "neg ">;
25 defm COPYSIGN : BinaryFP<fcopysign, "copysign">;
26
27 defm MIN : BinaryFP<fminnan, "min ">;
28 defm MAX : BinaryFP<fmaxnan, "max ">;
29
30 defm CEIL : UnaryFP<fceil, "ceil">;
31 defm FLOOR : UnaryFP<ffloor, "floor">;
32 defm TRUNC : UnaryFP<ftrunc, "trunc">;
33 defm NEAREST : UnaryFP<fnearbyint, "nearest">;
34
35 } // Defs = [ARGUMENTS]
36
37 // WebAssembly doesn't expose inexact exceptions, so map frint to fnearbyint.
38 def : Pat<(frint f32:$src), (NEAREST_F32 f32:$src)>;
39 def : Pat<(frint f64:$src), (NEAREST_F64 f64:$src)>;
40
41 let Defs = [ARGUMENTS] in {
42
43 defm EQ : ComparisonFP<SETOEQ, "eq  ">;
44 defm NE : ComparisonFP<SETUNE, "ne  ">;
45 defm LT : ComparisonFP<SETOLT, "lt  ">;
46 defm LE : ComparisonFP<SETOLE, "le  ">;
47 defm GT : ComparisonFP<SETOGT, "gt  ">;
48 defm GE : ComparisonFP<SETOGE, "ge  ">;
49
50 } // Defs = [ARGUMENTS]
51
52 // Don't care floating-point comparisons, supported via other comparisons.
53 def : Pat<(seteq f32:$lhs, f32:$rhs), (EQ_F32 f32:$lhs, f32:$rhs)>;
54 def : Pat<(setne f32:$lhs, f32:$rhs), (NE_F32 f32:$lhs, f32:$rhs)>;
55 def : Pat<(setlt f32:$lhs, f32:$rhs), (LT_F32 f32:$lhs, f32:$rhs)>;
56 def : Pat<(setle f32:$lhs, f32:$rhs), (LE_F32 f32:$lhs, f32:$rhs)>;
57 def : Pat<(setgt f32:$lhs, f32:$rhs), (GT_F32 f32:$lhs, f32:$rhs)>;
58 def : Pat<(setge f32:$lhs, f32:$rhs), (GE_F32 f32:$lhs, f32:$rhs)>;
59 def : Pat<(seteq f64:$lhs, f64:$rhs), (EQ_F64 f64:$lhs, f64:$rhs)>;
60 def : Pat<(setne f64:$lhs, f64:$rhs), (NE_F64 f64:$lhs, f64:$rhs)>;
61 def : Pat<(setlt f64:$lhs, f64:$rhs), (LT_F64 f64:$lhs, f64:$rhs)>;
62 def : Pat<(setle f64:$lhs, f64:$rhs), (LE_F64 f64:$lhs, f64:$rhs)>;
63 def : Pat<(setgt f64:$lhs, f64:$rhs), (GT_F64 f64:$lhs, f64:$rhs)>;
64 def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>;
65
66 let Defs = [ARGUMENTS] in {
67
68 def SELECT_F32 : I<(outs F32:$dst), (ins I32:$cond, F32:$lhs, F32:$rhs),
69                    [(set F32:$dst, (select I32:$cond, F32:$lhs, F32:$rhs))],
70                    "f32.select\t$dst, $cond, $lhs, $rhs">;
71 def SELECT_F64 : I<(outs F64:$dst), (ins I32:$cond, F64:$lhs, F64:$rhs),
72                    [(set F64:$dst, (select I32:$cond, F64:$lhs, F64:$rhs))],
73                    "f64.select\t$dst, $cond, $lhs, $rhs">;
74
75 } // Defs = [ARGUMENTS]