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 5035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5046 }; | 5046 }; |
5047 | 5047 |
5048 nr_test_cases = sizeof(dahi_tc) / sizeof(TestCaseAui); | 5048 nr_test_cases = sizeof(dahi_tc) / sizeof(TestCaseAui); |
5049 for (size_t i = 0; i < nr_test_cases; ++i) { | 5049 for (size_t i = 0; i < nr_test_cases; ++i) { |
5050 uint64_t res = run_dahi(dahi_tc[i].rs, dahi_tc[i].offset); | 5050 uint64_t res = run_dahi(dahi_tc[i].rs, dahi_tc[i].offset); |
5051 CHECK_EQ(dahi_tc[i].ref_res, res); | 5051 CHECK_EQ(dahi_tc[i].ref_res, res); |
5052 } | 5052 } |
5053 } | 5053 } |
5054 } | 5054 } |
5055 | 5055 |
5056 | 5056 uint64_t run_li_macro(uint64_t imm, LiFlags mode, int32_t num_instr = 0) { |
5057 uint64_t run_li_macro(uint64_t rs, LiFlags mode) { | |
5058 Isolate* isolate = CcTest::i_isolate(); | 5057 Isolate* isolate = CcTest::i_isolate(); |
5059 HandleScope scope(isolate); | 5058 HandleScope scope(isolate); |
5060 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 5059 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
5061 | 5060 |
5062 __ li(a0, rs, mode); | 5061 Label code_start; |
5063 __ mov(v0, a0); | 5062 __ bind(&code_start); |
| 5063 __ li(v0, imm, mode); |
| 5064 if (num_instr > 0) { |
| 5065 CHECK_EQ(assm.InstructionsGeneratedSince(&code_start), num_instr); |
| 5066 } |
5064 __ jr(ra); | 5067 __ jr(ra); |
5065 __ nop(); | 5068 __ nop(); |
5066 | 5069 |
5067 CodeDesc desc; | 5070 CodeDesc desc; |
5068 assm.GetCode(&desc); | 5071 assm.GetCode(&desc); |
5069 Handle<Code> code = isolate->factory()->NewCode( | 5072 Handle<Code> code = isolate->factory()->NewCode( |
5070 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5073 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
5071 | |
5072 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5074 F2 f = FUNCTION_CAST<F2>(code->entry()); |
5073 | 5075 |
5074 uint64_t res = reinterpret_cast<uint64_t>( | 5076 uint64_t res = reinterpret_cast<uint64_t>( |
5075 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); | 5077 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
5076 | 5078 |
5077 return res; | 5079 return res; |
5078 } | 5080 } |
5079 | 5081 |
5080 | 5082 |
5081 TEST(li_macro) { | 5083 TEST(li_macro) { |
5082 CcTest::InitializeVM(); | 5084 CcTest::InitializeVM(); |
5083 | 5085 |
5084 uint64_t inputs[] = { | 5086 // Test li macro-instruction for border cases. |
5085 0x0000000000000000, 0x000000000000ffff, 0x00000000ffffffff, | 5087 |
5086 0x0000ffffffffffff, 0xffffffffffffffff, 0xffff000000000000, | 5088 struct TestCase_li { |
5087 0xffffffff00000000, 0xffffffffffff0000, 0xffff0000ffff0000, | 5089 uint64_t imm; |
5088 0x0000ffffffff0000, 0x0000ffff0000ffff, 0x00007fffffffffff, | 5090 int32_t r2_num_instr; |
5089 0x7fffffffffffffff, 0x000000007fffffff, 0x00007fff7fffffff, | 5091 int32_t r6_num_instr; |
5090 }; | 5092 }; |
5091 | 5093 |
5092 size_t nr_test_cases = sizeof(inputs) / sizeof(inputs[0]); | 5094 // We call li(v0, imm) to test cases listed below. |
| 5095 struct TestCase_li tc[] = { |
| 5096 // imm, r2_num_instr, r6_num_instr |
| 5097 {0xffffffffffff8000, 1, 1}, // min_int16 |
| 5098 // The test case above generates daddiu instruction. |
| 5099 // This is int16 value and we can load it using just daddiu. |
| 5100 {0x8000, 1, 1}, // max_int16 + 1 |
| 5101 // Generates ori |
| 5102 // max_int16 + 1 is not int16 but is uint16, just use ori. |
| 5103 {0xffffffffffff7fff, 2, 2}, // min_int16 - 1 |
| 5104 // Generates lui + ori |
| 5105 // We load int32 value using lui + ori. |
| 5106 {0x8001, 1, 1}, // max_int16 + 2 |
| 5107 // Generates ori |
| 5108 // Also an uint16 value, use ori. |
| 5109 {0x00010000, 1, 1}, // max_uint16 + 1 |
| 5110 // Generates lui |
| 5111 // Low 16 bits are 0, load value using lui. |
| 5112 {0x00010001, 2, 2}, // max_uint16 + 2 |
| 5113 // Generates lui + ori |
| 5114 // We have to generate two instructions in this case. |
| 5115 {0x00000000ffffffff, 2, 2}, // max_uint32 |
| 5116 // r2 - daddiu + dsrl32 |
| 5117 // r6 - daddiu + dahi |
| 5118 {0x00000000fffffffe, 3, 2}, // max_uint32 - 1 |
| 5119 // r2 - lui + ori + dsll |
| 5120 // r6 - daddiu + dahi |
| 5121 {0x00ffff000000fffe, 3, 3}, |
| 5122 // ori + dsll32 + ori |
| 5123 {0x00000001fffffffe, 4, 2}, // max_uint32 << 1 |
| 5124 // r2 - lui + ori + dsll + ori |
| 5125 // r6 - daddiu + dahi |
| 5126 {0x0000fffffffffffe, 5, 2}, // max_uint48 - 1 |
| 5127 // r2 - ori + dsll + ori + dsll + ori |
| 5128 // r6 - daddiu + dati |
| 5129 {0xffffffff00000000, 2, 2}, // max_uint32 << 32 |
| 5130 // r2 - daddiu + dsll32 |
| 5131 // r6 - ori + dahi |
| 5132 // We need ori to clear register before loading value using dahi. |
| 5133 {0xffffffff80000000, 1, 1}, // min_int32 |
| 5134 // The test case above generates lui instruction. |
| 5135 {0x0000000080000000, 2, 2}, // max_int32 + 1 |
| 5136 // r2 - ori + dsll |
| 5137 // r6 - lui + dahi |
| 5138 {0x0000800000000000, 2, 2}, |
| 5139 // ori + dsll32 |
| 5140 {0xffff800000000000, 2, 2}, |
| 5141 // r2 - daddiu + dsll32 |
| 5142 // r6 - ori + dahi |
| 5143 {0xffff80000000ffff, 3, 2}, |
| 5144 // r2 - daddiu + dsll32 + ori |
| 5145 // r6 - ori + dahi |
| 5146 {0xffffff123000ffff, 3, 3}, |
| 5147 // daddiu + dsll + ori |
| 5148 {0xffff00000000ffff, 3, 2}, |
| 5149 // r2 - daddiu + dsll32 + ori |
| 5150 // r6 - ori + dati |
| 5151 {0xffff8000ffff0000, 3, 2}, |
| 5152 // r2 - lui + ori + dsll |
| 5153 // r6 - lui + dahi |
| 5154 {0x1234ffff80000000, 3, 2}, |
| 5155 // r2 - lui + ori + dsll |
| 5156 // r6 - lui + dati |
| 5157 {0x1234ffff80010000, 5, 2}, |
| 5158 // r2 - lui + ori + dsll + ori + dsll |
| 5159 // r6 - lui + dati |
| 5160 {0xffff8000ffff8000, 2, 2}, |
| 5161 // r2 - daddiu + dinsu |
| 5162 // r6 - daddiu + dahi |
| 5163 {0xffff0000ffff8000, 5, 3}, |
| 5164 // r2 - lui + dsll + ori + dsll + ori |
| 5165 // r6 - daddiu + dahi + dati |
| 5166 {0x8000000080000000, 2, 2}, |
| 5167 // lui + dinsu |
| 5168 {0xabcd0000abcd0000, 2, 2}, |
| 5169 // lui + dinsu |
| 5170 {0x8000800080008000, 3, 3}, |
| 5171 // lui + ori + dinsu |
| 5172 {0xabcd1234abcd1234, 3, 3}, |
| 5173 // The test case above generates lui + ori + dinsu instruction sequence. |
| 5174 {0xffff800080008000, 4, 3}, |
| 5175 // r2 - lui + ori + dsll + ori |
| 5176 // r6 - lui + ori + dahi |
| 5177 {0xffffabcd, 3, 2}, |
| 5178 // r2 - ori + dsll + ori |
| 5179 // r6 - daddiu + dahi |
| 5180 {0x1ffffabcd, 4, 2}, |
| 5181 // r2 - lui + ori + dsll + ori |
| 5182 // r6 - daddiu + dahi |
| 5183 {0xffffffffabcd, 5, 2}, |
| 5184 // r2 - ori + dsll + ori + dsll + ori |
| 5185 // r6 - daddiu + dati |
| 5186 {0x1ffffffffabcd, 6, 2}, |
| 5187 // r2 - lui + ori + dsll + ori + dsll + ori |
| 5188 // r6 - daddiu + dati |
| 5189 {0xffff7fff80010000, 5, 2}, |
| 5190 // r2 - lui + ori + dsll + ori + dsll |
| 5191 // r6 - lui + dahi |
| 5192 // Here lui sets high 32 bits to 1 so dahi can be used to get target |
| 5193 // value. |
| 5194 {0x00007fff7fff0000, 3, 2}, |
| 5195 // r2 - lui + ori + dsll |
| 5196 // r6 - lui + dahi |
| 5197 // High 32 bits are not set so dahi can be used to get target value. |
| 5198 {0xffff7fff7fff0000, 5, 3}, |
| 5199 // r2 - lui + ori + dsll + ori + dsll |
| 5200 // r6 - lui + dahi + dati |
| 5201 // High 32 bits are not set so just dahi can't be used to get target |
| 5202 // value. |
| 5203 {0x00007fff80010000, 3, 3}, |
| 5204 // r2 - lui + ori + dsll |
| 5205 // r6 - lui + ori + dsll |
| 5206 // High 32 bits are set so can't just use lui + dahi to get target value. |
| 5207 {0x1234abcd87654321, 6, 4}, |
| 5208 // The test case above generates: |
| 5209 // r2 - lui + ori + dsll + ori + dsll + ori instruction sequence, |
| 5210 // r6 - lui + ori + dahi + dati. |
| 5211 // Load using full instruction sequence. |
| 5212 }; |
| 5213 |
| 5214 size_t nr_test_cases = sizeof(tc) / sizeof(TestCase_li); |
5093 for (size_t i = 0; i < nr_test_cases; ++i) { | 5215 for (size_t i = 0; i < nr_test_cases; ++i) { |
5094 uint64_t res = run_li_macro(inputs[i], OPTIMIZE_SIZE); | 5216 if (kArchVariant == kMips64r2) { |
5095 CHECK_EQ(inputs[i], res); | 5217 CHECK_EQ(tc[i].imm, |
5096 res = run_li_macro(inputs[i], CONSTANT_SIZE); | 5218 run_li_macro(tc[i].imm, OPTIMIZE_SIZE, tc[i].r2_num_instr)); |
5097 CHECK_EQ(inputs[i], res); | 5219 } else { |
5098 if (is_int48(inputs[i])) { | 5220 CHECK_EQ(tc[i].imm, |
5099 res = run_li_macro(inputs[i], ADDRESS_LOAD); | 5221 run_li_macro(tc[i].imm, OPTIMIZE_SIZE, tc[i].r6_num_instr)); |
5100 CHECK_EQ(inputs[i], res); | 5222 } |
| 5223 CHECK_EQ(tc[i].imm, run_li_macro(tc[i].imm, CONSTANT_SIZE)); |
| 5224 if (is_int48(tc[i].imm)) { |
| 5225 CHECK_EQ(tc[i].imm, run_li_macro(tc[i].imm, ADDRESS_LOAD)); |
5101 } | 5226 } |
5102 } | 5227 } |
5103 } | 5228 } |
5104 | 5229 |
5105 | 5230 |
5106 uint64_t run_lwpc(int offset) { | 5231 uint64_t run_lwpc(int offset) { |
5107 Isolate* isolate = CcTest::i_isolate(); | 5232 Isolate* isolate = CcTest::i_isolate(); |
5108 HandleScope scope(isolate); | 5233 HandleScope scope(isolate); |
5109 | 5234 |
5110 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 5235 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 TEST(maddf_msubf_d) { | 6175 TEST(maddf_msubf_d) { |
6051 if (kArchVariant != kMips64r6) return; | 6176 if (kArchVariant != kMips64r6) return; |
6052 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) { | 6177 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) { |
6053 __ maddf_d(f4, f6, f8); | 6178 __ maddf_d(f4, f6, f8); |
6054 __ Sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add))); | 6179 __ Sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add))); |
6055 __ msubf_d(f16, f6, f8); | 6180 __ msubf_d(f16, f6, f8); |
6056 __ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub))); | 6181 __ Sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub))); |
6057 }); | 6182 }); |
6058 } | 6183 } |
6059 | 6184 |
| 6185 uint64_t run_Subu(uint64_t imm, int32_t num_instr) { |
| 6186 Isolate* isolate = CcTest::i_isolate(); |
| 6187 HandleScope scope(isolate); |
| 6188 |
| 6189 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6190 |
| 6191 Label code_start; |
| 6192 __ bind(&code_start); |
| 6193 __ Subu(v0, zero_reg, Operand(imm)); |
| 6194 CHECK_EQ(assm.InstructionsGeneratedSince(&code_start), num_instr); |
| 6195 __ jr(ra); |
| 6196 __ nop(); |
| 6197 |
| 6198 CodeDesc desc; |
| 6199 assm.GetCode(&desc); |
| 6200 Handle<Code> code = isolate->factory()->NewCode( |
| 6201 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6202 F2 f = FUNCTION_CAST<F2>(code->entry()); |
| 6203 |
| 6204 uint64_t res = reinterpret_cast<uint64_t>( |
| 6205 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
| 6206 |
| 6207 return res; |
| 6208 } |
| 6209 |
| 6210 TEST(Subu) { |
| 6211 CcTest::InitializeVM(); |
| 6212 |
| 6213 // Test Subu macro-instruction for min_int16 and max_int16 border cases. |
| 6214 // For subtracting int16 immediate values we use addiu. |
| 6215 |
| 6216 struct TestCaseSubu { |
| 6217 uint64_t imm; |
| 6218 uint64_t expected_res; |
| 6219 int32_t num_instr; |
| 6220 }; |
| 6221 |
| 6222 // We call Subu(v0, zero_reg, imm) to test cases listed below. |
| 6223 // 0 - imm = expected_res |
| 6224 struct TestCaseSubu tc[] = { |
| 6225 // imm, expected_res, num_instr |
| 6226 {0xffffffffffff8000, 0x8000, 2}, // min_int16 |
| 6227 // The test case above generates ori + addu instruction sequence. |
| 6228 // We can't have just addiu because -min_int16 > max_int16 so use |
| 6229 // register. We can load min_int16 to at register with addiu and then |
| 6230 // subtract at with subu, but now we use ori + addu because -min_int16 can |
| 6231 // be loaded using ori. |
| 6232 {0x8000, 0xffffffffffff8000, 1}, // max_int16 + 1 |
| 6233 // Generates addiu |
| 6234 // max_int16 + 1 is not int16 but -(max_int16 + 1) is, just use addiu. |
| 6235 {0xffffffffffff7fff, 0x8001, 2}, // min_int16 - 1 |
| 6236 // Generates ori + addu |
| 6237 // To load this value to at we need two instructions and another one to |
| 6238 // subtract, lui + ori + subu. But we can load -value to at using just |
| 6239 // ori and then add at register with addu. |
| 6240 {0x8001, 0xffffffffffff7fff, 2}, // max_int16 + 2 |
| 6241 // Generates ori + subu |
| 6242 // Not int16 but is uint16, load value to at with ori and subtract with |
| 6243 // subu. |
| 6244 {0x00010000, 0xffffffffffff0000, 2}, |
| 6245 // Generates lui + subu |
| 6246 // Load value using lui to at and subtract with subu. |
| 6247 {0x00010001, 0xfffffffffffeffff, 3}, |
| 6248 // Generates lui + ori + subu |
| 6249 // We have to generate three instructions in this case. |
| 6250 {0x7fffffff, 0xffffffff80000001, 3}, // max_int32 |
| 6251 // Generates lui + ori + subu |
| 6252 {0xffffffff80000000, 0xffffffff80000000, 2}, // min_int32 |
| 6253 // The test case above generates lui + subu intruction sequence. |
| 6254 // The result of 0 - min_int32 eqauls max_int32 + 1, which wraps around to |
| 6255 // min_int32 again. |
| 6256 }; |
| 6257 |
| 6258 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseSubu); |
| 6259 for (size_t i = 0; i < nr_test_cases; ++i) { |
| 6260 CHECK_EQ(tc[i].expected_res, run_Subu(tc[i].imm, tc[i].num_instr)); |
| 6261 } |
| 6262 } |
| 6263 |
| 6264 uint64_t run_Dsubu(uint64_t imm, int32_t num_instr) { |
| 6265 Isolate* isolate = CcTest::i_isolate(); |
| 6266 HandleScope scope(isolate); |
| 6267 |
| 6268 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6269 |
| 6270 Label code_start; |
| 6271 __ bind(&code_start); |
| 6272 __ Dsubu(v0, zero_reg, Operand(imm)); |
| 6273 CHECK_EQ(assm.InstructionsGeneratedSince(&code_start), num_instr); |
| 6274 __ jr(ra); |
| 6275 __ nop(); |
| 6276 |
| 6277 CodeDesc desc; |
| 6278 assm.GetCode(&desc); |
| 6279 Handle<Code> code = isolate->factory()->NewCode( |
| 6280 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6281 F2 f = FUNCTION_CAST<F2>(code->entry()); |
| 6282 |
| 6283 uint64_t res = reinterpret_cast<uint64_t>( |
| 6284 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
| 6285 |
| 6286 return res; |
| 6287 } |
| 6288 |
| 6289 TEST(Dsubu) { |
| 6290 CcTest::InitializeVM(); |
| 6291 |
| 6292 // Test Dsubu macro-instruction for min_int16 and max_int16 border cases. |
| 6293 // For subtracting int16 immediate values we use daddiu. |
| 6294 |
| 6295 struct TestCaseDsubu { |
| 6296 uint64_t imm; |
| 6297 uint64_t expected_res; |
| 6298 int32_t num_instr; |
| 6299 }; |
| 6300 |
| 6301 // We call Dsubu(v0, zero_reg, imm) to test cases listed below. |
| 6302 // 0 - imm = expected_res |
| 6303 struct TestCaseDsubu tc[] = { |
| 6304 // imm, expected_res, num_instr |
| 6305 {0xffffffffffff8000, 0x8000, 2}, // min_int16 |
| 6306 // The test case above generates ori + daddu instruction sequence. |
| 6307 // We can't have just daddiu because -min_int16 > max_int16 so use |
| 6308 // register. We can load min_int16 to at register with daddiu and then |
| 6309 // subtract at with dsubu, but now we use ori + daddu because -min_int16 |
| 6310 // can be loaded using ori. |
| 6311 {0x8000, 0xffffffffffff8000, 1}, // max_int16 + 1 |
| 6312 // Generates daddiu |
| 6313 // max_int16 + 1 is not int16 but -(max_int16 + 1) is, just use daddiu. |
| 6314 {0xffffffffffff7fff, 0x8001, 2}, // min_int16 - 1 |
| 6315 // Generates ori + daddu |
| 6316 // To load this value to at we need two instructions and another one to |
| 6317 // subtract, lui + ori + dsubu. But we can load -value to at using just |
| 6318 // ori and then dadd at register with daddu. |
| 6319 {0x8001, 0xffffffffffff7fff, 2}, // max_int16 + 2 |
| 6320 // Generates ori + dsubu |
| 6321 // Not int16 but is uint16, load value to at with ori and subtract with |
| 6322 // dsubu. |
| 6323 {0x00010000, 0xffffffffffff0000, 2}, |
| 6324 // Generates lui + dsubu |
| 6325 // Load value using lui to at and subtract with dsubu. |
| 6326 {0x00010001, 0xfffffffffffeffff, 3}, |
| 6327 // Generates lui + ori + dsubu |
| 6328 // We have to generate three instructions in this case. |
| 6329 {0x7fffffff, 0xffffffff80000001, 3}, // max_int32 |
| 6330 // Generates lui + ori + dsubu |
| 6331 {0xffffffff80000000, 0x0000000080000000, 2}, // min_int32 |
| 6332 // Generates lui + dsubu |
| 6333 // The result of 0 - min_int32 eqauls max_int32 + 1, which fits into a 64 |
| 6334 // bit register, Dsubu gives a different result here. |
| 6335 {0x7fffffffffffffff, 0x8000000000000001, 3}, // max_int64 |
| 6336 // r2 - Generates daddiu + dsrl + dsubu |
| 6337 // r6 - Generates daddiu + dati + dsubu |
| 6338 {0x8000000000000000, 0x8000000000000000, 3}, // min_int64 |
| 6339 // The test case above generates: |
| 6340 // r2 - daddiu + dsrl32 + dsubu instruction sequence, |
| 6341 // r6 - ori + dati + dsubu. |
| 6342 // The result of 0 - min_int64 eqauls max_int64 + 1, which wraps around to |
| 6343 // min_int64 again. |
| 6344 }; |
| 6345 |
| 6346 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDsubu); |
| 6347 for (size_t i = 0; i < nr_test_cases; ++i) { |
| 6348 CHECK_EQ(tc[i].expected_res, run_Dsubu(tc[i].imm, tc[i].num_instr)); |
| 6349 } |
| 6350 } |
| 6351 |
6060 uint64_t run_Dins(uint64_t imm, uint64_t source, uint16_t pos, uint16_t size) { | 6352 uint64_t run_Dins(uint64_t imm, uint64_t source, uint16_t pos, uint16_t size) { |
6061 Isolate* isolate = CcTest::i_isolate(); | 6353 Isolate* isolate = CcTest::i_isolate(); |
6062 HandleScope scope(isolate); | 6354 HandleScope scope(isolate); |
6063 | 6355 |
6064 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 6356 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
6065 | 6357 |
6066 __ li(v0, imm); | 6358 __ li(v0, imm); |
6067 __ li(t0, source); | 6359 __ li(t0, source); |
6068 __ Dins(v0, t0, pos, size); | 6360 __ Dins(v0, t0, pos, size); |
6069 __ jr(ra); | 6361 __ jr(ra); |
(...skipping 21 matching lines...) Expand all Loading... |
6091 uint64_t source; | 6383 uint64_t source; |
6092 uint16_t pos; | 6384 uint16_t pos; |
6093 uint16_t size; | 6385 uint16_t size; |
6094 uint64_t expected_res; | 6386 uint64_t expected_res; |
6095 }; | 6387 }; |
6096 | 6388 |
6097 // We load imm to v0 and source to t0 and then call | 6389 // We load imm to v0 and source to t0 and then call |
6098 // Dins(v0, t0, pos, size) to test cases listed below. | 6390 // Dins(v0, t0, pos, size) to test cases listed below. |
6099 struct TestCaseDins tc[] = { | 6391 struct TestCaseDins tc[] = { |
6100 // imm, source, pos, size, expected_res | 6392 // imm, source, pos, size, expected_res |
6101 {0x5555555555555555, 0x1ABCDEF01, 31, 1, 0x55555555D5555555}, | 6393 {0x5555555555555555, 0x1abcdef01, 31, 1, 0x55555555d5555555}, |
6102 {0x5555555555555555, 0x1ABCDEF02, 30, 2, 0x5555555595555555}, | 6394 {0x5555555555555555, 0x1abcdef02, 30, 2, 0x5555555595555555}, |
6103 {0x201234567, 0x1FABCDEFF, 0, 32, 0x2FABCDEFF}, | 6395 {0x201234567, 0x1fabcdeff, 0, 32, 0x2fabcdeff}, |
6104 {0x201234567, 0x7FABCDEFF, 31, 2, 0x381234567}, | 6396 {0x201234567, 0x7fabcdeff, 31, 2, 0x381234567}, |
6105 {0x800000000, 0x7FABCDEFF, 0, 33, 0x9FABCDEFF}, | 6397 {0x800000000, 0x7fabcdeff, 0, 33, 0x9fabcdeff}, |
6106 {0x1234, 0xABCDABCDABCDABCD, 0, 64, 0xABCDABCDABCDABCD}, | 6398 {0x1234, 0xabcdabcdabcdabcd, 0, 64, 0xabcdabcdabcdabcd}, |
6107 {0xABCD, 0xABCEABCF, 32, 1, 0x10000ABCD}, | 6399 {0xabcd, 0xabceabcf, 32, 1, 0x10000abcd}, |
6108 {0xABCD, 0xABCEABCF, 63, 1, 0x800000000000ABCD}, | 6400 {0xabcd, 0xabceabcf, 63, 1, 0x800000000000abcd}, |
6109 {0xABCD, 0xABC1ABC2ABC3ABC4, 32, 32, 0xABC3ABC40000ABCD}, | 6401 {0x10000abcd, 0xabc1abc2abc3abc4, 32, 32, 0xabc3abc40000abcd}, |
6110 }; | 6402 }; |
6111 | 6403 |
6112 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); | 6404 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); |
6113 for (size_t i = 0; i < nr_test_cases; ++i) { | 6405 for (size_t i = 0; i < nr_test_cases; ++i) { |
6114 CHECK_EQ(tc[i].expected_res, | 6406 CHECK_EQ(tc[i].expected_res, |
6115 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); | 6407 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); |
6116 } | 6408 } |
6117 } | 6409 } |
6118 | 6410 |
6119 #undef __ | 6411 #undef __ |
OLD | NEW |