1 //===-- WebAssemblyInstrConv.td-WebAssembly Conversion support -*- tablegen -*-=
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief WebAssembly datatype conversions, truncations, reinterpretations,
12 /// promotions, and demotions operand code-gen constructs.
14 //===----------------------------------------------------------------------===//
16 let Defs = [ARGUMENTS] in {
18 def I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src),
19 [(set I32:$dst, (trunc I64:$src))],
20 "i32.wrap/i64\t$dst, $src">;
22 def I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src),
23 [(set I64:$dst, (sext I32:$src))],
24 "i64.extend_s/i32\t$dst, $src">;
25 def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src),
26 [(set I64:$dst, (zext I32:$src))],
27 "i64.extend_u/i32\t$dst, $src">;
29 // Conversion from floating point to integer traps on overflow and invalid.
30 let hasSideEffects = 1 in {
31 def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src),
32 [(set I32:$dst, (fp_to_sint F32:$src))],
33 "i32.trunc_s/f32\t$dst, $src">;
34 def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src),
35 [(set I32:$dst, (fp_to_uint F32:$src))],
36 "i32.trunc_u/f32\t$dst, $src">;
37 def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src),
38 [(set I64:$dst, (fp_to_sint F32:$src))],
39 "i64.trunc_s/f32\t$dst, $src">;
40 def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src),
41 [(set I64:$dst, (fp_to_uint F32:$src))],
42 "i64.trunc_u/f32\t$dst, $src">;
43 def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src),
44 [(set I32:$dst, (fp_to_sint F64:$src))],
45 "i32.trunc_s/f64\t$dst, $src">;
46 def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src),
47 [(set I32:$dst, (fp_to_uint F64:$src))],
48 "i32.trunc_u/f64\t$dst, $src">;
49 def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src),
50 [(set I64:$dst, (fp_to_sint F64:$src))],
51 "i64.trunc_s/f64\t$dst, $src">;
52 def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src),
53 [(set I64:$dst, (fp_to_uint F64:$src))],
54 "i64.trunc_u/f64\t$dst, $src">;
55 } // hasSideEffects = 1
57 def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src),
58 [(set F32:$dst, (sint_to_fp I32:$src))],
59 "f32.convert_s/i32\t$dst, $src">;
60 def F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src),
61 [(set F32:$dst, (uint_to_fp I32:$src))],
62 "f32.convert_u/i32\t$dst, $src">;
63 def F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src),
64 [(set F64:$dst, (sint_to_fp I32:$src))],
65 "f64.convert_s/i32\t$dst, $src">;
66 def F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src),
67 [(set F64:$dst, (uint_to_fp I32:$src))],
68 "f64.convert_u/i32\t$dst, $src">;
69 def F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src),
70 [(set F32:$dst, (sint_to_fp I64:$src))],
71 "f32.convert_s/i64\t$dst, $src">;
72 def F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src),
73 [(set F32:$dst, (uint_to_fp I64:$src))],
74 "f32.convert_u/i64\t$dst, $src">;
75 def F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src),
76 [(set F64:$dst, (sint_to_fp I64:$src))],
77 "f64.convert_s/i64\t$dst, $src">;
78 def F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src),
79 [(set F64:$dst, (uint_to_fp I64:$src))],
80 "f64.convert_u/i64\t$dst, $src">;
82 def F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src),
83 [(set F64:$dst, (fextend F32:$src))],
84 "f64.promote/f32\t$dst, $src">;
85 def F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src),
86 [(set F32:$dst, (fround F64:$src))],
87 "f32.demote/f64\t$dst, $src">;
89 def I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src),
90 [(set I32:$dst, (bitconvert F32:$src))],
91 "i32.reinterpret/f32\t$dst, $src">;
92 def F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src),
93 [(set F32:$dst, (bitconvert I32:$src))],
94 "f32.reinterpret/i32\t$dst, $src">;
95 def I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src),
96 [(set I64:$dst, (bitconvert F64:$src))],
97 "i64.reinterpret/f64\t$dst, $src">;
98 def F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src),
99 [(set F64:$dst, (bitconvert I64:$src))],
100 "f64.reinterpret/i64\t$dst, $src">;
102 } // Defs = [ARGUMENTS]