arch-power: Refactor rotate instructions
authorSandipan Das <sandipan@linux.ibm.com>
Sat, 6 Feb 2021 11:51:57 +0000 (17:21 +0530)
committerSandipan Das <sandipan@linux.ibm.com>
Mon, 15 Feb 2021 08:32:38 +0000 (14:02 +0530)
This renames the mask span fields and the rotate helper
of the base class.

Change-Id: I120006a0c052fcc34eb154a68d4b7f70a464df65
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
src/arch/power/insts/integer.cc
src/arch/power/insts/integer.hh
src/arch/power/isa/decoder.isa
src/arch/power/isa/formats/integer.isa

index fc429117c3cc591e8782354ed51b7673b2453be0..d921b5d1b08c07135b7a53b1e07d22cd71df6a96 100644 (file)
@@ -729,7 +729,7 @@ IntRotateOp::generateDisassembly(
     }
 
     // Print the shift, mask begin and mask end
-    ss << ", " << sh << ", " << mb << ", " << me;
+    ss << ", " << sh << ", " << maskBeg << ", " << maskEnd;
 
     return ss.str();
 }
index aab6910bca35a79481353f6d801d9413b12b8aa0..d96936291aebd1df6c51a0195e121e4974176517 100644 (file)
@@ -643,31 +643,33 @@ class IntConcatShiftOp : public IntOp
 
 
 /**
- * Class for integer rotate operations.
+ * Class for integer rotate operations with a shift amount obtained
+ * from a register or an immediate and the first and last bits of a
+ * mask obtained from immediates.
  */
 class IntRotateOp : public IntShiftOp
 {
   protected:
 
-    uint32_t mb;
-    uint32_t me;
     uint32_t fullMask;
+    uint32_t maskBeg;
+    uint32_t maskEnd;
 
     /// Constructor
     IntRotateOp(const char *mnem, MachInst _machInst, OpClass __opClass)
       : IntShiftOp(mnem, _machInst, __opClass),
-        mb(machInst.mb),
-        me(machInst.me)
+        maskBeg(machInst.mb),
+        maskEnd(machInst.me)
     {
-        if (me >= mb) {
-            fullMask = mask(31 - mb, 31 - me);
+        if (maskEnd >= maskBeg) {
+            fullMask = mask(31 - maskBeg, 31 - maskEnd);
         } else {
-            fullMask = ~mask(31 - (me + 1), 31 - (mb - 1));
+            fullMask = ~mask(31 - (maskEnd + 1), 31 - (maskBeg - 1));
         }
     }
 
-    uint32_t
-    rotateValue(uint32_t rs, uint32_t shift) const
+    inline uint32_t
+    rotate(uint32_t rs, uint32_t sh) const
     {
         uint32_t n = shift & 31;
         return (rs << n) | (rs >> (32 - n));
index e99769961ec669ec6d65e9bb9affd06ae3e97735..ef66ac95ddf98743842209df3bf430b757e30728 100644 (file)
@@ -266,9 +266,9 @@ decode PO default Unknown::unknown() {
     }
 
     format IntRotateOp {
-        21: rlwinm({{ Ra = rotateValue(Rs, sh) & fullMask; }});
-        23: rlwnm({{ Ra = rotateValue(Rs, Rb) & fullMask; }});
-        20: rlwimi({{ Ra = (rotateValue(Rs, sh) & fullMask) |
+        21: rlwinm({{ Ra = rotate(Rs, sh) & fullMask; }});
+        23: rlwnm({{ Ra = rotate(Rs, Rb) & fullMask; }});
+        20: rlwimi({{ Ra = (rotate(Rs, sh) & fullMask) |
                            (Ra & ~fullMask); }});
     }
 
index 571a1b6edbd558adedeacec3c234ac544d9a9ac2..bc52340ecd17aa3f5dd247d7ea7207c3fb0706b6 100644 (file)
@@ -526,15 +526,17 @@ def format IntConcatShiftOp(code, computeCA = 0, inst_flags = []) {{
 }};
 
 
-// A special format for rotate instructions which use certain fields
-// from the instruction's binary encoding. We need two versions for each
-// instruction to deal with the Rc bit.
+// Integer instructions with or without immediate that perform rotate
+// operations. All instructions write to Ra and use Rs as a source
+// register. If immediate is not used, Rb is also used as a source
+// register. We need two versions for each instruction to deal with
+// the Rc bit.
 def format IntRotateOp(code, inst_flags = []) {{
 
     # The result is always in Ra
     dict = {'result':'Ra'}
 
-    # Setup the code for when Rc is set
+    # Code when Rc is set
     code_rc1 = readXERCode + code + computeCR0Code % dict
 
     # Generate the first class