summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arch/arm/insts/mem64.hh67
-rw-r--r--src/base/amo.hh63
2 files changed, 63 insertions, 67 deletions
diff --git a/src/arch/arm/insts/mem64.hh b/src/arch/arm/insts/mem64.hh
index 25ef14841..0561dc60d 100644
--- a/src/arch/arm/insts/mem64.hh
+++ b/src/arch/arm/insts/mem64.hh
@@ -264,73 +264,6 @@ class MemoryLiteral64 : public Memory64
Addr pc, const SymbolTable *symtab) const override;
};
-/**
- * A generic atomic op class
- */
-
-template<typename T>
-class AtomicGeneric2Op : public TypedAtomicOpFunctor<T>
-{
- public:
- AtomicGeneric2Op(T _a, std::function<void(T*,T)> _op)
- : a(_a), op(_op)
- {}
- AtomicOpFunctor* clone() override
- {
- return new AtomicGeneric2Op<T>(*this);
- }
- void execute(T *b) override
- {
- op(b, a);
- }
- private:
- T a;
- std::function<void(T*,T)> op;
- };
-
-template<typename T>
-class AtomicGeneric3Op : public TypedAtomicOpFunctor<T>
-{
- public:
- AtomicGeneric3Op(T _a, T _c, std::function<void(T*, T, T)> _op)
- : a(_a), c(_c), op(_op)
- {}
- AtomicOpFunctor* clone() override
- {
- return new AtomicGeneric3Op<T>(*this);
- }
- void execute(T *b) override
- {
- op(b, a, c);
- }
- private:
- T a;
- T c;
- std::function<void(T*, T, T)> op;
-};
-
-template<typename T>
-class AtomicGenericPair3Op : public TypedAtomicOpFunctor<T>
-{
- public:
- AtomicGenericPair3Op(std::array<T, 2>& _a, std::array<T, 2> _c,
- std::function<void(T*, std::array<T, 2>&, std::array<T, 2>)> _op)
- : a(_a), c(_c), op(_op)
- {}
- AtomicOpFunctor* clone() override
- {
- return new AtomicGenericPair3Op<T>(*this);
- }
- void execute(T* b) override
- {
- op(b, a, c);
- }
- private:
- std::array<T, 2> a;
- std::array<T, 2> c;
- std::function<void(T*, std::array<T, 2>&, std::array<T, 2>)> op;
-};
-
}
#endif //__ARCH_ARM_INSTS_MEM_HH__
diff --git a/src/base/amo.hh b/src/base/amo.hh
index 504190e92..624c755ed 100644
--- a/src/base/amo.hh
+++ b/src/base/amo.hh
@@ -46,6 +46,69 @@ struct TypedAtomicOpFunctor : public AtomicOpFunctor
virtual void execute(T * p) = 0;
};
+template<typename T>
+class AtomicGeneric2Op : public TypedAtomicOpFunctor<T>
+{
+ public:
+ AtomicGeneric2Op(T _a, std::function<void(T*,T)> _op)
+ : a(_a), op(_op)
+ {}
+ AtomicOpFunctor* clone() override
+ {
+ return new AtomicGeneric2Op<T>(*this);
+ }
+ void execute(T *b) override
+ {
+ op(b, a);
+ }
+ private:
+ T a;
+ std::function<void(T*,T)> op;
+ };
+
+template<typename T>
+class AtomicGeneric3Op : public TypedAtomicOpFunctor<T>
+{
+ public:
+ AtomicGeneric3Op(T _a, T _c, std::function<void(T*, T, T)> _op)
+ : a(_a), c(_c), op(_op)
+ {}
+ AtomicOpFunctor* clone() override
+ {
+ return new AtomicGeneric3Op<T>(*this);
+ }
+ void execute(T *b) override
+ {
+ op(b, a, c);
+ }
+ private:
+ T a;
+ T c;
+ std::function<void(T*, T, T)> op;
+};
+
+template<typename T>
+class AtomicGenericPair3Op : public TypedAtomicOpFunctor<T>
+{
+ public:
+ AtomicGenericPair3Op(std::array<T, 2>& _a, std::array<T, 2> _c,
+ std::function<void(T*, std::array<T, 2>&, std::array<T, 2>)> _op)
+ : a(_a), c(_c), op(_op)
+ {}
+ AtomicOpFunctor* clone() override
+ {
+ return new AtomicGenericPair3Op<T>(*this);
+ }
+ void execute(T* b) override
+ {
+ op(b, a, c);
+ }
+ private:
+ std::array<T, 2> a;
+ std::array<T, 2> c;
+ std::function<void(T*, std::array<T, 2>&, std::array<T, 2>)> op;
+};
+
typedef std::unique_ptr<AtomicOpFunctor> AtomicOpFunctorPtr;
#endif // __BASE_AMO_HH__