JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 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 | |
Dan Gohman | fb3e059 | 2015-11-25 19:36:19 +0000 | [diff] [blame] | 16 | let Defs = [ARGUMENTS] in { |
| 17 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 18 | def I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src), |
| 19 | [(set I32:$dst, (trunc I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 20 | "i32.wrap/i64\t$dst, $src">; |
Dan Gohman | dc51b96 | 2015-10-03 02:10:28 +0000 | [diff] [blame] | 21 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 22 | def I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src), |
| 23 | [(set I64:$dst, (sext I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 24 | "i64.extend_s/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 25 | def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src), |
| 26 | [(set I64:$dst, (zext I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 27 | "i64.extend_u/i32\t$dst, $src">; |
Dan Gohman | dc51b96 | 2015-10-03 02:10:28 +0000 | [diff] [blame] | 28 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 29 | def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src), |
| 30 | [(set I32:$dst, (fp_to_sint F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 31 | "i32.trunc_s/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 32 | def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src), |
| 33 | [(set I32:$dst, (fp_to_uint F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 34 | "i32.trunc_u/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 35 | def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src), |
| 36 | [(set I64:$dst, (fp_to_sint F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 37 | "i64.trunc_s/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 38 | def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src), |
| 39 | [(set I64:$dst, (fp_to_uint F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 40 | "i64.trunc_u/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 41 | def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src), |
| 42 | [(set I32:$dst, (fp_to_sint F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 43 | "i32.trunc_s/f64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 44 | def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src), |
| 45 | [(set I32:$dst, (fp_to_uint F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 46 | "i32.trunc_u/f64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 47 | def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src), |
| 48 | [(set I64:$dst, (fp_to_sint F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 49 | "i64.trunc_s/f64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 50 | def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src), |
| 51 | [(set I64:$dst, (fp_to_uint F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 52 | "i64.trunc_u/f64\t$dst, $src">; |
Dan Gohman | dc51b96 | 2015-10-03 02:10:28 +0000 | [diff] [blame] | 53 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 54 | def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src), |
| 55 | [(set F32:$dst, (sint_to_fp I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 56 | "f32.convert_s/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 57 | def F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src), |
| 58 | [(set F32:$dst, (uint_to_fp I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 59 | "f32.convert_u/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 60 | def F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src), |
| 61 | [(set F64:$dst, (sint_to_fp I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 62 | "f64.convert_s/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 63 | def F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src), |
| 64 | [(set F64:$dst, (uint_to_fp I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 65 | "f64.convert_u/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 66 | def F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src), |
| 67 | [(set F32:$dst, (sint_to_fp I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 68 | "f32.convert_s/i64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 69 | def F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src), |
| 70 | [(set F32:$dst, (uint_to_fp I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 71 | "f32.convert_u/i64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 72 | def F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src), |
| 73 | [(set F64:$dst, (sint_to_fp I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 74 | "f64.convert_s/i64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 75 | def F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src), |
| 76 | [(set F64:$dst, (uint_to_fp I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 77 | "f64.convert_u/i64\t$dst, $src">; |
Dan Gohman | dc51b96 | 2015-10-03 02:10:28 +0000 | [diff] [blame] | 78 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 79 | def F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src), |
| 80 | [(set F64:$dst, (fextend F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 81 | "f64.promote/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 82 | def F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src), |
| 83 | [(set F32:$dst, (fround F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 84 | "f32.demote/f64\t$dst, $src">; |
Dan Gohman | dc51b96 | 2015-10-03 02:10:28 +0000 | [diff] [blame] | 85 | |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 86 | def I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src), |
| 87 | [(set I32:$dst, (bitconvert F32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 88 | "i32.reinterpret/f32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 89 | def F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src), |
| 90 | [(set F32:$dst, (bitconvert I32:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 91 | "f32.reinterpret/i32\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 92 | def I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src), |
| 93 | [(set I64:$dst, (bitconvert F64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 94 | "i64.reinterpret/f64\t$dst, $src">; |
Dan Gohman | bc58a7b | 2015-11-13 00:50:04 +0000 | [diff] [blame] | 95 | def F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src), |
| 96 | [(set F64:$dst, (bitconvert I64:$src))], |
Dan Gohman | 1031d4a | 2015-11-15 15:34:19 +0000 | [diff] [blame] | 97 | "f64.reinterpret/i64\t$dst, $src">; |
Dan Gohman | fb3e059 | 2015-11-25 19:36:19 +0000 | [diff] [blame] | 98 | |
| 99 | } // Defs = [ARGUMENTS] |