Commit d9af984e authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Use the Lsa() macro/r6 instruction in existing code.

BUG=

Review URL: https://codereview.chromium.org/1608933003

Cr-Commit-Position: refs/heads/master@{#33390}
parent 68654b64
......@@ -1411,8 +1411,7 @@ void LCodeGen::DoMulI(LMulI* instr) {
if (constant < 0) __ Subu(result, zero_reg, result);
} else if (base::bits::IsPowerOfTwo32(constant_abs - 1)) {
int32_t shift = WhichPowerOf2(constant_abs - 1);
__ sll(scratch, left, shift);
__ Addu(result, scratch, left);
__ Lsa(result, left, left, shift);
// Correct the sign of the result if the constant is negative.
if (constant < 0) __ Subu(result, zero_reg, result);
} else if (base::bits::IsPowerOfTwo32(constant_abs + 1)) {
......@@ -2578,8 +2577,7 @@ void LCodeGen::DoReturn(LReturn* instr) {
Register reg = ToRegister(instr->parameter_count());
// The argument count parameter is a smi
__ SmiUntag(reg);
__ sll(at, reg, kPointerSizeLog2);
__ Addu(sp, sp, at);
__ Lsa(sp, sp, reg, kPointerSizeLog2);
}
__ Jump(ra);
......@@ -2781,8 +2779,7 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
Register index = ToRegister(instr->index());
__ li(at, Operand(const_length + 1));
__ Subu(result, at, index);
__ sll(at, result, kPointerSizeLog2);
__ Addu(at, arguments, at);
__ Lsa(at, arguments, result, kPointerSizeLog2);
__ lw(result, MemOperand(at));
}
} else if (instr->index()->IsConstantOperand()) {
......@@ -2791,12 +2788,10 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
int loc = const_index - 1;
if (loc != 0) {
__ Subu(result, length, Operand(loc));
__ sll(at, result, kPointerSizeLog2);
__ Addu(at, arguments, at);
__ Lsa(at, arguments, result, kPointerSizeLog2);
__ lw(result, MemOperand(at));
} else {
__ sll(at, length, kPointerSizeLog2);
__ Addu(at, arguments, at);
__ Lsa(at, arguments, length, kPointerSizeLog2);
__ lw(result, MemOperand(at));
}
} else {
......@@ -2804,8 +2799,7 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
Register index = ToRegister(instr->index());
__ Subu(result, length, index);
__ Addu(result, result, 1);
__ sll(at, result, kPointerSizeLog2);
__ Addu(at, arguments, at);
__ Lsa(at, arguments, result, kPointerSizeLog2);
__ lw(result, MemOperand(at));
}
}
......@@ -2914,8 +2908,7 @@ void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
key = ToRegister(instr->key());
int shift_size = (instr->hydrogen()->key()->representation().IsSmi())
? (element_size_shift - kSmiTagSize) : element_size_shift;
__ sll(at, key, shift_size);
__ Addu(scratch, scratch, at);
__ Lsa(scratch, scratch, key, shift_size);
}
__ ldc1(result, MemOperand(scratch));
......@@ -2946,11 +2939,9 @@ void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
// during bound check elimination with the index argument to the bounds
// check, which can be tagged, so that case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsSmi()) {
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(scratch, elements, scratch);
__ Lsa(scratch, elements, key, kPointerSizeLog2 - kSmiTagSize);
} else {
__ sll(scratch, key, kPointerSizeLog2);
__ addu(scratch, elements, scratch);
__ Lsa(scratch, elements, key, kPointerSizeLog2);
}
}
__ lw(result, MemOperand(store_base, offset));
......@@ -3945,8 +3936,7 @@ void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
address = external_pointer;
}
} else {
__ sll(address, key, shift_size);
__ Addu(address, external_pointer, address);
__ Lsa(address, external_pointer, key, shift_size);
}
if (elements_kind == FLOAT32_ELEMENTS) {
......@@ -4063,11 +4053,9 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
// during bound check elimination with the index argument to the bounds
// check, which can be tagged, so that case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsSmi()) {
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(scratch, elements, scratch);
__ Lsa(scratch, elements, key, kPointerSizeLog2 - kSmiTagSize);
} else {
__ sll(scratch, key, kPointerSizeLog2);
__ addu(scratch, elements, scratch);
__ Lsa(scratch, elements, key, kPointerSizeLog2);
}
}
__ sw(value, MemOperand(store_base, offset));
......@@ -4354,8 +4342,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
__ Branch(deferred->entry(), hi,
char_code, Operand(String::kMaxOneByteCharCode));
__ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex);
__ sll(scratch, char_code, kPointerSizeLog2);
__ Addu(result, result, scratch);
__ Lsa(result, result, char_code, kPointerSizeLog2);
__ lw(result, FieldMemOperand(result, FixedArray::kHeaderSize));
__ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
__ Branch(deferred->entry(), eq, result, Operand(scratch));
......
......@@ -1140,8 +1140,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Get the current entry of the array into register a3.
__ lw(a2, MemOperand(sp, 2 * kPointerSize));
__ Addu(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize);
__ addu(t0, a2, t0); // Array base + scaled (smi) index.
__ Lsa(t0, a2, a0, kPointerSizeLog2 - kSmiTagSize);
__ lw(a3, MemOperand(t0)); // Current entry.
// Get the expected map from the stack or a smi in the
......@@ -3798,8 +3797,7 @@ void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
__ mov(string_length, zero_reg);
__ Addu(element,
elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ sll(elements_end, array_length, kPointerSizeLog2);
__ Addu(elements_end, element, elements_end);
__ Lsa(elements_end, element, array_length, kPointerSizeLog2);
// Loop condition: while (element < elements_end).
// Live values in registers:
// elements: Fixed array of strings.
......@@ -3876,8 +3874,7 @@ void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
// Prepare for looping. Set up elements_end to end of the array. Set
// result_pos to the position of the result where to write the first
// character.
__ sll(elements_end, array_length, kPointerSizeLog2);
__ Addu(elements_end, element, elements_end);
__ Lsa(elements_end, element, array_length, kPointerSizeLog2);
result_pos = array_length; // End of live range for array_length.
array_length = no_reg;
__ Addu(result_pos,
......
......@@ -230,8 +230,7 @@ static void GenerateFastArrayLoad(MacroAssembler* masm, Register receiver,
Operand(FixedArray::kHeaderSize - kHeapObjectTag));
// The key is a smi.
STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize < kPointerSizeLog2);
__ sll(at, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(at, at, scratch1);
__ Lsa(at, scratch1, key, kPointerSizeLog2 - kSmiTagSize);
__ lw(scratch2, MemOperand(at));
__ LoadRoot(at, Heap::kTheHoleValueRootIndex);
......@@ -491,8 +490,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
// there may be a callback on the element.
Label holecheck_passed1;
__ Addu(address, elements, FixedArray::kHeaderSize - kHeapObjectTag);
__ sll(at, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(address, address, at);
__ Lsa(address, address, key, kPointerSizeLog2 - kSmiTagSize);
__ lw(scratch, MemOperand(address));
__ Branch(&holecheck_passed1, ne, scratch,
Operand(masm->isolate()->factory()->the_hole_value()));
......@@ -511,8 +509,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
}
// It's irrelevant whether array is smi-only or not when writing a smi.
__ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ Addu(address, address, scratch);
__ Lsa(address, address, key, kPointerSizeLog2 - kSmiTagSize);
__ sw(value, MemOperand(address));
__ Ret();
......@@ -528,8 +525,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
__ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
}
__ Addu(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ Addu(address, address, scratch);
__ Lsa(address, address, key, kPointerSizeLog2 - kSmiTagSize);
__ sw(value, MemOperand(address));
// Update write barrier for the elements array address.
__ mov(scratch, value); // Preserve the value which is returned.
......@@ -550,8 +546,7 @@ static void KeyedStoreGenerateMegamorphicHelper(
// go to the runtime.
__ Addu(address, elements, Operand(FixedDoubleArray::kHeaderSize +
kHoleNanUpper32Offset - kHeapObjectTag));
__ sll(at, key, kPointerSizeLog2);
__ addu(address, address, at);
__ Lsa(address, address, key, kPointerSizeLog2);
__ lw(scratch, MemOperand(address));
__ Branch(&fast_double_without_map_check, ne, scratch,
Operand(kHoleNanUpper32));
......
......@@ -42,13 +42,11 @@ static void ProbeTable(Isolate* isolate, MacroAssembler* masm,
scratch = no_reg;
// Multiply by 3 because there are 3 fields per entry (name, code, map).
__ sll(offset_scratch, offset, 1);
__ Addu(offset_scratch, offset_scratch, offset);
__ Lsa(offset_scratch, offset, offset, 1);
// Calculate the base address of the entry.
__ li(base_addr, Operand(key_offset));
__ sll(at, offset_scratch, kPointerSizeLog2);
__ Addu(base_addr, base_addr, at);
__ Lsa(base_addr, base_addr, offset_scratch, kPointerSizeLog2);
// Check that the key in the entry matches the name.
__ lw(at, MemOperand(base_addr, 0));
......
This diff is collapsed.
This diff is collapsed.
......@@ -767,8 +767,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
__ Addu(scratch1, elements,
Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ Addu(scratch3, array, Operand(FixedDoubleArray::kHeaderSize));
__ sll(at, length, 2);
__ Addu(array_end, scratch3, at);
__ Lsa(array_end, scratch3, length, 2);
// Repurpose registers no longer in use.
Register hole_lower = elements;
......@@ -899,8 +898,7 @@ void ElementsTransitionGenerator::GenerateDoubleToObject(
FixedDoubleArray::kHeaderSize - kHeapObjectTag
+ Register::kExponentOffset));
__ Addu(dst_elements, array, Operand(FixedArray::kHeaderSize));
__ sll(dst_end, dst_end, 1);
__ Addu(dst_end, dst_elements, dst_end);
__ Lsa(dst_end, dst_elements, dst_end, 1);
// Allocating heap numbers in the loop below can fail and cause a jump to
// gc_required. We can't leave a partly initialized FixedArray behind,
......@@ -1082,8 +1080,7 @@ void StringCharLoadGenerator::Generate(MacroAssembler* masm,
__ And(at, result, Operand(kStringEncodingMask));
__ Branch(&one_byte, ne, at, Operand(zero_reg));
// Two-byte string.
__ sll(at, index, 1);
__ Addu(at, string, at);
__ Lsa(at, string, index, 1);
__ lhu(result, MemOperand(at));
__ jmp(&done);
__ bind(&one_byte);
......@@ -1156,8 +1153,7 @@ void MathExpGenerator::EmitMathExp(MacroAssembler* masm,
// Must not call ExpConstant() after overwriting temp3!
__ li(temp3, Operand(ExternalReference::math_exp_log_table()));
__ sll(at, temp2, 3);
__ Addu(temp3, temp3, Operand(at));
__ Lsa(temp3, temp3, temp2, 3);
__ lw(temp2, MemOperand(temp3, Register::kMantissaOffset));
__ lw(temp3, MemOperand(temp3, Register::kExponentOffset));
// The first word is loaded is the lower number register.
......
......@@ -268,8 +268,7 @@ void Deoptimizer::TableEntryGenerator::Generate() {
// a1 = one past the last FrameDescription**.
__ lw(a1, MemOperand(a0, Deoptimizer::output_count_offset()));
__ lw(t0, MemOperand(a0, Deoptimizer::output_offset())); // t0 is output_.
__ sll(a1, a1, kPointerSizeLog2); // Count to offset.
__ addu(a1, t0, a1); // a1 = one past the last FrameDescription**.
__ Lsa(a1, t0, a1, kPointerSizeLog2);
__ BranchShort(&outer_loop_header);
__ bind(&outer_push_loop);
// Inner loop state: a2 = current FrameDescription*, a3 = loop index.
......
......@@ -499,16 +499,14 @@ void MacroAssembler::GetNumberHash(Register reg0, Register scratch) {
//
// hash = ~hash + (hash << 15);
nor(scratch, reg0, zero_reg);
sll(at, reg0, 15);
addu(reg0, scratch, at);
Lsa(reg0, scratch, reg0, 15);
// hash = hash ^ (hash >> 12);
srl(at, reg0, 12);
xor_(reg0, reg0, at);
// hash = hash + (hash << 2);
sll(at, reg0, 2);
addu(reg0, reg0, at);
Lsa(reg0, reg0, reg0, 2);
// hash = hash ^ (hash >> 4);
srl(at, reg0, 4);
......@@ -516,8 +514,7 @@ void MacroAssembler::GetNumberHash(Register reg0, Register scratch) {
// hash = hash * 2057;
sll(scratch, reg0, 11);
sll(at, reg0, 3);
addu(reg0, reg0, at);
Lsa(reg0, reg0, reg0, 3);
addu(reg0, reg0, scratch);
// hash = hash ^ (hash >> 16);
......@@ -577,12 +574,10 @@ void MacroAssembler::LoadFromNumberDictionary(Label* miss,
// Scale the index by multiplying by the element size.
DCHECK(SeededNumberDictionary::kEntrySize == 3);
sll(at, reg2, 1); // 2x.
addu(reg2, reg2, at); // reg2 = reg2 * 3.
Lsa(reg2, reg2, reg2, 1); // reg2 = reg2 * 3.
// Check if the key is identical to the name.
sll(at, reg2, kPointerSizeLog2);
addu(reg2, elements, at);
Lsa(reg2, elements, reg2, kPointerSizeLog2);
lw(at, FieldMemOperand(reg2, SeededNumberDictionary::kElementsStartOffset));
if (i != kNumberDictionaryProbes - 1) {
......@@ -3412,8 +3407,7 @@ void MacroAssembler::Allocate(Register object_size, Register result,
// to calculate the new top. Object size may be in words so a shift is
// required to get the number of bytes.
if ((flags & SIZE_IN_WORDS) != 0) {
sll(result_end, object_size, kPointerSizeLog2);
Addu(result_end, result, result_end);
Lsa(result_end, result, object_size, kPointerSizeLog2);
} else {
Addu(result_end, result, Operand(object_size));
}
......@@ -3775,8 +3769,7 @@ void MacroAssembler::StoreNumberToDoubleElements(Register value_reg,
lw(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset));
bind(&have_double_value);
sll(scratch1, key_reg, kDoubleSizeLog2 - kSmiTagSize);
Addu(scratch1, scratch1, elements_reg);
Lsa(scratch1, elements_reg, key_reg, kDoubleSizeLog2 - kSmiTagSize);
sw(mantissa_reg,
FieldMemOperand(scratch1, FixedDoubleArray::kHeaderSize - elements_offset
+ kHoleNanLower32Offset));
......@@ -3802,8 +3795,7 @@ void MacroAssembler::StoreNumberToDoubleElements(Register value_reg,
Addu(scratch1, elements_reg,
Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag -
elements_offset));
sll(scratch2, key_reg, kDoubleSizeLog2 - kSmiTagSize);
Addu(scratch1, scratch1, scratch2);
Lsa(scratch1, scratch1, key_reg, kDoubleSizeLog2 - kSmiTagSize);
// scratch1 is now effective address of the double element
Register untagged_value = scratch2;
......@@ -4945,8 +4937,7 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count,
if (argument_count_is_length) {
addu(sp, sp, argument_count);
} else {
sll(t8, argument_count, kPointerSizeLog2);
addu(sp, sp, t8);
Lsa(sp, sp, argument_count, kPointerSizeLog2, t8);
}
}
......@@ -5473,8 +5464,7 @@ void MacroAssembler::GetMarkBits(Register addr_reg,
Ext(mask_reg, addr_reg, kPointerSizeLog2, Bitmap::kBitsPerCellLog2);
const int kLowBits = kPointerSizeLog2 + Bitmap::kBitsPerCellLog2;
Ext(t8, addr_reg, kLowBits, kPageSizeBits - kLowBits);
sll(t8, t8, kPointerSizeLog2);
Addu(bitmap_reg, bitmap_reg, t8);
Lsa(bitmap_reg, bitmap_reg, t8, kPointerSizeLog2, t8);
li(t8, Operand(1));
sllv(mask_reg, t8, mask_reg);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment