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

Side by Side Diff: test/cctest/test-macro-assembler-mips.cc

Issue 1545013002: Add assembler test. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 11 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 | « test/cctest/test-assembler-mips.cc ('k') | test/cctest/test-macro-assembler-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 F1 f = FUNCTION_CAST<F1>(code->entry()); 254 F1 f = FUNCTION_CAST<F1>(code->entry());
255 for (int i = 0; i < kNumCases; ++i) { 255 for (int i = 0; i < kNumCases; ++i) {
256 int res = 256 int res =
257 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); 257 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
258 ::printf("f(%d) = %d\n", i, res); 258 ::printf("f(%d) = %d\n", i, res);
259 CHECK_EQ(values[i], res); 259 CHECK_EQ(values[i], res);
260 } 260 }
261 } 261 }
262 262
263 263
264 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) {
265 Isolate* isolate = CcTest::i_isolate();
266 HandleScope scope(isolate);
267 MacroAssembler assembler(isolate, nullptr, 0,
268 v8::internal::CodeObjectRequired::kYes);
269 MacroAssembler* masm = &assembler;
270
271 __ Lsa(v0, a0, a1, sa);
272 __ jr(ra);
273 __ nop();
274
275 CodeDesc desc;
276 assembler.GetCode(&desc);
277 Handle<Code> code = isolate->factory()->NewCode(
278 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
279
280 F1 f = FUNCTION_CAST<F1>(code->entry());
281
282 uint32_t res = reinterpret_cast<uint32_t>(
283 CALL_GENERATED_CODE(isolate, f, rt, rs, 0, 0, 0));
284
285 return res;
286 }
287
288
289 TEST(Lsa) {
290 CcTest::InitializeVM();
291 struct TestCaseLsa {
292 int32_t rt;
293 int32_t rs;
294 uint8_t sa;
295 uint32_t expected_res;
296 };
297
298 struct TestCaseLsa tc[] = {// rt, rs, sa, expected_res
299 {0x4, 0x1, 1, 0x6},
300 {0x4, 0x1, 2, 0x8},
301 {0x4, 0x1, 3, 0xc},
302 {0x4, 0x1, 4, 0x14},
303 {0x4, 0x1, 5, 0x24},
304 {0x0, 0x1, 1, 0x2},
305 {0x0, 0x1, 2, 0x4},
306 {0x0, 0x1, 3, 0x8},
307 {0x0, 0x1, 4, 0x10},
308 {0x0, 0x1, 5, 0x20},
309 {0x4, 0x0, 1, 0x4},
310 {0x4, 0x0, 2, 0x4},
311 {0x4, 0x0, 3, 0x4},
312 {0x4, 0x0, 4, 0x4},
313 {0x4, 0x0, 5, 0x4},
314
315 // Shift overflow.
316 {0x4, INT32_MAX, 1, 0x2},
317 {0x4, INT32_MAX >> 1, 2, 0x0},
318 {0x4, INT32_MAX >> 2, 3, 0xfffffffc},
319 {0x4, INT32_MAX >> 3, 4, 0xfffffff4},
320 {0x4, INT32_MAX >> 4, 5, 0xffffffe4},
321
322 // Signed addition overflow.
323 {INT32_MAX - 1, 0x1, 1, 0x80000000},
324 {INT32_MAX - 3, 0x1, 2, 0x80000000},
325 {INT32_MAX - 7, 0x1, 3, 0x80000000},
326 {INT32_MAX - 15, 0x1, 4, 0x80000000},
327 {INT32_MAX - 31, 0x1, 5, 0x80000000},
328
329 // Addition overflow.
330 {-2, 0x1, 1, 0x0},
331 {-4, 0x1, 2, 0x0},
332 {-8, 0x1, 3, 0x0},
333 {-16, 0x1, 4, 0x0},
334 {-32, 0x1, 5, 0x0}};
335
336 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa);
337 for (size_t i = 0; i < nr_test_cases; ++i) {
338 uint32_t res = run_lsa(tc[i].rt, tc[i].rs, tc[i].sa);
339 PrintF("0x%x =? 0x%x == lsa(v0, %x, %x, %hhu)\n", tc[i].expected_res, res,
340 tc[i].rt, tc[i].rs, tc[i].sa);
341 CHECK_EQ(tc[i].expected_res, res);
342 }
343 }
344
264 #undef __ 345 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698