// if they can be encoded in the ARM's 12 bits of immediate-offset instruction
// space. There is no guarantee that the relocated location can be similarly
// encoded.
-static bool MustUseConstantPool(RelocInfo::Mode rmode) {
- if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
+bool Operand::must_use_constant_pool() const {
+ if (rmode_ == RelocInfo::EXTERNAL_REFERENCE) {
#ifdef DEBUG
if (!Serializer::enabled()) {
Serializer::TooLateToEnableNow();
}
#endif // def DEBUG
return Serializer::enabled();
- } else if (rmode == RelocInfo::NONE) {
+ } else if (rmode_ == RelocInfo::NONE) {
return false;
}
return true;
bool Operand::is_single_instruction() const {
if (rm_.is_valid()) return true;
- if (MustUseConstantPool(rmode_)) return false;
+ if (must_use_constant_pool()) return false;
uint32_t dummy1, dummy2;
return fits_shifter(imm32_, &dummy1, &dummy2, NULL);
}
// Immediate.
uint32_t rotate_imm;
uint32_t immed_8;
- if (MustUseConstantPool(x.rmode_) ||
+ if (x.must_use_constant_pool() ||
!fits_shifter(x.imm32_, &rotate_imm, &immed_8, &instr)) {
// The immediate operand cannot be encoded as a shifter operand, so load
// it first to register ip and change the original instruction to use ip.
CHECK(!rn.is(ip)); // rn should never be ip, or will be trashed
Condition cond = static_cast<Condition>(instr & CondMask);
if ((instr & ~CondMask) == 13*B21) { // mov, S not set
- if (MustUseConstantPool(x.rmode_) ||
- !CpuFeatures::IsSupported(ARMv7)) {
+ if (x.must_use_constant_pool() || !CpuFeatures::IsSupported(ARMv7)) {
RecordRelocInfo(x.rmode_, x.imm32_);
ldr(rd, MemOperand(pc, 0), cond);
} else {
} else {
// If this is not a mov or mvn instruction we may still be able to avoid
// a constant pool entry by using mvn or movw.
- if (!MustUseConstantPool(x.rmode_) &&
+ if (!x.must_use_constant_pool() &&
(instr & kMovMvnMask) != kMovMvnPattern) {
mov(ip, x, LeaveCC, cond);
} else {
// Immediate.
uint32_t rotate_imm;
uint32_t immed_8;
- if (MustUseConstantPool(src.rmode_) ||
+ if (src.must_use_constant_pool() ||
!fits_shifter(src.imm32_, &rotate_imm, &immed_8, NULL)) {
// Immediate operand cannot be encoded, load it first to register ip.
RecordRelocInfo(src.rmode_, src.imm32_);
void MacroAssembler::And(Register dst, Register src1, const Operand& src2,
Condition cond) {
- if (!CpuFeatures::IsSupported(ARMv7) || src2.is_single_instruction()) {
- and_(dst, src1, src2, LeaveCC, cond);
- return;
- }
- int32_t immediate = src2.immediate();
- if (immediate == 0) {
+ if (!src2.is_reg() &&
+ !src2.must_use_constant_pool() &&
+ src2.immediate() == 0) {
mov(dst, Operand(0, RelocInfo::NONE), LeaveCC, cond);
- return;
- }
- if (IsPowerOf2(immediate + 1) && ((immediate & 1) != 0)) {
- ubfx(dst, src1, 0, WhichPowerOf2(immediate + 1), cond);
- return;
+
+ } else if (!src2.is_single_instruction() &&
+ !src2.must_use_constant_pool() &&
+ CpuFeatures::IsSupported(ARMv7) &&
+ IsPowerOf2(src2.immediate() + 1)) {
+ ubfx(dst, src1, 0, WhichPowerOf2(src2.immediate() + 1), cond);
+
+ } else {
+ and_(dst, src1, src2, LeaveCC, cond);
}
- and_(dst, src1, src2, LeaveCC, cond);
}