blob: 4926b8fd8725e919cca59c8b4e661f6d9a879330 [file] [log] [blame]
JF Bastien5ca0bac2015-07-10 18:23:10 +00001//===-- 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
Dan Gohmanfb3e0592015-11-25 19:36:19 +000016let Defs = [ARGUMENTS] in {
17
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000018def I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src),
19 [(set I32:$dst, (trunc I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000020 "i32.wrap/i64\t$dst, $src">;
Dan Gohmandc51b962015-10-03 02:10:28 +000021
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000022def I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src),
23 [(set I64:$dst, (sext I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000024 "i64.extend_s/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000025def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src),
26 [(set I64:$dst, (zext I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000027 "i64.extend_u/i32\t$dst, $src">;
Dan Gohmandc51b962015-10-03 02:10:28 +000028
Dan Gohman174b2d82015-11-29 22:59:19 +000029// Conversion from floating point to integer traps on overflow and invalid.
30let hasSideEffects = 1 in {
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000031def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src),
32 [(set I32:$dst, (fp_to_sint F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000033 "i32.trunc_s/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000034def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src),
35 [(set I32:$dst, (fp_to_uint F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000036 "i32.trunc_u/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000037def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src),
38 [(set I64:$dst, (fp_to_sint F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000039 "i64.trunc_s/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000040def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src),
41 [(set I64:$dst, (fp_to_uint F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000042 "i64.trunc_u/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000043def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src),
44 [(set I32:$dst, (fp_to_sint F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000045 "i32.trunc_s/f64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000046def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src),
47 [(set I32:$dst, (fp_to_uint F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000048 "i32.trunc_u/f64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000049def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src),
50 [(set I64:$dst, (fp_to_sint F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000051 "i64.trunc_s/f64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000052def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src),
53 [(set I64:$dst, (fp_to_uint F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000054 "i64.trunc_u/f64\t$dst, $src">;
Dan Gohman174b2d82015-11-29 22:59:19 +000055} // hasSideEffects = 1
Dan Gohmandc51b962015-10-03 02:10:28 +000056
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000057def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src),
58 [(set F32:$dst, (sint_to_fp I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000059 "f32.convert_s/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000060def F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src),
61 [(set F32:$dst, (uint_to_fp I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000062 "f32.convert_u/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000063def F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src),
64 [(set F64:$dst, (sint_to_fp I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000065 "f64.convert_s/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000066def F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src),
67 [(set F64:$dst, (uint_to_fp I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000068 "f64.convert_u/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000069def F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src),
70 [(set F32:$dst, (sint_to_fp I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000071 "f32.convert_s/i64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000072def F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src),
73 [(set F32:$dst, (uint_to_fp I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000074 "f32.convert_u/i64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000075def F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src),
76 [(set F64:$dst, (sint_to_fp I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000077 "f64.convert_s/i64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000078def F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src),
79 [(set F64:$dst, (uint_to_fp I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000080 "f64.convert_u/i64\t$dst, $src">;
Dan Gohmandc51b962015-10-03 02:10:28 +000081
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000082def F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src),
83 [(set F64:$dst, (fextend F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000084 "f64.promote/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000085def F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src),
86 [(set F32:$dst, (fround F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000087 "f32.demote/f64\t$dst, $src">;
Dan Gohmandc51b962015-10-03 02:10:28 +000088
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000089def I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src),
90 [(set I32:$dst, (bitconvert F32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000091 "i32.reinterpret/f32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000092def F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src),
93 [(set F32:$dst, (bitconvert I32:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000094 "f32.reinterpret/i32\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000095def I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src),
96 [(set I64:$dst, (bitconvert F64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +000097 "i64.reinterpret/f64\t$dst, $src">;
Dan Gohmanbc58a7b2015-11-13 00:50:04 +000098def F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src),
99 [(set F64:$dst, (bitconvert I64:$src))],
Dan Gohman1031d4a2015-11-15 15:34:19 +0000100 "f64.reinterpret/i64\t$dst, $src">;
Dan Gohmanfb3e0592015-11-25 19:36:19 +0000101
102} // Defs = [ARGUMENTS]