feat(amd64): encode legacy SSE binaries, imm8 shuffles and MOVQ xmm moves

This commit is contained in:
2026-08-27 22:02:11 +02:00
parent be2ceaafb9
commit 0d62818db7
6 changed files with 84 additions and 0 deletions
+25
View File
@@ -48,6 +48,31 @@ func (e *enc) encodeMov(ops []Operand, size int) error {
}
src, dst := ops[0], ops[1]
// MOVQ with an XMM operand is the SSE2 packed-quadword move, NOT a
// GPR move: mem→xmm and xmm↔xmm encode as F3 0F 7E (reg = dst),
// xmm→mem as 66 0F D6 (rm = xmm). A GPR-move fallback would
// silently emit REX.W 8B with the wrong operand meaning.
_, srcVec := vecReg(src)
dstReg, dstVec := vecReg(dst)
if srcVec || dstVec {
if dstVec {
i := &instr{prefix: 0xF3, opcode: []byte{0x0F, 0x7E}, modrm: -1, sib: -1}
if err := setRM(i, dstReg, src, 8); err != nil {
return err
}
return e.emit(i)
}
srcXMM, srcIsXMM := src.(Reg)
if !srcIsXMM || !srcXMM.isVec() {
return fmt.Errorf("MOVQ: store needs an XMM source")
}
i := &instr{prefix: 0x66, opcode: []byte{0x0F, 0xD6}, modrm: -1, sib: -1}
if err := setRM(i, srcXMM, dst, 8); err != nil {
return err
}
return e.emit(i)
}
dstReg, dstIsReg := dst.(Reg)
switch src := src.(type) {
case Reg: