Commit fce4faaf authored by Ivo Markovic's avatar Ivo Markovic Committed by Commit Bot

MIPS[64]: Fix register validation on R6

Bug: 
Change-Id: I62414a59246af359634b1309b03216c0a5c8764b
Reviewed-on: https://chromium-review.googlesource.com/663728Reviewed-by: 's avatarIvica Bogosavljevic <ivica.bogosavljevic@imgtec.com>
Commit-Queue: Ivica Bogosavljevic <ivica.bogosavljevic@imgtec.com>
Cr-Commit-Position: refs/heads/master@{#48090}
parent b2ef3777
...@@ -2741,7 +2741,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2741,7 +2741,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
bc(offset); bc(offset);
break; break;
case eq: case eq:
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
// Pre R6 beq is used here to make the code patchable. Otherwise bc // Pre R6 beq is used here to make the code patchable. Otherwise bc
// should be used which has no condition field so is not patchable. // should be used which has no condition field so is not patchable.
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -2759,7 +2759,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2759,7 +2759,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
} }
break; break;
case ne: case ne:
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
// Pre R6 bne is used here to make the code patchable. Otherwise we // Pre R6 bne is used here to make the code patchable. Otherwise we
// should not generate any instruction. // should not generate any instruction.
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -2780,7 +2780,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2780,7 +2780,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
// Signed comparison. // Signed comparison.
case greater: case greater:
// rs > rt // rs > rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -2798,7 +2798,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2798,7 +2798,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case greater_equal: case greater_equal:
// rs >= rt // rs >= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -2817,7 +2817,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2817,7 +2817,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case less: case less:
// rs < rt // rs < rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -2835,7 +2835,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2835,7 +2835,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case less_equal: case less_equal:
// rs <= rt // rs <= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -2856,7 +2856,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2856,7 +2856,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
// Unsigned comparison. // Unsigned comparison.
case Ugreater: case Ugreater:
// rs > rt // rs > rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt))
...@@ -2874,7 +2874,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2874,7 +2874,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Ugreater_equal: case Ugreater_equal:
// rs >= rt // rs >= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -2893,7 +2893,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2893,7 +2893,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Uless: case Uless:
// rs < rt // rs < rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt))
...@@ -2910,7 +2910,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -2910,7 +2910,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Uless_equal: case Uless_equal:
// rs <= rt // rs <= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
......
...@@ -3206,7 +3206,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3206,7 +3206,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
bc(offset); bc(offset);
break; break;
case eq: case eq:
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
// Pre R6 beq is used here to make the code patchable. Otherwise bc // Pre R6 beq is used here to make the code patchable. Otherwise bc
// should be used which has no condition field so is not patchable. // should be used which has no condition field so is not patchable.
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -3224,7 +3224,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3224,7 +3224,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
} }
break; break;
case ne: case ne:
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
// Pre R6 bne is used here to make the code patchable. Otherwise we // Pre R6 bne is used here to make the code patchable. Otherwise we
// should not generate any instruction. // should not generate any instruction.
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -3245,7 +3245,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3245,7 +3245,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
// Signed comparison. // Signed comparison.
case greater: case greater:
// rs > rt // rs > rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -3263,7 +3263,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3263,7 +3263,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case greater_equal: case greater_equal:
// rs >= rt // rs >= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -3282,7 +3282,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3282,7 +3282,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case less: case less:
// rs < rt // rs < rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset16, scratch, rt))
...@@ -3300,7 +3300,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3300,7 +3300,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case less_equal: case less_equal:
// rs <= rt // rs <= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -3321,7 +3321,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3321,7 +3321,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
// Unsigned comparison. // Unsigned comparison.
case Ugreater: case Ugreater:
// rs > rt // rs > rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt))
...@@ -3339,7 +3339,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3339,7 +3339,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Ugreater_equal: case Ugreater_equal:
// rs >= rt // rs >= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
...@@ -3358,7 +3358,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3358,7 +3358,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Uless: case Uless:
// rs < rt // rs < rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
break; // No code needs to be emitted. break; // No code needs to be emitted.
} else if (rs == zero_reg) { } else if (rs == zero_reg) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt)) if (!CalculateOffset(L, offset, OffsetSize::kOffset21, scratch, rt))
...@@ -3375,7 +3375,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L, ...@@ -3375,7 +3375,7 @@ bool TurboAssembler::BranchShortHelperR6(int32_t offset, Label* L,
break; break;
case Uless_equal: case Uless_equal:
// rs <= rt // rs <= rt
if (rs.code() == rt.rm().code()) { if (rt.is_reg() && rs.code() == rt.rm().code()) {
if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false; if (!CalculateOffset(L, offset, OffsetSize::kOffset26)) return false;
bc(offset); bc(offset);
} else if (rs == zero_reg) { } else if (rs == zero_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