Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 | 348 |
| 349 void Assembler::CodeTargetAlign() { | 349 void Assembler::CodeTargetAlign() { |
| 350 // Preferred alignment of jump targets on some ARM chips. | 350 // Preferred alignment of jump targets on some ARM chips. |
| 351 Align(8); | 351 Align(8); |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 Condition Assembler::GetCondition(Instr instr) { | |
|
Alexandre
2011/02/09 13:57:16
Same as Instruction::ConditionField(). Do we want
Søren Thygesen Gjesse
2011/02/09 14:48:28
This now calls Instruction::ConditionField()
| |
| 356 return static_cast<Condition>(instr & kConditionMask); | |
| 357 } | |
| 358 | |
| 355 bool Assembler::IsBranch(Instr instr) { | 359 bool Assembler::IsBranch(Instr instr) { |
| 356 return (instr & (B27 | B25)) == (B27 | B25); | 360 return (instr & (B27 | B25)) == (B27 | B25); |
| 357 } | 361 } |
| 358 | 362 |
| 359 | 363 |
| 360 int Assembler::GetBranchOffset(Instr instr) { | 364 int Assembler::GetBranchOffset(Instr instr) { |
| 361 ASSERT(IsBranch(instr)); | 365 ASSERT(IsBranch(instr)); |
| 362 // Take the jump offset in the lower 24 bits, sign extend it and multiply it | 366 // Take the jump offset in the lower 24 bits, sign extend it and multiply it |
| 363 // with 4 to get the offset in bytes. | 367 // with 4 to get the offset in bytes. |
| 364 return ((instr & kImm24Mask) << 8) >> 6; | 368 return ((instr & kImm24Mask) << 8) >> 6; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 } | 425 } |
| 422 | 426 |
| 423 | 427 |
| 424 Register Assembler::GetRd(Instr instr) { | 428 Register Assembler::GetRd(Instr instr) { |
| 425 Register reg; | 429 Register reg; |
| 426 reg.code_ = Instruction::RdValue(instr); | 430 reg.code_ = Instruction::RdValue(instr); |
| 427 return reg; | 431 return reg; |
| 428 } | 432 } |
| 429 | 433 |
| 430 | 434 |
| 435 Register Assembler::GetRn(Instr instr) { | |
| 436 Register reg; | |
| 437 reg.code_ = Instruction::RnValue(instr); | |
| 438 return reg; | |
| 439 } | |
| 440 | |
| 441 | |
| 442 Register Assembler::GetRm(Instr instr) { | |
| 443 Register reg; | |
| 444 reg.code_ = Instruction::RmValue(instr); | |
| 445 return reg; | |
| 446 } | |
| 447 | |
| 448 | |
| 431 bool Assembler::IsPush(Instr instr) { | 449 bool Assembler::IsPush(Instr instr) { |
| 432 return ((instr & ~kRdMask) == kPushRegPattern); | 450 return ((instr & ~kRdMask) == kPushRegPattern); |
| 433 } | 451 } |
| 434 | 452 |
| 435 | 453 |
| 436 bool Assembler::IsPop(Instr instr) { | 454 bool Assembler::IsPop(Instr instr) { |
| 437 return ((instr & ~kRdMask) == kPopRegPattern); | 455 return ((instr & ~kRdMask) == kPopRegPattern); |
| 438 } | 456 } |
| 439 | 457 |
| 440 | 458 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 458 } | 476 } |
| 459 | 477 |
| 460 | 478 |
| 461 bool Assembler::IsLdrPcImmediateOffset(Instr instr) { | 479 bool Assembler::IsLdrPcImmediateOffset(Instr instr) { |
| 462 // Check the instruction is indeed a | 480 // Check the instruction is indeed a |
| 463 // ldr<cond> <Rd>, [pc +/- offset_12]. | 481 // ldr<cond> <Rd>, [pc +/- offset_12]. |
| 464 return (instr & (kLdrPCMask & ~kCondMask)) == 0x051f0000; | 482 return (instr & (kLdrPCMask & ~kCondMask)) == 0x051f0000; |
| 465 } | 483 } |
| 466 | 484 |
| 467 | 485 |
| 486 bool Assembler::IsTstImmediate(Instr instr) { | |
| 487 return (instr & (B27 | B26 | I | kOpCodeMask | S | kRdMask)) == | |
| 488 (I | TST | S); | |
| 489 } | |
| 490 | |
| 491 | |
| 492 bool Assembler::IsCmpRegister(Instr instr) { | |
| 493 return (instr & (B27 | B26 | I | kOpCodeMask | S | kRdMask | B4)) == | |
| 494 (CMP | S); | |
| 495 } | |
| 496 | |
| 497 | |
| 498 bool Assembler::IsCmpImmediate(Instr instr) { | |
| 499 return (instr & (B27 | B26 | I | kOpCodeMask | S | kRdMask)) == | |
| 500 (I | CMP | S); | |
| 501 } | |
| 502 | |
| 503 | |
| 504 Register Assembler::GetCmpImmediateRegister(Instr instr) { | |
| 505 ASSERT(IsCmpImmediate(instr)); | |
| 506 return GetRn(instr); | |
| 507 } | |
| 508 | |
| 509 | |
| 510 int Assembler::GetCmpImmediateRawImmediate(Instr instr) { | |
| 511 ASSERT(IsCmpImmediate(instr)); | |
| 512 return instr & kOff12Mask; | |
| 513 } | |
| 514 | |
|
Alexandre
2011/02/09 13:57:16
Not sure, but should we move these to the Instruct
Søren Thygesen Gjesse
2011/02/09 14:48:28
I think it will be fine to have these in the Instr
| |
| 468 // Labels refer to positions in the (to be) generated code. | 515 // Labels refer to positions in the (to be) generated code. |
| 469 // There are bound, linked, and unused labels. | 516 // There are bound, linked, and unused labels. |
| 470 // | 517 // |
| 471 // Bound labels refer to known positions in the already | 518 // Bound labels refer to known positions in the already |
| 472 // generated code. pos() is the position the label refers to. | 519 // generated code. pos() is the position the label refers to. |
| 473 // | 520 // |
| 474 // Linked labels refer to unknown positions in the code | 521 // Linked labels refer to unknown positions in the code |
| 475 // to be generated; pos() is the position of the last | 522 // to be generated; pos() is the position of the last |
| 476 // instruction using the label. | 523 // instruction using the label. |
| 477 | 524 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 void Assembler::teq(Register src1, const Operand& src2, Condition cond) { | 1092 void Assembler::teq(Register src1, const Operand& src2, Condition cond) { |
| 1046 addrmod1(cond | TEQ | S, src1, r0, src2); | 1093 addrmod1(cond | TEQ | S, src1, r0, src2); |
| 1047 } | 1094 } |
| 1048 | 1095 |
| 1049 | 1096 |
| 1050 void Assembler::cmp(Register src1, const Operand& src2, Condition cond) { | 1097 void Assembler::cmp(Register src1, const Operand& src2, Condition cond) { |
| 1051 addrmod1(cond | CMP | S, src1, r0, src2); | 1098 addrmod1(cond | CMP | S, src1, r0, src2); |
| 1052 } | 1099 } |
| 1053 | 1100 |
| 1054 | 1101 |
| 1102 void Assembler::cmp_raw_immediate( | |
| 1103 Register src, int raw_immediate, Condition cond) { | |
| 1104 ASSERT(is_uint12(raw_immediate)); | |
| 1105 emit(cond | I | CMP | S | src.code() << 16 | raw_immediate); | |
| 1106 } | |
| 1107 | |
| 1108 | |
| 1055 void Assembler::cmn(Register src1, const Operand& src2, Condition cond) { | 1109 void Assembler::cmn(Register src1, const Operand& src2, Condition cond) { |
| 1056 addrmod1(cond | CMN | S, src1, r0, src2); | 1110 addrmod1(cond | CMN | S, src1, r0, src2); |
| 1057 } | 1111 } |
| 1058 | 1112 |
| 1059 | 1113 |
| 1060 void Assembler::orr(Register dst, Register src1, const Operand& src2, | 1114 void Assembler::orr(Register dst, Register src1, const Operand& src2, |
| 1061 SBit s, Condition cond) { | 1115 SBit s, Condition cond) { |
| 1062 addrmod1(cond | ORR | s, src1, dst, src2); | 1116 addrmod1(cond | ORR | s, src1, dst, src2); |
| 1063 } | 1117 } |
| 1064 | 1118 |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2356 | 2410 |
| 2357 // Pseudo instructions. | 2411 // Pseudo instructions. |
| 2358 void Assembler::nop(int type) { | 2412 void Assembler::nop(int type) { |
| 2359 // This is mov rx, rx. | 2413 // This is mov rx, rx. |
| 2360 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. | 2414 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. |
| 2361 emit(al | 13*B21 | type*B12 | type); | 2415 emit(al | 13*B21 | type*B12 | type); |
| 2362 } | 2416 } |
| 2363 | 2417 |
| 2364 | 2418 |
| 2365 bool Assembler::IsNop(Instr instr, int type) { | 2419 bool Assembler::IsNop(Instr instr, int type) { |
| 2366 // Check for mov rx, rx. | 2420 // Check for mov rx, rx where x = type. |
| 2367 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. | 2421 ASSERT(0 <= type && type <= 14); // mov pc, pc is not a nop. |
| 2368 return instr == (al | 13*B21 | type*B12 | type); | 2422 return instr == (al | 13*B21 | type*B12 | type); |
| 2369 } | 2423 } |
| 2370 | 2424 |
| 2371 | 2425 |
| 2372 bool Assembler::ImmediateFitsAddrMode1Instruction(int32_t imm32) { | 2426 bool Assembler::ImmediateFitsAddrMode1Instruction(int32_t imm32) { |
| 2373 uint32_t dummy1; | 2427 uint32_t dummy1; |
| 2374 uint32_t dummy2; | 2428 uint32_t dummy2; |
| 2375 return fits_shifter(imm32, &dummy1, &dummy2, NULL); | 2429 return fits_shifter(imm32, &dummy1, &dummy2, NULL); |
| 2376 } | 2430 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2615 | 2669 |
| 2616 // Since a constant pool was just emitted, move the check offset forward by | 2670 // Since a constant pool was just emitted, move the check offset forward by |
| 2617 // the standard interval. | 2671 // the standard interval. |
| 2618 next_buffer_check_ = pc_offset() + kCheckConstInterval; | 2672 next_buffer_check_ = pc_offset() + kCheckConstInterval; |
| 2619 } | 2673 } |
| 2620 | 2674 |
| 2621 | 2675 |
| 2622 } } // namespace v8::internal | 2676 } } // namespace v8::internal |
| 2623 | 2677 |
| 2624 #endif // V8_TARGET_ARCH_ARM | 2678 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |