From 3225c4075b0ddfd83a9f7a220d39740f86a64f16 Mon Sep 17 00:00:00 2001 From: Giacomo Travaglini Date: Thu, 5 Dec 2019 11:16:12 +0000 Subject: [PATCH] arch, base: Move arm AtomicOpFunctor into the generic header 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 Reviewed-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23564 Reviewed-by: Daniel Carvalho Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/arch/arm/insts/mem64.hh | 67 ------------------------------------- src/base/amo.hh | 63 ++++++++++++++++++++++++++++++++++ 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 -class AtomicGeneric2Op : public TypedAtomicOpFunctor -{ - public: - AtomicGeneric2Op(T _a, std::function _op) - : a(_a), op(_op) - {} - AtomicOpFunctor* clone() override - { - return new AtomicGeneric2Op(*this); - } - void execute(T *b) override - { - op(b, a); - } - private: - T a; - std::function op; - }; - -template -class AtomicGeneric3Op : public TypedAtomicOpFunctor -{ - public: - AtomicGeneric3Op(T _a, T _c, std::function _op) - : a(_a), c(_c), op(_op) - {} - AtomicOpFunctor* clone() override - { - return new AtomicGeneric3Op(*this); - } - void execute(T *b) override - { - op(b, a, c); - } - private: - T a; - T c; - std::function op; -}; - -template -class AtomicGenericPair3Op : public TypedAtomicOpFunctor -{ - public: - AtomicGenericPair3Op(std::array& _a, std::array _c, - std::function&, std::array)> _op) - : a(_a), c(_c), op(_op) - {} - AtomicOpFunctor* clone() override - { - return new AtomicGenericPair3Op(*this); - } - void execute(T* b) override - { - op(b, a, c); - } - private: - std::array a; - std::array c; - std::function&, std::array)> 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 +class AtomicGeneric2Op : public TypedAtomicOpFunctor +{ + public: + AtomicGeneric2Op(T _a, std::function _op) + : a(_a), op(_op) + {} + AtomicOpFunctor* clone() override + { + return new AtomicGeneric2Op(*this); + } + void execute(T *b) override + { + op(b, a); + } + private: + T a; + std::function op; + }; + +template +class AtomicGeneric3Op : public TypedAtomicOpFunctor +{ + public: + AtomicGeneric3Op(T _a, T _c, std::function _op) + : a(_a), c(_c), op(_op) + {} + AtomicOpFunctor* clone() override + { + return new AtomicGeneric3Op(*this); + } + void execute(T *b) override + { + op(b, a, c); + } + private: + T a; + T c; + std::function op; +}; + +template +class AtomicGenericPair3Op : public TypedAtomicOpFunctor +{ + public: + AtomicGenericPair3Op(std::array& _a, std::array _c, + std::function&, std::array)> _op) + : a(_a), c(_c), op(_op) + {} + AtomicOpFunctor* clone() override + { + return new AtomicGenericPair3Op(*this); + } + void execute(T* b) override + { + op(b, a, c); + } + private: + std::array a; + std::array c; + std::function&, std::array)> op; +}; + typedef std::unique_ptr AtomicOpFunctorPtr; #endif // __BASE_AMO_HH__ -- 2.30.2