summaryrefslogtreecommitdiff
path: root/src/arch/riscv/insts/amo.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/riscv/insts/amo.hh')
-rw-r--r--src/arch/riscv/insts/amo.hh65
1 files changed, 60 insertions, 5 deletions
diff --git a/src/arch/riscv/insts/amo.hh b/src/arch/riscv/insts/amo.hh
index 7c07bc243..748fe14a3 100644
--- a/src/arch/riscv/insts/amo.hh
+++ b/src/arch/riscv/insts/amo.hh
@@ -41,24 +41,62 @@
namespace RiscvISA
{
-class LoadReserved : public MemInst
+// memfence micro instruction
+class MemFenceMicro : public RiscvMicroInst
{
+ public:
+ MemFenceMicro(ExtMachInst _machInst, OpClass __opClass)
+ : RiscvMicroInst("fence", _machInst, __opClass)
+ { }
protected:
- using MemInst::MemInst;
+ using RiscvMicroInst::RiscvMicroInst;
+ Fault execute(ExecContext *, Trace::InstRecord *) const override;
std::string generateDisassembly(
Addr pc, const SymbolTable *symtab) const override;
};
-class StoreCond : public MemInst
+// load-reserved
+class LoadReserved : public RiscvMacroInst
{
protected:
- using MemInst::MemInst;
+ using RiscvMacroInst::RiscvMacroInst;
std::string generateDisassembly(
Addr pc, const SymbolTable *symtab) const override;
};
+class LoadReservedMicro : public RiscvMicroInst
+{
+ protected:
+ Request::Flags memAccessFlags;
+ using RiscvMicroInst::RiscvMicroInst;
+
+ std::string generateDisassembly(
+ Addr pc, const SymbolTable *symtab) const override;
+};
+
+// store-cond
+class StoreCond : public RiscvMacroInst
+{
+ protected:
+ using RiscvMacroInst::RiscvMacroInst;
+
+ std::string generateDisassembly(
+ Addr pc, const SymbolTable *symtab) const override;
+};
+
+class StoreCondMicro : public RiscvMicroInst
+{
+ protected:
+ Request::Flags memAccessFlags;
+ using RiscvMicroInst::RiscvMicroInst;
+
+ std::string generateDisassembly(
+ Addr pc, const SymbolTable *symtab) const override;
+};
+
+// AMOs
class AtomicMemOp : public RiscvMacroInst
{
protected:
@@ -78,6 +116,23 @@ class AtomicMemOpMicro : public RiscvMicroInst
Addr pc, const SymbolTable *symtab) const override;
};
+/**
+ * A generic atomic op class
+ */
+
+template<typename T>
+class AtomicGenericOp : public TypedAtomicOpFunctor<T>
+{
+ public:
+ AtomicGenericOp(T _a, std::function<void(T*,T)> _op)
+ : a(_a), op(_op) { }
+ AtomicOpFunctor* clone() { return new AtomicGenericOp<T>(*this); }
+ void execute(T *b) { op(b, a); }
+ private:
+ T a;
+ std::function<void(T*,T)> op;
+};
+
}
-#endif // __ARCH_RISCV_INSTS_AMO_HH__ \ No newline at end of file
+#endif // __ARCH_RISCV_INSTS_AMO_HH__