emit_x64_vector_floating_point: Simplify Get*Vector functions

This commit is contained in:
MerryMage 2018-08-03 11:46:11 +01:00
parent bcaced297a
commit 4a1ce797cb

View file

@ -123,31 +123,32 @@ void HandleNaNs(BlockOfCode& code, EmitContext& ctx, std::array<Xbyak::Xmm, narg
code.SwitchToNearCode(); code.SwitchToNearCode();
} }
template<size_t fsize, u64 value>
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<size_t fsize> template<size_t fsize>
Xbyak::Address GetNaNVector(BlockOfCode& code) { Xbyak::Address GetNaNVector(BlockOfCode& code) {
if constexpr (fsize == 32) { using FPT = mp::unsigned_integer_of_size<fsize>;
return code.MConst(xword, 0x7fc0'0000'7fc0'0000, 0x7fc0'0000'7fc0'0000); return GetVectorOf<fsize, FP::FPInfo<FPT>::DefaultNaN()>(code);
} else {
return code.MConst(xword, 0x7ff8'0000'0000'0000, 0x7ff8'0000'0000'0000);
}
} }
template<size_t fsize> template<size_t fsize>
Xbyak::Address GetNegativeZeroVector(BlockOfCode& code) { Xbyak::Address GetNegativeZeroVector(BlockOfCode& code) {
if constexpr (fsize == 32) { using FPT = mp::unsigned_integer_of_size<fsize>;
return code.MConst(xword, 0x8000'0000'8000'0000, 0x8000'0000'8000'0000); return GetVectorOf<fsize, FP::FPInfo<FPT>::Zero(true)>(code);
} else {
return code.MConst(xword, 0x8000'0000'0000'0000, 0x8000'0000'0000'0000);
}
} }
template<size_t fsize> template<size_t fsize>
Xbyak::Address GetSmallestNormalVector(BlockOfCode& code) { Xbyak::Address GetSmallestNormalVector(BlockOfCode& code) {
if constexpr (fsize == 32) { using FPT = mp::unsigned_integer_of_size<fsize>;
return code.MConst(xword, 0x0080'0000'0080'0000, 0x0080'0000'0080'0000); constexpr FPT smallest_normal_number = FP::FPValue<FPT, false, FP::FPInfo<FPT>::exponent_min, FP::FPInfo<FPT>::implicit_leading_bit>();
} else { return GetVectorOf<fsize, smallest_normal_number>(code);
return code.MConst(xword, 0x0010'0000'0000'0000, 0x0010'0000'0000'0000);
}
} }
template<size_t fsize> template<size_t fsize>