From 4a1ce797cb5e8ceb94eb407e118d7df81800ac1a Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 3 Aug 2018 11:46:11 +0100 Subject: [PATCH] emit_x64_vector_floating_point: Simplify Get*Vector functions --- .../emit_x64_vector_floating_point.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/backend_x64/emit_x64_vector_floating_point.cpp b/src/backend_x64/emit_x64_vector_floating_point.cpp index 455f7058..4d468c36 100644 --- a/src/backend_x64/emit_x64_vector_floating_point.cpp +++ b/src/backend_x64/emit_x64_vector_floating_point.cpp @@ -123,31 +123,32 @@ void HandleNaNs(BlockOfCode& code, EmitContext& ctx, std::array +Xbyak::Address GetVectorOf(BlockOfCode& code) { + if constexpr (fsize == 32) { + return code.MConst(xword, (value << 32) | value, (value << 32) | value); + } else { + return code.MConst(xword, value, value); + } +} + template Xbyak::Address GetNaNVector(BlockOfCode& code) { - if constexpr (fsize == 32) { - return code.MConst(xword, 0x7fc0'0000'7fc0'0000, 0x7fc0'0000'7fc0'0000); - } else { - return code.MConst(xword, 0x7ff8'0000'0000'0000, 0x7ff8'0000'0000'0000); - } + using FPT = mp::unsigned_integer_of_size; + return GetVectorOf::DefaultNaN()>(code); } template Xbyak::Address GetNegativeZeroVector(BlockOfCode& code) { - if constexpr (fsize == 32) { - return code.MConst(xword, 0x8000'0000'8000'0000, 0x8000'0000'8000'0000); - } else { - return code.MConst(xword, 0x8000'0000'0000'0000, 0x8000'0000'0000'0000); - } + using FPT = mp::unsigned_integer_of_size; + return GetVectorOf::Zero(true)>(code); } template Xbyak::Address GetSmallestNormalVector(BlockOfCode& code) { - if constexpr (fsize == 32) { - return code.MConst(xword, 0x0080'0000'0080'0000, 0x0080'0000'0080'0000); - } else { - return code.MConst(xword, 0x0010'0000'0000'0000, 0x0010'0000'0000'0000); - } + using FPT = mp::unsigned_integer_of_size; + constexpr FPT smallest_normal_number = FP::FPValue::exponent_min, FP::FPInfo::implicit_leading_bit>(); + return GetVectorOf(code); } template