From e1b662e90c7264e315c20ead5c8715456ea66067 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Apr 2018 14:36:35 -0400 Subject: [PATCH] ir: Add helper functions for vector rotation --- src/frontend/ir/ir_emitter.cpp | 22 ++++++++++++++++++++++ src/frontend/ir/ir_emitter.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/frontend/ir/ir_emitter.cpp b/src/frontend/ir/ir_emitter.cpp index 635abb21..78c13a39 100644 --- a/src/frontend/ir/ir_emitter.cpp +++ b/src/frontend/ir/ir_emitter.cpp @@ -1075,6 +1075,28 @@ U128 IREmitter::VectorReverseBits(const U128& a) { return Inst(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(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(esize - amount))); +} + U128 IREmitter::VectorShuffleHighHalfwords(const U128& a, u8 mask) { return Inst(Opcode::VectorShuffleHighHalfwords, a, mask); } diff --git a/src/frontend/ir/ir_emitter.h b/src/frontend/ir/ir_emitter.h index c5b8bb14..1819c52c 100644 --- a/src/frontend/ir/ir_emitter.h +++ b/src/frontend/ir/ir_emitter.h @@ -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);