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

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

Issue 2908753002: MIPS[64]: Implement insert.df and I8 instructions in simulator (Closed)
Patch Set: 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 | « no previous file | src/mips64/simulator-mips64.cc » ('j') | test/cctest/test-assembler-mips.cc » ('J')
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_MIPS 10 #if V8_TARGET_ARCH_MIPS
(...skipping 4245 matching lines...) Expand 10 before | Expand all | Expand 10 after
4256 break; 4256 break;
4257 } 4257 }
4258 } 4258 }
4259 return df; 4259 return df;
4260 } 4260 }
4261 4261
4262 void Simulator::DecodeTypeMsaI8() { 4262 void Simulator::DecodeTypeMsaI8() {
4263 DCHECK(IsMipsArchVariant(kMips32r6)); 4263 DCHECK(IsMipsArchVariant(kMips32r6));
4264 DCHECK(CpuFeatures::IsSupported(MIPS_SIMD)); 4264 DCHECK(CpuFeatures::IsSupported(MIPS_SIMD));
4265 uint32_t opcode = instr_.InstructionBits() & kMsaI8Mask; 4265 uint32_t opcode = instr_.InstructionBits() & kMsaI8Mask;
4266 int8_t i8 = instr_.MsaImm8Value() & 0xFFu;
Ilija.Pavlovic1 2017/05/29 07:31:21 Is this mask 0xFFu needed?
dusan.simicic 2017/05/29 16:32:15 Not needed, MsaImm8Value() method returns 8bit val
4266 4267
4267 switch (opcode) { 4268 switch (opcode) {
4268 case ANDI_B: 4269 case ANDI_B: {
4269 case ORI_B: 4270 int8_t ws[16], wd[16];
Ilija.Pavlovic1 2017/05/29 07:31:21 Value 16 is used in all subsequent "case" statemen
dusan.simicic 2017/05/29 16:32:15 Done. Also added definition for msa_reg_t union.
4270 case NORI_B: 4271 get_msa_register(instr_.WsValue(), ws);
4271 case XORI_B: 4272 for (int i = 0; i < 16; i++) {
4272 case BMNZI_B: 4273 wd[i] = ws[i] & i8;
4273 case BMZI_B: 4274 }
4274 case BSELI_B: 4275 set_msa_register(instr_.WdValue(), wd);
4275 case SHF_B: 4276 TraceMSARegWr(wd, BYTE);
4276 case SHF_H: 4277 } break;
4277 case SHF_W: 4278 case ORI_B: {
4278 UNIMPLEMENTED(); 4279 int8_t ws[16], wd[16];
4279 break; 4280 get_msa_register(instr_.WsValue(), ws);
4281 for (int i = 0; i < 16; i++) {
4282 wd[i] = ws[i] | i8;
4283 }
4284 set_msa_register(instr_.WdValue(), wd);
4285 TraceMSARegWr(wd, BYTE);
4286 } break;
4287 case NORI_B: {
4288 int8_t ws[16], wd[16];
4289 get_msa_register(instr_.WsValue(), ws);
4290 for (int i = 0; i < 16; i++) {
4291 wd[i] = ~(ws[i] | i8);
4292 }
4293 set_msa_register(instr_.WdValue(), wd);
4294 TraceMSARegWr(wd, BYTE);
4295 } break;
4296 case XORI_B: {
4297 int8_t ws[16], wd[16];
4298 get_msa_register(instr_.WsValue(), ws);
4299 for (int i = 0; i < 16; i++) {
4300 wd[i] = ws[i] ^ i8;
4301 }
4302 set_msa_register(instr_.WdValue(), wd);
4303 TraceMSARegWr(wd, BYTE);
4304 } break;
4305 case BMNZI_B: {
4306 int8_t ws[16], wd[16];
4307 get_msa_register(instr_.WsValue(), ws);
4308 get_msa_register(instr_.WdValue(), wd);
4309 for (int i = 0; i < 16; i++) {
4310 wd[i] = (ws[i] & i8) | (wd[i] & ~i8);
4311 }
4312 set_msa_register(instr_.WdValue(), wd);
4313 TraceMSARegWr(wd, BYTE);
4314 } break;
4315 case BMZI_B: {
4316 int8_t ws[16], wd[16];
4317 get_msa_register(instr_.WsValue(), ws);
4318 get_msa_register(instr_.WdValue(), wd);
4319 for (int i = 0; i < 16; i++) {
4320 wd[i] = (ws[i] & ~i8) | (wd[i] & i8);
4321 }
4322 set_msa_register(instr_.WdValue(), wd);
4323 TraceMSARegWr(wd, BYTE);
4324 } break;
4325 case BSELI_B: {
4326 int8_t ws[16], wd[16];
4327 get_msa_register(instr_.WsValue(), ws);
4328 get_msa_register(instr_.WdValue(), wd);
4329 for (int i = 0; i < 16; i++) {
4330 wd[i] = (ws[i] & ~wd[i]) | (wd[i] & i8);
4331 }
4332 set_msa_register(instr_.WdValue(), wd);
4333 TraceMSARegWr(wd, BYTE);
4334 } break;
4335 case SHF_B: {
4336 int8_t ws[16], wd[16];
4337 get_msa_register(instr_.WsValue(), ws);
4338 for (int i = 0; i < 16; i++) {
4339 int j = i % 4;
4340 int k = (i8 >> (2 * j)) & 0x3;
4341 wd[i] = ws[i - j + k];
4342 }
4343 set_msa_register(instr_.WdValue(), wd);
4344 TraceMSARegWr(wd, BYTE);
4345 } break;
4346 case SHF_H: {
4347 int16_t ws[8], wd[8];
Ilija.Pavlovic1 2017/05/29 07:31:21 Value 8 as constant WRLEN_16?
dusan.simicic 2017/05/29 16:32:15 Done.
4348 get_msa_register(instr_.WsValue(), ws);
4349 for (int i = 0; i < 8; i++) {
4350 int j = i % 4;
4351 int k = (i8 >> (2 * j)) & 0x3;
4352 wd[i] = ws[i - j + k];
4353 }
4354 set_msa_register(instr_.WdValue(), wd);
4355 TraceMSARegWr(wd, HALF);
4356 } break;
4357 case SHF_W: {
4358 int32_t ws[4], wd[4];
Ilija.Pavlovic1 2017/05/29 07:31:21 Value 4 as constant WRLEN_32?
dusan.simicic 2017/05/29 16:32:15 Done.
4359 get_msa_register(instr_.WsValue(), ws);
4360 for (int i = 0; i < 4; i++) {
4361 int j = (i8 >> (2 * i)) & 0x3;
4362 wd[i] = ws[j];
4363 }
4364 set_msa_register(instr_.WdValue(), wd);
4365 TraceMSARegWr(wd, WORD);
4366 } break;
4280 default: 4367 default:
4281 UNREACHABLE(); 4368 UNREACHABLE();
4282 } 4369 }
4283 } 4370 }
4284 4371
4285 void Simulator::DecodeTypeMsaI5() { 4372 void Simulator::DecodeTypeMsaI5() {
4286 DCHECK(IsMipsArchVariant(kMips32r6)); 4373 DCHECK(IsMipsArchVariant(kMips32r6));
4287 DCHECK(CpuFeatures::IsSupported(MIPS_SIMD)); 4374 DCHECK(CpuFeatures::IsSupported(MIPS_SIMD));
4288 uint32_t opcode = instr_.InstructionBits() & kMsaI5Mask; 4375 uint32_t opcode = instr_.InstructionBits() & kMsaI5Mask;
4289 4376
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4348 int32_t ws[4]; 4435 int32_t ws[4];
4349 get_msa_register(instr_.WsValue(), ws); 4436 get_msa_register(instr_.WsValue(), ws);
4350 alu_out = static_cast<int32_t>(ws[n]); 4437 alu_out = static_cast<int32_t>(ws[n]);
4351 SetResult(wd_reg(), alu_out); 4438 SetResult(wd_reg(), alu_out);
4352 break; 4439 break;
4353 } 4440 }
4354 default: 4441 default:
4355 UNREACHABLE(); 4442 UNREACHABLE();
4356 } 4443 }
4357 break; 4444 break;
4445 case INSERT:
4446 switch (DecodeMsaDataFormat()) {
4447 case MSA_BYTE: {
4448 DCHECK(n < 16);
4449 int8_t wd[16];
4450 int32_t rs = get_register(instr_.WsValue());
4451 get_msa_register(instr_.WdValue(), wd);
4452 wd[n] = rs & 0xFFu;
4453 set_msa_register(instr_.WdValue(), wd);
4454 TraceMSARegWr(wd, BYTE);
4455 break;
4456 }
4457 case MSA_HALF: {
4458 DCHECK(n < 8);
4459 int16_t wd[8];
4460 int32_t rs = get_register(instr_.WsValue());
4461 get_msa_register(instr_.WdValue(), wd);
4462 wd[n] = rs & 0xFFFFu;
4463 set_msa_register(instr_.WdValue(), wd);
4464 TraceMSARegWr(wd, HALF);
4465 break;
4466 }
4467 case MSA_WORD: {
4468 DCHECK(n < 4);
4469 int32_t wd[4];
4470 int32_t rs = get_register(instr_.WsValue());
4471 get_msa_register(instr_.WdValue(), wd);
4472 wd[n] = rs;
4473 set_msa_register(instr_.WdValue(), wd);
4474 TraceMSARegWr(wd, WORD);
4475 break;
4476 }
4477 default:
4478 UNREACHABLE();
4479 }
4480 break;
4358 case SLDI: 4481 case SLDI:
4359 case SPLATI: 4482 case SPLATI:
4360 case INSERT:
4361 case INSVE: 4483 case INSVE:
4362 UNIMPLEMENTED(); 4484 UNIMPLEMENTED();
4363 break; 4485 break;
4364 default: 4486 default:
4365 UNREACHABLE(); 4487 UNREACHABLE();
4366 } 4488 }
4367 } 4489 }
4368 4490
4369 void Simulator::DecodeTypeMsaBIT() { 4491 void Simulator::DecodeTypeMsaBIT() {
4370 DCHECK(IsMipsArchVariant(kMips32r6)); 4492 DCHECK(IsMipsArchVariant(kMips32r6));
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 5543
5422 5544
5423 #undef UNSUPPORTED 5545 #undef UNSUPPORTED
5424 5546
5425 } // namespace internal 5547 } // namespace internal
5426 } // namespace v8 5548 } // namespace v8
5427 5549
5428 #endif // USE_SIMULATOR 5550 #endif // USE_SIMULATOR
5429 5551
5430 #endif // V8_TARGET_ARCH_MIPS 5552 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips64/simulator-mips64.cc » ('j') | test/cctest/test-assembler-mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698