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

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

Issue 2069933003: Implement byte swapping instructions on MIPS32 and MIPS64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests Created 4 years, 6 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/mips/macro-assembler-mips.cc ('k') | src/mips64/assembler-mips64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/simulator-mips.cc
diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc
index 07cfcff5b4813e7d16276009b2ca7c3ca182b8f8..71dcda276646a2bed2257d4d2166b40f82b1a8d2 100644
--- a/src/mips/simulator-mips.cc
+++ b/src/mips/simulator-mips.cc
@@ -3833,12 +3833,51 @@ void Simulator::DecodeTypeRegisterSPECIAL3() {
alu_out = static_cast<int32_t>(output);
break;
}
- case SEB:
- case SEH:
- case WSBH:
- alu_out = 0x12345678;
- UNREACHABLE();
+ case SEB: {
+ uint8_t input = static_cast<uint8_t>(rt());
+ uint32_t output = input;
+ uint32_t mask = 0x00000080;
+
+ // Extending sign
+ if (mask & input) {
+ output |= 0xFFFFFF00;
+ }
+
+ alu_out = static_cast<int32_t>(output);
break;
+ }
+ case SEH: {
+ uint16_t input = static_cast<uint16_t>(rt());
+ uint32_t output = input;
+ uint32_t mask = 0x00008000;
+
+ // Extending sign
+ if (mask & input) {
+ output |= 0xFFFF0000;
+ }
+
+ alu_out = static_cast<int32_t>(output);
+ break;
+ }
+ case WSBH: {
+ uint32_t input = static_cast<uint32_t>(rt());
+ uint32_t output = 0;
+
+ uint32_t mask = 0xFF000000;
+ for (int i = 0; i < 4; i++) {
+ uint32_t tmp = mask & input;
+ if (i % 2 == 0) {
+ tmp = tmp >> 8;
+ } else {
+ tmp = tmp << 8;
+ }
+ output = output | tmp;
+ mask = mask >> 8;
+ }
+
+ alu_out = static_cast<int32_t>(output);
+ break;
+ }
default: {
const uint8_t bp = get_instr()->Bp2Value();
sa >>= kBp2Bits;
« no previous file with comments | « src/mips/macro-assembler-mips.cc ('k') | src/mips64/assembler-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698