target/i386: implement FMA instructions
A message that is not in the archive (sent off-list or not yet received): [email protected]
Richard Henderson
Reviewed-byQuoted 18 lines · Paolo Bonzini
The only issue with FMA instructions is that there
are_alot_of them (30 opcodes, each of which comes in up to 4 versions depending on VEX.W and VEX.L; a total of 96 possibilities). However, they can be implement with only 6 helpers, two for scalar operations and four for packed operations. (Scalar versions do not do any merging; they only affect the bottom 32 or 64 bits of the output operand. Therefore, there is no separate XMM and YMM of the scalar helpers).First, we can reduce the number of helpers to one third by passing four operands (one output and three inputs); the reordering of which operands go to the multiply and which go to the add is done in
emit.c.Second, the different instructions also dispatch to the same softfloat function, so the flags for
float32_muladdandfloat64_muladdare passed in the helper as int arguments, with a little extra complication to handle FMADDSUB and FMSUBADD.Signed-off-by Paolo Bonzini<[email protected]>
Quoted 10 lines
--- target/i386/cpu.c | 5 ++-- target/i386/ops_sse.h | 27 +++++++++++++++++ target/i386/ops_sse_header.h | 11 +++++++ target/i386/tcg/decode-new.c.inc | 40 +++++++++++++++++++++++++ target/i386/tcg/decode-new.h | 1 + target/i386/tcg/emit.c.inc | 51 ++++++++++++++++++++++++++++++++ target/i386/tcg/translate.c | 1 + tests/tcg/i386/test-avx.py | 2 +- 8 files changed, 135 insertions(+), 3 deletions(-)
r~