Commit 7a6d35e6 authored by Ilija Pavlovic's avatar Ilija Pavlovic Committed by Commit Bot

MIPS[64]: Fix restartability issues.

For handling restartability issues, following conditions must be
fulfilled:
- For Branch-and-link restartability: GPR 31 (ra register) must not be
used for the source register rs.
- For Jump-and-Link restartability: Register specifiers rs and rd must
not be equal.
This CL implements checking that GPR 31 is not used as source register.

TEST=
BUG=

Change-Id: I568ff9c497b4efca73f1a5353cb7520202524479
Reviewed-on: https://chromium-review.googlesource.com/549362Reviewed-by: 's avatarIvica Bogosavljevic <ivica.bogosavljevic@imgtec.com>
Commit-Queue: Ivica Bogosavljevic <ivica.bogosavljevic@imgtec.com>
Cr-Commit-Position: refs/heads/master@{#46252}
parent 8060b9cc
...@@ -1467,6 +1467,7 @@ void Assembler::bgec(Register rs, Register rt, int16_t offset) { ...@@ -1467,6 +1467,7 @@ void Assembler::bgec(Register rs, Register rt, int16_t offset) {
void Assembler::bgezal(Register rs, int16_t offset) { void Assembler::bgezal(Register rs, int16_t offset) {
DCHECK(!IsMipsArchVariant(kMips32r6) || rs.is(zero_reg)); DCHECK(!IsMipsArchVariant(kMips32r6) || rs.is(zero_reg));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BGEZAL, offset); GenInstrImmediate(REGIMM, rs, BGEZAL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1537,6 +1538,7 @@ void Assembler::bltz(Register rs, int16_t offset) { ...@@ -1537,6 +1538,7 @@ void Assembler::bltz(Register rs, int16_t offset) {
void Assembler::bltzal(Register rs, int16_t offset) { void Assembler::bltzal(Register rs, int16_t offset) {
DCHECK(!IsMipsArchVariant(kMips32r6) || rs.is(zero_reg)); DCHECK(!IsMipsArchVariant(kMips32r6) || rs.is(zero_reg));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BLTZAL, offset); GenInstrImmediate(REGIMM, rs, BLTZAL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1573,6 +1575,7 @@ void Assembler::bnvc(Register rs, Register rt, int16_t offset) { ...@@ -1573,6 +1575,7 @@ void Assembler::bnvc(Register rs, Register rt, int16_t offset) {
void Assembler::blezalc(Register rt, int16_t offset) { void Assembler::blezalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BLEZ, zero_reg, rt, offset, GenInstrImmediate(BLEZ, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1581,6 +1584,7 @@ void Assembler::blezalc(Register rt, int16_t offset) { ...@@ -1581,6 +1584,7 @@ void Assembler::blezalc(Register rt, int16_t offset) {
void Assembler::bgezalc(Register rt, int16_t offset) { void Assembler::bgezalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BLEZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH); GenInstrImmediate(BLEZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1588,6 +1592,7 @@ void Assembler::bgezalc(Register rt, int16_t offset) { ...@@ -1588,6 +1592,7 @@ void Assembler::bgezalc(Register rt, int16_t offset) {
void Assembler::bgezall(Register rs, int16_t offset) { void Assembler::bgezall(Register rs, int16_t offset) {
DCHECK(!IsMipsArchVariant(kMips32r6)); DCHECK(!IsMipsArchVariant(kMips32r6));
DCHECK(!(rs.is(zero_reg))); DCHECK(!(rs.is(zero_reg)));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BGEZALL, offset); GenInstrImmediate(REGIMM, rs, BGEZALL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1597,6 +1602,7 @@ void Assembler::bgezall(Register rs, int16_t offset) { ...@@ -1597,6 +1602,7 @@ void Assembler::bgezall(Register rs, int16_t offset) {
void Assembler::bltzalc(Register rt, int16_t offset) { void Assembler::bltzalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BGTZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH); GenInstrImmediate(BGTZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1604,6 +1610,7 @@ void Assembler::bltzalc(Register rt, int16_t offset) { ...@@ -1604,6 +1610,7 @@ void Assembler::bltzalc(Register rt, int16_t offset) {
void Assembler::bgtzalc(Register rt, int16_t offset) { void Assembler::bgtzalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BGTZ, zero_reg, rt, offset, GenInstrImmediate(BGTZ, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1612,6 +1619,7 @@ void Assembler::bgtzalc(Register rt, int16_t offset) { ...@@ -1612,6 +1619,7 @@ void Assembler::bgtzalc(Register rt, int16_t offset) {
void Assembler::beqzalc(Register rt, int16_t offset) { void Assembler::beqzalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(ADDI, zero_reg, rt, offset, GenInstrImmediate(ADDI, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1620,6 +1628,7 @@ void Assembler::beqzalc(Register rt, int16_t offset) { ...@@ -1620,6 +1628,7 @@ void Assembler::beqzalc(Register rt, int16_t offset) {
void Assembler::bnezalc(Register rt, int16_t offset) { void Assembler::bnezalc(Register rt, int16_t offset) {
DCHECK(IsMipsArchVariant(kMips32r6)); DCHECK(IsMipsArchVariant(kMips32r6));
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(DADDI, zero_reg, rt, offset, GenInstrImmediate(DADDI, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
......
...@@ -1453,6 +1453,7 @@ void Assembler::bgec(Register rs, Register rt, int16_t offset) { ...@@ -1453,6 +1453,7 @@ void Assembler::bgec(Register rs, Register rt, int16_t offset) {
void Assembler::bgezal(Register rs, int16_t offset) { void Assembler::bgezal(Register rs, int16_t offset) {
DCHECK(kArchVariant != kMips64r6 || rs.is(zero_reg)); DCHECK(kArchVariant != kMips64r6 || rs.is(zero_reg));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BGEZAL, offset); GenInstrImmediate(REGIMM, rs, BGEZAL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1523,6 +1524,7 @@ void Assembler::bltz(Register rs, int16_t offset) { ...@@ -1523,6 +1524,7 @@ void Assembler::bltz(Register rs, int16_t offset) {
void Assembler::bltzal(Register rs, int16_t offset) { void Assembler::bltzal(Register rs, int16_t offset) {
DCHECK(kArchVariant != kMips64r6 || rs.is(zero_reg)); DCHECK(kArchVariant != kMips64r6 || rs.is(zero_reg));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BLTZAL, offset); GenInstrImmediate(REGIMM, rs, BLTZAL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1559,6 +1561,7 @@ void Assembler::bnvc(Register rs, Register rt, int16_t offset) { ...@@ -1559,6 +1561,7 @@ void Assembler::bnvc(Register rs, Register rt, int16_t offset) {
void Assembler::blezalc(Register rt, int16_t offset) { void Assembler::blezalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BLEZ, zero_reg, rt, offset, GenInstrImmediate(BLEZ, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1567,6 +1570,7 @@ void Assembler::blezalc(Register rt, int16_t offset) { ...@@ -1567,6 +1570,7 @@ void Assembler::blezalc(Register rt, int16_t offset) {
void Assembler::bgezalc(Register rt, int16_t offset) { void Assembler::bgezalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BLEZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH); GenInstrImmediate(BLEZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1574,6 +1578,7 @@ void Assembler::bgezalc(Register rt, int16_t offset) { ...@@ -1574,6 +1578,7 @@ void Assembler::bgezalc(Register rt, int16_t offset) {
void Assembler::bgezall(Register rs, int16_t offset) { void Assembler::bgezall(Register rs, int16_t offset) {
DCHECK(kArchVariant != kMips64r6); DCHECK(kArchVariant != kMips64r6);
DCHECK(!(rs.is(zero_reg))); DCHECK(!(rs.is(zero_reg)));
DCHECK(!(rs.is(ra)));
BlockTrampolinePoolScope block_trampoline_pool(this); BlockTrampolinePoolScope block_trampoline_pool(this);
GenInstrImmediate(REGIMM, rs, BGEZALL, offset); GenInstrImmediate(REGIMM, rs, BGEZALL, offset);
BlockTrampolinePoolFor(1); // For associated delay slot. BlockTrampolinePoolFor(1); // For associated delay slot.
...@@ -1583,6 +1588,7 @@ void Assembler::bgezall(Register rs, int16_t offset) { ...@@ -1583,6 +1588,7 @@ void Assembler::bgezall(Register rs, int16_t offset) {
void Assembler::bltzalc(Register rt, int16_t offset) { void Assembler::bltzalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BGTZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH); GenInstrImmediate(BGTZ, rt, rt, offset, CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1590,6 +1596,7 @@ void Assembler::bltzalc(Register rt, int16_t offset) { ...@@ -1590,6 +1596,7 @@ void Assembler::bltzalc(Register rt, int16_t offset) {
void Assembler::bgtzalc(Register rt, int16_t offset) { void Assembler::bgtzalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(BGTZ, zero_reg, rt, offset, GenInstrImmediate(BGTZ, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1598,6 +1605,7 @@ void Assembler::bgtzalc(Register rt, int16_t offset) { ...@@ -1598,6 +1605,7 @@ void Assembler::bgtzalc(Register rt, int16_t offset) {
void Assembler::beqzalc(Register rt, int16_t offset) { void Assembler::beqzalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(ADDI, zero_reg, rt, offset, GenInstrImmediate(ADDI, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
...@@ -1606,6 +1614,7 @@ void Assembler::beqzalc(Register rt, int16_t offset) { ...@@ -1606,6 +1614,7 @@ void Assembler::beqzalc(Register rt, int16_t offset) {
void Assembler::bnezalc(Register rt, int16_t offset) { void Assembler::bnezalc(Register rt, int16_t offset) {
DCHECK(kArchVariant == kMips64r6); DCHECK(kArchVariant == kMips64r6);
DCHECK(!(rt.is(zero_reg))); DCHECK(!(rt.is(zero_reg)));
DCHECK(!(rt.is(ra)));
GenInstrImmediate(DADDI, zero_reg, rt, offset, GenInstrImmediate(DADDI, zero_reg, rt, offset,
CompactBranchType::COMPACT_BRANCH); CompactBranchType::COMPACT_BRANCH);
} }
......
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