2015-07-11 02:23:10 +08:00
|
|
|
//===-- WebAssemblyInstrConv.td-WebAssembly Conversion support -*- tablegen -*-=
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief WebAssembly datatype conversions, truncations, reinterpretations,
|
|
|
|
/// promotions, and demotions operand code-gen constructs.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-11-26 03:36:19 +08:00
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src),
|
|
|
|
[(set I32:$dst, (trunc I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.wrap/i64\t$dst, $src", 0xa7>;
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src),
|
|
|
|
[(set I64:$dst, (sext I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.extend_s/i32\t$dst, $src", 0xac>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src),
|
|
|
|
[(set I64:$dst, (zext I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.extend_u/i32\t$dst, $src", 0xad>;
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2017-09-13 08:29:06 +08:00
|
|
|
let Predicates = [HasAtomics] in {
|
|
|
|
def I32_EXTEND8_S_I32 : I<(outs I32:$dst), (ins I32:$src),
|
|
|
|
[(set I32:$dst, (sext_inreg I32:$src, i8))],
|
|
|
|
"i32.extend8_s\t$dst, $src", 0xc0>;
|
|
|
|
def I32_EXTEND16_S_I32 : I<(outs I32:$dst), (ins I32:$src),
|
|
|
|
[(set I32:$dst, (sext_inreg I32:$src, i16))],
|
|
|
|
"i32.extend16_s\t$dst, $src", 0xc1>;
|
|
|
|
def I64_EXTEND8_S_I64 : I<(outs I64:$dst), (ins I64:$src),
|
|
|
|
[(set I64:$dst, (sext_inreg I64:$src, i8))],
|
|
|
|
"i64.extend8_s\t$dst, $src", 0xc2>;
|
|
|
|
def I64_EXTEND16_S_I64 : I<(outs I64:$dst), (ins I64:$src),
|
|
|
|
[(set I64:$dst, (sext_inreg I64:$src, i16))],
|
|
|
|
"i64.extend16_s\t$dst, $src", 0xc3>;
|
|
|
|
def I64_EXTEND32_S_I64 : I<(outs I64:$dst), (ins I64:$src),
|
|
|
|
[(set I64:$dst, (sext_inreg I64:$src, i32))],
|
|
|
|
"i64.extend32_s\t$dst, $src", 0xc4>;
|
|
|
|
} // Predicates = [HasAtomics]
|
|
|
|
|
2015-12-10 08:17:35 +08:00
|
|
|
} // defs = [ARGUMENTS]
|
|
|
|
|
|
|
|
// Expand a "don't care" extend into zero-extend (chosen over sign-extend
|
|
|
|
// somewhat arbitrarily, although it favors popular hardware architectures
|
|
|
|
// and is conceptually a simpler operation).
|
|
|
|
def : Pat<(i64 (anyext I32:$src)), (I64_EXTEND_U_I32 I32:$src)>;
|
|
|
|
|
|
|
|
let Defs = [ARGUMENTS] in {
|
|
|
|
|
2015-11-30 06:59:19 +08:00
|
|
|
// Conversion from floating point to integer traps on overflow and invalid.
|
|
|
|
let hasSideEffects = 1 in {
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src),
|
|
|
|
[(set I32:$dst, (fp_to_sint F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.trunc_s/f32\t$dst, $src", 0xa8>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src),
|
|
|
|
[(set I32:$dst, (fp_to_uint F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.trunc_u/f32\t$dst, $src", 0xa9>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src),
|
|
|
|
[(set I64:$dst, (fp_to_sint F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.trunc_s/f32\t$dst, $src", 0xae>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src),
|
|
|
|
[(set I64:$dst, (fp_to_uint F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.trunc_u/f32\t$dst, $src", 0xaf>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src),
|
|
|
|
[(set I32:$dst, (fp_to_sint F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.trunc_s/f64\t$dst, $src", 0xaa>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src),
|
|
|
|
[(set I32:$dst, (fp_to_uint F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.trunc_u/f64\t$dst, $src", 0xab>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src),
|
|
|
|
[(set I64:$dst, (fp_to_sint F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.trunc_s/f64\t$dst, $src", 0xb0>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src),
|
|
|
|
[(set I64:$dst, (fp_to_uint F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.trunc_u/f64\t$dst, $src", 0xb1>;
|
2015-11-30 06:59:19 +08:00
|
|
|
} // hasSideEffects = 1
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src),
|
|
|
|
[(set F32:$dst, (sint_to_fp I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.convert_s/i32\t$dst, $src", 0xb2>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src),
|
|
|
|
[(set F32:$dst, (uint_to_fp I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.convert_u/i32\t$dst, $src", 0xb3>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src),
|
|
|
|
[(set F64:$dst, (sint_to_fp I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.convert_s/i32\t$dst, $src", 0xb7>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src),
|
|
|
|
[(set F64:$dst, (uint_to_fp I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.convert_u/i32\t$dst, $src", 0xb8>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src),
|
|
|
|
[(set F32:$dst, (sint_to_fp I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.convert_s/i64\t$dst, $src", 0xb4>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src),
|
|
|
|
[(set F32:$dst, (uint_to_fp I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.convert_u/i64\t$dst, $src", 0xb5>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src),
|
|
|
|
[(set F64:$dst, (sint_to_fp I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.convert_s/i64\t$dst, $src", 0xb9>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src),
|
|
|
|
[(set F64:$dst, (uint_to_fp I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.convert_u/i64\t$dst, $src", 0xba>;
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src),
|
2016-08-19 04:08:15 +08:00
|
|
|
[(set F64:$dst, (fpextend F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.promote/f32\t$dst, $src", 0xbb>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src),
|
2016-08-19 04:08:15 +08:00
|
|
|
[(set F32:$dst, (fpround F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.demote/f64\t$dst, $src", 0xb6>;
|
2015-10-03 10:10:28 +08:00
|
|
|
|
2015-11-13 08:50:04 +08:00
|
|
|
def I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src),
|
|
|
|
[(set I32:$dst, (bitconvert F32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i32.reinterpret/f32\t$dst, $src", 0xbc>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src),
|
|
|
|
[(set F32:$dst, (bitconvert I32:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f32.reinterpret/i32\t$dst, $src", 0xbe>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src),
|
|
|
|
[(set I64:$dst, (bitconvert F64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"i64.reinterpret/f64\t$dst, $src", 0xbd>;
|
2015-11-13 08:50:04 +08:00
|
|
|
def F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src),
|
|
|
|
[(set F64:$dst, (bitconvert I64:$src))],
|
2016-10-25 04:21:49 +08:00
|
|
|
"f64.reinterpret/i64\t$dst, $src", 0xbf>;
|
2015-11-26 03:36:19 +08:00
|
|
|
|
|
|
|
} // Defs = [ARGUMENTS]
|