Sandipan Das has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/16618

Change subject: arch-power: Add fixed-point arithmetic add instructions
......................................................................

arch-power: Add fixed-point arithmetic add instructions

This adds the following arithmetic instructions:
  * Add PC Immediate Shifted (addpcis)

Change-Id: Id9de59427cbf8578fd75cbb7c98fb767d885d89a
Signed-off-by: Sandipan Das <[email protected]>
---
M src/arch/power/insts/integer.cc
M src/arch/power/insts/integer.hh
M src/arch/power/isa/decoder.isa
M src/arch/power/isa/formats/integer.isa
4 files changed, 89 insertions(+), 0 deletions(-)



diff --git a/src/arch/power/insts/integer.cc b/src/arch/power/insts/integer.cc
index 62a8b26..293efdf 100644
--- a/src/arch/power/insts/integer.cc
+++ b/src/arch/power/insts/integer.cc
@@ -216,6 +216,57 @@


 string
+IntDispArithOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
+{
+    stringstream ss;
+    bool printSrcs = true;
+    bool printDisp = true;
+    bool negateDisp = false;
+
+    // Generate the correct mnemonic
+    string myMnemonic(mnemonic);
+
+    // Special cases
+    if (!myMnemonic.compare("addpcis")) {
+        printSrcs = false;
+        if (disp == 0) {
+            myMnemonic = "lnia";
+            printDisp = false;
+        } else if (disp < 0) {
+            myMnemonic = "subpcis";
+            negateDisp = true;
+        }
+    }
+
+    ccprintf(ss, "%-10s ", myMnemonic);
+
+    // Print the first destination only
+    if (_numDestRegs > 0) {
+        printReg(ss, _destRegIdx[0]);
+    }
+
+    // Print the source register
+    if (_numSrcRegs > 0 && printSrcs) {
+        if (_numDestRegs > 0) {
+            ss << ", ";
+        }
+        printReg(ss, _srcRegIdx[0]);
+    }
+
+    // Print the displacement
+    if (printDisp) {
+        if (negateDisp) {
+            ss << ", " << -disp;
+        } else {
+            ss << ", " << disp;
+        }
+    }
+
+    return ss.str();
+}
+
+
+string
 IntShiftOp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
 {
     stringstream ss;
diff --git a/src/arch/power/insts/integer.hh b/src/arch/power/insts/integer.hh
index 0c15132..4ffd469 100644
--- a/src/arch/power/insts/integer.hh
+++ b/src/arch/power/insts/integer.hh
@@ -183,6 +183,27 @@


 /**
+ * Class for integer arithmetic operations with displacement.
+ */
+class IntDispArithOp : public IntArithOp
+{
+  protected:
+
+    int32_t disp;
+
+    /// Constructor
+    IntDispArithOp(const char *mnem, MachInst _machInst, OpClass __opClass)
+      : IntArithOp(mnem, _machInst, __opClass),
+ disp((int16_t)((machInst.d0 << 6) | (machInst.d1 << 1) | machInst.d2))
+    {
+    }
+
+    std::string generateDisassembly(
+            Addr pc, const SymbolTable *symtab) const override;
+};
+
+
+/**
  * Class for integer operations with a shift.
  */
 class IntShiftOp : public IntOp
diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa
index 7241130..daa265e 100644
--- a/src/arch/power/isa/decoder.isa
+++ b/src/arch/power/isa/decoder.isa
@@ -137,6 +137,12 @@
         format MiscOp {
             150: isync({{ }}, [ IsSerializeAfter ]);
         }
+
+        default: decode DX_XO {
+            format IntDispArithOp {
+                2: addpcis({{ Rt = NIA + (disp << 16); }});
+            }
+        }
     }

     17: IntOp::sc({{ xc->syscall(R0, &fault); }},
diff --git a/src/arch/power/isa/formats/integer.isa b/src/arch/power/isa/formats/integer.isa
index 9bbd65e..54c35eb 100644
--- a/src/arch/power/isa/formats/integer.isa
+++ b/src/arch/power/isa/formats/integer.isa
@@ -212,6 +212,17 @@
 }};


+// Integer instructions with displacement that perform arithmetic.
+// There are no control flags to set.
+def format IntDispArithOp(code, inst_flags = []) {{
+
+    # Generate the class
+    (header_output, decoder_output, decode_block, exec_output) = \
+ GenAluOp(name, Name, 'IntDispArithOp', code, inst_flags, BasicDecode,
+                 BasicConstructor)
+}};
+
+
 // Integer instructions that perform logic operations. The result is
 // always written into Ra. All instructions have 2 versions depending on
 // whether the Rc bit is set to compute the CR0 code. This is determined

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/16618
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Id9de59427cbf8578fd75cbb7c98fb767d885d89a
Gerrit-Change-Number: 16618
Gerrit-PatchSet: 1
Gerrit-Owner: Sandipan Das <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to