~ubuntu-branches/ubuntu/precise/nodejs/precise

« back to all changes in this revision

Viewing changes to deps/v8/src/x64/disasm-x64.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jérémy Lal
  • Date: 2010-08-20 11:49:04 UTC
  • mfrom: (7.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100820114904-lz22w6fkth7yh179
Tags: 0.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
468
468
        if (index == 4 && (base & 7) == 4 && scale == 0 /*times_1*/) {
469
469
          // index == rsp means no index. Only use sib byte with no index for
470
470
          // rsp and r12 base.
471
 
          AppendToBuffer("[%s]", (this->*register_name)(base));
 
471
          AppendToBuffer("[%s]", NameOfCPURegister(base));
472
472
          return 2;
473
473
        } else if (base == 5) {
474
474
          // base == rbp means no base register (when mod == 0).
475
475
          int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 2);
476
476
          AppendToBuffer("[%s*%d+0x%x]",
477
 
                         (this->*register_name)(index),
 
477
                         NameOfCPURegister(index),
478
478
                         1 << scale, disp);
479
479
          return 6;
480
480
        } else if (index != 4 && base != 5) {
481
481
          // [base+index*scale]
482
482
          AppendToBuffer("[%s+%s*%d]",
483
 
                         (this->*register_name)(base),
484
 
                         (this->*register_name)(index),
 
483
                         NameOfCPURegister(base),
 
484
                         NameOfCPURegister(index),
485
485
                         1 << scale);
486
486
          return 2;
487
487
        } else {
489
489
          return 1;
490
490
        }
491
491
      } else {
492
 
        AppendToBuffer("[%s]", (this->*register_name)(rm));
 
492
        AppendToBuffer("[%s]", NameOfCPURegister(rm));
493
493
        return 1;
494
494
      }
495
495
      break;
503
503
                              : *reinterpret_cast<char*>(modrmp + 2);
504
504
        if (index == 4 && (base & 7) == 4 && scale == 0 /*times_1*/) {
505
505
          if (-disp > 0) {
506
 
            AppendToBuffer("[%s-0x%x]", (this->*register_name)(base), -disp);
 
506
            AppendToBuffer("[%s-0x%x]", NameOfCPURegister(base), -disp);
507
507
          } else {
508
 
            AppendToBuffer("[%s+0x%x]", (this->*register_name)(base), disp);
 
508
            AppendToBuffer("[%s+0x%x]", NameOfCPURegister(base), disp);
509
509
          }
510
510
        } else {
511
511
          if (-disp > 0) {
512
512
            AppendToBuffer("[%s+%s*%d-0x%x]",
513
 
                           (this->*register_name)(base),
514
 
                           (this->*register_name)(index),
 
513
                           NameOfCPURegister(base),
 
514
                           NameOfCPURegister(index),
515
515
                           1 << scale,
516
516
                           -disp);
517
517
          } else {
518
518
            AppendToBuffer("[%s+%s*%d+0x%x]",
519
 
                           (this->*register_name)(base),
520
 
                           (this->*register_name)(index),
 
519
                           NameOfCPURegister(base),
 
520
                           NameOfCPURegister(index),
521
521
                           1 << scale,
522
522
                           disp);
523
523
          }
528
528
        int disp = (mod == 2) ? *reinterpret_cast<int32_t*>(modrmp + 1)
529
529
                              : *reinterpret_cast<char*>(modrmp + 1);
530
530
        if (-disp > 0) {
531
 
        AppendToBuffer("[%s-0x%x]", (this->*register_name)(rm), -disp);
 
531
        AppendToBuffer("[%s-0x%x]", NameOfCPURegister(rm), -disp);
532
532
        } else {
533
 
        AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp);
 
533
        AppendToBuffer("[%s+0x%x]", NameOfCPURegister(rm), disp);
534
534
        }
535
535
        return (mod == 2) ? 5 : 2;
536
536
      }
1019
1019
                       NameOfXMMRegister(regop));
