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

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

Issue 12545024: Adds a few MIPS arithmetic instructions to the 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 18 matching lines...) Expand all
29 void Print(const char* str); 29 void Print(const char* str);
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 40
40 // Convenience functions. 41 // Convenience functions.
41 char* get_buffer() const { return buffer_; } 42 char* get_buffer() const { return buffer_; }
42 char* current_position_in_buffer() { return buffer_ + buffer_pos_; } 43 char* current_position_in_buffer() { return buffer_ + buffer_pos_; }
43 size_t remaining_size_in_buffer() { return buffer_size_ - buffer_pos_; } 44 size_t remaining_size_in_buffer() { return buffer_size_ - buffer_pos_; }
44 45
45 char* buffer_; // Decode instructions into this buffer. 46 char* buffer_; // Decode instructions into this buffer.
46 size_t buffer_size_; // The size of the character buffer. 47 size_t buffer_size_; // The size of the character buffer.
47 size_t buffer_pos_; // Current character position in buffer. 48 size_t buffer_pos_; // Current character position in buffer.
48 49
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 buffer_[buffer_pos_++] = cur; 170 buffer_[buffer_pos_++] = cur;
170 } 171 }
171 cur = *format++; 172 cur = *format++;
172 } 173 }
173 buffer_[buffer_pos_] = '\0'; 174 buffer_[buffer_pos_] = '\0';
174 } 175 }
175 176
176 177
177 void MIPSDecoder::DecodeSpecial(Instr* instr) { 178 void MIPSDecoder::DecodeSpecial(Instr* instr) {
178 switch (instr->FunctionField()) { 179 switch (instr->FunctionField()) {
180 case ADDU: {
181 Format(instr, "addu 'rd, 'rs, 'rt");
182 break;
183 }
184 case AND: {
185 Format(instr, "and 'rd, 'rs, 'rt");
186 break;
187 }
188 case DIV: {
189 Format(instr, "div 'rs, 'rt");
190 break;
191 }
192 case DIVU: {
193 Format(instr, "divu 'rs, 'rt");
194 break;
195 }
196 case MFHI: {
197 Format(instr, "mfhi 'rd");
198 break;
199 }
200 case MFLO: {
201 Format(instr, "mflo 'rd");
202 break;
203 }
179 case SLL: { 204 case SLL: {
180 if ((instr->RdField() == R0) && 205 if ((instr->RdField() == R0) &&
181 (instr->RtField() == R0) && 206 (instr->RtField() == R0) &&
182 (instr->SaField() == 0)) { 207 (instr->SaField() == 0)) {
183 Format(instr, "nop"); 208 Format(instr, "nop");
184 } else { 209 } else {
185 Format(instr, "sll 'rd, 'rt, 'sa"); 210 Format(instr, "sll 'rd, 'rt, 'sa");
186 } 211 }
187 break; 212 break;
188 } 213 }
189 case JR: { 214 case JR: {
190 ASSERT(instr->RtField() == R0); 215 ASSERT(instr->RtField() == R0);
191 ASSERT(instr->RdField() == R0); 216 ASSERT(instr->RdField() == R0);
192 Format(instr, "jr'hint 'rs"); 217 Format(instr, "jr'hint 'rs");
193 break; 218 break;
194 } 219 }
195 default: { 220 default: {
196 OS::PrintErr("DecodeSpecial: 0x%x\n", instr->InstructionBits()); 221 OS::PrintErr("DecodeSpecial: 0x%x\n", instr->InstructionBits());
197 UNREACHABLE(); 222 UNREACHABLE();
198 break; 223 break;
199 } 224 }
200 } 225 }
201 } 226 }
202 227
203 228
229 void MIPSDecoder::DecodeSpecial2(Instr* instr) {
230 switch (instr->FunctionField()) {
231 case CLO: {
232 Format(instr, "clo 'rd, 'rs");
233 }
234 case CLZ: {
235 Format(instr, "clz 'rd, 'rs");
236 }
237 default: {
238 OS::PrintErr("DecodeSpecial2: 0x%x\n", instr->InstructionBits());
239 UNREACHABLE();
240 break;
241 }
242 }
243 }
244
245
204 void MIPSDecoder::InstructionDecode(Instr* instr) { 246 void MIPSDecoder::InstructionDecode(Instr* instr) {
205 switch (instr->OpcodeField()) { 247 switch (instr->OpcodeField()) {
206 case SPECIAL: { 248 case SPECIAL: {
207 DecodeSpecial(instr); 249 DecodeSpecial(instr);
208 break; 250 break;
209 } 251 }
252 case SPECIAL2: {
253 DecodeSpecial2(instr);
254 break;
255 }
256 case ADDI: {
257 Format(instr, "addi 'rt, 'rs, 'immu");
258 break;
259 }
260 case ADDIU: {
261 Format(instr, "addiu 'rt, 'rs, 'immu");
262 break;
263 }
264 case ANDI: {
265 Format(instr, "andi 'rt, 'rs, 'immu");
266 break;
267 }
210 case ORI: { 268 case ORI: {
211 Format(instr, "ori 'rt, 'rs, 'immu"); 269 Format(instr, "ori 'rt, 'rs, 'immu");
212 break; 270 break;
213 } 271 }
214 default: { 272 default: {
215 OS::PrintErr("Undecoded instruction: 0x%x\n", instr->InstructionBits()); 273 OS::PrintErr("Undecoded instruction: 0x%x\n", instr->InstructionBits());
216 UNREACHABLE(); 274 UNREACHABLE();
217 break; 275 break;
218 } 276 }
219 } 277 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 human_buffer, 317 human_buffer,
260 sizeof(human_buffer), 318 sizeof(human_buffer),
261 pc); 319 pc);
262 pc += instruction_length; 320 pc += instruction_length;
263 } 321 }
264 } 322 }
265 323
266 } // namespace dart 324 } // namespace dart
267 325
268 #endif // defined TARGET_ARCH_MIPS 326 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698