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

Side by Side Diff: src/mips/constants-mips.h

Issue 1320006: Updates and fixes for MIPS support. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_MIPS_CONSTANTS_H_ 28 #ifndef V8_MIPS_CONSTANTS_H_
29 #define V8_MIPS_CONSTANTS_H_ 29 #define V8_MIPS_CONSTANTS_H_
30 30
31 #include "checks.h" 31 #include "checks.h"
32 32
33 // UNIMPLEMENTED_ macro for MIPS. 33 // UNIMPLEMENTED_ macro for MIPS.
34 #ifdef DEBUG
34 #define UNIMPLEMENTED_MIPS() \ 35 #define UNIMPLEMENTED_MIPS() \
35 v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ 36 v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \
36 __FILE__, __LINE__, __func__) 37 __FILE__, __LINE__, __func__)
38 #else
39 #define UNIMPLEMENTED_MIPS()
40 #endif
41
37 #define UNSUPPORTED_MIPS() v8::internal::PrintF("Unsupported instruction.\n") 42 #define UNSUPPORTED_MIPS() v8::internal::PrintF("Unsupported instruction.\n")
38 43
39 44
40 // Defines constants and accessor classes to assemble, disassemble and 45 // Defines constants and accessor classes to assemble, disassemble and
41 // simulate MIPS32 instructions. 46 // simulate MIPS32 instructions.
42 // 47 //
43 // See: MIPS32 Architecture For Programmers 48 // See: MIPS32 Architecture For Programmers
44 // Volume II: The MIPS32 Instruction Set 49 // Volume II: The MIPS32 Instruction Set
45 // Try www.cs.cornell.edu/courses/cs3410/2008fa/MIPS_Vol2.pdf. 50 // Try www.cs.cornell.edu/courses/cs3410/2008fa/MIPS_Vol2.pdf.
46 51
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 144
140 static const int kImm16Shift = 0; 145 static const int kImm16Shift = 0;
141 static const int kImm16Bits = 16; 146 static const int kImm16Bits = 16;
142 static const int kImm26Shift = 0; 147 static const int kImm26Shift = 0;
143 static const int kImm26Bits = 26; 148 static const int kImm26Bits = 26;
144 149
145 static const int kFsShift = 11; 150 static const int kFsShift = 11;
146 static const int kFsBits = 5; 151 static const int kFsBits = 5;
147 static const int kFtShift = 16; 152 static const int kFtShift = 16;
148 static const int kFtBits = 5; 153 static const int kFtBits = 5;
154 static const int kFdShift = 6;
155 static const int kFdBits = 5;
156 static const int kFCccShift = 8;
157 static const int kFCccBits = 3;
158 static const int kFBccShift = 18;
159 static const int kFBccBits = 3;
160 static const int kFBtrueShift = 16;
161 static const int kFBtrueBits = 1;
149 162
150 // ----- Miscellianous useful masks. 163 // ----- Miscellianous useful masks.
151 // Instruction bit masks. 164 // Instruction bit masks.
152 static const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; 165 static const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift;
153 static const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; 166 static const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift;
154 static const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; 167 static const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift;
155 static const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; 168 static const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift;
156 static const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; 169 static const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift;
157 static const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; 170 static const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift;
158 static const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; 171 static const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift;
(...skipping 28 matching lines...) Expand all
187 XORI = ((1 << 3) + 6) << kOpcodeShift, 200 XORI = ((1 << 3) + 6) << kOpcodeShift,
188 LUI = ((1 << 3) + 7) << kOpcodeShift, 201 LUI = ((1 << 3) + 7) << kOpcodeShift,
189 202
190 COP1 = ((2 << 3) + 1) << kOpcodeShift, // Coprocessor 1 class 203 COP1 = ((2 << 3) + 1) << kOpcodeShift, // Coprocessor 1 class
191 BEQL = ((2 << 3) + 4) << kOpcodeShift, 204 BEQL = ((2 << 3) + 4) << kOpcodeShift,
192 BNEL = ((2 << 3) + 5) << kOpcodeShift, 205 BNEL = ((2 << 3) + 5) << kOpcodeShift,
193 BLEZL = ((2 << 3) + 6) << kOpcodeShift, 206 BLEZL = ((2 << 3) + 6) << kOpcodeShift,
194 BGTZL = ((2 << 3) + 7) << kOpcodeShift, 207 BGTZL = ((2 << 3) + 7) << kOpcodeShift,
195 208
196 SPECIAL2 = ((3 << 3) + 4) << kOpcodeShift, 209 SPECIAL2 = ((3 << 3) + 4) << kOpcodeShift,
210 SPECIAL3 = ((3 << 3) + 7) << kOpcodeShift,
197 211
198 LB = ((4 << 3) + 0) << kOpcodeShift, 212 LB = ((4 << 3) + 0) << kOpcodeShift,
213 LH = ((4 << 3) + 1) << kOpcodeShift,
199 LW = ((4 << 3) + 3) << kOpcodeShift, 214 LW = ((4 << 3) + 3) << kOpcodeShift,
200 LBU = ((4 << 3) + 4) << kOpcodeShift, 215 LBU = ((4 << 3) + 4) << kOpcodeShift,
216 LHU = ((4 << 3) + 5) << kOpcodeShift,
201 SB = ((5 << 3) + 0) << kOpcodeShift, 217 SB = ((5 << 3) + 0) << kOpcodeShift,
218 SH = ((5 << 3) + 1) << kOpcodeShift,
202 SW = ((5 << 3) + 3) << kOpcodeShift, 219 SW = ((5 << 3) + 3) << kOpcodeShift,
203 220
204 LWC1 = ((6 << 3) + 1) << kOpcodeShift, 221 LWC1 = ((6 << 3) + 1) << kOpcodeShift,
205 LDC1 = ((6 << 3) + 5) << kOpcodeShift, 222 LDC1 = ((6 << 3) + 5) << kOpcodeShift,
206 223
207 SWC1 = ((7 << 3) + 1) << kOpcodeShift, 224 SWC1 = ((7 << 3) + 1) << kOpcodeShift,
208 SDC1 = ((7 << 3) + 5) << kOpcodeShift 225 SDC1 = ((7 << 3) + 5) << kOpcodeShift
209 }; 226 };
210 227
211 enum SecondaryField { 228 enum SecondaryField {
212 // SPECIAL Encoding of Function Field. 229 // SPECIAL Encoding of Function Field.
213 SLL = ((0 << 3) + 0), 230 SLL = ((0 << 3) + 0),
214 SRL = ((0 << 3) + 2), 231 SRL = ((0 << 3) + 2),
215 SRA = ((0 << 3) + 3), 232 SRA = ((0 << 3) + 3),
216 SLLV = ((0 << 3) + 4), 233 SLLV = ((0 << 3) + 4),
217 SRLV = ((0 << 3) + 6), 234 SRLV = ((0 << 3) + 6),
218 SRAV = ((0 << 3) + 7), 235 SRAV = ((0 << 3) + 7),
219 236
220 JR = ((1 << 3) + 0), 237 JR = ((1 << 3) + 0),
221 JALR = ((1 << 3) + 1), 238 JALR = ((1 << 3) + 1),
239 MOVZ = ((1 << 3) + 2),
240 MOVN = ((1 << 3) + 3),
222 BREAK = ((1 << 3) + 5), 241 BREAK = ((1 << 3) + 5),
223 242
224 MFHI = ((2 << 3) + 0), 243 MFHI = ((2 << 3) + 0),
225 MFLO = ((2 << 3) + 2), 244 MFLO = ((2 << 3) + 2),
226 245
227 MULT = ((3 << 3) + 0), 246 MULT = ((3 << 3) + 0),
228 MULTU = ((3 << 3) + 1), 247 MULTU = ((3 << 3) + 1),
229 DIV = ((3 << 3) + 2), 248 DIV = ((3 << 3) + 2),
230 DIVU = ((3 << 3) + 3), 249 DIVU = ((3 << 3) + 3),
231 250
(...skipping 11 matching lines...) Expand all
243 262
244 TGE = ((6 << 3) + 0), 263 TGE = ((6 << 3) + 0),
245 TGEU = ((6 << 3) + 1), 264 TGEU = ((6 << 3) + 1),
246 TLT = ((6 << 3) + 2), 265 TLT = ((6 << 3) + 2),
247 TLTU = ((6 << 3) + 3), 266 TLTU = ((6 << 3) + 3),
248 TEQ = ((6 << 3) + 4), 267 TEQ = ((6 << 3) + 4),
249 TNE = ((6 << 3) + 6), 268 TNE = ((6 << 3) + 6),
250 269
251 // SPECIAL2 Encoding of Function Field. 270 // SPECIAL2 Encoding of Function Field.
252 MUL = ((0 << 3) + 2), 271 MUL = ((0 << 3) + 2),
272 CLZ = ((4 << 3) + 0),
273 CLO = ((4 << 3) + 1),
274
275 // SPECIAL3 Encoding of Function Field.
276 EXT = ((0 << 3) + 0),
277 INS = ((0 << 3) + 4),
253 278
254 // REGIMM encoding of rt Field. 279 // REGIMM encoding of rt Field.
255 BLTZ = ((0 << 3) + 0) << 16, 280 BLTZ = ((0 << 3) + 0) << 16,
256 BGEZ = ((0 << 3) + 1) << 16, 281 BGEZ = ((0 << 3) + 1) << 16,
257 BLTZAL = ((2 << 3) + 0) << 16, 282 BLTZAL = ((2 << 3) + 0) << 16,
258 BGEZAL = ((2 << 3) + 1) << 16, 283 BGEZAL = ((2 << 3) + 1) << 16,
259 284
260 // COP1 Encoding of rs Field. 285 // COP1 Encoding of rs Field.
261 MFC1 = ((0 << 3) + 0) << 21, 286 MFC1 = ((0 << 3) + 0) << 21,
262 MFHC1 = ((0 << 3) + 3) << 21, 287 MFHC1 = ((0 << 3) + 3) << 21,
263 MTC1 = ((0 << 3) + 4) << 21, 288 MTC1 = ((0 << 3) + 4) << 21,
264 MTHC1 = ((0 << 3) + 7) << 21, 289 MTHC1 = ((0 << 3) + 7) << 21,
265 BC1 = ((1 << 3) + 0) << 21, 290 BC1 = ((1 << 3) + 0) << 21,
266 S = ((2 << 3) + 0) << 21, 291 S = ((2 << 3) + 0) << 21,
267 D = ((2 << 3) + 1) << 21, 292 D = ((2 << 3) + 1) << 21,
268 W = ((2 << 3) + 4) << 21, 293 W = ((2 << 3) + 4) << 21,
269 L = ((2 << 3) + 5) << 21, 294 L = ((2 << 3) + 5) << 21,
270 PS = ((2 << 3) + 6) << 21, 295 PS = ((2 << 3) + 6) << 21,
271 // COP1 Encoding of Function Field When rs=S. 296 // COP1 Encoding of Function Field When rs=S.
272 CVT_D_S = ((4 << 3) + 1), 297 CVT_D_S = ((4 << 3) + 1),
273 CVT_W_S = ((4 << 3) + 4), 298 CVT_W_S = ((4 << 3) + 4),
274 CVT_L_S = ((4 << 3) + 5), 299 CVT_L_S = ((4 << 3) + 5),
275 CVT_PS_S = ((4 << 3) + 6), 300 CVT_PS_S = ((4 << 3) + 6),
276 // COP1 Encoding of Function Field When rs=D. 301 // COP1 Encoding of Function Field When rs=D.
302 ADD_D = ((0 << 3) + 0),
303 SUB_D = ((0 << 3) + 1),
304 MUL_D = ((0 << 3) + 2),
305 DIV_D = ((0 << 3) + 3),
306 SQRT_D = ((0 << 3) + 4),
307 ABS_D = ((0 << 3) + 5),
308 MOV_D = ((0 << 3) + 6),
309 NEG_D = ((0 << 3) + 7),
277 CVT_S_D = ((4 << 3) + 0), 310 CVT_S_D = ((4 << 3) + 0),
278 CVT_W_D = ((4 << 3) + 4), 311 CVT_W_D = ((4 << 3) + 4),
279 CVT_L_D = ((4 << 3) + 5), 312 CVT_L_D = ((4 << 3) + 5),
313 C_F_D = ((6 << 3) + 0),
314 C_UN_D = ((6 << 3) + 1),
315 C_EQ_D = ((6 << 3) + 2),
316 C_UEQ_D = ((6 << 3) + 3),
317 C_OLT_D = ((6 << 3) + 4),
318 C_ULT_D = ((6 << 3) + 5),
319 C_OLE_D = ((6 << 3) + 6),
320 C_ULE_D = ((6 << 3) + 7),
280 // COP1 Encoding of Function Field When rs=W or L. 321 // COP1 Encoding of Function Field When rs=W or L.
281 CVT_S_W = ((4 << 3) + 0), 322 CVT_S_W = ((4 << 3) + 0),
282 CVT_D_W = ((4 << 3) + 1), 323 CVT_D_W = ((4 << 3) + 1),
283 CVT_S_L = ((4 << 3) + 0), 324 CVT_S_L = ((4 << 3) + 0),
284 CVT_D_L = ((4 << 3) + 1), 325 CVT_D_L = ((4 << 3) + 1),
285 // COP1 Encoding of Function Field When rs=PS. 326 // COP1 Encoding of Function Field When rs=PS.
286 327
287 NULLSF = 0 328 NULLSF = 0
288 }; 329 };
289 330
(...skipping 26 matching lines...) Expand all
316 357
317 // aliases 358 // aliases
318 carry = Uless, 359 carry = Uless,
319 not_carry = Ugreater_equal, 360 not_carry = Ugreater_equal,
320 zero = equal, 361 zero = equal,
321 eq = equal, 362 eq = equal,
322 not_zero = not_equal, 363 not_zero = not_equal,
323 ne = not_equal, 364 ne = not_equal,
324 sign = negative, 365 sign = negative,
325 not_sign = positive, 366 not_sign = positive,
367 mi = negative,
368 pl = positive,
369 hi = Ugreater,
370 ls = Uless_equal,
371 ge = greater_equal,
372 lt = less,
373 gt = greater,
374 le = less_equal,
375 hs = Ugreater_equal,
376 lo = Uless,
377 al = cc_always,
326 378
327 cc_default = no_condition 379 cc_default = no_condition
328 }; 380 };
329 381
330 // ----- Coprocessor conditions. 382 // ----- Coprocessor conditions.
331 enum FPUCondition { 383 enum FPUCondition {
332 F, // False 384 F, // False
333 UN, // Unordered 385 UN, // Unordered
334 EQ, // Equal 386 EQ, // Equal
335 UEQ, // Unordered or Equal 387 UEQ, // Unordered or Equal
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ASSERT(InstructionType() == kRegisterType); 466 ASSERT(InstructionType() == kRegisterType);
415 return Bits(kSaShift + kSaBits - 1, kSaShift); 467 return Bits(kSaShift + kSaBits - 1, kSaShift);
416 } 468 }
417 469
418 inline int FunctionField() const { 470 inline int FunctionField() const {
419 ASSERT(InstructionType() == kRegisterType || 471 ASSERT(InstructionType() == kRegisterType ||
420 InstructionType() == kImmediateType); 472 InstructionType() == kImmediateType);
421 return Bits(kFunctionShift + kFunctionBits - 1, kFunctionShift); 473 return Bits(kFunctionShift + kFunctionBits - 1, kFunctionShift);
422 } 474 }
423 475
476 inline int FdField() const {
477 return Bits(kFdShift + kFdBits - 1, kFdShift);
478 }
479
424 inline int FsField() const { 480 inline int FsField() const {
425 return Bits(kFsShift + kRsBits - 1, kFsShift); 481 return Bits(kFsShift + kFsBits - 1, kFsShift);
426 } 482 }
427 483
428 inline int FtField() const { 484 inline int FtField() const {
429 return Bits(kFtShift + kRsBits - 1, kFtShift); 485 return Bits(kFtShift + kFtBits - 1, kFtShift);
486 }
487
488 // Float Compare condition code instruction bits.
489 inline int FCccField() const {
490 return Bits(kFCccShift + kFCccBits - 1, kFCccShift);
491 }
492
493 // Float Branch condition code instruction bits.
494 inline int FBccField() const {
495 return Bits(kFBccShift + kFBccBits - 1, kFBccShift);
496 }
497
498 // Float Branch true/false instruction bit.
499 inline int FBtrueField() const {
500 return Bits(kFBtrueShift + kFBtrueBits - 1, kFBtrueShift);
430 } 501 }
431 502
432 // Return the fields at their original place in the instruction encoding. 503 // Return the fields at their original place in the instruction encoding.
433 inline Opcode OpcodeFieldRaw() const { 504 inline Opcode OpcodeFieldRaw() const {
434 return static_cast<Opcode>(InstructionBits() & kOpcodeMask); 505 return static_cast<Opcode>(InstructionBits() & kOpcodeMask);
435 } 506 }
436 507
437 inline int RsFieldRaw() const { 508 inline int RsFieldRaw() const {
438 ASSERT(InstructionType() == kRegisterType || 509 ASSERT(InstructionType() == kRegisterType ||
439 InstructionType() == kImmediateType); 510 InstructionType() == kImmediateType);
440 return InstructionBits() & kRsFieldMask; 511 return InstructionBits() & kRsFieldMask;
441 } 512 }
442 513
514 // Same as above function, but safe to call within InstructionType().
515 inline int RsFieldRawNoAssert() const {
516 return InstructionBits() & kRsFieldMask;
517 }
518
443 inline int RtFieldRaw() const { 519 inline int RtFieldRaw() const {
444 ASSERT(InstructionType() == kRegisterType || 520 ASSERT(InstructionType() == kRegisterType ||
445 InstructionType() == kImmediateType); 521 InstructionType() == kImmediateType);
446 return InstructionBits() & kRtFieldMask; 522 return InstructionBits() & kRtFieldMask;
447 } 523 }
448 524
449 inline int RdFieldRaw() const { 525 inline int RdFieldRaw() const {
450 ASSERT(InstructionType() == kRegisterType); 526 ASSERT(InstructionType() == kRegisterType);
451 return InstructionBits() & kRdFieldMask; 527 return InstructionBits() & kRdFieldMask;
452 } 528 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 579
504 private: 580 private:
505 // We need to prevent the creation of instances of class Instruction. 581 // We need to prevent the creation of instances of class Instruction.
506 DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); 582 DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
507 }; 583 };
508 584
509 585
510 // ----------------------------------------------------------------------------- 586 // -----------------------------------------------------------------------------
511 // MIPS assembly various constants. 587 // MIPS assembly various constants.
512 588
589
513 static const int kArgsSlotsSize = 4 * Instruction::kInstructionSize; 590 static const int kArgsSlotsSize = 4 * Instruction::kInstructionSize;
514 static const int kArgsSlotsNum = 4; 591 static const int kArgsSlotsNum = 4;
592 // C/C++ argument slots size.
593 static const int kCArgsSlotsSize = 4 * Instruction::kInstructionSize;
594 // JS argument slots size.
595 static const int kJSArgsSlotsSize = 0 * Instruction::kInstructionSize;
596 // Assembly builtins argument slots size.
597 static const int kBArgsSlotsSize = 0 * Instruction::kInstructionSize;
Søren Thygesen Gjesse 2010/05/25 09:00:56 DO you need a separate constant for builtins? Aren
515 598
516 static const int kBranchReturnOffset = 2 * Instruction::kInstructionSize; 599 static const int kBranchReturnOffset = 2 * Instruction::kInstructionSize;
517 600
518 static const int kDoubleAlignment = 2 * 8; 601 static const int kDoubleAlignmentBits = 3;
519 static const int kDoubleAlignmentMask = kDoubleAlignmentMask - 1; 602 static const int kDoubleAlignment = (1 << kDoubleAlignmentBits);
603 static const int kDoubleAlignmentMask = kDoubleAlignment - 1;
604
605
606 // -----------------------------------------------------------------------------
607 // MIPS Assembly utils.
608
609 int32_t ISA_utils_instr_at(int32_t* pc);
610 int32_t* ISA_utils_target_address_at(int32_t* pc);
520 611
521 612
522 } } // namespace assembler::mips 613 } } // namespace assembler::mips
523 614
524 #endif // #ifndef V8_MIPS_CONSTANTS_H_ 615 #endif // #ifndef V8_MIPS_CONSTANTS_H_
525 616
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698