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

Side by Side Diff: runtime/vm/simulator_mips.cc

Issue 14672037: Implements FPU compare and branching for MIPS simulator, assembler, disassembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/simulator_mips.h ('k') | runtime/vm/stub_code_mips.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <math.h> // for isnan. 5 #include <math.h> // for isnan.
6 #include <setjmp.h> 6 #include <setjmp.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #if defined(TARGET_ARCH_MIPS) 10 #if defined(TARGET_ARCH_MIPS)
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 552 }
553 pc_ = 0; 553 pc_ = 0;
554 // The sp is initialized to point to the bottom (high address) of the 554 // The sp is initialized to point to the bottom (high address) of the
555 // allocated stack area. 555 // allocated stack area.
556 registers_[SP] = StackTop(); 556 registers_[SP] = StackTop();
557 557
558 // All double-precision registers are initialized to zero. 558 // All double-precision registers are initialized to zero.
559 for (int i = 0; i < kNumberOfFRegisters; i++) { 559 for (int i = 0; i < kNumberOfFRegisters; i++) {
560 fregisters_[i] = 0.0; 560 fregisters_[i] = 0.0;
561 } 561 }
562 fcsr_ = 0;
562 } 563 }
563 564
564 565
565 Simulator::~Simulator() { 566 Simulator::~Simulator() {
566 delete[] stack_; 567 delete[] stack_;
567 Isolate* isolate = Isolate::Current(); 568 Isolate* isolate = Isolate::Current();
568 if (isolate != NULL) { 569 if (isolate != NULL) {
569 isolate->set_simulator(NULL); 570 isolate->set_simulator(NULL);
570 } 571 }
571 } 572 }
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 } 1369 }
1369 } 1370 }
1370 } 1371 }
1371 1372
1372 1373
1373 void Simulator::DecodeCop1(Instr* instr) { 1374 void Simulator::DecodeCop1(Instr* instr) {
1374 ASSERT(instr->OpcodeField() == COP1); 1375 ASSERT(instr->OpcodeField() == COP1);
1375 if (instr->HasFormat()) { 1376 if (instr->HasFormat()) {
1376 // If the rs field is a valid format, then the function field identifies the 1377 // If the rs field is a valid format, then the function field identifies the
1377 // instruction. 1378 // instruction.
1379 ASSERT(instr->FormatField() == FMT_D); // Only D supported.
1380 double fs_val = get_fregister_double(instr->FsField());
1381 double ft_val = get_fregister_double(instr->FtField());
1382 uint32_t cc, fcsr_cc;
1383 cc = instr->FpuCCField();
1384 fcsr_cc = get_fcsr_condition_bit(cc);
1378 switch (instr->Cop1FunctionField()) { 1385 switch (instr->Cop1FunctionField()) {
1379 case COP1_ADD: { 1386 case COP1_ADD: {
1380 // Format(instr, "add.'fmt 'fd, 'fs, 'ft"); 1387 // Format(instr, "add.'fmt 'fd, 'fs, 'ft");
1381 if (instr->FormatField() == FMT_S) { 1388 set_fregister_double(instr->FdField(), fs_val + ft_val);
1382 float fs_val = get_fregister_float(instr->FsField());
1383 float ft_val = get_fregister_float(instr->FtField());
1384 set_fregister_float(instr->FdField(), fs_val + ft_val);
1385 } else {
1386 ASSERT(instr->FormatField() == FMT_D); // Only S and D supported.
1387 double fs_val = get_fregister_double(instr->FsField());
1388 double ft_val = get_fregister_double(instr->FtField());
1389 set_fregister_double(instr->FdField(), fs_val + ft_val);
1390 }
1391 break; 1389 break;
1392 } 1390 }
1393 case COP1_MOV: { 1391 case COP1_MOV: {
1394 // Format(instr, "mov.'fmt 'fd, 'fs"); 1392 // Format(instr, "mov.'fmt 'fd, 'fs");
1395 ASSERT(instr->FtField() == F0); 1393 set_fregister_double(instr->FdField(), fs_val);
1396 if (instr->FormatField() == FMT_S) { 1394 break;
1397 float fs_val = get_fregister_float(instr->FsField()); 1395 }
1398 set_fregister_float(instr->FdField(), fs_val); 1396 case COP1_C_F: {
1399 } else { 1397 ASSERT(instr->FdField() == F0);
1400 ASSERT(instr->FormatField() == FMT_D); 1398 set_fcsr_bit(fcsr_cc, false);
1401 double fs_val = get_fregister_double(instr->FsField()); 1399 break;
1402 set_fregister_double(instr->FdField(), fs_val); 1400 }
1403 } 1401 case COP1_C_UN: {
1402 ASSERT(instr->FdField() == F0);
1403 set_fcsr_bit(fcsr_cc, isnan(fs_val) || isnan(ft_val));
1404 break;
1405 }
1406 case COP1_C_EQ: {
1407 ASSERT(instr->FdField() == F0);
1408 set_fcsr_bit(fcsr_cc, (fs_val == ft_val));
1409 break;
1410 }
1411 case COP1_C_UEQ: {
1412 ASSERT(instr->FdField() == F0);
1413 set_fcsr_bit(fcsr_cc,
1414 (fs_val == ft_val) || isnan(fs_val) || isnan(ft_val));
1415 break;
1416 }
1417 case COP1_C_OLT: {
1418 ASSERT(instr->FdField() == F0);
1419 set_fcsr_bit(fcsr_cc, (fs_val < ft_val));
1420 break;
1421 }
1422 case COP1_C_ULT: {
1423 ASSERT(instr->FdField() == F0);
1424 set_fcsr_bit(fcsr_cc,
1425 (fs_val < ft_val) || isnan(fs_val) || isnan(ft_val));
1426 break;
1427 }
1428 case COP1_C_OLE: {
1429 ASSERT(instr->FdField() == F0);
1430 set_fcsr_bit(fcsr_cc, (fs_val <= ft_val));
1431 break;
1432 }
1433 case COP1_C_ULE: {
1434 ASSERT(instr->FdField() == F0);
1435 set_fcsr_bit(fcsr_cc,
1436 (fs_val <= ft_val) || isnan(fs_val) || isnan(ft_val));
1404 break; 1437 break;
1405 } 1438 }
1406 default: { 1439 default: {
1407 OS::PrintErr("DecodeCop1: 0x%x\n", instr->InstructionBits()); 1440 OS::PrintErr("DecodeCop1: 0x%x\n", instr->InstructionBits());
1408 UnimplementedInstruction(instr); 1441 UnimplementedInstruction(instr);
1409 break; 1442 break;
1410 } 1443 }
1411 } 1444 }
1412 } else { 1445 } else {
1413 // If the rs field isn't a valid format, then it must be a sub-op. 1446 // If the rs field isn't a valid format, then it must be a sub-op.
1414 switch (instr->Cop1SubField()) { 1447 switch (instr->Cop1SubField()) {
1415 case COP1_MF: { 1448 case COP1_MF: {
1416 // Format(instr, "mfc1 'rt, 'fs"); 1449 // Format(instr, "mfc1 'rt, 'fs");
1417 ASSERT(instr->Bits(0, 11) == 0); 1450 ASSERT(instr->Bits(0, 11) == 0);
1418 int32_t fs_val = get_fregister(instr->FsField()); 1451 int32_t fs_val = get_fregister(instr->FsField());
1419 set_register(instr->RtField(), fs_val); 1452 set_register(instr->RtField(), fs_val);
1420 break; 1453 break;
1421 } 1454 }
1422 case COP1_MT: { 1455 case COP1_MT: {
1423 // Format(instr, "mtc1 'rt, 'fs"); 1456 // Format(instr, "mtc1 'rt, 'fs");
1424 ASSERT(instr->Bits(0, 11) == 0); 1457 ASSERT(instr->Bits(0, 11) == 0);
1425 int32_t rt_val = get_register(instr->RtField()); 1458 int32_t rt_val = get_register(instr->RtField());
1426 set_fregister(instr->FsField(), rt_val); 1459 set_fregister(instr->FsField(), rt_val);
1427 break; 1460 break;
1428 } 1461 }
1462 case COP1_BC: {
1463 ASSERT(instr->Bit(17) == 0);
1464 uint32_t cc, fcsr_cc;
1465 cc = instr->Bits(18, 3);
1466 fcsr_cc = get_fcsr_condition_bit(cc);
1467 if (instr->Bit(16) == 1) { // Branch on true.
1468 DoBranch(instr, test_fcsr_bit(fcsr_cc), false);
1469 } else { // Branch on false.
1470 DoBranch(instr, !test_fcsr_bit(fcsr_cc), false);
1471 }
1472 break;
1473 }
1429 default: { 1474 default: {
1430 OS::PrintErr("DecodeCop1: 0x%x\n", instr->InstructionBits()); 1475 OS::PrintErr("DecodeCop1: 0x%x\n", instr->InstructionBits());
1431 UnimplementedInstruction(instr); 1476 UnimplementedInstruction(instr);
1432 break; 1477 break;
1433 } 1478 }
1434 } 1479 }
1435 } 1480 }
1436 } 1481 }
1437 1482
1438 1483
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); 1924 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace));
1880 } 1925 }
1881 buf->Longjmp(); 1926 buf->Longjmp();
1882 } 1927 }
1883 1928
1884 } // namespace dart 1929 } // namespace dart
1885 1930
1886 #endif // !defined(HOST_ARCH_MIPS) 1931 #endif // !defined(HOST_ARCH_MIPS)
1887 1932
1888 #endif // defined TARGET_ARCH_MIPS 1933 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/simulator_mips.h ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698