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

Side by Side Diff: src/mips64/simulator-mips64.cc

Issue 2871663002: MIPS64: Add/fix bit insertion/extraction instrs. (Closed)
Patch Set: Remove pps variable use Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | test/cctest/test-assembler-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #if V8_TARGET_ARCH_MIPS64 10 #if V8_TARGET_ARCH_MIPS64
(...skipping 4019 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 default: 4030 default:
4031 alu_out = 0x12345678; 4031 alu_out = 0x12345678;
4032 UNREACHABLE(); 4032 UNREACHABLE();
4033 } 4033 }
4034 } 4034 }
4035 4035
4036 4036
4037 void Simulator::DecodeTypeRegisterSPECIAL3() { 4037 void Simulator::DecodeTypeRegisterSPECIAL3() {
4038 int64_t alu_out; 4038 int64_t alu_out;
4039 switch (instr_.FunctionFieldRaw()) { 4039 switch (instr_.FunctionFieldRaw()) {
4040 case INS: { // Mips64r2 instruction. 4040 case EXT: { // Mips32r2 instruction.
4041 // Interpret rd field as 5-bit msbd of extract.
4042 uint16_t msbd = rd_reg();
4043 // Interpret sa field as 5-bit lsb of extract.
4044 uint16_t lsb = sa();
4045 uint16_t size = msbd + 1;
4046 uint64_t mask = (1ULL << size) - 1;
4047 alu_out = static_cast<int32_t>((rs_u() & (mask << lsb)) >> lsb);
4048 SetResult(rt_reg(), alu_out);
4049 break;
4050 }
4051 case DEXT: { // Mips64r2 instruction.
4052 // Interpret rd field as 5-bit msbd of extract.
4053 uint16_t msbd = rd_reg();
4054 // Interpret sa field as 5-bit lsb of extract.
4055 uint16_t lsb = sa();
4056 uint16_t size = msbd + 1;
4057 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1;
4058 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb);
4059 SetResult(rt_reg(), alu_out);
4060 break;
4061 }
4062 case DEXTM: {
4063 // Interpret rd field as 5-bit msbdminus32 of extract.
4064 uint16_t msbdminus32 = rd_reg();
4065 // Interpret sa field as 5-bit lsb of extract.
4066 uint16_t lsb = sa();
4067 uint16_t size = msbdminus32 + 1 + 32;
4068 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1;
4069 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb);
4070 SetResult(rt_reg(), alu_out);
4071 break;
4072 }
4073 case DEXTU: {
4074 // Interpret rd field as 5-bit msbd of extract.
4075 uint16_t msbd = rd_reg();
4076 // Interpret sa field as 5-bit lsbminus32 of extract and add 32 to get
4077 // lsb.
4078 uint16_t lsb = sa() + 32;
4079 uint16_t size = msbd + 1;
4080 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1;
4081 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb);
4082 SetResult(rt_reg(), alu_out);
4083 break;
4084 }
4085 case INS: { // Mips32r2 instruction.
4041 // Interpret rd field as 5-bit msb of insert. 4086 // Interpret rd field as 5-bit msb of insert.
4042 uint16_t msb = rd_reg(); 4087 uint16_t msb = rd_reg();
4043 // Interpret sa field as 5-bit lsb of insert. 4088 // Interpret sa field as 5-bit lsb of insert.
4044 uint16_t lsb = sa(); 4089 uint16_t lsb = sa();
4045 uint16_t size = msb - lsb + 1; 4090 uint16_t size = msb - lsb + 1;
4046 uint64_t mask = (1ULL << size) - 1; 4091 uint64_t mask = (1ULL << size) - 1;
4047 alu_out = static_cast<int32_t>((rt_u() & ~(mask << lsb)) | 4092 alu_out = static_cast<int32_t>((rt_u() & ~(mask << lsb)) |
4048 ((rs_u() & mask) << lsb)); 4093 ((rs_u() & mask) << lsb));
4049 SetResult(rt_reg(), alu_out); 4094 SetResult(rt_reg(), alu_out);
4050 break; 4095 break;
4051 } 4096 }
4052 case DINS: { // Mips64r2 instruction. 4097 case DINS: { // Mips64r2 instruction.
4053 // Interpret rd field as 5-bit msb of insert. 4098 // Interpret rd field as 5-bit msb of insert.
4054 uint16_t msb = rd_reg(); 4099 uint16_t msb = rd_reg();
4055 // Interpret sa field as 5-bit lsb of insert. 4100 // Interpret sa field as 5-bit lsb of insert.
4056 uint16_t lsb = sa(); 4101 uint16_t lsb = sa();
4057 uint16_t size = msb - lsb + 1; 4102 uint16_t size = msb - lsb + 1;
4058 uint64_t mask = (1ULL << size) - 1; 4103 uint64_t mask = (1ULL << size) - 1;
4059 alu_out = (rt_u() & ~(mask << lsb)) | ((rs_u() & mask) << lsb); 4104 alu_out = (rt_u() & ~(mask << lsb)) | ((rs_u() & mask) << lsb);
4060 SetResult(rt_reg(), alu_out); 4105 SetResult(rt_reg(), alu_out);
4061 break; 4106 break;
4062 } 4107 }
4063 case EXT: { // Mips64r2 instruction. 4108 case DINSM: { // Mips64r2 instruction.
4064 // Interpret rd field as 5-bit msb of extract. 4109 // Interpret rd field as 5-bit msbminus32 of insert.
4065 uint16_t msb = rd_reg(); 4110 uint16_t msbminus32 = rd_reg();
4066 // Interpret sa field as 5-bit lsb of extract. 4111 // Interpret sa field as 5-bit lsb of insert.
4067 uint16_t lsb = sa(); 4112 uint16_t lsb = sa();
4068 uint16_t size = msb + 1; 4113 uint16_t size = msbminus32 + 32 - lsb + 1;
4069 uint64_t mask = (1ULL << size) - 1; 4114 uint64_t mask;
4070 alu_out = static_cast<int32_t>((rs_u() & (mask << lsb)) >> lsb); 4115 if (size < 64)
4116 mask = (1ULL << size) - 1;
4117 else
4118 mask = std::numeric_limits<uint64_t>::max();
4119 alu_out = (rt_u() & ~(mask << lsb)) | ((rs_u() & mask) << lsb);
4071 SetResult(rt_reg(), alu_out); 4120 SetResult(rt_reg(), alu_out);
4072 break; 4121 break;
4073 } 4122 }
4074 case DEXT: { // Mips64r2 instruction. 4123 case DINSU: { // Mips64r2 instruction.
4075 // Interpret rd field as 5-bit msb of extract. 4124 // Interpret rd field as 5-bit msbminus32 of insert.
4076 uint16_t msb = rd_reg(); 4125 uint16_t msbminus32 = rd_reg();
4077 // Interpret sa field as 5-bit lsb of extract. 4126 // Interpret rd field as 5-bit lsbminus32 of insert.
4078 uint16_t lsb = sa(); 4127 uint16_t lsbminus32 = sa();
4079 uint16_t size = msb + 1; 4128 uint16_t lsb = lsbminus32 + 32;
4080 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1; 4129 uint16_t size = msbminus32 + 32 - lsb + 1;
4081 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb); 4130 uint64_t mask = (1ULL << size) - 1;
4082 SetResult(rt_reg(), alu_out); 4131 alu_out = (rt_u() & ~(mask << lsb)) | ((rs_u() & mask) << lsb);
4083 break;
4084 }
4085 case DEXTM: {
4086 // Interpret rd field as 5-bit msb of extract.
4087 uint16_t msb = rd_reg();
4088 // Interpret sa field as 5-bit lsb of extract.
4089 uint16_t lsb = sa();
4090 uint16_t size = msb + 33;
4091 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1;
4092 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb);
4093 SetResult(rt_reg(), alu_out);
4094 break;
4095 }
4096 case DEXTU: {
4097 // Interpret rd field as 5-bit msb of extract.
4098 uint16_t msb = rd_reg();
4099 // Interpret sa field as 5-bit lsb of extract.
4100 uint16_t lsb = sa() + 32;
4101 uint16_t size = msb + 1;
4102 uint64_t mask = (size == 64) ? UINT64_MAX : (1ULL << size) - 1;
4103 alu_out = static_cast<int64_t>((rs_u() & (mask << lsb)) >> lsb);
4104 SetResult(rt_reg(), alu_out); 4132 SetResult(rt_reg(), alu_out);
4105 break; 4133 break;
4106 } 4134 }
4107 case BSHFL: { 4135 case BSHFL: {
4108 int32_t sa = instr_.SaFieldRaw() >> kSaShift; 4136 int32_t sa = instr_.SaFieldRaw() >> kSaShift;
4109 switch (sa) { 4137 switch (sa) {
4110 case BITSWAP: { 4138 case BITSWAP: {
4111 uint32_t input = static_cast<uint32_t>(rt()); 4139 uint32_t input = static_cast<uint32_t>(rt());
4112 uint32_t output = 0; 4140 uint32_t output = 0;
4113 uint8_t i_byte, o_byte; 4141 uint8_t i_byte, o_byte;
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
5148 } 5176 }
5149 5177
5150 5178
5151 #undef UNSUPPORTED 5179 #undef UNSUPPORTED
5152 } // namespace internal 5180 } // namespace internal
5153 } // namespace v8 5181 } // namespace v8
5154 5182
5155 #endif // USE_SIMULATOR 5183 #endif // USE_SIMULATOR
5156 5184
5157 #endif // V8_TARGET_ARCH_MIPS64 5185 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | test/cctest/test-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698