From 1162c5344bf412249651a912d2dcbd128fc15276 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Mon, 16 Feb 2015 23:32:25 -0200 Subject: [PATCH] Jit64: Use variadic templates for RegCache locking --- .../Core/Core/PowerPC/Jit64/JitRegCache.cpp | 35 ------------------- Source/Core/Core/PowerPC/Jit64/JitRegCache.h | 31 ++++++++++++++-- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index 334c46379e..04ca255176 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -48,41 +48,6 @@ void RegCache::Start() //But only preload IF written OR reads >= 3 } -// these are powerpc reg indices -void RegCache::Lock(int p1, int p2, int p3, int p4) -{ - regs[p1].locked = true; - - if (p2 != 0xFF) - regs[p2].locked = true; - - if (p3 != 0xFF) - regs[p3].locked = true; - - if (p4 != 0xFF) - regs[p4].locked = true; -} - -// these are x64 reg indices -void RegCache::LockX(int x1, int x2, int x3, int x4) -{ - if (xregs[x1].locked) - { - PanicAlert("RegCache: x %i already locked!", x1); - } - - xregs[x1].locked = true; - - if (x2 != 0xFF) - xregs[x2].locked = true; - - if (x3 != 0xFF) - xregs[x3].locked = true; - - if (x4 != 0xFF) - xregs[x4].locked = true; -} - void RegCache::UnlockAll() { for (auto& reg : regs) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h index 0e2f2ea687..c9ceab2f13 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h @@ -109,8 +109,35 @@ public: virtual Gen::OpArg GetDefaultLocation(size_t reg) const = 0; // Register locking. - void Lock(int p1, int p2=0xff, int p3=0xff, int p4=0xff); - void LockX(int x1, int x2=0xff, int x3=0xff, int x4=0xff); + + // these are powerpc reg indices + template + void Lock(T p) + { + regs[p].locked = true; + } + template + void Lock(T first, Args... args) + { + Lock(first); + Lock(args...); + } + + // these are x64 reg indices + template + void LockX(T x) + { + if (xregs[x].locked) + PanicAlert("RegCache: x %i already locked!", x); + xregs[x].locked = true; + } + template + void LockX(T first, Args... args) + { + LockX(first); + LockX(args...); + } + void UnlockAll(); void UnlockAllX();