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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 // Verify that all invocations of the COMPARE macro passed successfully. | 93 // Verify that all invocations of the COMPARE macro passed successfully. |
94 // Exit with a failure if at least one of the tests failed. | 94 // Exit with a failure if at least one of the tests failed. |
95 #define VERIFY_RUN() \ | 95 #define VERIFY_RUN() \ |
96 if (failure) { \ | 96 if (failure) { \ |
97 V8_Fatal(__FILE__, __LINE__, "MIPS Disassembler tests failed.\n"); \ | 97 V8_Fatal(__FILE__, __LINE__, "MIPS Disassembler tests failed.\n"); \ |
98 } | 98 } |
99 | 99 |
100 | |
101 #define COMPARE_PC_REL_COMPACT(asm_, compare_string, offset) \ | 100 #define COMPARE_PC_REL_COMPACT(asm_, compare_string, offset) \ |
102 { \ | 101 { \ |
103 int pc_offset = assm.pc_offset(); \ | 102 int pc_offset = assm.pc_offset(); \ |
104 byte *progcounter = &buffer[pc_offset]; \ | 103 byte *progcounter = &buffer[pc_offset]; \ |
105 char str_with_address[100]; \ | 104 char str_with_address[100]; \ |
106 prev_instr_compact_branch = assm.IsPrevInstrCompactBranch(); \ | 105 prev_instr_compact_branch = assm.IsPrevInstrCompactBranch(); \ |
107 if (prev_instr_compact_branch) { \ | 106 if (prev_instr_compact_branch) { \ |
108 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ | 107 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ |
109 compare_string, progcounter + 8 + (offset * 4)); \ | 108 compare_string, \ |
| 109 static_cast<void *>(progcounter + 8 + (offset * 4))); \ |
110 } else { \ | 110 } else { \ |
111 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ | 111 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ |
112 compare_string, progcounter + 4 + (offset * 4)); \ | 112 compare_string, \ |
| 113 static_cast<void *>(progcounter + 4 + (offset * 4))); \ |
113 } \ | 114 } \ |
114 assm.asm_; \ | 115 assm.asm_; \ |
115 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ | 116 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ |
116 } | 117 } |
117 | 118 |
118 | |
119 #define COMPARE_PC_REL(asm_, compare_string, offset) \ | 119 #define COMPARE_PC_REL(asm_, compare_string, offset) \ |
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 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ | 124 snprintf(str_with_address, sizeof(str_with_address), "%s -> %p", \ |
125 compare_string, progcounter + (offset * 4)); \ | 125 compare_string, static_cast<void *>(progcounter + (offset * 4))); \ |
126 assm.asm_; \ | 126 assm.asm_; \ |
127 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ | 127 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ |
128 } | 128 } |
129 | 129 |
130 | |
131 #define COMPARE_PC_JUMP(asm_, compare_string, target) \ | 130 #define COMPARE_PC_JUMP(asm_, compare_string, target) \ |
132 { \ | 131 { \ |
133 int pc_offset = assm.pc_offset(); \ | 132 int pc_offset = assm.pc_offset(); \ |
134 byte *progcounter = &buffer[pc_offset]; \ | 133 byte *progcounter = &buffer[pc_offset]; \ |
135 char str_with_address[100]; \ | 134 char str_with_address[100]; \ |
136 int instr_index = (target >> 2) & kImm26Mask; \ | 135 int instr_index = (target >> 2) & kImm26Mask; \ |
137 snprintf( \ | 136 snprintf( \ |
138 str_with_address, sizeof(str_with_address), "%s %p -> %p", \ | 137 str_with_address, sizeof(str_with_address), "%s %p -> %p", \ |
139 compare_string, reinterpret_cast<byte *>(target), \ | 138 compare_string, reinterpret_cast<void *>(target), \ |
140 reinterpret_cast<byte *>(((uint64_t)(progcounter + 1) & ~0xfffffff) | \ | 139 reinterpret_cast<void *>(((uint64_t)(progcounter + 1) & ~0xfffffff) | \ |
141 (instr_index << 2))); \ | 140 (instr_index << 2))); \ |
142 assm.asm_; \ | 141 assm.asm_; \ |
143 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ | 142 if (!DisassembleAndCompare(progcounter, str_with_address)) failure = true; \ |
144 } | 143 } |
145 | 144 |
146 | |
147 #define GET_PC_REGION(pc_region) \ | 145 #define GET_PC_REGION(pc_region) \ |
148 { \ | 146 { \ |
149 int pc_offset = assm.pc_offset(); \ | 147 int pc_offset = assm.pc_offset(); \ |
150 byte *progcounter = &buffer[pc_offset]; \ | 148 byte *progcounter = &buffer[pc_offset]; \ |
151 pc_region = reinterpret_cast<int64_t>(progcounter + 4) & ~0xfffffff; \ | 149 pc_region = reinterpret_cast<int64_t>(progcounter + 4) & ~0xfffffff; \ |
152 } | 150 } |
153 | 151 |
154 | 152 |
155 TEST(Type0) { | 153 TEST(Type0) { |
156 SET_UP(); | 154 SET_UP(); |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 | 1245 |
1248 | 1246 |
1249 TEST(ctc1_cfc1_disasm) { | 1247 TEST(ctc1_cfc1_disasm) { |
1250 SET_UP(); | 1248 SET_UP(); |
1251 COMPARE(abs_d(f10, f31), "4620fa85 abs.d f10, f31"); | 1249 COMPARE(abs_d(f10, f31), "4620fa85 abs.d f10, f31"); |
1252 COMPARE(ceil_w_s(f8, f31), "4600fa0e ceil.w.s f8, f31"); | 1250 COMPARE(ceil_w_s(f8, f31), "4600fa0e ceil.w.s f8, f31"); |
1253 COMPARE(ctc1(a0, FCSR), "44c4f800 ctc1 a0, FCSR"); | 1251 COMPARE(ctc1(a0, FCSR), "44c4f800 ctc1 a0, FCSR"); |
1254 COMPARE(cfc1(a0, FCSR), "4444f800 cfc1 a0, FCSR"); | 1252 COMPARE(cfc1(a0, FCSR), "4444f800 cfc1 a0, FCSR"); |
1255 VERIFY_RUN(); | 1253 VERIFY_RUN(); |
1256 } | 1254 } |
OLD | NEW |