ir: Add helper functions for vector rotation

This commit is contained in:
Lioncash 2018-04-10 14:36:35 -04:00 committed by MerryMage
parent 8a60a63a8b
commit e1b662e90c
2 changed files with 24 additions and 0 deletions

View file

@ -1075,6 +1075,28 @@ U128 IREmitter::VectorReverseBits(const U128& a) {
return Inst<U128>(Opcode::VectorReverseBits, a);
}
U128 IREmitter::VectorRotateLeft(size_t esize, const U128& a, u8 amount) {
ASSERT(amount < esize);
if (amount == 0) {
return a;
}
return VectorOr(VectorLogicalShiftLeft(esize, a, amount),
VectorLogicalShiftRight(esize, a, static_cast<u8>(esize - amount)));
}
U128 IREmitter::VectorRotateRight(size_t esize, const U128& a, u8 amount) {
ASSERT(amount < esize);
if (amount == 0) {
return a;
}
return VectorOr(VectorLogicalShiftRight(esize, a, amount),
VectorLogicalShiftLeft(esize, a, static_cast<u8>(esize - amount)));
}
U128 IREmitter::VectorShuffleHighHalfwords(const U128& a, u8 mask) {
return Inst<U128>(Opcode::VectorShuffleHighHalfwords, a, mask);
}

View file

@ -225,6 +225,8 @@ public:
U128 VectorPairedAddLower(size_t esize, const U128& a, const U128& b);
U128 VectorPopulationCount(const U128& a);
U128 VectorReverseBits(const U128& a);
U128 VectorRotateLeft(size_t esize, const U128& a, u8 amount);
U128 VectorRotateRight(size_t esize, const U128& a, u8 amount);
U128 VectorShuffleHighHalfwords(const U128& a, u8 mask);
U128 VectorShuffleLowHalfwords(const U128& a, u8 mask);
U128 VectorShuffleWords(const U128& a, u8 mask);