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

Side by Side Diff: src/compiler/arm64/code-generator-arm64.cc

Issue 1945783002: [turbofan] ARM64: Use zr to store immediate zero (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/arm64/macro-assembler-arm64.h" 8 #include "src/arm64/macro-assembler-arm64.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/compiler/code-generator-impl.h" 10 #include "src/compiler/code-generator-impl.h"
(...skipping 15 matching lines...) Expand all
26 : InstructionOperandConverter(gen, instr) {} 26 : InstructionOperandConverter(gen, instr) {}
27 27
28 DoubleRegister InputFloat32Register(size_t index) { 28 DoubleRegister InputFloat32Register(size_t index) {
29 return InputDoubleRegister(index).S(); 29 return InputDoubleRegister(index).S();
30 } 30 }
31 31
32 DoubleRegister InputFloat64Register(size_t index) { 32 DoubleRegister InputFloat64Register(size_t index) {
33 return InputDoubleRegister(index); 33 return InputDoubleRegister(index);
34 } 34 }
35 35
36 CPURegister InputFloat32OrZeroRegister(size_t index) {
37 if (instr_->InputAt(index)->IsImmediate()) {
38 DCHECK(instr_->InputAt(index)->IsImmediate() &&
39 (InputFloat32(index) == 0.0f) &&
40 (copysignf(1.0f, InputFloat32(index)) > 0.0f));
Benedikt Meurer 2016/05/03 17:33:20 Use std::signbit or bit_cast<int32_t>(InputFloat32
martyn.capewell 2016/05/04 09:47:47 Done.
41 return wzr;
42 }
43 DCHECK(instr_->InputAt(index)->IsDoubleRegister());
44 return InputDoubleRegister(index).S();
45 }
46
47 CPURegister InputFloat64OrZeroRegister(size_t index) {
48 if (instr_->InputAt(index)->IsImmediate()) {
49 DCHECK(instr_->InputAt(index)->IsImmediate() &&
50 (InputDouble(index) == 0.0f) &&
51 (copysign(1.0, InputDouble(index)) > 0.0));
Benedikt Meurer 2016/05/03 17:33:20 Use std::signbit or bit_cast<int64_t>(InputFloat64
martyn.capewell 2016/05/04 09:47:47 Done.
52 return xzr;
53 }
54 DCHECK(instr_->InputAt(index)->IsDoubleRegister());
55 return InputDoubleRegister(index);
56 }
57
36 size_t OutputCount() { return instr_->OutputCount(); } 58 size_t OutputCount() { return instr_->OutputCount(); }
37 59
38 DoubleRegister OutputFloat32Register() { return OutputDoubleRegister().S(); } 60 DoubleRegister OutputFloat32Register() { return OutputDoubleRegister().S(); }
39 61
40 DoubleRegister OutputFloat64Register() { return OutputDoubleRegister(); } 62 DoubleRegister OutputFloat64Register() { return OutputDoubleRegister(); }
41 63
42 Register InputRegister32(size_t index) { 64 Register InputRegister32(size_t index) {
43 return ToRegister(instr_->InputAt(index)).W(); 65 return ToRegister(instr_->InputAt(index)).W();
44 } 66 }
45 67
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 auto buffer = i.InputRegister(0); \ 431 auto buffer = i.InputRegister(0); \
410 auto offset = i.InputRegister32(1); \ 432 auto offset = i.InputRegister32(1); \
411 auto length = i.InputOperand32(2); \ 433 auto length = i.InputOperand32(2); \
412 __ Cmp(offset, length); \ 434 __ Cmp(offset, length); \
413 auto ool = new (zone()) OutOfLineLoadZero(this, result); \ 435 auto ool = new (zone()) OutOfLineLoadZero(this, result); \
414 __ B(hs, ool->entry()); \ 436 __ B(hs, ool->entry()); \
415 __ asm_instr(result, MemOperand(buffer, offset, UXTW)); \ 437 __ asm_instr(result, MemOperand(buffer, offset, UXTW)); \
416 __ Bind(ool->exit()); \ 438 __ Bind(ool->exit()); \
417 } while (0) 439 } while (0)
418 440
419 441 #define ASSEMBLE_CHECKED_STORE_FLOAT(width) \
420 #define ASSEMBLE_CHECKED_STORE_FLOAT(width) \ 442 do { \
421 do { \ 443 auto buffer = i.InputRegister(0); \
422 auto buffer = i.InputRegister(0); \ 444 auto offset = i.InputRegister32(1); \
423 auto offset = i.InputRegister32(1); \ 445 auto length = i.InputOperand32(2); \
424 auto length = i.InputOperand32(2); \ 446 auto value = i.InputFloat##width##OrZeroRegister(3); \
425 auto value = i.InputFloat##width##Register(3); \ 447 __ Cmp(offset, length); \
426 __ Cmp(offset, length); \ 448 Label done; \
427 Label done; \ 449 __ B(hs, &done); \
428 __ B(hs, &done); \ 450 __ Str(value, MemOperand(buffer, offset, UXTW)); \
429 __ Str(value, MemOperand(buffer, offset, UXTW)); \ 451 __ Bind(&done); \
430 __ Bind(&done); \
431 } while (0) 452 } while (0)
432 453
433
434 #define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \ 454 #define ASSEMBLE_CHECKED_STORE_INTEGER(asm_instr) \
435 do { \ 455 do { \
436 auto buffer = i.InputRegister(0); \ 456 auto buffer = i.InputRegister(0); \
437 auto offset = i.InputRegister32(1); \ 457 auto offset = i.InputRegister32(1); \
438 auto length = i.InputOperand32(2); \ 458 auto length = i.InputOperand32(2); \
439 auto value = i.InputRegister32(3); \ 459 auto value = i.InputOrZeroRegister32(3); \
440 __ Cmp(offset, length); \ 460 __ Cmp(offset, length); \
441 Label done; \ 461 Label done; \
442 __ B(hs, &done); \ 462 __ B(hs, &done); \
443 __ asm_instr(value, MemOperand(buffer, offset, UXTW)); \ 463 __ asm_instr(value, MemOperand(buffer, offset, UXTW)); \
444 __ Bind(&done); \ 464 __ Bind(&done); \
445 } while (0) 465 } while (0)
446 466
447
448 #define ASSEMBLE_CHECKED_STORE_INTEGER_64(asm_instr) \ 467 #define ASSEMBLE_CHECKED_STORE_INTEGER_64(asm_instr) \
449 do { \ 468 do { \
450 auto buffer = i.InputRegister(0); \ 469 auto buffer = i.InputRegister(0); \
451 auto offset = i.InputRegister32(1); \ 470 auto offset = i.InputRegister32(1); \
452 auto length = i.InputOperand32(2); \ 471 auto length = i.InputOperand32(2); \
453 auto value = i.InputRegister(3); \ 472 auto value = i.InputOrZeroRegister64(3); \
454 __ Cmp(offset, length); \ 473 __ Cmp(offset, length); \
455 Label done; \ 474 Label done; \
456 __ B(hs, &done); \ 475 __ B(hs, &done); \
457 __ asm_instr(value, MemOperand(buffer, offset, UXTW)); \ 476 __ asm_instr(value, MemOperand(buffer, offset, UXTW)); \
458 __ Bind(&done); \ 477 __ Bind(&done); \
459 } while (0) 478 } while (0)
460 479
461
462 #define ASSEMBLE_SHIFT(asm_instr, width) \ 480 #define ASSEMBLE_SHIFT(asm_instr, width) \
463 do { \ 481 do { \
464 if (instr->InputAt(1)->IsRegister()) { \ 482 if (instr->InputAt(1)->IsRegister()) { \
465 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ 483 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \
466 i.InputRegister##width(1)); \ 484 i.InputRegister##width(1)); \
467 } else { \ 485 } else { \
468 uint32_t imm = \ 486 uint32_t imm = \
469 static_cast<uint32_t>(i.InputOperand##width(1).ImmediateValue()); \ 487 static_cast<uint32_t>(i.InputOperand##width(1).ImmediateValue()); \
470 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \ 488 __ asm_instr(i.OutputRegister##width(), i.InputRegister##width(0), \
471 imm % (width)); \ 489 imm % (width)); \
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 case kArm64U64MoveFloat64: 1348 case kArm64U64MoveFloat64:
1331 __ Fmov(i.OutputRegister(), i.InputDoubleRegister(0)); 1349 __ Fmov(i.OutputRegister(), i.InputDoubleRegister(0));
1332 break; 1350 break;
1333 case kArm64Ldrb: 1351 case kArm64Ldrb:
1334 __ Ldrb(i.OutputRegister(), i.MemoryOperand()); 1352 __ Ldrb(i.OutputRegister(), i.MemoryOperand());
1335 break; 1353 break;
1336 case kArm64Ldrsb: 1354 case kArm64Ldrsb:
1337 __ Ldrsb(i.OutputRegister(), i.MemoryOperand()); 1355 __ Ldrsb(i.OutputRegister(), i.MemoryOperand());
1338 break; 1356 break;
1339 case kArm64Strb: 1357 case kArm64Strb:
1340 __ Strb(i.InputRegister(2), i.MemoryOperand()); 1358 __ Strb(i.InputOrZeroRegister64(2), i.MemoryOperand());
1341 break; 1359 break;
1342 case kArm64Ldrh: 1360 case kArm64Ldrh:
1343 __ Ldrh(i.OutputRegister(), i.MemoryOperand()); 1361 __ Ldrh(i.OutputRegister(), i.MemoryOperand());
1344 break; 1362 break;
1345 case kArm64Ldrsh: 1363 case kArm64Ldrsh:
1346 __ Ldrsh(i.OutputRegister(), i.MemoryOperand()); 1364 __ Ldrsh(i.OutputRegister(), i.MemoryOperand());
1347 break; 1365 break;
1348 case kArm64Strh: 1366 case kArm64Strh:
1349 __ Strh(i.InputRegister(2), i.MemoryOperand()); 1367 __ Strh(i.InputOrZeroRegister64(2), i.MemoryOperand());
1350 break; 1368 break;
1351 case kArm64LdrW: 1369 case kArm64LdrW:
1352 __ Ldr(i.OutputRegister32(), i.MemoryOperand()); 1370 __ Ldr(i.OutputRegister32(), i.MemoryOperand());
1353 break; 1371 break;
1354 case kArm64StrW: 1372 case kArm64StrW:
1355 __ Str(i.InputRegister32(2), i.MemoryOperand()); 1373 __ Str(i.InputOrZeroRegister32(2), i.MemoryOperand());
1356 break; 1374 break;
1357 case kArm64Ldr: 1375 case kArm64Ldr:
1358 __ Ldr(i.OutputRegister(), i.MemoryOperand()); 1376 __ Ldr(i.OutputRegister(), i.MemoryOperand());
1359 break; 1377 break;
1360 case kArm64Str: 1378 case kArm64Str:
1361 __ Str(i.InputRegister(2), i.MemoryOperand()); 1379 __ Str(i.InputOrZeroRegister64(2), i.MemoryOperand());
1362 break; 1380 break;
1363 case kArm64LdrS: 1381 case kArm64LdrS:
1364 __ Ldr(i.OutputDoubleRegister().S(), i.MemoryOperand()); 1382 __ Ldr(i.OutputDoubleRegister().S(), i.MemoryOperand());
1365 break; 1383 break;
1366 case kArm64StrS: 1384 case kArm64StrS:
1367 __ Str(i.InputDoubleRegister(2).S(), i.MemoryOperand()); 1385 __ Str(i.InputFloat32OrZeroRegister(2), i.MemoryOperand());
1368 break; 1386 break;
1369 case kArm64LdrD: 1387 case kArm64LdrD:
1370 __ Ldr(i.OutputDoubleRegister(), i.MemoryOperand()); 1388 __ Ldr(i.OutputDoubleRegister(), i.MemoryOperand());
1371 break; 1389 break;
1372 case kArm64StrD: 1390 case kArm64StrD:
1373 __ Str(i.InputDoubleRegister(2), i.MemoryOperand()); 1391 __ Str(i.InputFloat64OrZeroRegister(2), i.MemoryOperand());
1374 break; 1392 break;
1375 case kCheckedLoadInt8: 1393 case kCheckedLoadInt8:
1376 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrsb); 1394 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrsb);
1377 break; 1395 break;
1378 case kCheckedLoadUint8: 1396 case kCheckedLoadUint8:
1379 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrb); 1397 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrb);
1380 break; 1398 break;
1381 case kCheckedLoadInt16: 1399 case kCheckedLoadInt16:
1382 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrsh); 1400 ASSEMBLE_CHECKED_LOAD_INTEGER(Ldrsh);
1383 break; 1401 break;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 padding_size -= kInstructionSize; 1875 padding_size -= kInstructionSize;
1858 } 1876 }
1859 } 1877 }
1860 } 1878 }
1861 1879
1862 #undef __ 1880 #undef __
1863 1881
1864 } // namespace compiler 1882 } // namespace compiler
1865 } // namespace internal 1883 } // namespace internal
1866 } // namespace v8 1884 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/arm64/instruction-selector-arm64.cc » ('j') | src/compiler/arm64/instruction-selector-arm64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698