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

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

Issue 12519007: Adds MIPS instructions to simulator, assembler, disassembler (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 (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 "vm/disassembler.h" 5 #include "vm/disassembler.h"
6 6
7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. 7 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
8 #if defined(TARGET_ARCH_MIPS) 8 #if defined(TARGET_ARCH_MIPS)
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 // Printing of common values. 31 // Printing of common values.
32 void PrintRegister(Register reg); 32 void PrintRegister(Register reg);
33 33
34 int FormatRegister(Instr* instr, const char* format); 34 int FormatRegister(Instr* instr, const char* format);
35 int FormatOption(Instr* instr, const char* format); 35 int FormatOption(Instr* instr, const char* format);
36 void Format(Instr* instr, const char* format); 36 void Format(Instr* instr, const char* format);
37 37
38 void DecodeSpecial(Instr* instr); 38 void DecodeSpecial(Instr* instr);
39 void DecodeSpecial2(Instr* instr); 39 void DecodeSpecial2(Instr* instr);
40 void DecodeSpecial3(Instr* instr);
40 41
41 // Convenience functions. 42 // Convenience functions.
42 char* get_buffer() const { return buffer_; } 43 char* get_buffer() const { return buffer_; }
43 char* current_position_in_buffer() { return buffer_ + buffer_pos_; } 44 char* current_position_in_buffer() { return buffer_ + buffer_pos_; }
44 size_t remaining_size_in_buffer() { return buffer_size_ - buffer_pos_; } 45 size_t remaining_size_in_buffer() { return buffer_size_ - buffer_pos_; }
45 46
46 char* buffer_; // Decode instructions into this buffer. 47 char* buffer_; // Decode instructions into this buffer.
47 size_t buffer_size_; // The size of the character buffer. 48 size_t buffer_size_; // The size of the character buffer.
48 size_t buffer_pos_; // Current character position in buffer. 49 size_t buffer_pos_; // Current character position in buffer.
49 50
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } else { 170 } else {
170 buffer_[buffer_pos_++] = cur; 171 buffer_[buffer_pos_++] = cur;
171 } 172 }
172 cur = *format++; 173 cur = *format++;
173 } 174 }
174 buffer_[buffer_pos_] = '\0'; 175 buffer_[buffer_pos_] = '\0';
175 } 176 }
176 177
177 178
178 void MIPSDecoder::DecodeSpecial(Instr* instr) { 179 void MIPSDecoder::DecodeSpecial(Instr* instr) {
180 ASSERT(instr->OpcodeField() == SPECIAL);
179 switch (instr->FunctionField()) { 181 switch (instr->FunctionField()) {
180 case ADDU: { 182 case ADDU: {
181 Format(instr, "addu 'rd, 'rs, 'rt"); 183 Format(instr, "addu 'rd, 'rs, 'rt");
182 break; 184 break;
183 } 185 }
184 case AND: { 186 case AND: {
185 Format(instr, "and 'rd, 'rs, 'rt"); 187 Format(instr, "and 'rd, 'rs, 'rt");
186 break; 188 break;
187 } 189 }
188 case DIV: { 190 case DIV: {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 default: { 222 default: {
221 OS::PrintErr("DecodeSpecial: 0x%x\n", instr->InstructionBits()); 223 OS::PrintErr("DecodeSpecial: 0x%x\n", instr->InstructionBits());
222 UNREACHABLE(); 224 UNREACHABLE();
223 break; 225 break;
224 } 226 }
225 } 227 }
226 } 228 }
227 229
228 230
229 void MIPSDecoder::DecodeSpecial2(Instr* instr) { 231 void MIPSDecoder::DecodeSpecial2(Instr* instr) {
232 ASSERT(instr->OpcodeField() == SPECIAL2);
230 switch (instr->FunctionField()) { 233 switch (instr->FunctionField()) {
231 case CLO: { 234 case CLO: {
232 Format(instr, "clo 'rd, 'rs"); 235 Format(instr, "clo 'rd, 'rs");
233 break; 236 break;
234 } 237 }
235 case CLZ: { 238 case CLZ: {
236 Format(instr, "clz 'rd, 'rs"); 239 Format(instr, "clz 'rd, 'rs");
237 break; 240 break;
238 } 241 }
239 default: { 242 default: {
240 OS::PrintErr("DecodeSpecial2: 0x%x\n", instr->InstructionBits()); 243 OS::PrintErr("DecodeSpecial2: 0x%x\n", instr->InstructionBits());
241 UNREACHABLE(); 244 UNREACHABLE();
242 break; 245 break;
243 } 246 }
244 } 247 }
245 } 248 }
246 249
247 250
251 void MIPSDecoder::DecodeSpecial3(Instr* instr) {
252 ASSERT(instr->OpcodeField() == SPECIAL3);
253 switch (instr->FunctionField()) {
254 case EXT: {
255 Format(instr, "ext 'rt, 'rs, 'sa, 'rd");
Ivan Posva 2013/03/11 17:29:04 'rd is certainly incorrect here. It will print the
256 break;
257 }
258 case INS: {
259 Format(instr, "ins 'rt, 'rs, 'sa, 'rd");
Ivan Posva 2013/03/11 17:29:04 ditto
260 break;
261 }
262 default: {
263 OS::PrintErr("DecodeSpecial3: 0x%x\n", instr->InstructionBits());
264 UNREACHABLE();
265 break;
266 }
267 }
268 }
269
270
248 void MIPSDecoder::InstructionDecode(Instr* instr) { 271 void MIPSDecoder::InstructionDecode(Instr* instr) {
249 switch (instr->OpcodeField()) { 272 switch (instr->OpcodeField()) {
250 case SPECIAL: { 273 case SPECIAL: {
251 DecodeSpecial(instr); 274 DecodeSpecial(instr);
252 break; 275 break;
253 } 276 }
254 case SPECIAL2: { 277 case SPECIAL2: {
255 DecodeSpecial2(instr); 278 DecodeSpecial2(instr);
256 break; 279 break;
257 } 280 }
281 case SPECIAL3: {
282 DecodeSpecial3(instr);
283 break;
284 }
258 case ADDI: { 285 case ADDI: {
259 Format(instr, "addi 'rt, 'rs, 'immu"); 286 Format(instr, "addi 'rt, 'rs, 'imms");
260 break; 287 break;
261 } 288 }
262 case ADDIU: { 289 case ADDIU: {
263 Format(instr, "addiu 'rt, 'rs, 'immu"); 290 Format(instr, "addiu 'rt, 'rs, 'imms");
264 break; 291 break;
265 } 292 }
266 case ANDI: { 293 case ANDI: {
267 Format(instr, "andi 'rt, 'rs, 'immu"); 294 Format(instr, "andi 'rt, 'rs, 'immu");
268 break; 295 break;
269 } 296 }
297 case LB: {
298 Format(instr, "lb 'rt, 'imms('rs)");
299 break;
300 }
301 case LBU: {
302 Format(instr, "lbu 'rt, 'imms('rs)");
303 break;
304 }
305 case LH: {
306 Format(instr, "lh 'rt, 'imms('rs)");
307 break;
308 }
270 case LUI: { 309 case LUI: {
271 Format(instr, "lui 'rt, 'immu"); 310 Format(instr, "lui 'rt, 'immu");
272 break; 311 break;
273 } 312 }
313 case LW: {
314 Format(instr, "lw 'rt, 'imms('rs)");
315 break;
316 }
274 case ORI: { 317 case ORI: {
275 Format(instr, "ori 'rt, 'rs, 'immu"); 318 Format(instr, "ori 'rt, 'rs, 'immu");
276 break; 319 break;
277 } 320 }
321 case SB: {
322 Format(instr, "sb 'rt, 'imms('rs)");
323 break;
324 }
325 case SH: {
326 Format(instr, "sh 'rt, 'imms('rs)");
327 break;
328 }
329 case SW: {
330 Format(instr, "sw 'rt, 'imms('rs)");
331 break;
332 }
278 default: { 333 default: {
279 OS::PrintErr("Undecoded instruction: 0x%x\n", instr->InstructionBits()); 334 OS::PrintErr("Undecoded instruction: 0x%x\n", instr->InstructionBits());
280 UNREACHABLE(); 335 UNREACHABLE();
281 break; 336 break;
282 } 337 }
283 } 338 }
284 } 339 }
285 340
286 341
287 int Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size, 342 int Disassembler::DecodeInstruction(char* hex_buffer, intptr_t hex_size,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 human_buffer, 378 human_buffer,
324 sizeof(human_buffer), 379 sizeof(human_buffer),
325 pc); 380 pc);
326 pc += instruction_length; 381 pc += instruction_length;
327 } 382 }
328 } 383 }
329 384
330 } // namespace dart 385 } // namespace dart
331 386
332 #endif // defined TARGET_ARCH_MIPS 387 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698