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

Side by Side Diff: runtime/vm/constants_mips.h

Issue 14206002: Adds some floating point instructions to MIPS simulator, assembler, disassembler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 #ifndef VM_CONSTANTS_MIPS_H_ 5 #ifndef VM_CONSTANTS_MIPS_H_
6 #define VM_CONSTANTS_MIPS_H_ 6 #define VM_CONSTANTS_MIPS_H_
7 7
8 namespace dart { 8 namespace dart {
9 9
10 enum Register { 10 enum Register {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 K0 = R26, 81 K0 = R26,
82 K1 = R27, 82 K1 = R27,
83 83
84 GP = R28, 84 GP = R28,
85 SP = R29, 85 SP = R29,
86 FP = R30, 86 FP = R30,
87 RA = R31, 87 RA = R31,
88 }; 88 };
89 89
90 90
91 // Values for double-precision floating point registers. 91 // Values for floating point registers.
92 // Double-precision values use register pairs.
92 enum FRegister { 93 enum FRegister {
93 F0 = 0, 94 F0 = 0,
94 F1 = 1, 95 F1 = 1,
95 F2 = 2, 96 F2 = 2,
96 F3 = 3, 97 F3 = 3,
97 F4 = 4, 98 F4 = 4,
98 F5 = 5, 99 F5 = 5,
99 F6 = 6, 100 F6 = 6,
100 F7 = 7, 101 F7 = 7,
101 F8 = 8, 102 F8 = 8,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 156
156 const RegList kAbiArgumentCpuRegs = 157 const RegList kAbiArgumentCpuRegs =
157 (1 << A0) | (1 << A1) | (1 << A2) | (1 << A3); 158 (1 << A0) | (1 << A1) | (1 << A2) | (1 << A3);
158 const RegList kAbiPreservedCpuRegs = 159 const RegList kAbiPreservedCpuRegs =
159 (1 << S0) | (1 << S1) | (1 << S2) | (1 << S3) | 160 (1 << S0) | (1 << S1) | (1 << S2) | (1 << S3) |
160 (1 << S4) | (1 << S5) | (1 << S6) | (1 << S7); 161 (1 << S4) | (1 << S5) | (1 << S6) | (1 << S7);
161 const int kAbiPreservedCpuRegCount = 8; 162 const int kAbiPreservedCpuRegCount = 8;
162 163
163 164
165 // FPU registers 20 - 31 are preserved across calls.
166 const FRegister kAbiFirstPreservedFpuReg = F20;
167 const FRegister kAbiLastPreservedFpuReg =
168 static_cast<FRegister>(kNumberOfFRegisters - 1);
169
170 // FPU registers 0 - 19 are not preserved across calls.
171 const FRegister kDartFirstVolatileFpuReg = F0;
172 const FRegister kDartLastVolatileFpuReg = F19;
173 const int kDartVolatileFpuRegCount = 20;
174
164 // Dart stack frame layout. 175 // Dart stack frame layout.
165 static const int kLastParamSlotIndex = 3; 176 static const int kLastParamSlotIndex = 3;
166 static const int kFirstLocalSlotIndex = -2; 177 static const int kFirstLocalSlotIndex = -2;
167 178
168 179
169 // Values for the condition field. 180 // Values for the condition field.
170 // There is no condition field on MIPS, but Conditions are used and passed 181 // There is no condition field on MIPS, but Conditions are used and passed
171 // around by the intermediate language, so we need them here, too. 182 // around by the intermediate language, so we need them here, too.
172 enum Condition { 183 enum Condition {
173 EQ, // equal 184 EQ, // equal
174 NE, // not equal 185 NE, // not equal
175 }; 186 };
176 187
177 188
178 // Constants used for the decoding or encoding of the individual fields of 189 // Constants used for the decoding or encoding of the individual fields of
179 // instructions. Based on the "Table 4.25 CPU Instruction Format Fields". 190 // instructions. Based on the "Table 4.25 CPU Instruction Format Fields".
180 enum InstructionFields { 191 enum InstructionFields {
181 kOpcodeShift = 26, 192 kOpcodeShift = 26,
182 kOpcodeBits = 6, 193 kOpcodeBits = 6,
183 kRsShift = 21, 194 kRsShift = 21,
184 kRsBits = 5, 195 kRsBits = 5,
196 kFmtShift = 21,
197 kFmtBits = 5,
185 kRtShift = 16, 198 kRtShift = 16,
186 kRtBits = 5, 199 kRtBits = 5,
200 kFtShift = 16,
201 kFtBits = 5,
187 kRdShift = 11, 202 kRdShift = 11,
188 kRdBits = 5, 203 kRdBits = 5,
204 kFsShift = 11,
205 kFsBits = 5,
189 kSaShift = 6, 206 kSaShift = 6,
190 kSaBits = 5, 207 kSaBits = 5,
208 kFdShift = 6,
209 kFdBits = 5,
191 kFunctionShift = 0, 210 kFunctionShift = 0,
192 kFunctionBits = 6, 211 kFunctionBits = 6,
212 kCop1FnShift = 0,
213 kCop1FnBits = 6,
214 kCop1SubShift = 21,
215 kCop1SubBits = 5,
193 kImmShift = 0, 216 kImmShift = 0,
194 kImmBits = 16, 217 kImmBits = 16,
195 kInstrShift = 0, 218 kInstrShift = 0,
196 kInstrBits = 26, 219 kInstrBits = 26,
197 kBreakCodeShift = 6, 220 kBreakCodeShift = 6,
198 kBreakCodeBits = 20, 221 kBreakCodeBits = 20,
199 222
200 kBranchOffsetMask = 0x0000ffff, 223 kBranchOffsetMask = 0x0000ffff,
201 }; 224 };
202 225
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 TEQI = 12, 338 TEQI = 12,
316 TNEI = 14, 339 TNEI = 14,
317 BLTZAL = 16, 340 BLTZAL = 16,
318 BGEZAL = 17, 341 BGEZAL = 17,
319 BLTZALL = 18, 342 BLTZALL = 18,
320 BGEZALL = 19, 343 BGEZALL = 19,
321 SYNCI = 31, 344 SYNCI = 31,
322 }; 345 };
323 346
324 347
348 enum Cop1Function {
349 COP1_ADD = 0,
350 COP1_MOV = 6,
351 };
352
353 enum Cop1Sub {
354 COP1_MF = 0,
355 COP1_MT = 4,
356 };
357
358 enum Format {
359 FMT_S = 16,
360 FMT_D = 17,
361 FMT_W = 20,
362 FMT_L = 21,
363 FMT_PS = 22,
364 };
365
325 class Instr { 366 class Instr {
326 public: 367 public:
327 enum { 368 enum {
328 kInstrSize = 4, 369 kInstrSize = 4,
329 }; 370 };
330 371
331 static const int32_t kBreakPointInstruction = 372 static const int32_t kBreakPointInstruction =
332 (SPECIAL << kOpcodeShift) | (BREAK << kFunctionShift); 373 (SPECIAL << kOpcodeShift) | (BREAK << kFunctionShift);
333 static const int32_t kNopInstruction = 0; 374 static const int32_t kNopInstruction = 0;
334 static const int32_t kStopMessageCode = 1; 375 static const int32_t kStopMessageCode = 1;
(...skipping 29 matching lines...) Expand all
364 } 405 }
365 406
366 inline Register RtField() const { 407 inline Register RtField() const {
367 return static_cast<Register>(Bits(kRtShift, kRtBits)); 408 return static_cast<Register>(Bits(kRtShift, kRtBits));
368 } 409 }
369 410
370 inline Register RdField() const { 411 inline Register RdField() const {
371 return static_cast<Register>(Bits(kRdShift, kRdBits)); 412 return static_cast<Register>(Bits(kRdShift, kRdBits));
372 } 413 }
373 414
415 inline FRegister FsField() const {
416 return static_cast<FRegister>(Bits(kFsShift, kFsBits));
417 }
418
419 inline FRegister FtField() const {
420 return static_cast<FRegister>(Bits(kFtShift, kFtBits));
421 }
422
423 inline FRegister FdField() const {
424 return static_cast<FRegister>(Bits(kFdShift, kFdBits));
425 }
426
374 inline int SaField() const { 427 inline int SaField() const {
375 return Bits(kSaShift, kSaBits); 428 return Bits(kSaShift, kSaBits);
376 } 429 }
377 430
378 inline int32_t UImmField() const { 431 inline int32_t UImmField() const {
379 return Bits(kImmShift, kImmBits); 432 return Bits(kImmShift, kImmBits);
380 } 433 }
381 434
382 inline int32_t SImmField() const { 435 inline int32_t SImmField() const {
383 // Sign-extend the imm field. 436 // Sign-extend the imm field.
384 return (Bits(kImmShift, kImmBits) << (32 - kImmBits)) >> (32 - kImmBits); 437 return (Bits(kImmShift, kImmBits) << (32 - kImmBits)) >> (32 - kImmBits);
385 } 438 }
386 439
387 inline int32_t BreakCodeField() const { 440 inline int32_t BreakCodeField() const {
388 return Bits(kBreakCodeShift, kBreakCodeBits); 441 return Bits(kBreakCodeShift, kBreakCodeBits);
389 } 442 }
390 443
391 inline SpecialFunction FunctionField() const { 444 inline SpecialFunction FunctionField() const {
392 return static_cast<SpecialFunction>(Bits(kFunctionShift, kFunctionBits)); 445 return static_cast<SpecialFunction>(Bits(kFunctionShift, kFunctionBits));
393 } 446 }
394 447
395 inline RtRegImm RegImmFnField() const { 448 inline RtRegImm RegImmFnField() const {
396 return static_cast<RtRegImm>(Bits(kRtShift, kRtBits)); 449 return static_cast<RtRegImm>(Bits(kRtShift, kRtBits));
397 } 450 }
398 451
399 inline bool IsBreakPoint() { 452 inline bool IsBreakPoint() {
400 return (OpcodeField() == SPECIAL) && (FunctionField() == BREAK); 453 return (OpcodeField() == SPECIAL) && (FunctionField() == BREAK);
401 } 454 }
402 455
456 inline Cop1Function Cop1FunctionField() const {
457 return static_cast<Cop1Function>(Bits(kCop1FnShift, kCop1FnBits));
458 }
459
460 inline Cop1Sub Cop1SubField() const {
461 return static_cast<Cop1Sub>(Bits(kCop1SubShift, kCop1SubBits));
462 }
463
464 inline bool HasFormat() const {
465 return (OpcodeField() == COP1) && (Bit(25) == 1);
466 }
467
468 inline Format FormatField() const {
469 return static_cast<Format>(Bits(kFmtShift, kFmtBits));
470 }
471
403 // Instructions are read out of a code stream. The only way to get a 472 // Instructions are read out of a code stream. The only way to get a
404 // reference to an instruction is to convert a pc. There is no way 473 // reference to an instruction is to convert a pc. There is no way
405 // to allocate or create instances of class Instr. 474 // to allocate or create instances of class Instr.
406 // Use the At(pc) function to create references to Instr. 475 // Use the At(pc) function to create references to Instr.
407 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); } 476 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }
408 477
409 private: 478 private:
410 DISALLOW_ALLOCATION(); 479 DISALLOW_ALLOCATION();
411 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); 480 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
412 }; 481 };
413 482
414 } // namespace dart 483 } // namespace dart
415 484
416 #endif // VM_CONSTANTS_MIPS_H_ 485 #endif // VM_CONSTANTS_MIPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698