1//===-- WebAssemblyInstrConv.td-WebAssembly Conversion 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 datatype conversions, truncations, reinterpretations,
12/// promotions, and demotions operand code-gen constructs.
13///
14//===----------------------------------------------------------------------===//
15
16def I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src),
17                     [(set I32:$dst, (trunc I64:$src))]>;
18
19def I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src),
20                         [(set I64:$dst, (sext I32:$src))]>;
21def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src),
22                         [(set I64:$dst, (zext I32:$src))]>;
23
24def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src),
25                        [(set I32:$dst, (fp_to_sint F32:$src))]>;
26def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src),
27                        [(set I32:$dst, (fp_to_uint F32:$src))]>;
28def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src),
29                        [(set I64:$dst, (fp_to_sint F32:$src))]>;
30def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src),
31                        [(set I64:$dst, (fp_to_uint F32:$src))]>;
32def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src),
33                        [(set I32:$dst, (fp_to_sint F64:$src))]>;
34def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src),
35                        [(set I32:$dst, (fp_to_uint F64:$src))]>;
36def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src),
37                        [(set I64:$dst, (fp_to_sint F64:$src))]>;
38def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src),
39                        [(set I64:$dst, (fp_to_uint F64:$src))]>;
40
41def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src),
42                          [(set F32:$dst, (sint_to_fp I32:$src))]>;
43def F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src),
44                          [(set F32:$dst, (uint_to_fp I32:$src))]>;
45def F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src),
46                          [(set F64:$dst, (sint_to_fp I32:$src))]>;
47def F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src),
48                          [(set F64:$dst, (uint_to_fp I32:$src))]>;
49def F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src),
50                          [(set F32:$dst, (sint_to_fp I64:$src))]>;
51def F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src),
52                          [(set F32:$dst, (uint_to_fp I64:$src))]>;
53def F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src),
54                          [(set F64:$dst, (sint_to_fp I64:$src))]>;
55def F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src),
56                          [(set F64:$dst, (uint_to_fp I64:$src))]>;
57
58def F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src),
59                        [(set F64:$dst, (fextend F32:$src))]>;
60def F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src),
61                       [(set F32:$dst, (fround F64:$src))]>;
62
63def I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src),
64                            [(set I32:$dst, (bitconvert F32:$src))]>;
65def F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src),
66                            [(set F32:$dst, (bitconvert I32:$src))]>;
67def I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src),
68                            [(set I64:$dst, (bitconvert F64:$src))]>;
69def F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src),
70                            [(set F64:$dst, (bitconvert I64:$src))]>;
71