Sandipan Das has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/40925 )
Change subject: arch-power: Fix shift instructions
......................................................................
arch-power: Fix shift instructions
Now that 64-bit registers are being used, the instructions
must use only the lower word of the operand to be shifted.
This fixes the following instructions.
* Shift Left Word (slw[.])
* Shift Right Word (srw[.])
* Shift Right Algebraic Word (sraw[.])
* Shift Right Algebraic Word Immediate (srawi[.])
Change-Id: Ibc3124b9e3a8660b0ff9d0178218e34bcc028310
Signed-off-by: Sandipan Das <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40925
Reviewed-by: Boris Shingarov <[email protected]>
Maintainer: Boris Shingarov <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/arch/power/isa/decoder.isa
1 file changed, 32 insertions(+), 37 deletions(-)
Approvals:
Boris Shingarov: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/power/isa/decoder.isa b/src/arch/power/isa/decoder.isa
index 859ccf2..2db66b6 100644
--- a/src/arch/power/isa/decoder.isa
+++ b/src/arch/power/isa/decoder.isa
@@ -241,11 +241,13 @@
}
24: IntShiftOp::slw({{
- if (Rb & 0x20) {
- Ra = 0;
- } else {
- Ra = Rs << (Rb & 0x1f);
+ int32_t shift = Rb_sw;
+ uint32_t res = Rs_uw & ~((shift << 26) >> 31);
+ if (shift != 0) {
+ shift = bits(shift, 4, 0);
+ res = res << shift;
}
+ Ra = res;
}});
format IntLogicOp {
@@ -500,11 +502,13 @@
}
536: IntShiftOp::srw({{
- if (Rb & 0x20) {
- Ra = 0;
- } else {
- Ra = Rs >> (Rb & 0x1f);
+ int32_t shift = Rb_sw;
+ uint32_t res = Rs_uw & ~((shift << 26) >> 31);
+ if (shift != 0) {
+ shift = bits(shift, 4, 0);
+ res = res >> shift;
}
+ Ra = res;
}});
538: IntLogicOp::cnttzw({{ Ra = findTrailingZeros(Rs_uw); }},
true);
@@ -588,45 +592,36 @@
format IntShiftOp {
792: sraw({{
- int32_t s = Rs;
- if (Rb == 0) {
- Ra = Rs;
- setCA = true;
- } else if (Rb & 0x20) {
- if (s < 0) {
- Ra = (uint32_t)-1;
- if (s & 0x7fffffff) {
- setCA = true;
- } else {
- setCA = false;
- }
- } else {
- Ra = 0;
- setCA = false;
+ int32_t src = Rs_sw;
+ uint32_t shift = Rb_uw;
+ int64_t res;
+ if (bits(shift, 5)) {
+ res = src >> 31;
+ if (res != 0) {
+ setCA = true;
}
} else {
- Ra = s >> (Rb & 0x1f);
- if (s < 0 && (s << (32 - (Rb & 0x1f))) != 0) {
- setCA = true;
+ if (shift != 0) {
+ shift = bits(shift, 4, 0);
+ res = src >> shift;
+ setCA = src < 0 && (src & mask(shift)) != 0;
} else {
- setCA = false;
+ res = src;
}
}
+ Ra = res;
}}, true);
824: srawi({{
- if (sh == 0) {
- Ra = Rs;
- setCA = false;
+ int32_t src = Rs_sw;
+ int64_t res;
+ if (sh) {
+ res = src >> sh;
+ setCA = src < 0 && (src & mask(sh)) != 0;
} else {
- int32_t s = Rs;
- Ra = s >> sh;
- if (s < 0 && (s << (32 - sh)) != 0) {
- setCA = true;
- } else {
- setCA = false;
- }
+ res = src;
}
+ Ra = res;
}}, true);
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40925
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ibc3124b9e3a8660b0ff9d0178218e34bcc028310
Gerrit-Change-Number: 40925
Gerrit-PatchSet: 8
Gerrit-Owner: Sandipan Das <[email protected]>
Gerrit-Reviewer: Boris Shingarov <[email protected]>
Gerrit-Reviewer: Sandipan Das <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s