mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-01 05:38:50 +00:00
CommonFuncs: Generify rotation functions and move them to BitUtils.h
These are bit manipulation functions, so they belong within BitUtils. This also gets rid of duplicated code and avoids relying on compiler reserved names existing or not existing to determine whether or not we define a set of functions. Optimizers are smart enough in GCC and clang to transform the code to a ROR or ROL instruction in the respective functions.
This commit is contained in:
parent
76e1a5b892
commit
c3483a1823
7 changed files with 81 additions and 65 deletions
|
@ -3,8 +3,10 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/Hash.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/Intrinsics.h"
|
||||
|
@ -117,15 +119,15 @@ static u64 getblock(const u64* p, int i)
|
|||
static void bmix64(u64& h1, u64& h2, u64& k1, u64& k2, u64& c1, u64& c2)
|
||||
{
|
||||
k1 *= c1;
|
||||
k1 = _rotl64(k1, 23);
|
||||
k1 = Common::RotateLeft(k1, 23);
|
||||
k1 *= c2;
|
||||
h1 ^= k1;
|
||||
h1 += h2;
|
||||
|
||||
h2 = _rotl64(h2, 41);
|
||||
h2 = Common::RotateLeft(h2, 41);
|
||||
|
||||
k2 *= c2;
|
||||
k2 = _rotl64(k2, 23);
|
||||
k2 = Common::RotateLeft(k2, 23);
|
||||
k2 *= c1;
|
||||
h2 ^= k2;
|
||||
h2 += h1;
|
||||
|
@ -396,15 +398,15 @@ static u32 fmix32(u32 h)
|
|||
static void bmix32(u32& h1, u32& h2, u32& k1, u32& k2, u32& c1, u32& c2)
|
||||
{
|
||||
k1 *= c1;
|
||||
k1 = _rotl(k1, 11);
|
||||
k1 = Common::RotateLeft(k1, 11);
|
||||
k1 *= c2;
|
||||
h1 ^= k1;
|
||||
h1 += h2;
|
||||
|
||||
h2 = _rotl(h2, 17);
|
||||
h2 = Common::RotateLeft(h2, 17);
|
||||
|
||||
k2 *= c2;
|
||||
k2 = _rotl(k2, 11);
|
||||
k2 = Common::RotateLeft(k2, 11);
|
||||
k2 *= c1;
|
||||
h2 ^= k2;
|
||||
h2 += h1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue