/src/WasmEdge/include/executor/engine/cast_numeric.ipp
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | #include "executor/executor.h" |
5 | | |
6 | | #include <cmath> |
7 | | #include <cstring> |
8 | | |
9 | | namespace WasmEdge { |
10 | | namespace Executor { |
11 | | |
12 | | // Helper for types transform |
13 | | namespace { |
14 | | template <typename T, size_t B = sizeof(T)> struct TypeFromBytes { |
15 | | using type = T; |
16 | | }; |
17 | | template <typename T> struct TypeFromBytes<T, 8> { |
18 | | using type = |
19 | | typename std::conditional<std::is_signed_v<T>, int8_t, uint8_t>::type; |
20 | | }; |
21 | | template <typename T> struct TypeFromBytes<T, 16> { |
22 | | using type = |
23 | | typename std::conditional<std::is_signed_v<T>, int16_t, uint16_t>::type; |
24 | | }; |
25 | | template <typename T> struct TypeFromBytes<T, 32> { |
26 | | using type = |
27 | | typename std::conditional<std::is_signed_v<T>, int32_t, uint32_t>::type; |
28 | | }; |
29 | | template <typename T, size_t B> |
30 | | using TypeFromBytesT = typename TypeFromBytes<T, B>::type; |
31 | | } // namespace |
32 | | |
33 | | template <typename TIn, typename TOut> |
34 | 0 | TypeUU<TIn, TOut> Executor::runWrapOp(ValVariant &Val) const { |
35 | 0 | Val.emplace<TOut>(static_cast<TOut>(Val.get<TIn>())); |
36 | 0 | return {}; |
37 | 0 | } |
38 | | |
39 | | template <typename TIn, typename TOut> |
40 | | TypeFI<TIn, TOut> Executor::runTruncateOp(const AST::Instruction &Instr, |
41 | 0 | ValVariant &Val) const { |
42 | 0 | TIn Z = Val.get<TIn>(); |
43 | | // If z is a NaN or an infinity, then the result is undefined. |
44 | 0 | if (std::isnan(Z)) { |
45 | 0 | spdlog::error(ErrCode::Value::InvalidConvToInt); |
46 | 0 | spdlog::error(ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset(), |
47 | 0 | {Val}, {ValTypeFromType<TIn>()})); |
48 | 0 | return Unexpect(ErrCode::Value::InvalidConvToInt); |
49 | 0 | } |
50 | 0 | if (std::isinf(Z)) { |
51 | 0 | spdlog::error(ErrCode::Value::IntegerOverflow); |
52 | 0 | spdlog::error(ErrInfo::InfoInstruction(Instr.getOpCode(), Instr.getOffset(), |
53 | 0 | {Val}, {ValTypeFromType<TIn>()})); |
54 | 0 | return Unexpect(ErrCode::Value::IntegerOverflow); |
55 | 0 | } |
56 | | // If trunc(z) is out of range of target type, then the result is undefined. |
57 | 0 | Z = std::trunc(Z); |
58 | 0 | TIn ValTOutMin = static_cast<TIn>(std::numeric_limits<TOut>::min()); |
59 | 0 | TIn ValTOutMax = static_cast<TIn>(std::numeric_limits<TOut>::max()); |
60 | 0 | if constexpr (sizeof(TIn) > sizeof(TOut)) { |
61 | | // Floating precision is better than integer case. |
62 | 0 | if (Z < ValTOutMin || Z > ValTOutMax) { |
63 | 0 | spdlog::error(ErrCode::Value::IntegerOverflow); |
64 | 0 | spdlog::error(ErrInfo::InfoInstruction(Instr.getOpCode(), |
65 | 0 | Instr.getOffset(), {Val}, |
66 | 0 | {ValTypeFromType<TIn>()})); |
67 | 0 | return Unexpect(ErrCode::Value::IntegerOverflow); |
68 | 0 | } |
69 | 0 | } else { |
70 | | // Floating precision is worse than integer case. |
71 | 0 | if (Z < ValTOutMin || Z >= ValTOutMax) { |
72 | 0 | spdlog::error(ErrCode::Value::IntegerOverflow); |
73 | 0 | spdlog::error(ErrInfo::InfoInstruction(Instr.getOpCode(), |
74 | 0 | Instr.getOffset(), {Val}, |
75 | 0 | {ValTypeFromType<TIn>()})); |
76 | 0 | return Unexpect(ErrCode::Value::IntegerOverflow); |
77 | 0 | } |
78 | 0 | } |
79 | | // Else, return trunc(z). Signed case handled. |
80 | 0 | Val.emplace<TOut>(static_cast<TOut>(Z)); |
81 | 0 | return {}; |
82 | 0 | } Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<float, int>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<float, unsigned int>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<double, int>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<double, unsigned int>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<float, long>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<float, unsigned long>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<double, long>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateOp<double, unsigned long>(WasmEdge::AST::Instruction const&, WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const |
83 | | |
84 | | template <typename TIn, typename TOut> |
85 | 0 | TypeFI<TIn, TOut> Executor::runTruncateSatOp(ValVariant &Val) const { |
86 | 0 | TIn Z = Val.get<TIn>(); |
87 | 0 | if (std::isnan(Z)) { |
88 | | // If z is a NaN, return 0. |
89 | 0 | Val.emplace<TOut>(static_cast<TOut>(0)); |
90 | 0 | } else if (std::isinf(Z)) { |
91 | 0 | if (Z < std::numeric_limits<TIn>::lowest()) { |
92 | | // If z is -inf, return min limit. |
93 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::min()); |
94 | 0 | } else { |
95 | | // If z is +inf, return max limit. |
96 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::max()); |
97 | 0 | } |
98 | 0 | } else { |
99 | 0 | Z = std::trunc(Z); |
100 | 0 | TIn ValTOutMin = static_cast<TIn>(std::numeric_limits<TOut>::min()); |
101 | 0 | TIn ValTOutMax = static_cast<TIn>(std::numeric_limits<TOut>::max()); |
102 | 0 | if constexpr (sizeof(TIn) > sizeof(TOut)) { |
103 | | // Floating precision is better than integer case. |
104 | 0 | if (Z < ValTOutMin) { |
105 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::min()); |
106 | 0 | } else if (Z > ValTOutMax) { |
107 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::max()); |
108 | 0 | } else { |
109 | 0 | Val.emplace<TOut>(static_cast<TOut>(Z)); |
110 | 0 | } |
111 | 0 | } else { |
112 | | // Floating precision is worse than integer case. |
113 | 0 | if (Z < ValTOutMin) { |
114 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::min()); |
115 | 0 | } else if (Z >= ValTOutMax) { |
116 | 0 | Val.emplace<TOut>(std::numeric_limits<TOut>::max()); |
117 | 0 | } else { |
118 | 0 | Val.emplace<TOut>(static_cast<TOut>(Z)); |
119 | 0 | } |
120 | 0 | } |
121 | 0 | } |
122 | 0 | return {}; |
123 | 0 | } Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<float, int>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<float, unsigned int>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<double, int>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<double, unsigned int>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<float, long>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<float>)&&(IsWasmIntV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<float, unsigned long>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<double, long>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmFloatV<double>)&&(IsWasmIntV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runTruncateSatOp<double, unsigned long>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const |
124 | | |
125 | | template <typename TIn, typename TOut, size_t B> |
126 | 0 | TypeIU<TIn, TOut> Executor::runExtendOp(ValVariant &Val) const { |
127 | | // Return i extend to TOut. Signed case handled. |
128 | 0 | if constexpr (B == sizeof(TIn) * 8) { |
129 | 0 | Val.emplace<TOut>(static_cast<TOut>(Val.get<TIn>())); |
130 | 0 | } else { |
131 | 0 | Val.emplace<TOut>( |
132 | 0 | static_cast<TOut>(static_cast<TypeFromBytesT<TIn, B>>(Val.get<TIn>()))); |
133 | 0 | } |
134 | 0 | return {}; |
135 | 0 | } Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<int>)&&(IsWasmUnsignV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<int, unsigned long, 32ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<unsigned int>)&&(IsWasmUnsignV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<unsigned int, unsigned long, 32ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<int>)&&(IsWasmUnsignV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<int, unsigned int, 8ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<int>)&&(IsWasmUnsignV<unsigned int>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<int, unsigned int, 16ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<long>)&&(IsWasmUnsignV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<long, unsigned long, 8ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<long>)&&(IsWasmUnsignV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<long, unsigned long, 16ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<long>)&&(IsWasmUnsignV<unsigned long>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runExtendOp<long, unsigned long, 32ul>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const |
136 | | |
137 | | template <typename TIn, typename TOut> |
138 | 0 | TypeIF<TIn, TOut> Executor::runConvertOp(ValVariant &Val) const { |
139 | | // Return i convert to TOut. Signed case handled. |
140 | 0 | Val.emplace<TOut>(static_cast<TOut>(Val.get<TIn>())); |
141 | 0 | return {}; |
142 | 0 | } Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<int>)&&(IsWasmFloatV<float>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<int, float>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<unsigned int>)&&(IsWasmFloatV<float>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<unsigned int, float>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<long>)&&(IsWasmFloatV<float>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<long, float>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<unsigned long>)&&(IsWasmFloatV<float>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<unsigned long, float>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<int>)&&(IsWasmFloatV<double>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<int, double>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<unsigned int>)&&(IsWasmFloatV<double>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<unsigned int, double>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<long>)&&(IsWasmFloatV<double>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<long, double>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<(IsWasmIntV<unsigned long>)&&(IsWasmFloatV<double>), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runConvertOp<unsigned long, double>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const |
143 | | |
144 | | template <typename TIn, typename TOut> |
145 | 0 | TypeFF<TIn, TOut> Executor::runDemoteOp(ValVariant &Val) const { |
146 | | // Return i convert to TOut. (NaN, inf, and zeros handled) |
147 | 0 | Val.emplace<TOut>(static_cast<TOut>(Val.get<TIn>())); |
148 | 0 | return {}; |
149 | 0 | } |
150 | | |
151 | | template <typename TIn, typename TOut> |
152 | 0 | TypeFF<TIn, TOut> Executor::runPromoteOp(ValVariant &Val) const { |
153 | | // Return i convert to TOut. (NaN, inf, and zeros handled) |
154 | 0 | Val.emplace<TOut>(static_cast<TOut>(Val.get<TIn>())); |
155 | 0 | return {}; |
156 | 0 | } |
157 | | |
158 | | template <typename TIn, typename TOut> |
159 | 0 | TypeNN<TIn, TOut> Executor::runReinterpretOp(ValVariant &Val) const { |
160 | | // Return ValVariant with type TOut which copy bits of V. |
161 | 0 | TOut VOut; |
162 | 0 | TIn VIn = Val.get<TIn>(); |
163 | 0 | std::memcpy(&VOut, &VIn, sizeof(TIn)); |
164 | 0 | Val.emplace<TOut>(VOut); |
165 | 0 | return {}; |
166 | 0 | } Unexecuted instantiation: std::__1::enable_if<((IsWasmNativeNumV<float>)&&(IsWasmNativeNumV<unsigned int>))&&((sizeof (float))==(sizeof (unsigned int))), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runReinterpretOp<float, unsigned int>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<((IsWasmNativeNumV<double>)&&(IsWasmNativeNumV<unsigned long>))&&((sizeof (double))==(sizeof (unsigned long))), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runReinterpretOp<double, unsigned long>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<((IsWasmNativeNumV<unsigned int>)&&(IsWasmNativeNumV<float>))&&((sizeof (unsigned int))==(sizeof (float))), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runReinterpretOp<unsigned int, float>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const Unexecuted instantiation: std::__1::enable_if<((IsWasmNativeNumV<unsigned long>)&&(IsWasmNativeNumV<double>))&&((sizeof (unsigned long))==(sizeof (double))), cxx20::expected<void, WasmEdge::ErrCode> >::type WasmEdge::Executor::Executor::runReinterpretOp<unsigned long, double>(WasmEdge::Variant<unsigned int, int, unsigned long, long, float, double, unsigned __int128, __int128, unsigned long __vector(2), long __vector(2), unsigned int __vector(4), int __vector(4), unsigned short __vector(8), short __vector(8), unsigned char __vector(16), signed char __vector(16), float __vector(4), double __vector(2), WasmEdge::RefVariant>&) const |
167 | | |
168 | | } // namespace Executor |
169 | | } // namespace WasmEdge |