From: Jordi Vaquero Date: Fri, 5 Jul 2019 17:02:05 +0000 (+0200) Subject: arch-arm: Add TypeAtomicOp class to be used by new atomic instructions X-Git-Tag: v19.0.0.0~685 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5f0ffd5d49ee5907847f398bbd976f0ebb785e36;p=gem5.git arch-arm: Add TypeAtomicOp class to be used by new atomic instructions Creating a new object TypeAtomicOp that will be used by the atomic instructions following gem5 AMO feature. Change-Id: If082b596fb37d7a1cb569a4320c23505591df6a5 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19810 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/arch/arm/insts/mem64.hh b/src/arch/arm/insts/mem64.hh index 8e21bb3b6..34eb43fa9 100644 --- a/src/arch/arm/insts/mem64.hh +++ b/src/arch/arm/insts/mem64.hh @@ -260,6 +260,52 @@ class MemoryLiteral64 : public Memory64 std::string generateDisassembly( 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; +}; + } #endif //__ARCH_ARM_INSTS_MEM_HH__