| Index: src/mips/assembler-mips.cc
|
| diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc
|
| index f5b235d1f6f1f045fe19ea5ef7709cbfa22bbce8..865e64c87d26fabb81a7511d774d1fb9b8440c60 100644
|
| --- a/src/mips/assembler-mips.cc
|
| +++ b/src/mips/assembler-mips.cc
|
| @@ -1784,13 +1784,44 @@ void Assembler::LoadRegPlusOffsetToAt(const MemOperand& src) {
|
| addu(at, at, src.rm()); // Add base register.
|
| }
|
|
|
| +// Helper for base-reg + upper part of offset, when offset is larger than int16.
|
| +// Loads higher part of the offset to AT register.
|
| +// Returns lower part of the offset to be used as offset
|
| +// in Load/Store instructions
|
| +int32_t Assembler::LoadRegPlusUpperOffsetPartToAt(const MemOperand& src) {
|
| + DCHECK(!src.rm().is(at));
|
| + int32_t hi = (src.offset_ >> kLuiShift) & kImm16Mask;
|
| + // If the highest bit of the lower part of the offset is 1, this would make
|
| + // the offset in the load/store instruction negative. We need to compensate
|
| + // for this by adding 1 to the upper part of the offset.
|
| + if (src.offset_ & kNegOffset) {
|
| + hi += 1;
|
| + }
|
| + lui(at, hi);
|
| + addu(at, at, src.rm());
|
| + return (src.offset_ & kImm16Mask);
|
| +}
|
| +
|
| +// Helper for loading base-reg + upper offset's part to AT reg when we are using
|
| +// two 32-bit loads/stores instead of one 64-bit
|
| +int32_t Assembler::LoadUpperOffsetForTwoMemoryAccesses(const MemOperand& src) {
|
| + DCHECK(!src.rm().is(at));
|
| + if (is_int16((src.offset_ & kImm16Mask) + kIntSize)) {
|
| + // Only if lower part of offset + kIntSize fits in 16bits
|
| + return LoadRegPlusUpperOffsetPartToAt(src);
|
| + }
|
| + // In case offset's lower part + kIntSize doesn't fit in 16bits,
|
| + // load reg + hole offset to AT
|
| + LoadRegPlusOffsetToAt(src);
|
| + return 0;
|
| +}
|
|
|
| void Assembler::lb(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(LB, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(LB, at, rd, 0); // Equiv to lb(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(LB, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1799,8 +1830,8 @@ void Assembler::lbu(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(LBU, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(LBU, at, rd, 0); // Equiv to lbu(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(LBU, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1809,8 +1840,8 @@ void Assembler::lh(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(LH, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(LH, at, rd, 0); // Equiv to lh(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(LH, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1819,8 +1850,8 @@ void Assembler::lhu(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(LHU, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(LHU, at, rd, 0); // Equiv to lhu(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(LHU, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1829,8 +1860,8 @@ void Assembler::lw(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(LW, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(LW, at, rd, 0); // Equiv to lw(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(LW, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1855,8 +1886,8 @@ void Assembler::sb(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(SB, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to store.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(SB, at, rd, 0); // Equiv to sb(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(SB, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1865,8 +1896,8 @@ void Assembler::sh(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(SH, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to store.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(SH, at, rd, 0); // Equiv to sh(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(SH, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -1875,8 +1906,8 @@ void Assembler::sw(Register rd, const MemOperand& rs) {
|
| if (is_int16(rs.offset_)) {
|
| GenInstrImmediate(SW, rs.rm(), rd, rs.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to store.
|
| - LoadRegPlusOffsetToAt(rs);
|
| - GenInstrImmediate(SW, at, rd, 0); // Equiv to sw(rd, MemOperand(at, 0));
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(rs);
|
| + GenInstrImmediate(SW, at, rd, off16);
|
| }
|
| }
|
|
|
| @@ -2172,8 +2203,8 @@ void Assembler::lwc1(FPURegister fd, const MemOperand& src) {
|
| if (is_int16(src.offset_)) {
|
| GenInstrImmediate(LWC1, src.rm(), fd, src.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(LWC1, at, fd, 0);
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(src);
|
| + GenInstrImmediate(LWC1, at, fd, off16);
|
| }
|
| }
|
|
|
| @@ -2190,11 +2221,11 @@ void Assembler::ldc1(FPURegister fd, const MemOperand& src) {
|
| GenInstrImmediate(LWC1, src.rm(), nextfpreg,
|
| src.offset_ + Register::kExponentOffset);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(LWC1, at, fd, Register::kMantissaOffset);
|
| + int32_t off16 = LoadUpperOffsetForTwoMemoryAccesses(src);
|
| + GenInstrImmediate(LWC1, at, fd, off16 + Register::kMantissaOffset);
|
| FPURegister nextfpreg;
|
| nextfpreg.setcode(fd.code() + 1);
|
| - GenInstrImmediate(LWC1, at, nextfpreg, Register::kExponentOffset);
|
| + GenInstrImmediate(LWC1, at, nextfpreg, off16 + Register::kExponentOffset);
|
| }
|
| } else {
|
| DCHECK(IsFp64Mode() || IsFpxxMode());
|
| @@ -2207,9 +2238,9 @@ void Assembler::ldc1(FPURegister fd, const MemOperand& src) {
|
| src.offset_ + Register::kExponentOffset);
|
| mthc1(at, fd);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(LWC1, at, fd, Register::kMantissaOffset);
|
| - GenInstrImmediate(LW, at, at, Register::kExponentOffset);
|
| + int32_t off16 = LoadUpperOffsetForTwoMemoryAccesses(src);
|
| + GenInstrImmediate(LWC1, at, fd, off16 + Register::kMantissaOffset);
|
| + GenInstrImmediate(LW, at, at, off16 + Register::kExponentOffset);
|
| mthc1(at, fd);
|
| }
|
| }
|
| @@ -2220,8 +2251,8 @@ void Assembler::swc1(FPURegister fd, const MemOperand& src) {
|
| if (is_int16(src.offset_)) {
|
| GenInstrImmediate(SWC1, src.rm(), fd, src.offset_);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(SWC1, at, fd, 0);
|
| + int32_t off16 = LoadRegPlusUpperOffsetPartToAt(src);
|
| + GenInstrImmediate(SWC1, at, fd, off16);
|
| }
|
| }
|
|
|
| @@ -2240,11 +2271,11 @@ void Assembler::sdc1(FPURegister fd, const MemOperand& src) {
|
| GenInstrImmediate(SWC1, src.rm(), nextfpreg,
|
| src.offset_ + Register::kExponentOffset);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(SWC1, at, fd, Register::kMantissaOffset);
|
| + int32_t off16 = LoadUpperOffsetForTwoMemoryAccesses(src);
|
| + GenInstrImmediate(SWC1, at, fd, off16 + Register::kMantissaOffset);
|
| FPURegister nextfpreg;
|
| nextfpreg.setcode(fd.code() + 1);
|
| - GenInstrImmediate(SWC1, at, nextfpreg, Register::kExponentOffset);
|
| + GenInstrImmediate(SWC1, at, nextfpreg, off16 + Register::kExponentOffset);
|
| }
|
| } else {
|
| DCHECK(IsFp64Mode() || IsFpxxMode());
|
| @@ -2257,10 +2288,10 @@ void Assembler::sdc1(FPURegister fd, const MemOperand& src) {
|
| GenInstrImmediate(SW, src.rm(), at,
|
| src.offset_ + Register::kExponentOffset);
|
| } else { // Offset > 16 bits, use multiple instructions to load.
|
| - LoadRegPlusOffsetToAt(src);
|
| - GenInstrImmediate(SWC1, at, fd, Register::kMantissaOffset);
|
| + int32_t off16 = LoadUpperOffsetForTwoMemoryAccesses(src);
|
| + GenInstrImmediate(SWC1, at, fd, off16 + Register::kMantissaOffset);
|
| mfhc1(t8, fd);
|
| - GenInstrImmediate(SW, at, t8, Register::kExponentOffset);
|
| + GenInstrImmediate(SW, at, t8, off16 + Register::kExponentOffset);
|
| }
|
| }
|
| }
|
|
|