Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: src/mips/macro-assembler-mips.cc

Issue 1446343002: MIPS: Fix trampoline pool handling in MacroAssembler::BranchShort() for r6. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Support all the mips revisions in cctest case. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | src/mips64/assembler-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mips/macro-assembler-mips.cc
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc
index 272f8147b94185aac05ed5dd75d18940e2fb7e03..4a5a386fa0f7cbf09eb0324bad52521f127c74c0 100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -2094,270 +2094,273 @@ bool MacroAssembler::BranchShortHelperR6(int32_t offset, Label* L,
// Be careful to always use shifted_branch_offset only just before the
// branch instruction, as the location will be remember for patching the
// target.
- BlockTrampolinePoolScope block_trampoline_pool(this);
- switch (cond) {
- case cc_always:
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bc(offset);
- break;
- case eq:
- if (rs.code() == rt.rm_.reg_code) {
- // 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.
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- beq(rs, scratch, offset);
- nop();
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- beqzc(rs, offset);
- } else {
- // We don't want any other register but scratch clobbered.
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- beqc(rs, scratch, offset);
- }
- break;
- case ne:
- if (rs.code() == rt.rm_.reg_code) {
- // Pre R6 bne is used here to make the code patchable. Otherwise we
- // should not generate any instruction.
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bne(rs, scratch, offset);
- nop();
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bnezc(rs, offset);
- } else {
- // We don't want any other register but scratch clobbered.
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bnec(rs, scratch, offset);
- }
- break;
-
- // Signed comparison.
- case greater:
- // rs > rt
- if (rs.code() == rt.rm_.reg_code) {
- break; // No code needs to be emitted.
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bltzc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bgtzc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bltc(scratch, rs, offset);
- }
- break;
- case greater_equal:
- // rs >= rt
- if (rs.code() == rt.rm_.reg_code) {
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bc(offset);
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- blezc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bgezc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bgec(rs, scratch, offset);
- }
- break;
- case less:
- // rs < rt
- if (rs.code() == rt.rm_.reg_code) {
- break; // No code needs to be emitted.
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bgtzc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bltzc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bltc(rs, scratch, offset);
- }
- break;
- case less_equal:
- // rs <= rt
- if (rs.code() == rt.rm_.reg_code) {
+ {
+ BlockTrampolinePoolScope block_trampoline_pool(this);
+ switch (cond) {
+ case cc_always:
bits = OffsetSize::kOffset26;
if (!is_near(L, bits)) return false;
offset = GetOffset(offset, L, bits);
bc(offset);
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bgezc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- blezc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bgec(scratch, rs, offset);
- }
- break;
+ break;
+ case eq:
+ if (rs.code() == rt.rm_.reg_code) {
+ // 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.
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ beq(rs, scratch, offset);
+ nop();
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ beqzc(rs, offset);
+ } else {
+ // We don't want any other register but scratch clobbered.
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ beqc(rs, scratch, offset);
+ }
+ break;
+ case ne:
+ if (rs.code() == rt.rm_.reg_code) {
+ // Pre R6 bne is used here to make the code patchable. Otherwise we
+ // should not generate any instruction.
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bne(rs, scratch, offset);
+ nop();
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bnezc(rs, offset);
+ } else {
+ // We don't want any other register but scratch clobbered.
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bnec(rs, scratch, offset);
+ }
+ break;
- // Unsigned comparison.
- case Ugreater:
- // rs > rt
- if (rs.code() == rt.rm_.reg_code) {
- break; // No code needs to be emitted.
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bnezc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bnezc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bltuc(scratch, rs, offset);
- }
- break;
- case Ugreater_equal:
- // rs >= rt
- if (rs.code() == rt.rm_.reg_code) {
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bc(offset);
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- beqzc(scratch, offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bc(offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bgeuc(rs, scratch, offset);
- }
- break;
- case Uless:
- // rs < rt
- if (rs.code() == rt.rm_.reg_code) {
- break; // No code needs to be emitted.
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bnezc(scratch, offset);
- } else if (IsZero(rt)) {
- break; // No code needs to be emitted.
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bltuc(rs, scratch, offset);
- }
- break;
- case Uless_equal:
- // rs <= rt
- if (rs.code() == rt.rm_.reg_code) {
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- bc(offset);
- } else if (rs.is(zero_reg)) {
- bits = OffsetSize::kOffset26;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- offset = GetOffset(offset, L, bits);
- bc(offset);
- } else if (IsZero(rt)) {
- bits = OffsetSize::kOffset21;
- if (!is_near(L, bits)) return false;
- offset = GetOffset(offset, L, bits);
- beqzc(rs, offset);
- } else {
- bits = OffsetSize::kOffset16;
- if (!is_near(L, bits)) return false;
- scratch = GetRtAsRegisterHelper(rt, scratch);
- DCHECK(!rs.is(scratch));
- offset = GetOffset(offset, L, bits);
- bgeuc(scratch, rs, offset);
- }
- break;
- default:
- UNREACHABLE();
+ // Signed comparison.
+ case greater:
+ // rs > rt
+ if (rs.code() == rt.rm_.reg_code) {
+ break; // No code needs to be emitted.
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bltzc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bgtzc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bltc(scratch, rs, offset);
+ }
+ break;
+ case greater_equal:
+ // rs >= rt
+ if (rs.code() == rt.rm_.reg_code) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ blezc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bgezc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bgec(rs, scratch, offset);
+ }
+ break;
+ case less:
+ // rs < rt
+ if (rs.code() == rt.rm_.reg_code) {
+ break; // No code needs to be emitted.
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bgtzc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bltzc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bltc(rs, scratch, offset);
+ }
+ break;
+ case less_equal:
+ // rs <= rt
+ if (rs.code() == rt.rm_.reg_code) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bgezc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ blezc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bgec(scratch, rs, offset);
+ }
+ break;
+
+ // Unsigned comparison.
+ case Ugreater:
+ // rs > rt
+ if (rs.code() == rt.rm_.reg_code) {
+ break; // No code needs to be emitted.
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bnezc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bnezc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bltuc(scratch, rs, offset);
+ }
+ break;
+ case Ugreater_equal:
+ // rs >= rt
+ if (rs.code() == rt.rm_.reg_code) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ beqzc(scratch, offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bgeuc(rs, scratch, offset);
+ }
+ break;
+ case Uless:
+ // rs < rt
+ if (rs.code() == rt.rm_.reg_code) {
+ break; // No code needs to be emitted.
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bnezc(scratch, offset);
+ } else if (IsZero(rt)) {
+ break; // No code needs to be emitted.
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bltuc(rs, scratch, offset);
+ }
+ break;
+ case Uless_equal:
+ // rs <= rt
+ if (rs.code() == rt.rm_.reg_code) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else if (rs.is(zero_reg)) {
+ bits = OffsetSize::kOffset26;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ offset = GetOffset(offset, L, bits);
+ bc(offset);
+ } else if (IsZero(rt)) {
+ bits = OffsetSize::kOffset21;
+ if (!is_near(L, bits)) return false;
+ offset = GetOffset(offset, L, bits);
+ beqzc(rs, offset);
+ } else {
+ bits = OffsetSize::kOffset16;
+ if (!is_near(L, bits)) return false;
+ scratch = GetRtAsRegisterHelper(rt, scratch);
+ DCHECK(!rs.is(scratch));
+ offset = GetOffset(offset, L, bits);
+ bgeuc(scratch, rs, offset);
+ }
+ break;
+ default:
+ UNREACHABLE();
+ }
}
+ CheckTrampolinePoolQuick(1);
return true;
}
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | src/mips64/assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698