summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorFiora <fioraaeterna@gmail.com>2015-02-17 08:53:07 -0800
committerFiora <fioraaeterna@gmail.com>2015-02-17 08:53:07 -0800
commit53bf21e15ac1069d9f9bcba56bc579b3ae1c07d9 (patch)
tree15eb78748f3b1c4c7fbe3acf9df857716ba1398c /Source/Core
parent39e121e5517e402ae67b832e2d9937f3d2fdc394 (diff)
parent1162c5344bf412249651a912d2dcbd128fc15276 (diff)
Merge pull request #2066 from lpereira/regcache-with-variadic-tpl
Jit64: Use variadic templates for RegCache locking
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp35
-rw-r--r--Source/Core/Core/PowerPC/Jit64/JitRegCache.h31
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<typename T>
+ void Lock(T p)
+ {
+ regs[p].locked = true;
+ }
+ template<typename T, typename... Args>
+ void Lock(T first, Args... args)
+ {
+ Lock(first);
+ Lock(args...);
+ }
+
+ // these are x64 reg indices
+ template<typename T>
+ void LockX(T x)
+ {
+ if (xregs[x].locked)
+ PanicAlert("RegCache: x %i already locked!", x);
+ xregs[x].locked = true;
+ }
+ template<typename T, typename... Args>
+ void LockX(T first, Args... args)
+ {
+ LockX(first);
+ LockX(args...);
+ }
+
void UnlockAll();
void UnlockAllX();