| 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 if (instr != NULL && (*instr & 0xd*B21) == 0xd*B21) { | 484 if (instr != NULL && (*instr & 0xd*B21) == 0xd*B21) { |
| 485 if (fits_shifter(~imm32, rotate_imm, immed_8, NULL)) { | 485 if (fits_shifter(~imm32, rotate_imm, immed_8, NULL)) { |
| 486 *instr ^= 0x2*B21; | 486 *instr ^= 0x2*B21; |
| 487 return true; | 487 return true; |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 return false; | 490 return false; |
| 491 } | 491 } |
| 492 | 492 |
| 493 | 493 |
| 494 // We have to use the temporary register for things that can be relocated even |
| 495 // if they can be encoded in the ARM's 12 bits of immediate-offset instruction |
| 496 // space. There is no guarantee that the relocated location can be similarly |
| 497 // encoded. |
| 498 static bool MustUseIp(RelocInfo::Mode rmode) { |
| 499 if (rmode == RelocInfo::EXTERNAL_REFERENCE) { |
| 500 return Serializer::enabled(); |
| 501 } else if (rmode == RelocInfo::NONE) { |
| 502 return false; |
| 503 } |
| 504 return true; |
| 505 } |
| 506 |
| 507 |
| 494 void Assembler::addrmod1(Instr instr, | 508 void Assembler::addrmod1(Instr instr, |
| 495 Register rn, | 509 Register rn, |
| 496 Register rd, | 510 Register rd, |
| 497 const Operand& x) { | 511 const Operand& x) { |
| 498 CheckBuffer(); | 512 CheckBuffer(); |
| 499 ASSERT((instr & ~(CondMask | OpCodeMask | S)) == 0); | 513 ASSERT((instr & ~(CondMask | OpCodeMask | S)) == 0); |
| 500 if (!x.rm_.is_valid()) { | 514 if (!x.rm_.is_valid()) { |
| 501 // immediate | 515 // immediate |
| 502 uint32_t rotate_imm; | 516 uint32_t rotate_imm; |
| 503 uint32_t immed_8; | 517 uint32_t immed_8; |
| 504 if ((x.rmode_ != RelocInfo::NONE && | 518 if (MustUseIp(x.rmode_) || |
| 505 x.rmode_ != RelocInfo::EXTERNAL_REFERENCE) || | |
| 506 !fits_shifter(x.imm32_, &rotate_imm, &immed_8, &instr)) { | 519 !fits_shifter(x.imm32_, &rotate_imm, &immed_8, &instr)) { |
| 507 // The immediate operand cannot be encoded as a shifter operand, so load | 520 // The immediate operand cannot be encoded as a shifter operand, so load |
| 508 // it first to register ip and change the original instruction to use ip. | 521 // it first to register ip and change the original instruction to use ip. |
| 509 // However, if the original instruction is a 'mov rd, x' (not setting the | 522 // However, if the original instruction is a 'mov rd, x' (not setting the |
| 510 // condition code), then replace it with a 'ldr rd, [pc]' | 523 // condition code), then replace it with a 'ldr rd, [pc]' |
| 511 RecordRelocInfo(x.rmode_, x.imm32_); | 524 RecordRelocInfo(x.rmode_, x.imm32_); |
| 512 CHECK(!rn.is(ip)); // rn should never be ip, or will be trashed | 525 CHECK(!rn.is(ip)); // rn should never be ip, or will be trashed |
| 513 Condition cond = static_cast<Condition>(instr & CondMask); | 526 Condition cond = static_cast<Condition>(instr & CondMask); |
| 514 if ((instr & ~CondMask) == 13*B21) { // mov, S not set | 527 if ((instr & ~CondMask) == 13*B21) { // mov, S not set |
| 515 ldr(rd, MemOperand(pc, 0), cond); | 528 ldr(rd, MemOperand(pc, 0), cond); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 | 910 |
| 898 | 911 |
| 899 void Assembler::msr(SRegisterFieldMask fields, const Operand& src, | 912 void Assembler::msr(SRegisterFieldMask fields, const Operand& src, |
| 900 Condition cond) { | 913 Condition cond) { |
| 901 ASSERT(fields >= B16 && fields < B20); // at least one field set | 914 ASSERT(fields >= B16 && fields < B20); // at least one field set |
| 902 Instr instr; | 915 Instr instr; |
| 903 if (!src.rm_.is_valid()) { | 916 if (!src.rm_.is_valid()) { |
| 904 // immediate | 917 // immediate |
| 905 uint32_t rotate_imm; | 918 uint32_t rotate_imm; |
| 906 uint32_t immed_8; | 919 uint32_t immed_8; |
| 907 if ((src.rmode_ != RelocInfo::NONE && | 920 if (MustUseIp(src.rmode_) || |
| 908 src.rmode_ != RelocInfo::EXTERNAL_REFERENCE)|| | |
| 909 !fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) { | 921 !fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) { |
| 910 // immediate operand cannot be encoded, load it first to register ip | 922 // immediate operand cannot be encoded, load it first to register ip |
| 911 RecordRelocInfo(src.rmode_, src.imm32_); | 923 RecordRelocInfo(src.rmode_, src.imm32_); |
| 912 ldr(ip, MemOperand(pc, 0), cond); | 924 ldr(ip, MemOperand(pc, 0), cond); |
| 913 msr(fields, Operand(ip), cond); | 925 msr(fields, Operand(ip), cond); |
| 914 return; | 926 return; |
| 915 } | 927 } |
| 916 instr = I | rotate_imm*B8 | immed_8; | 928 instr = I | rotate_imm*B8 | immed_8; |
| 917 } else { | 929 } else { |
| 918 ASSERT(!src.rs_.is_valid() && src.shift_imm_ == 0); // only rm allowed | 930 ASSERT(!src.rs_.is_valid() && src.shift_imm_ == 0); // only rm allowed |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 bind(&after_pool); | 1475 bind(&after_pool); |
| 1464 } | 1476 } |
| 1465 | 1477 |
| 1466 // Since a constant pool was just emitted, move the check offset forward by | 1478 // Since a constant pool was just emitted, move the check offset forward by |
| 1467 // the standard interval. | 1479 // the standard interval. |
| 1468 next_buffer_check_ = pc_offset() + kCheckConstInterval; | 1480 next_buffer_check_ = pc_offset() + kCheckConstInterval; |
| 1469 } | 1481 } |
| 1470 | 1482 |
| 1471 | 1483 |
| 1472 } } // namespace v8::internal | 1484 } } // namespace v8::internal |
| OLD | NEW |