From d84161cbfe968f8b0e67d945fd3669b71c5e73bb Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Thu, 28 Mar 2019 16:42:19 -0700 Subject: Add ParseInt{8,16} functions, for use with SIMD (#1052) --- src/wast-parser.cc | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'src/wast-parser.cc') diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 92beffcc..98c22967 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -1791,47 +1791,33 @@ Result WastParser::ParseSimdV128Const(Const* const_, TokenType token_type) { // the array of bytes: if (integer) { switch(lane_count) { - case 16: { - int32_t value; - result = ParseInt32(s, end, Bitcast(&value), ParseIntType::SignedAndUnsigned); - if (value < static_cast(std::numeric_limits::min()) || - value > static_cast(std::numeric_limits::max())) { - Error(loc, "literal \"%s\" out-of-bounds of i8", literal.text.c_str()); - return Result::Error; - } - *lane_ptr = static_cast(value); + case 16: + result = ParseInt8(s, end, reinterpret_cast(lane_ptr), + ParseIntType::SignedAndUnsigned); break; - } - case 8: { - int32_t value; - result = ParseInt32(s, end, Bitcast(&value), ParseIntType::SignedAndUnsigned); - if (value < static_cast(std::numeric_limits::min()) || - value > static_cast(std::numeric_limits::max())) { - Error(loc, "literal \"%s\" out-of-bounds of i16", literal.text.c_str()); - return Result::Error; - } - *lane_ptr = static_cast(value); + case 8: + result = ParseInt16(s, end, reinterpret_cast(lane_ptr), + ParseIntType::SignedAndUnsigned); break; - } - case 4: { - result = ParseInt32(s, end, Bitcast(lane_ptr), ParseIntType::SignedAndUnsigned); + case 4: + result = ParseInt32(s, end, reinterpret_cast(lane_ptr), + ParseIntType::SignedAndUnsigned); break; - } - case 2: { - result = ParseInt64(s, end, Bitcast(lane_ptr), ParseIntType::SignedAndUnsigned); + case 2: + result = ParseInt64(s, end, reinterpret_cast(lane_ptr), + ParseIntType::SignedAndUnsigned); break; - } } } else { switch(lane_count) { - case 4: { - result = ParseFloat(literal.type, s, end, Bitcast(lane_ptr)); + case 4: + result = ParseFloat(literal.type, s, end, + reinterpret_cast(lane_ptr)); break; - } - case 2: { - result = ParseDouble(literal.type,s, end, Bitcast(lane_ptr)); + case 2: + result = ParseDouble(literal.type, s, end, + reinterpret_cast(lane_ptr)); break; - } } } -- cgit v1.2.3