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

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

Issue 155109: - Update comments and fix a small glitch in the ARM disassembler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 // Handle execution based on instruction types. 1073 // Handle execution based on instruction types.
1074 1074
1075 // Instruction types 0 and 1 are both rolled into one function because they 1075 // Instruction types 0 and 1 are both rolled into one function because they
1076 // only differ in the handling of the shifter_operand. 1076 // only differ in the handling of the shifter_operand.
1077 void Simulator::DecodeType01(Instr* instr) { 1077 void Simulator::DecodeType01(Instr* instr) {
1078 int type = instr->TypeField(); 1078 int type = instr->TypeField();
1079 if ((type == 0) && instr->IsSpecialType0()) { 1079 if ((type == 0) && instr->IsSpecialType0()) {
1080 // multiply instruction or extra loads and stores 1080 // multiply instruction or extra loads and stores
1081 if (instr->Bits(7, 4) == 9) { 1081 if (instr->Bits(7, 4) == 9) {
1082 if (instr->Bit(24) == 0) { 1082 if (instr->Bit(24) == 0) {
1083 // Multiply instructions have Rd in a funny place. 1083 // Raw field decoding here. Multiply instructions have their Rd in
1084 int rd = instr->RnField(); 1084 // funny places.
1085 int rn = instr->RnField();
1085 int rm = instr->RmField(); 1086 int rm = instr->RmField();
1086 int rs = instr->RsField(); 1087 int rs = instr->RsField();
1087 int32_t rs_val = get_register(rs); 1088 int32_t rs_val = get_register(rs);
1088 int32_t rm_val = get_register(rm); 1089 int32_t rm_val = get_register(rm);
1089 if (instr->Bit(23) == 0) { 1090 if (instr->Bit(23) == 0) {
1090 if (instr->Bit(21) == 0) { 1091 if (instr->Bit(21) == 0) {
1092 // The MUL instruction description (A 4.1.33) refers to Rd as being
1093 // the destination for the operation, but it confusingly uses the
1094 // Rn field to encode it.
1091 // Format(instr, "mul'cond's 'rn, 'rm, 'rs"); 1095 // Format(instr, "mul'cond's 'rn, 'rm, 'rs");
1096 int rd = rn; // Remap the rn field to the Rd register.
1092 int32_t alu_out = rm_val * rs_val; 1097 int32_t alu_out = rm_val * rs_val;
1093 set_register(rd, alu_out); 1098 set_register(rd, alu_out);
1094 if (instr->HasS()) { 1099 if (instr->HasS()) {
1095 SetNZFlags(alu_out); 1100 SetNZFlags(alu_out);
1096 } 1101 }
1097 } else { 1102 } else {
1098 UNIMPLEMENTED(); // mla is not used by V8. 1103 // mla is not currently being used by V8.
1104 Format(instr, "mla'cond's 'rd, 'rm, 'rs, 'rn");
Erik Corry 2009/07/07 08:14:16 Should be 'rn 'rm 'rs 'rd for similar reasons to t
iposva 2009/07/08 21:33:26 Fixed by copying the whole block out of the disass
1099 } 1105 }
1100 } else { 1106 } else {
1101 // Format(instr, "'um'al'cond's 'rn, 'rd, 'rs, 'rm"); 1107 // The signed/long multiply instructions use the terms RdHi and RdLo
1108 // when referring to the target registers. They are mapped to the Rn
1109 // and Rd fields as follows:
1110 // RdLo == Rd
1111 // RdHi == Rn (This is confusingly stored in variable rd here
1112 // because the mul instruction from above uses the
1113 // Rn field to encode the Rd register. Good luck figuring
1114 // this out without reading the ARM instruction manual
1115 // at a very detailed level.)
1116 // Format(instr, "'um'al'cond's 'rd, 'rn, 'rs, 'rm");
1117 int rd_hi = rn; // Remap the rn field to the RdHi register.
1102 int rd_lo = instr->RdField(); 1118 int rd_lo = instr->RdField();
1103 int32_t hi_res = 0; 1119 int32_t hi_res = 0;
1104 int32_t lo_res = 0; 1120 int32_t lo_res = 0;
1105 if (instr->Bit(22) == 1) { 1121 if (instr->Bit(22) == 1) {
1106 int64_t left_op = static_cast<int32_t>(rm_val); 1122 int64_t left_op = static_cast<int32_t>(rm_val);
1107 int64_t right_op = static_cast<int32_t>(rs_val); 1123 int64_t right_op = static_cast<int32_t>(rs_val);
1108 uint64_t result = left_op * right_op; 1124 uint64_t result = left_op * right_op;
1109 hi_res = static_cast<int32_t>(result >> 32); 1125 hi_res = static_cast<int32_t>(result >> 32);
1110 lo_res = static_cast<int32_t>(result & 0xffffffff); 1126 lo_res = static_cast<int32_t>(result & 0xffffffff);
1111 } else { 1127 } else {
1112 // unsigned multiply 1128 // unsigned multiply
1113 uint64_t left_op = static_cast<uint32_t>(rm_val); 1129 uint64_t left_op = static_cast<uint32_t>(rm_val);
1114 uint64_t right_op = static_cast<uint32_t>(rs_val); 1130 uint64_t right_op = static_cast<uint32_t>(rs_val);
1115 uint64_t result = left_op * right_op; 1131 uint64_t result = left_op * right_op;
1116 hi_res = static_cast<int32_t>(result >> 32); 1132 hi_res = static_cast<int32_t>(result >> 32);
1117 lo_res = static_cast<int32_t>(result & 0xffffffff); 1133 lo_res = static_cast<int32_t>(result & 0xffffffff);
1118 } 1134 }
1119 set_register(rd_lo, lo_res); 1135 set_register(rd_lo, lo_res);
1120 set_register(rd, hi_res); 1136 set_register(rd_hi, hi_res);
1121 if (instr->HasS()) { 1137 if (instr->HasS()) {
1122 UNIMPLEMENTED(); 1138 UNIMPLEMENTED();
1123 } 1139 }
1124 } 1140 }
1125 } else { 1141 } else {
1126 UNIMPLEMENTED(); // not used by V8 1142 UNIMPLEMENTED(); // not used by V8
1127 } 1143 }
1128 } else { 1144 } else {
1129 // extra load/store instructions 1145 // extra load/store instructions
1130 int rd = instr->RdField(); 1146 int rd = instr->RdField();
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 set_register(r10, r10_val); 1810 set_register(r10, r10_val);
1795 set_register(r11, r11_val); 1811 set_register(r11, r11_val);
1796 1812
1797 int result = get_register(r0); 1813 int result = get_register(r0);
1798 return reinterpret_cast<Object*>(result); 1814 return reinterpret_cast<Object*>(result);
1799 } 1815 }
1800 1816
1801 } } // namespace assembler::arm 1817 } } // namespace assembler::arm
1802 1818
1803 #endif // !defined(__arm__) 1819 #endif // !defined(__arm__)
OLDNEW
« src/arm/macro-assembler-arm.cc ('K') | « src/arm/macro-assembler-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698