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

Change subject: arch-power: Add fixed-point compare instructions
......................................................................

arch-power: Add fixed-point compare instructions

This adds the following compare instructions:
  * Compare Ranged Byte (cmprb)
  * Compare Equal Byte (cmpeqb)

Change-Id: I44765b3a9a8f0a3d81ecd6984efce3fd01ba4b24
Signed-off-by: Sandipan Das <[email protected]>
---
M src/arch/power/isa/decoder.isa
M src/arch/power/isa/formats/integer.isa
2 files changed, 25 insertions(+), 1 deletion(-)



diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa
index 1838637..943d17d 100644
--- a/src/arch/power/isa/decoder.isa
+++ b/src/arch/power/isa/decoder.isa
@@ -476,6 +476,30 @@
                     cr = makeCRField((uint32_t)Ra, (uint32_t)Rb, xer.so);
                 }
             }});
+
+            192: cmprb({{
+                uint32_t src1 = Ra_ub;
+                uint32_t src2 = Rb_uw;
+                uint8_t src2lo = src2 & 0xff;
+                uint8_t src2hi = (src2 >>= 8) & 0xff;
+                uint32_t res = (src2lo <= src1) & (src1 <= src2hi);
+                if (length) {
+                    src2lo = (src2 >>= 8) & 0xff;
+                    src2hi = (src2 >>= 8) & 0xff;
+                    res = ((src2lo <= src1) & (src1 <= src2hi)) | res;
+                }
+                cr = res << 2;
+            }});
+
+            224: cmpeqb({{
+                // Based on "Determine if a word has a byte equal to n"
+ // from https://graphics.stanford.edu/~seander/bithacks.html
+                const uint64_t m1 = 0x0101010101010101;
+                const uint64_t m2 = 0x8080808080808080;
+                uint64_t res = Rb ^ (Ra_ub * m1);
+                res = (res - m1) & ~res & m2;
+                cr = (res != 0) << 2;
+            }});
         }

         // Integer logic instructions use source registers Rs and Rb,
diff --git a/src/arch/power/isa/formats/integer.isa b/src/arch/power/isa/formats/integer.isa
index e5e6d2d..41fe64c 100644
--- a/src/arch/power/isa/formats/integer.isa
+++ b/src/arch/power/isa/formats/integer.isa
@@ -67,7 +67,7 @@

 let {{

-readXERCode = 'Xer xer = XER;'
+readXERCode = 'Xer xer M5_VAR_USED = XER;'

 setXERCode = 'XER = xer;'


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/16626
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: I44765b3a9a8f0a3d81ecd6984efce3fd01ba4b24
Gerrit-Change-Number: 16626
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