mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06: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:
@ -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;
|
||||
|
Reference in New Issue
Block a user