arch, base: Move arm AtomicOpFunctor into the generic header
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Thu, 5 Dec 2019 11:16:12 +0000 (11:16 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 8 Jan 2020 09:32:08 +0000 (09:32 +0000)
These AtomicGenericxOp functors are not arm specific:
They just define a set of different functors depending
on the number of operands they are using.

Change-Id: Ida75066823c7718aee05717194cdb8225b700c5d
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23564
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/insts/mem64.hh
src/base/amo.hh

index 25ef1484108e9897064b8d4e52e3bc30f9cf780a..0561dc60dd42b53a8d6e7532ecb572926d4c1556 100644 (file)
@@ -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__
index 504190e92a7df1a2fbd1a7da4d8b788417f3a135..624c755ed519ad4b477701e9e234994c1925b62a 100644 (file)
@@ -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__