1*9880d681SAndroid Build Coastguard Worker//===-- WebAssemblyInstrConv.td-WebAssembly Conversion support -*- tablegen -*-= 2*9880d681SAndroid Build Coastguard Worker// 3*9880d681SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker// 5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker// 8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker/// 10*9880d681SAndroid Build Coastguard Worker/// \file 11*9880d681SAndroid Build Coastguard Worker/// \brief WebAssembly datatype conversions, truncations, reinterpretations, 12*9880d681SAndroid Build Coastguard Worker/// promotions, and demotions operand code-gen constructs. 13*9880d681SAndroid Build Coastguard Worker/// 14*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in { 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerdef I32_WRAP_I64 : I<(outs I32:$dst), (ins I64:$src), 19*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (trunc I64:$src))], 20*9880d681SAndroid Build Coastguard Worker "i32.wrap/i64\t$dst, $src">; 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Workerdef I64_EXTEND_S_I32 : I<(outs I64:$dst), (ins I32:$src), 23*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (sext I32:$src))], 24*9880d681SAndroid Build Coastguard Worker "i64.extend_s/i32\t$dst, $src">; 25*9880d681SAndroid Build Coastguard Workerdef I64_EXTEND_U_I32 : I<(outs I64:$dst), (ins I32:$src), 26*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (zext I32:$src))], 27*9880d681SAndroid Build Coastguard Worker "i64.extend_u/i32\t$dst, $src">; 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker} // defs = [ARGUMENTS] 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker// Expand a "don't care" extend into zero-extend (chosen over sign-extend 32*9880d681SAndroid Build Coastguard Worker// somewhat arbitrarily, although it favors popular hardware architectures 33*9880d681SAndroid Build Coastguard Worker// and is conceptually a simpler operation). 34*9880d681SAndroid Build Coastguard Workerdef : Pat<(i64 (anyext I32:$src)), (I64_EXTEND_U_I32 I32:$src)>; 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerlet Defs = [ARGUMENTS] in { 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Worker// Conversion from floating point to integer traps on overflow and invalid. 39*9880d681SAndroid Build Coastguard Workerlet hasSideEffects = 1 in { 40*9880d681SAndroid Build Coastguard Workerdef I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src), 41*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (fp_to_sint F32:$src))], 42*9880d681SAndroid Build Coastguard Worker "i32.trunc_s/f32\t$dst, $src">; 43*9880d681SAndroid Build Coastguard Workerdef I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src), 44*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (fp_to_uint F32:$src))], 45*9880d681SAndroid Build Coastguard Worker "i32.trunc_u/f32\t$dst, $src">; 46*9880d681SAndroid Build Coastguard Workerdef I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src), 47*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (fp_to_sint F32:$src))], 48*9880d681SAndroid Build Coastguard Worker "i64.trunc_s/f32\t$dst, $src">; 49*9880d681SAndroid Build Coastguard Workerdef I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src), 50*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (fp_to_uint F32:$src))], 51*9880d681SAndroid Build Coastguard Worker "i64.trunc_u/f32\t$dst, $src">; 52*9880d681SAndroid Build Coastguard Workerdef I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src), 53*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (fp_to_sint F64:$src))], 54*9880d681SAndroid Build Coastguard Worker "i32.trunc_s/f64\t$dst, $src">; 55*9880d681SAndroid Build Coastguard Workerdef I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src), 56*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (fp_to_uint F64:$src))], 57*9880d681SAndroid Build Coastguard Worker "i32.trunc_u/f64\t$dst, $src">; 58*9880d681SAndroid Build Coastguard Workerdef I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src), 59*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (fp_to_sint F64:$src))], 60*9880d681SAndroid Build Coastguard Worker "i64.trunc_s/f64\t$dst, $src">; 61*9880d681SAndroid Build Coastguard Workerdef I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src), 62*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (fp_to_uint F64:$src))], 63*9880d681SAndroid Build Coastguard Worker "i64.trunc_u/f64\t$dst, $src">; 64*9880d681SAndroid Build Coastguard Worker} // hasSideEffects = 1 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Workerdef F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src), 67*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (sint_to_fp I32:$src))], 68*9880d681SAndroid Build Coastguard Worker "f32.convert_s/i32\t$dst, $src">; 69*9880d681SAndroid Build Coastguard Workerdef F32_CONVERT_U_I32 : I<(outs F32:$dst), (ins I32:$src), 70*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (uint_to_fp I32:$src))], 71*9880d681SAndroid Build Coastguard Worker "f32.convert_u/i32\t$dst, $src">; 72*9880d681SAndroid Build Coastguard Workerdef F64_CONVERT_S_I32 : I<(outs F64:$dst), (ins I32:$src), 73*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (sint_to_fp I32:$src))], 74*9880d681SAndroid Build Coastguard Worker "f64.convert_s/i32\t$dst, $src">; 75*9880d681SAndroid Build Coastguard Workerdef F64_CONVERT_U_I32 : I<(outs F64:$dst), (ins I32:$src), 76*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (uint_to_fp I32:$src))], 77*9880d681SAndroid Build Coastguard Worker "f64.convert_u/i32\t$dst, $src">; 78*9880d681SAndroid Build Coastguard Workerdef F32_CONVERT_S_I64 : I<(outs F32:$dst), (ins I64:$src), 79*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (sint_to_fp I64:$src))], 80*9880d681SAndroid Build Coastguard Worker "f32.convert_s/i64\t$dst, $src">; 81*9880d681SAndroid Build Coastguard Workerdef F32_CONVERT_U_I64 : I<(outs F32:$dst), (ins I64:$src), 82*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (uint_to_fp I64:$src))], 83*9880d681SAndroid Build Coastguard Worker "f32.convert_u/i64\t$dst, $src">; 84*9880d681SAndroid Build Coastguard Workerdef F64_CONVERT_S_I64 : I<(outs F64:$dst), (ins I64:$src), 85*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (sint_to_fp I64:$src))], 86*9880d681SAndroid Build Coastguard Worker "f64.convert_s/i64\t$dst, $src">; 87*9880d681SAndroid Build Coastguard Workerdef F64_CONVERT_U_I64 : I<(outs F64:$dst), (ins I64:$src), 88*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (uint_to_fp I64:$src))], 89*9880d681SAndroid Build Coastguard Worker "f64.convert_u/i64\t$dst, $src">; 90*9880d681SAndroid Build Coastguard Worker 91*9880d681SAndroid Build Coastguard Workerdef F64_PROMOTE_F32 : I<(outs F64:$dst), (ins F32:$src), 92*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (fextend F32:$src))], 93*9880d681SAndroid Build Coastguard Worker "f64.promote/f32\t$dst, $src">; 94*9880d681SAndroid Build Coastguard Workerdef F32_DEMOTE_F64 : I<(outs F32:$dst), (ins F64:$src), 95*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (fround F64:$src))], 96*9880d681SAndroid Build Coastguard Worker "f32.demote/f64\t$dst, $src">; 97*9880d681SAndroid Build Coastguard Worker 98*9880d681SAndroid Build Coastguard Workerdef I32_REINTERPRET_F32 : I<(outs I32:$dst), (ins F32:$src), 99*9880d681SAndroid Build Coastguard Worker [(set I32:$dst, (bitconvert F32:$src))], 100*9880d681SAndroid Build Coastguard Worker "i32.reinterpret/f32\t$dst, $src">; 101*9880d681SAndroid Build Coastguard Workerdef F32_REINTERPRET_I32 : I<(outs F32:$dst), (ins I32:$src), 102*9880d681SAndroid Build Coastguard Worker [(set F32:$dst, (bitconvert I32:$src))], 103*9880d681SAndroid Build Coastguard Worker "f32.reinterpret/i32\t$dst, $src">; 104*9880d681SAndroid Build Coastguard Workerdef I64_REINTERPRET_F64 : I<(outs I64:$dst), (ins F64:$src), 105*9880d681SAndroid Build Coastguard Worker [(set I64:$dst, (bitconvert F64:$src))], 106*9880d681SAndroid Build Coastguard Worker "i64.reinterpret/f64\t$dst, $src">; 107*9880d681SAndroid Build Coastguard Workerdef F64_REINTERPRET_I64 : I<(outs F64:$dst), (ins I64:$src), 108*9880d681SAndroid Build Coastguard Worker [(set F64:$dst, (bitconvert I64:$src))], 109*9880d681SAndroid Build Coastguard Worker "f64.reinterpret/i64\t$dst, $src">; 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker} // Defs = [ARGUMENTS] 112