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

Side by Side Diff: test/cctest/test-disasm-mips.cc

Issue 1237083003: MIPS: Improved checking target ranges for J and JAL instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | test/cctest/test-disasm-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 assm.asm_; \ 114 assm.asm_; \
115 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ 115 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \
116 } 116 }
117 117
118 118
119 #define COMPARE_PC_JUMP(asm_, compare_string, target) \ 119 #define COMPARE_PC_JUMP(asm_, compare_string, target) \
120 { \ 120 { \
121 int pc_offset = assm.pc_offset(); \ 121 int pc_offset = assm.pc_offset(); \
122 byte *progcounter = &buffer[pc_offset]; \ 122 byte *progcounter = &buffer[pc_offset]; \
123 char str_with_address[100]; \ 123 char str_with_address[100]; \
124 int instr_index = target >> 2; \ 124 int instr_index = (target >> 2) & kImm26Mask; \
125 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ 125 snprintf( \
126 compare_string, reinterpret_cast<byte *>( \ 126 str_with_address, sizeof(str_with_address), "%s %p -> %p", \
127 ((uint32_t)(progcounter + 1) & ~0xfffffff) | \ 127 compare_string, reinterpret_cast<byte *>(target), \
128 reinterpret_cast<byte *>(((uint32_t)(progcounter + 4) & ~0xfffffff) | \
128 (instr_index << 2))); \ 129 (instr_index << 2))); \
129 assm.asm_; \ 130 assm.asm_; \
130 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ 131 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \
131 } 132 }
132 133
133 134
135 #define GET_PC_REGION(pc_region) \
136 { \
137 int pc_offset = assm.pc_offset(); \
138 byte *progcounter = &buffer[pc_offset]; \
139 pc_region = reinterpret_cast<int32_t>(progcounter + 4) & ~0xfffffff; \
140 }
141
142
134 TEST(Type0) { 143 TEST(Type0) {
135 SET_UP(); 144 SET_UP();
136 145
137 COMPARE(addu(a0, a1, a2), 146 COMPARE(addu(a0, a1, a2),
138 "00a62021 addu a0, a1, a2"); 147 "00a62021 addu a0, a1, a2");
139 COMPARE(addu(t2, t3, t4), 148 COMPARE(addu(t2, t3, t4),
140 "016c5021 addu t2, t3, t4"); 149 "016c5021 addu t2, t3, t4");
141 COMPARE(addu(v0, v1, s0), 150 COMPARE(addu(v0, v1, s0),
142 "00701021 addu v0, v1, s0"); 151 "00701021 addu v0, v1, s0");
143 152
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 COMPARE_PC_REL_COMPACT(blez(a0, 32767), "18807fff blez a0, 32767", 468 COMPARE_PC_REL_COMPACT(blez(a0, 32767), "18807fff blez a0, 32767",
460 32767); 469 32767);
461 470
462 COMPARE_PC_REL_COMPACT(bgtz(a0, -32768), "1c808000 bgtz a0, -32768", 471 COMPARE_PC_REL_COMPACT(bgtz(a0, -32768), "1c808000 bgtz a0, -32768",
463 -32768); 472 -32768);
464 COMPARE_PC_REL_COMPACT(bgtz(a0, -1), "1c80ffff bgtz a0, -1", -1); 473 COMPARE_PC_REL_COMPACT(bgtz(a0, -1), "1c80ffff bgtz a0, -1", -1);
465 COMPARE_PC_REL_COMPACT(bgtz(a0, 1), "1c800001 bgtz a0, 1", 1); 474 COMPARE_PC_REL_COMPACT(bgtz(a0, 1), "1c800001 bgtz a0, 1", 1);
466 COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767", 475 COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767",
467 32767); 476 32767);
468 477
469 COMPARE_PC_JUMP(j(0x4), "08000001 j 0x4", 0x4); 478 int32_t pc_region;
470 COMPARE_PC_JUMP(j(0xffffffc), "0bffffff j 0xffffffc", 0xffffffc); 479 GET_PC_REGION(pc_region);
471 480
472 COMPARE_PC_JUMP(jal(0x4), "0c000001 jal 0x4", 0x4); 481 int32_t target = pc_region | 0x4;
473 COMPARE_PC_JUMP(jal(0xffffffc), "0fffffff jal 0xffffffc", 482 COMPARE_PC_JUMP(j(target), "08000001 j ", target);
474 0xffffffc); 483 target = pc_region | 0xffffffc;
484 COMPARE_PC_JUMP(j(target), "0bffffff j ", target);
485
486 target = pc_region | 0x4;
487 COMPARE_PC_JUMP(jal(target), "0c000001 jal ", target);
488 target = pc_region | 0xffffffc;
489 COMPARE_PC_JUMP(jal(target), "0fffffff jal ", target);
475 490
476 COMPARE(addiu(a0, a1, 0x0), 491 COMPARE(addiu(a0, a1, 0x0),
477 "24a40000 addiu a0, a1, 0"); 492 "24a40000 addiu a0, a1, 0");
478 COMPARE(addiu(s0, s1, 32767), 493 COMPARE(addiu(s0, s1, 32767),
479 "26307fff addiu s0, s1, 32767"); 494 "26307fff addiu s0, s1, 32767");
480 COMPARE(addiu(t2, t3, -32768), 495 COMPARE(addiu(t2, t3, -32768),
481 "256a8000 addiu t2, t3, -32768"); 496 "256a8000 addiu t2, t3, -32768");
482 COMPARE(addiu(v0, v1, -1), 497 COMPARE(addiu(v0, v1, -1),
483 "2462ffff addiu v0, v1, -1"); 498 "2462ffff addiu v0, v1, -1");
484 499
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); 1046 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24");
1032 if (IsMipsArchVariant(kMips32r6) || IsMipsArchVariant(kMips32r2)) { 1047 if (IsMipsArchVariant(kMips32r6) || IsMipsArchVariant(kMips32r2)) {
1033 COMPARE(cvt_s_l(f22, f24), "46a0c5a0 cvt.s.l f22, f24"); 1048 COMPARE(cvt_s_l(f22, f24), "46a0c5a0 cvt.s.l f22, f24");
1034 } 1049 }
1035 1050
1036 COMPARE(cvt_s_d(f22, f24), "4620c5a0 cvt.s.d f22, f24"); 1051 COMPARE(cvt_s_d(f22, f24), "4620c5a0 cvt.s.d f22, f24");
1037 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); 1052 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24");
1038 1053
1039 VERIFY_RUN(); 1054 VERIFY_RUN();
1040 } 1055 }
OLDNEW
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | test/cctest/test-disasm-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698