OLD | NEW |
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 Loading... |
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 ((uint64_t)(progcounter + 1) & ~0xfffffff) | \ | 127 compare_string, reinterpret_cast<byte *>(target), \ |
| 128 reinterpret_cast<byte *>(((uint64_t)(progcounter + 1) & ~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<int64_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(daddu(a0, a1, a2), | 148 COMPARE(daddu(a0, a1, a2), |
140 "00a6202d daddu a0, a1, a2"); | 149 "00a6202d daddu a0, a1, a2"); |
141 COMPARE(addu(a6, a7, t0), | 150 COMPARE(addu(a6, a7, t0), |
142 "016c5021 addu a6, a7, t0"); | 151 "016c5021 addu a6, a7, t0"); |
143 COMPARE(daddu(a6, a7, t0), | 152 COMPARE(daddu(a6, a7, t0), |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 COMPARE_PC_REL_COMPACT(blez(a0, 32767), "18807fff blez a0, 32767", | 1116 COMPARE_PC_REL_COMPACT(blez(a0, 32767), "18807fff blez a0, 32767", |
1108 32767); | 1117 32767); |
1109 | 1118 |
1110 COMPARE_PC_REL_COMPACT(bgtz(a0, -32768), "1c808000 bgtz a0, -32768", | 1119 COMPARE_PC_REL_COMPACT(bgtz(a0, -32768), "1c808000 bgtz a0, -32768", |
1111 -32768); | 1120 -32768); |
1112 COMPARE_PC_REL_COMPACT(bgtz(a0, -1), "1c80ffff bgtz a0, -1", -1); | 1121 COMPARE_PC_REL_COMPACT(bgtz(a0, -1), "1c80ffff bgtz a0, -1", -1); |
1113 COMPARE_PC_REL_COMPACT(bgtz(a0, 1), "1c800001 bgtz a0, 1", 1); | 1122 COMPARE_PC_REL_COMPACT(bgtz(a0, 1), "1c800001 bgtz a0, 1", 1); |
1114 COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767", | 1123 COMPARE_PC_REL_COMPACT(bgtz(a0, 32767), "1c807fff bgtz a0, 32767", |
1115 32767); | 1124 32767); |
1116 | 1125 |
1117 COMPARE_PC_JUMP(j(0x4), "08000001 j 0x4", 0x4); | 1126 int64_t pc_region; |
1118 COMPARE_PC_JUMP(j(0xffffffc), "0bffffff j 0xffffffc", 0xffffffc); | 1127 GET_PC_REGION(pc_region); |
1119 | 1128 |
1120 COMPARE_PC_JUMP(jal(0x4), "0c000001 jal 0x4", 0x4); | 1129 int64_t target = pc_region | 0x4; |
1121 COMPARE_PC_JUMP(jal(0xffffffc), "0fffffff jal 0xffffffc", | 1130 COMPARE_PC_JUMP(j(target), "08000001 j ", target); |
1122 0xffffffc); | 1131 target = pc_region | 0xffffffc; |
| 1132 COMPARE_PC_JUMP(j(target), "0bffffff j ", target); |
| 1133 |
| 1134 target = pc_region | 0x4; |
| 1135 COMPARE_PC_JUMP(jal(target), "0c000001 jal ", target); |
| 1136 target = pc_region | 0xffffffc; |
| 1137 COMPARE_PC_JUMP(jal(target), "0fffffff jal ", target); |
1123 | 1138 |
1124 VERIFY_RUN(); | 1139 VERIFY_RUN(); |
1125 } | 1140 } |
1126 | 1141 |
1127 | 1142 |
1128 TEST(C_FMT_DISASM) { | 1143 TEST(C_FMT_DISASM) { |
1129 if (kArchVariant == kMips64r2) { | 1144 if (kArchVariant == kMips64r2) { |
1130 SET_UP(); | 1145 SET_UP(); |
1131 | 1146 |
1132 COMPARE(c_s(F, f8, f10, 0), "460a4030 c.f.s f8, f10, cc(0)"); | 1147 COMPARE(c_s(F, f8, f10, 0), "460a4030 c.f.s f8, f10, cc(0)"); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); | 1232 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); |
1218 if (kArchVariant == kMips64r6 || kArchVariant == kMips64r2) { | 1233 if (kArchVariant == kMips64r6 || kArchVariant == kMips64r2) { |
1219 COMPARE(cvt_s_l(f22, f24), "46a0c5a0 cvt.s.l f22, f24"); | 1234 COMPARE(cvt_s_l(f22, f24), "46a0c5a0 cvt.s.l f22, f24"); |
1220 } | 1235 } |
1221 | 1236 |
1222 COMPARE(cvt_s_d(f22, f24), "4620c5a0 cvt.s.d f22, f24"); | 1237 COMPARE(cvt_s_d(f22, f24), "4620c5a0 cvt.s.d f22, f24"); |
1223 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); | 1238 COMPARE(cvt_s_w(f22, f24), "4680c5a0 cvt.s.w f22, f24"); |
1224 | 1239 |
1225 VERIFY_RUN(); | 1240 VERIFY_RUN(); |
1226 } | 1241 } |
OLD | NEW |