ir: Add helper functions for vector rotation
This commit is contained in:
parent
8a60a63a8b
commit
e1b662e90c
2 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue