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

Side by Side Diff: runtime/vm/assembler_arm64_test.cc

Issue 630093004: Fix 32-bit and 64-bit carry out calculation in arm64 simulator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 __ ret(); 279 __ ret();
280 } 280 }
281 281
282 282
283 ASSEMBLER_TEST_RUN(AddExtReg, test) { 283 ASSEMBLER_TEST_RUN(AddExtReg, test) {
284 typedef int64_t (*Int64Return)() DART_UNUSED; 284 typedef int64_t (*Int64Return)() DART_UNUSED;
285 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); 285 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
286 } 286 }
287 287
288 288
289 ASSEMBLER_TEST_GENERATE(AddCarryInOut, assembler) {
290 __ LoadImmediate(R2, -1, kNoPP);
291 __ LoadImmediate(R1, 1, kNoPP);
292 __ LoadImmediate(R0, 0, kNoPP);
293 __ adds(IP0, R2, Operand(R1)); // c_out = 1.
294 __ adcs(IP0, R2, R0); // c_in = 1, c_out = 1.
295 __ adc(R0, R0, R0); // c_in = 1.
296 __ ret();
297 }
298
299
300 ASSEMBLER_TEST_RUN(AddCarryInOut, test) {
301 typedef int64_t (*Int64Return)() DART_UNUSED;
302 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
303 }
304
305
306 ASSEMBLER_TEST_GENERATE(SubCarryInOut, assembler) {
307 __ LoadImmediate(R1, 1, kNoPP);
308 __ LoadImmediate(R0, 0, kNoPP);
309 __ subs(IP0, R0, Operand(R1)); // c_out = 1.
310 __ sbcs(IP0, R0, R0); // c_in = 1, c_out = 1.
311 __ sbc(R0, R0, R0); // c_in = 1.
312 __ ret();
313 }
314
315
316 ASSEMBLER_TEST_RUN(SubCarryInOut, test) {
317 typedef int64_t (*Int64Return)() DART_UNUSED;
318 EXPECT_EQ(-1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
319 }
320
321
322 ASSEMBLER_TEST_GENERATE(Overflow, assembler) {
323 __ LoadImmediate(R0, 0, kNoPP);
324 __ LoadImmediate(R1, 1, kNoPP);
325 __ LoadImmediate(R2, 0xFFFFFFFFFFFFFFFF, kNoPP);
326 __ LoadImmediate(R3, 0x7FFFFFFFFFFFFFFF, kNoPP);
327 __ adds(IP0, R2, Operand(R1)); // c_out = 1.
328 __ adcs(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1.
329 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1.
330 __ ret();
331 }
332
333
334 ASSEMBLER_TEST_RUN(Overflow, test) {
335 typedef int64_t (*Int64Return)() DART_UNUSED;
336 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
337 }
338
339
340 ASSEMBLER_TEST_GENERATE(WordAddCarryInOut, assembler) {
341 __ LoadImmediate(R2, -1, kNoPP);
342 __ LoadImmediate(R1, 1, kNoPP);
343 __ LoadImmediate(R0, 0, kNoPP);
344 __ addsw(IP0, R2, Operand(R1)); // c_out = 1.
345 __ adcsw(IP0, R2, R0); // c_in = 1, c_out = 1.
346 __ adcw(R0, R0, R0); // c_in = 1.
347 __ ret();
348 }
349
350
351 ASSEMBLER_TEST_RUN(WordAddCarryInOut, test) {
352 typedef int64_t (*Int64Return)() DART_UNUSED;
353 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
354 }
355
356
357 ASSEMBLER_TEST_GENERATE(WordSubCarryInOut, assembler) {
358 __ LoadImmediate(R1, 1, kNoPP);
359 __ LoadImmediate(R0, 0, kNoPP);
360 __ subsw(IP0, R0, Operand(R1)); // c_out = 1.
361 __ sbcsw(IP0, R0, R0); // c_in = 1, c_out = 1.
362 __ sbcw(R0, R0, R0); // c_in = 1.
363 __ ret();
364 }
365
366
367 ASSEMBLER_TEST_RUN(WordSubCarryInOut, test) {
368 typedef int64_t (*Int64Return)() DART_UNUSED;
369 EXPECT_EQ(0x0FFFFFFFF, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
370 }
371
372
373 ASSEMBLER_TEST_GENERATE(WordOverflow, assembler) {
374 __ LoadImmediate(R0, 0, kNoPP);
375 __ LoadImmediate(R1, 1, kNoPP);
376 __ LoadImmediate(R2, 0xFFFFFFFF, kNoPP);
377 __ LoadImmediate(R3, 0x7FFFFFFF, kNoPP);
378 __ addsw(IP0, R2, Operand(R1)); // c_out = 1.
379 __ adcsw(IP0, R3, R0); // c_in = 1, c_out = 1, v = 1.
380 __ csinc(R0, R0, R0, VS); // R0 = v ? R0 : R0 + 1.
381 __ ret();
382 }
383
384
385 ASSEMBLER_TEST_RUN(WordOverflow, test) {
386 typedef int64_t (*Int64Return)() DART_UNUSED;
387 EXPECT_EQ(0, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry()));
388 }
389
390
289 // Loads and Stores. 391 // Loads and Stores.
290 ASSEMBLER_TEST_GENERATE(SimpleLoadStore, assembler) { 392 ASSEMBLER_TEST_GENERATE(SimpleLoadStore, assembler) {
291 __ SetupDartSP(kTestStackSpace); 393 __ SetupDartSP(kTestStackSpace);
292 __ movz(R0, Immediate(43), 0); 394 __ movz(R0, Immediate(43), 0);
293 __ movz(R1, Immediate(42), 0); 395 __ movz(R1, Immediate(42), 0);
294 __ str(R1, Address(SP, -1*kWordSize, Address::PreIndex)); 396 __ str(R1, Address(SP, -1*kWordSize, Address::PreIndex));
295 __ ldr(R0, Address(SP, 1*kWordSize, Address::PostIndex)); 397 __ ldr(R0, Address(SP, 1*kWordSize, Address::PostIndex));
296 __ mov(CSP, SP); 398 __ mov(CSP, SP);
297 __ ret(); 399 __ ret();
298 } 400 }
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 __ Pop(LR); 3376 __ Pop(LR);
3275 __ Pop(CTX); 3377 __ Pop(CTX);
3276 __ PopAndUntagPP(); 3378 __ PopAndUntagPP();
3277 __ mov(CSP, SP); 3379 __ mov(CSP, SP);
3278 __ ret(); 3380 __ ret();
3279 } 3381 }
3280 3382
3281 } // namespace dart 3383 } // namespace dart
3282 3384
3283 #endif // defined(TARGET_ARCH_ARM64) 3385 #endif // defined(TARGET_ARCH_ARM64)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698