Alec Roelke has uploaded this change for review. (
https://gem5-review.googlesource.com/6025
Change subject: arch-riscv: Remove static parts of AMOs out of ISA
......................................................................
arch-riscv: Remove static parts of AMOs out of ISA
This patch removes the static parts of the RISC-V atomic memory
instructions out of the ISA generated code and into arch/riscv/insts. It
also makes the LR and SC instructions subclasses of MemInst from
arch/riscv/insts/mem.hh.
Change-Id: I6591f3d171045c4f1b457eb1264bbb7bd62b3e51
---
M src/arch/riscv/insts/SConscript
A src/arch/riscv/insts/amo.cc
A src/arch/riscv/insts/amo.hh
M src/arch/riscv/isa/formats/amo.isa
M src/arch/riscv/isa/includes.isa
5 files changed, 98 insertions(+), 97 deletions(-)
diff --git a/src/arch/riscv/insts/SConscript
b/src/arch/riscv/insts/SConscript
index 49b31f0..d058f85 100644
--- a/src/arch/riscv/insts/SConscript
+++ b/src/arch/riscv/insts/SConscript
@@ -1,6 +1,7 @@
Import('*')
if env['TARGET_ISA'] == 'riscv':
+ Source('amo.cc')
Source('mem.cc')
Source('standard.cc')
Source('static_inst.cc')
diff --git a/src/arch/riscv/insts/amo.cc b/src/arch/riscv/insts/amo.cc
new file mode 100644
index 0000000..e492281
--- /dev/null
+++ b/src/arch/riscv/insts/amo.cc
@@ -0,0 +1,52 @@
+#include "arch/riscv/insts/amo.hh"
+
+#include <sstream>
+#include <string>
+
+#include "arch/riscv/utility.hh"
+#include "cpu/exec_context.hh"
+#include "cpu/static_inst.hh"
+
+using namespace std;
+
+namespace RiscvISA
+{
+
+string LoadReserved::generateDisassembly(Addr pc,
+ const SymbolTable *symtab) const
+{
+ stringstream ss;
+ ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", ("
+ << registerName(_srcRegIdx[0]) << ')';
+ return ss.str();
+}
+
+string StoreCond::generateDisassembly(Addr pc,
+ const SymbolTable *symtab) const
+{
+ stringstream ss;
+ ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
+ << registerName(_srcRegIdx[1]) << ", ("
+ << registerName(_srcRegIdx[0]) << ')';
+ return ss.str();
+}
+
+string AtomicMemOp::generateDisassembly(Addr pc,
+ const SymbolTable *symtab) const
+{
+ stringstream ss;
+ ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
+ << registerName(_srcRegIdx[1]) << ", ("
+ << registerName(_srcRegIdx[0]) << ')';
+ return ss.str();
+}
+
+string AtomicMemOpMicro::generateDisassembly(Addr pc,
+ const SymbolTable *symtab) const
+{
+ stringstream ss;
+ ss << csprintf("0x%08x", machInst) << ' ' << mnemonic;
+ return ss.str();
+}
+
+}
\ No newline at end of file
diff --git a/src/arch/riscv/insts/amo.hh b/src/arch/riscv/insts/amo.hh
new file mode 100644
index 0000000..6e81722
--- /dev/null
+++ b/src/arch/riscv/insts/amo.hh
@@ -0,0 +1,44 @@
+#ifndef __ARCH_RISCV_INSTS_AMO_HH__
+#define __ARCH_RISCV_INSTS_AMO_HH__
+
+#include <string>
+
+#include "arch/riscv/insts/mem.hh"
+#include "arch/riscv/insts/static_inst.hh"
+#include "cpu/static_inst.hh"
+
+namespace RiscvISA
+{
+
+class LoadReserved : public MemInst
+{
+ protected:
+ using MemInst::MemInst;
+ std::string generateDisassembly(Addr pc, const SymbolTable *symtab)
const;
+};
+
+class StoreCond : public MemInst
+{
+ protected:
+ using MemInst::MemInst;
+ std::string generateDisassembly(Addr pc, const SymbolTable *symtab)
const;
+};
+
+class AtomicMemOp : public RiscvMacroInst
+{
+ protected:
+ using RiscvMacroInst::RiscvMacroInst;
+ std::string generateDisassembly(Addr pc, const SymbolTable *symtab)
const;
+};
+
+class AtomicMemOpMicro : public RiscvMicroInst
+{
+ protected:
+ Request::Flags memAccessFlags;
+ using RiscvMicroInst::RiscvMicroInst;
+ std::string generateDisassembly(Addr pc, const SymbolTable *symtab)
const;
+};
+
+}
+
+#endif // __ARCH_RISCV_INSTS_AMO_HH__
\ No newline at end of file
diff --git a/src/arch/riscv/isa/formats/amo.isa
b/src/arch/riscv/isa/formats/amo.isa
index 80a5faa..ea4e148 100644
--- a/src/arch/riscv/isa/formats/amo.isa
+++ b/src/arch/riscv/isa/formats/amo.isa
@@ -33,103 +33,6 @@
//
// Atomic memory operation instructions
//
-output header {{
- class LoadReserved : public RiscvStaticInst
- {
- protected:
- Request::Flags memAccessFlags;
-
- LoadReserved(const char *mnem, ExtMachInst _machInst,
- OpClass __opClass)
- : RiscvStaticInst(mnem, _machInst, __opClass)
- {}
-
- std::string
- generateDisassembly(Addr pc, const SymbolTable *symtab) const;
- };
-
- class StoreCond : public RiscvStaticInst
- {
- protected:
- Request::Flags memAccessFlags;
-
- StoreCond(const char* mnem, ExtMachInst _machInst, OpClass
__opClass)
- : RiscvStaticInst(mnem, _machInst, __opClass)
- {}
-
- std::string
- generateDisassembly(Addr pc, const SymbolTable *symtab) const;
- };
-
- class AtomicMemOp : public RiscvMacroInst
- {
- protected:
- /// Constructor
- // Each AtomicMemOp has a load and a store phase
- AtomicMemOp(const char *mnem, ExtMachInst _machInst, OpClass
__opClass)
- : RiscvMacroInst(mnem, _machInst, __opClass)
- {}
-
- std::string generateDisassembly(Addr pc,
- const SymbolTable *symtab) const;
- };
-
- class AtomicMemOpMicro : public RiscvMicroInst
- {
- protected:
- /// Memory request flags. See mem/request.hh.
- Request::Flags memAccessFlags;
-
- /// Constructor
- AtomicMemOpMicro(const char *mnem, ExtMachInst _machInst,
- OpClass __opClass)
- : RiscvMicroInst(mnem, _machInst, __opClass)
- {}
-
- std::string generateDisassembly(Addr pc,
- const SymbolTable *symtab) const;
- };
-}};
-
-output decoder {{
- std::string LoadReserved::generateDisassembly(Addr pc,
- const SymbolTable *symtab) const
- {
- std::stringstream ss;
- ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", ("
- << registerName(_srcRegIdx[0]) << ')';
- return ss.str();
- }
-
- std::string StoreCond::generateDisassembly(Addr pc,
- const SymbolTable *symtab) const
- {
- std::stringstream ss;
- ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
- << registerName(_srcRegIdx[1]) << ", ("
- << registerName(_srcRegIdx[0]) << ')';
- return ss.str();
- }
-
- std::string AtomicMemOp::generateDisassembly(Addr pc,
- const SymbolTable *symtab) const
- {
- std::stringstream ss;
- ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
- << registerName(_srcRegIdx[1]) << ", ("
- << registerName(_srcRegIdx[0]) << ')';
- return ss.str();
- }
-
- std::string AtomicMemOpMicro::generateDisassembly(Addr pc,
- const SymbolTable *symtab) const
- {
- std::stringstream ss;
- ss << csprintf("0x%08x", machInst) << ' ' << mnemonic;
- return ss.str();
- }
-}};
-
def template AtomicMemOpDeclare {{
/**
* Static instruction class for an AtomicMemOp operation
diff --git a/src/arch/riscv/isa/includes.isa
b/src/arch/riscv/isa/includes.isa
index 0723620..f4662da 100644
--- a/src/arch/riscv/isa/includes.isa
+++ b/src/arch/riscv/isa/includes.isa
@@ -42,6 +42,7 @@
#include <tuple>
#include <vector>
+#include "arch/riscv/insts/amo.hh"
#include "arch/riscv/insts/mem.hh"
#include "arch/riscv/insts/standard.hh"
#include "arch/riscv/insts/static_inst.hh"
--
To view, visit https://gem5-review.googlesource.com/6025
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6591f3d171045c4f1b457eb1264bbb7bd62b3e51
Gerrit-Change-Number: 6025
Gerrit-PatchSet: 1
Gerrit-Owner: Alec Roelke <ar...@virginia.edu>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev