A64: Handle half-precision floating point in FCVTN

Now that we have IR instructions for performing conversions with
half-precision floating point, we can also handle half-precision values
within FCVTN.
This commit is contained in:
Lioncash 2019-03-23 12:32:01 -04:00 committed by MerryMage
parent 16de99d3e3
commit fac9224d5e

View file

@ -362,22 +362,27 @@ bool TranslatorVisitor::FCVTL(bool Q, bool sz, Vec Vn, Vec Vd) {
} }
bool TranslatorVisitor::FCVTN(bool Q, bool sz, Vec Vn, Vec Vd) { bool TranslatorVisitor::FCVTN(bool Q, bool sz, Vec Vn, Vec Vd) {
// Half-precision not handled directly. const size_t datasize = 64;
if (!sz) { const size_t esize = sz ? 32 : 16;
return InterpretThisInstruction(); const size_t num_elements = datasize / esize;
}
const IR::U128 operand = V(128, Vn); const IR::U128 operand = V(128, Vn);
const auto rounding_mode = ir.current_location->FPCR().RMode(); const auto rounding_mode = ir.current_location->FPCR().RMode();
IR::U128 result = ir.ZeroVector(); IR::U128 result = ir.ZeroVector();
for (size_t i = 0; i < 2; i++) { for (size_t i = 0; i < num_elements; i++) {
const IR::U32 element = ir.FPDoubleToSingle(ir.VectorGetElement(64, operand, i), rounding_mode); IR::U16U32U64 element = ir.VectorGetElement(2 * esize, operand, i);
result = ir.VectorSetElement(32, result, i, element); if (esize == 16) {
element = ir.FPSingleToHalf(element, rounding_mode);
} else if (esize == 32) {
element = ir.FPDoubleToSingle(element, rounding_mode);
}
result = ir.VectorSetElement(esize, result, i, element);
} }
Vpart(64, Vd, Q, result); Vpart(datasize, Vd, Q, result);
return true; return true;
} }