Get rid of shlx
This commit is contained in:
parent
4f6fe82936
commit
1d073fe56d
|
@ -424,6 +424,9 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
||||||
|
|
||||||
SaveRegisters(c, {scratch1, scratch2, index, mask});
|
SaveRegisters(c, {scratch1, scratch2, index, mask});
|
||||||
|
|
||||||
|
// Backup rcx temporarily since we need it to shift
|
||||||
|
c.mov(scratch2, rcx);
|
||||||
|
|
||||||
// Get upper 64 bits of src
|
// Get upper 64 bits of src
|
||||||
c.pextrq(index, src, 1);
|
c.pextrq(index, src, 1);
|
||||||
c.mov(mask, index);
|
c.mov(mask, index);
|
||||||
|
@ -437,23 +440,28 @@ static void GenerateINSERTQ(const ZydisDecodedOperand* operands, Xbyak::CodeGene
|
||||||
c.and_(index, 0x3F);
|
c.and_(index, 0x3F);
|
||||||
|
|
||||||
// Create a mask out of the length
|
// Create a mask out of the length
|
||||||
c.mov(scratch1, 1);
|
c.mov(cl, mask.cvt8());
|
||||||
c.shlx(mask, scratch1, mask);
|
c.mov(mask, 1);
|
||||||
c.sub(mask, 1);
|
c.shl(mask, cl);
|
||||||
|
|
||||||
c.movq(scratch1, src);
|
c.movq(scratch1, src);
|
||||||
c.movq(scratch2, dst);
|
|
||||||
|
|
||||||
// src &= mask
|
// src &= mask
|
||||||
c.and_(scratch1, mask);
|
c.and_(scratch1, mask);
|
||||||
|
|
||||||
// dst &= ~(mask << index)
|
// dst &= ~(mask << index)
|
||||||
c.shlx(mask, mask, index);
|
c.mov(cl, index.cvt8());
|
||||||
|
c.shl(mask, cl);
|
||||||
c.not_(mask);
|
c.not_(mask);
|
||||||
c.and_(scratch2, mask);
|
|
||||||
|
|
||||||
// dst |= (src << index)
|
// src <<= index
|
||||||
c.shlx(scratch1, scratch1, index);
|
c.shl(scratch1, cl);
|
||||||
|
|
||||||
|
// Restore rcx
|
||||||
|
c.mov(rcx, scratch2);
|
||||||
|
|
||||||
|
c.movq(scratch2, dst);
|
||||||
|
c.and_(scratch2, mask);
|
||||||
c.or_(scratch2, scratch1);
|
c.or_(scratch2, scratch1);
|
||||||
|
|
||||||
// Insert scratch2 into low 64 bits of dst, upper 64 bits are unaffected
|
// Insert scratch2 into low 64 bits of dst, upper 64 bits are unaffected
|
||||||
|
|
Loading…
Reference in New Issue