cpu: Add a pointer to a generic Nop StaticInst.
authorGabe Black <gabeblack@google.com>
Wed, 20 Dec 2017 07:44:39 +0000 (23:44 -0800)
committerGabe Black <gabeblack@google.com>
Fri, 22 Dec 2017 00:27:20 +0000 (00:27 +0000)
This can be used whenever generic code needs a filler instruction that
doesn't do anything.

Change-Id: Ib245d3e880a951e229eb315a09ecc7c47e6ae00f
Reviewed-on: https://gem5-review.googlesource.com/6823
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/cpu/static_inst.cc
src/cpu/static_inst.hh

index d50c9f15daedf85772efbce4190cb09f1130f5ba..cdcd93c587267bac1c448fdda3e4b5dc371b97fa 100644 (file)
 
 #include "sim/core.hh"
 
+namespace {
+
+static TheISA::ExtMachInst nopMachInst;
+
+class NopStaticInst : public StaticInst
+{
+  public:
+    NopStaticInst() : StaticInst("gem5 nop", nopMachInst, No_OpClass)
+    {}
+
+    Fault
+    execute(ExecContext *xc, Trace::InstRecord *traceData) const override
+    {
+        return NoFault;
+    }
+
+    void
+    advancePC(TheISA::PCState &pcState) const override
+    {
+        pcState.advance();
+    }
+
+    std::string
+    generateDisassembly(Addr pc, const SymbolTable *symtab) const override
+    {
+        return mnemonic;
+    }
+
+  private:
+};
+
+}
+
 StaticInstPtr StaticInst::nullStaticInstPtr;
+StaticInstPtr StaticInst::nopStaticInstPtr = new NopStaticInst;
 
 using namespace std;
 
index a4077e1d08e028915c271799b697cd7ef57f7bc0..79f45d8282088f533785370770efd36a81efbfa4 100644 (file)
@@ -205,6 +205,9 @@ class StaticInst : public RefCounted, public StaticInstFlags
     /// Pointer to a statically allocated "null" instruction object.
     static StaticInstPtr nullStaticInstPtr;
 
+    /// Pointer to a statically allocated generic "nop" instruction object.
+    static StaticInstPtr nopStaticInstPtr;
+
     /// The binary machine instruction.
     const ExtMachInst machInst;