MIPS: Use Lsa/Dlsa when possible.
For MIPS32R6 replace instances of "sll/addu" to calculate the
address of an item in an array with "lsa". For other versions of
MIPS32 use the "sll/addu" sequence. Encapsulate this logic in an
assembler method to eliminate having a lot of statements like
"if (IsR6()) { ... } else { ... }" scattered throughout the code.
MIPS64 always supports R6. This means that all instances of
"dsll/daddu" used to calculate the address of an item in an array
can be replaced by "dlsa" so there is no need to encapsulate
conditional logic in a special method. The code can just emit
"dlsa" directly.
Test: mma -j2 ART_TEST_OPTIMIZING=true test-art-target-run-test
Tested on MIPS32, and MIPS64 QEMU.
Test: "make test-art-target-gtest32" on CI20 board.
Test: "cd art; test/testrunner/testrunner.py --target --optimizing --32"
on CI20 board.
Change-Id: Ibe5facc1bc2a6a7a6584e23d3a48e163ae38077d
diff --git a/compiler/optimizing/intrinsics_mips.cc b/compiler/optimizing/intrinsics_mips.cc
index b67793c..900b00e 100644
--- a/compiler/optimizing/intrinsics_mips.cc
+++ b/compiler/optimizing/intrinsics_mips.cc
@@ -2701,12 +2701,7 @@
// Calculate destination address.
__ Addiu(dstPtr, dstObj, data_offset);
- if (IsR6()) {
- __ Lsa(dstPtr, dstBegin, dstPtr, char_shift);
- } else {
- __ Sll(AT, dstBegin, char_shift);
- __ Addu(dstPtr, dstPtr, AT);
- }
+ __ ShiftAndAdd(dstPtr, dstBegin, dstPtr, char_shift);
if (mirror::kUseStringCompression) {
MipsLabel uncompressed_copy, compressed_loop;
@@ -2734,12 +2729,7 @@
// Calculate source address.
__ Addiu(srcPtr, srcObj, value_offset);
- if (IsR6()) {
- __ Lsa(srcPtr, srcBegin, srcPtr, char_shift);
- } else {
- __ Sll(AT, srcBegin, char_shift);
- __ Addu(srcPtr, srcPtr, AT);
- }
+ __ ShiftAndAdd(srcPtr, srcBegin, srcPtr, char_shift);
__ Bind(&loop);
__ Lh(AT, srcPtr, 0);