1020
1020
        current += PrintRightOperand(current);
1021
1021
      } else if (opcode == 0x7E) {
1022
 
        AppendToBuffer("mov%c %s,",
1023
 
                       rex_w() ? 'q' : 'd',
1024
 
                       NameOfCPURegister(regop));
1025
 
        current += PrintRightXMMOperand(current);
 
1022
        AppendToBuffer("mov%c ",
 
1023
                       rex_w() ? 'q' : 'd');
 
1024
        current += PrintRightOperand(current);
 
1025
        AppendToBuffer(", %s", NameOfXMMRegister(regop));
1026
1026
      } else {
1027
1027
        const char* mnemonic = "?";
1028
1028
        if (opcode == 0x57) {
1029
1029
          mnemonic = "xorpd";
1030
1030
        } else if (opcode == 0x2E) {
 
1031
          mnemonic = "ucomisd";
 
1032
        } else if (opcode == 0x2F) {
1031
1033
          mnemonic = "comisd";
1032
 
        } else if (opcode == 0x2F) {
1033
 
          mnemonic = "ucomisd";
1034
1034
        } else {
1035
1035
          UnimplementedInstruction();
1036
1036
        }
1057
1057
      // CVTSI2SD: integer to XMM double conversion.
1058
1058
      int mod, regop, rm;
1059
1059
      get_modrm(*current, &mod, &regop, &rm);
1060
 
      AppendToBuffer("%s %s,", mnemonic, NameOfXMMRegister(regop));
 
1060
      AppendToBuffer("%sd %s,", mnemonic, NameOfXMMRegister(regop));
1061
1061
      current += PrintRightOperand(current);
1062
1062
    } else if ((opcode & 0xF8) == 0x58 || opcode == 0x51) {
1063
1063
      // XMM arithmetic. Mnemonic was retrieved at the start of this function.
1070
1070
    }
1071
1071
  } else if (group_1_prefix_ == 0xF3) {
1072
1072
    // Instructions with prefix 0xF3.
1073
 
    if (opcode == 0x2C) {
 
1073
    if (opcode == 0x11 || opcode == 0x10) {
 
1074
      // MOVSS: Move scalar double-precision fp to/from/between XMM registers.
 
1075
      AppendToBuffer("movss ");
 
1076
      int mod, regop, rm;
 
1077
      get_modrm(*current, &mod, &regop, &rm);
 
1078
      if (opcode == 0x11) {
 
1079
        current += PrintRightOperand(current);
 
1080
        AppendToBuffer(",%s", NameOfXMMRegister(regop));
 
1081
      } else {
 
1082
        AppendToBuffer("%s,", NameOfXMMRegister(regop));
 
1083
        current += PrintRightOperand(current);
 
1084
      }
 
1085
    } else if (opcode == 0x2A) {
 
1086
      // CVTSI2SS: integer to XMM single conversion.
 
1087
      int mod, regop, rm;
 
1088
      get_modrm(*current, &mod, &regop, &rm);
 
1089
      AppendToBuffer("%ss %s,", mnemonic, NameOfXMMRegister(regop));
 
1090
      current += PrintRightOperand(current);
 
1091
    } else if (opcode == 0x2C) {
1074
1092
      // CVTTSS2SI: Convert scalar single-precision FP to dword integer.
1075
1093
      // Assert that mod is not 3, so source is memory, not an XMM register.
1076
1094
      ASSERT_NE(0xC0, *current & 0xC0);
1146
1164
  switch (opcode) {
1147
1165
    case 0x1F:
1148
1166
      return "nop";
1149
 
    case 0x2A:  // F2 prefix.
1150
 
      return "cvtsi2sd";
 
1167
    case 0x2A:  // F2/F3 prefix.
 
1168
      return "cvtsi2s";
1151
1169
    case 0x31:
1152
1170
      return "rdtsc";
1153
1171
    case 0x51:  // F2 prefix.