Sandipan Das has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/16630
Change subject: arch-power: Add fixed-point logical population count
instructions
......................................................................
arch-power: Add fixed-point logical population count instructions
This adds the following logical instructions:
* Population Count Bytes (popcntb)
* Population Count Words (popcntw)
* Population Count Doubleword (popcntd)
Change-Id: I946d1f8b270b4c75849cdfb7e413974ae8748494
Signed-off-by: Sandipan Das <[email protected]>
---
M src/arch/power/isa/decoder.isa
1 file changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa
index 71aa52c..31f85a5 100644
--- a/src/arch/power/isa/decoder.isa
+++ b/src/arch/power/isa/decoder.isa
@@ -533,6 +533,45 @@
Ra = res;
}});
+ 122: popcntb({{
+ // Based on "Counting bits set, in parallel"
+ // from
https://graphics.stanford.edu/~seander/bithacks.html
+ const uint64_t m1 = 0x5555555555555555ULL;
+ const uint64_t m2 = 0x3333333333333333ULL;
+ const uint64_t m4 = 0x0f0f0f0f0f0f0f0fULL;
+ uint64_t res = Rs;
+ res = (res & m1) + ((res >> 1) & m1);
+ res = (res & m2) + ((res >> 2) & m2);
+ res = (res & m4) + ((res >> 4) & m4);
+ Ra = res;
+ }});
+
+ 378: popcntw({{
+ #if defined(__GNUC__) || (defined(__clang__) && \
+ __has_builtin(__builtin_popcount))
+ uint64_t src = Rs;
+ uint64_t res = __builtin_popcount(src >> 32);
+ res = (res << 32) | __builtin_popcount(src);
+ #else
+ // Based on "Counting bits set, in parallel"
+ // from
https://graphics.stanford.edu/~seander/bithacks.html
+ const uint64_t m1 = 0x5555555555555555ULL;
+ const uint64_t m2 = 0x3333333333333333ULL;
+ const uint64_t m4 = 0x0f0f0f0f0f0f0f0fULL;
+ const uint64_t m8 = 0x00ff00ff00ff00ffULL;
+ const uint64_t m16 = 0x0000ffff0000ffffULL;
+ uint64_t res = Rs;
+ res = (res & m1) + ((res >> 1) & m1);
+ res = (res & m2) + ((res >> 2) & m2);
+ res = (res & m4) + ((res >> 4) & m4);
+ res = (res & m8) + ((res >> 8) & m8);
+ res = (res & m16) + ((res >> 16) & m16);
+ #endif
+ Ra = res;
+ }});
+
+ 506: popcntd({{ Ra = popCount(Rs); }});
+
24: slw({{
if (Rb & 0x20) {
Ra = 0;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/16630
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: I946d1f8b270b4c75849cdfb7e413974ae8748494
Gerrit-Change-Number: 16630
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