Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: src/mips64/simulator-mips64.cc

Issue 1880953002: MIPS64: Fix rotate instructions in simulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments and add tests Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips64/disasm-mips64.cc ('k') | test/cctest/test-disasm-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips64/simulator-mips64.cc
diff --git a/src/mips64/simulator-mips64.cc b/src/mips64/simulator-mips64.cc
index 9519865c8231eab71bcc54840827e82537b702fe..0916e48d4353af713e468214b649c6605fcc47cf 100644
--- a/src/mips64/simulator-mips64.cc
+++ b/src/mips64/simulator-mips64.cc
@@ -3420,21 +3420,50 @@ void Simulator::DecodeTypeRegisterSPECIAL() {
// bits instruction. RS field is always equal to 0.
// Sign-extend the 32-bit result.
alu_out = static_cast<int32_t>(static_cast<uint32_t>(rt_u()) >> sa());
balazs.kilvady 2016/04/12 13:14:33 I see. A lot of unnecessary casting existed alread
- } else {
+ } else if (rs_reg() == 1) {
// Logical right-rotate of a word by a fixed number of bits. This
// is special case of SRL instruction, added in MIPS32 Release 2.
// RS field is equal to 00001.
alu_out = static_cast<int32_t>(
base::bits::RotateRight32(static_cast<const uint32_t>(rt_u()),
static_cast<const uint32_t>(sa())));
balazs.kilvady 2016/04/12 13:14:33 I see. A lot of unecessary comment existed already
+ } else {
+ UNREACHABLE();
}
SetResult(rd_reg(), alu_out);
break;
case DSRL:
- SetResult(rd_reg(), rt_u() >> sa());
+ if (rs_reg() == 0) {
+ // Regular logical right shift of a word by a fixed number of
+ // bits instruction. RS field is always equal to 0.
+ // Sign-extend the 64-bit result.
+ alu_out = static_cast<int64_t>(rt_u() >> sa());
+ } else if (rs_reg() == 1) {
+ // Logical right-rotate of a word by a fixed number of bits. This
+ // is special case of SRL instruction, added in MIPS32 Release 2.
+ // RS field is equal to 00001.
+ alu_out = static_cast<int64_t>(base::bits::RotateRight64(rt_u(), sa()));
+ } else {
+ UNREACHABLE();
+ }
+ SetResult(rd_reg(), alu_out);
break;
case DSRL32:
- SetResult(rd_reg(), rt_u() >> sa() >> 32);
+ if (rs_reg() == 0) {
+ // Regular logical right shift of a word by a fixed number of
+ // bits instruction. RS field is always equal to 0.
+ // Sign-extend the 64-bit result.
+ alu_out = static_cast<int64_t>(rt_u() >> sa() >> 32);
+ } else if (rs_reg() == 1) {
+ // Logical right-rotate of a word by a fixed number of bits. This
+ // is special case of SRL instruction, added in MIPS32 Release 2.
+ // RS field is equal to 00001.
+ alu_out =
+ static_cast<int64_t>(base::bits::RotateRight64(rt_u(), sa() + 32));
+ } else {
+ UNREACHABLE();
+ }
+ SetResult(rd_reg(), alu_out);
break;
case SRA:
SetResult(rd_reg(), (int32_t)rt() >> sa());
@@ -3470,12 +3499,13 @@ void Simulator::DecodeTypeRegisterSPECIAL() {
if (sa() == 0) {
// Regular logical right-shift of a word by a variable number of
// bits instruction. SA field is always equal to 0.
- alu_out = rt_u() >> rs();
+ alu_out = static_cast<int64_t>(rt_u() >> rs());
} else {
// Logical right-rotate of a word by a variable number of bits.
// This is special case od SRLV instruction, added in MIPS32
// Release 2. SA field is equal to 00001.
- alu_out = base::bits::RotateRight64(rt_u(), rs_u());
+ alu_out =
+ static_cast<int64_t>(base::bits::RotateRight64(rt_u(), rs_u()));
}
SetResult(rd_reg(), alu_out);
break;
« no previous file with comments | « src/mips64/disasm-mips64.cc ('k') | test/cctest/test-disasm-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698