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

Side by Side Diff: src/compiler/node-matchers.h

Issue 1578723002: [turbofan] Build s/NULL/nullptr/g and CHECK(x != nullptr) to CHECK_NOT_NULL(x). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/compiler/node-cache.h ('k') | src/compiler/node-properties.h » ('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 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 #ifndef V8_COMPILER_NODE_MATCHERS_H_ 5 #ifndef V8_COMPILER_NODE_MATCHERS_H_
6 #define V8_COMPILER_NODE_MATCHERS_H_ 6 #define V8_COMPILER_NODE_MATCHERS_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 // TODO(turbofan): Move ExternalReference out of assembler.h 10 // TODO(turbofan): Move ExternalReference out of assembler.h
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 typedef AddMatcher<Int32BinopMatcher, IrOpcode::kInt32Add, IrOpcode::kInt32Mul, 377 typedef AddMatcher<Int32BinopMatcher, IrOpcode::kInt32Add, IrOpcode::kInt32Mul,
378 IrOpcode::kWord32Shl> Int32AddMatcher; 378 IrOpcode::kWord32Shl> Int32AddMatcher;
379 typedef AddMatcher<Int64BinopMatcher, IrOpcode::kInt64Add, IrOpcode::kInt64Mul, 379 typedef AddMatcher<Int64BinopMatcher, IrOpcode::kInt64Add, IrOpcode::kInt64Mul,
380 IrOpcode::kWord64Shl> Int64AddMatcher; 380 IrOpcode::kWord64Shl> Int64AddMatcher;
381 381
382 382
383 template <class AddMatcher> 383 template <class AddMatcher>
384 struct BaseWithIndexAndDisplacementMatcher { 384 struct BaseWithIndexAndDisplacementMatcher {
385 BaseWithIndexAndDisplacementMatcher(Node* node, bool allow_input_swap) 385 BaseWithIndexAndDisplacementMatcher(Node* node, bool allow_input_swap)
386 : matches_(false), 386 : matches_(false),
387 index_(NULL), 387 index_(nullptr),
388 scale_(0), 388 scale_(0),
389 base_(NULL), 389 base_(nullptr),
390 displacement_(NULL) { 390 displacement_(nullptr) {
391 Initialize(node, allow_input_swap); 391 Initialize(node, allow_input_swap);
392 } 392 }
393 393
394 explicit BaseWithIndexAndDisplacementMatcher(Node* node) 394 explicit BaseWithIndexAndDisplacementMatcher(Node* node)
395 : matches_(false), 395 : matches_(false),
396 index_(NULL), 396 index_(nullptr),
397 scale_(0), 397 scale_(0),
398 base_(NULL), 398 base_(nullptr),
399 displacement_(NULL) { 399 displacement_(nullptr) {
400 Initialize(node, node->op()->HasProperty(Operator::kCommutative)); 400 Initialize(node, node->op()->HasProperty(Operator::kCommutative));
401 } 401 }
402 402
403 bool matches() const { return matches_; } 403 bool matches() const { return matches_; }
404 Node* index() const { return index_; } 404 Node* index() const { return index_; }
405 int scale() const { return scale_; } 405 int scale() const { return scale_; }
406 Node* base() const { return base_; } 406 Node* base() const { return base_; }
407 Node* displacement() const { return displacement_; } 407 Node* displacement() const { return displacement_; }
408 408
409 private: 409 private:
(...skipping 17 matching lines...) Expand all
427 // ((S + D) + B) 427 // ((S + D) + B)
428 // ((S + B) + D) 428 // ((S + B) + D)
429 // ((B + D) + B) 429 // ((B + D) + B)
430 // ((B + B) + D) 430 // ((B + B) + D)
431 // (B + D) 431 // (B + D)
432 // (B + B) 432 // (B + B)
433 if (node->InputCount() < 2) return; 433 if (node->InputCount() < 2) return;
434 AddMatcher m(node, allow_input_swap); 434 AddMatcher m(node, allow_input_swap);
435 Node* left = m.left().node(); 435 Node* left = m.left().node();
436 Node* right = m.right().node(); 436 Node* right = m.right().node();
437 Node* displacement = NULL; 437 Node* displacement = nullptr;
438 Node* base = NULL; 438 Node* base = nullptr;
439 Node* index = NULL; 439 Node* index = nullptr;
440 Node* scale_expression = NULL; 440 Node* scale_expression = nullptr;
441 bool power_of_two_plus_one = false; 441 bool power_of_two_plus_one = false;
442 int scale = 0; 442 int scale = 0;
443 if (m.HasIndexInput() && left->OwnedBy(node)) { 443 if (m.HasIndexInput() && left->OwnedBy(node)) {
444 index = m.IndexInput(); 444 index = m.IndexInput();
445 scale = m.scale(); 445 scale = m.scale();
446 scale_expression = left; 446 scale_expression = left;
447 power_of_two_plus_one = m.power_of_two_plus_one(); 447 power_of_two_plus_one = m.power_of_two_plus_one();
448 if (right->opcode() == AddMatcher::kOpcode && right->OwnedBy(node)) { 448 if (right->opcode() == AddMatcher::kOpcode && right->OwnedBy(node)) {
449 AddMatcher right_matcher(right); 449 AddMatcher right_matcher(right);
450 if (right_matcher.right().HasValue()) { 450 if (right_matcher.right().HasValue()) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 base = left; 512 base = left;
513 displacement = right; 513 displacement = right;
514 } else { 514 } else {
515 // (B + B) 515 // (B + B)
516 base = left; 516 base = left;
517 index = right; 517 index = right;
518 } 518 }
519 } 519 }
520 } 520 }
521 int64_t value = 0; 521 int64_t value = 0;
522 if (displacement != NULL) { 522 if (displacement != nullptr) {
523 switch (displacement->opcode()) { 523 switch (displacement->opcode()) {
524 case IrOpcode::kInt32Constant: { 524 case IrOpcode::kInt32Constant: {
525 value = OpParameter<int32_t>(displacement); 525 value = OpParameter<int32_t>(displacement);
526 break; 526 break;
527 } 527 }
528 case IrOpcode::kInt64Constant: { 528 case IrOpcode::kInt64Constant: {
529 value = OpParameter<int64_t>(displacement); 529 value = OpParameter<int64_t>(displacement);
530 break; 530 break;
531 } 531 }
532 default: 532 default:
533 UNREACHABLE(); 533 UNREACHABLE();
534 break; 534 break;
535 } 535 }
536 if (value == 0) { 536 if (value == 0) {
537 displacement = NULL; 537 displacement = nullptr;
538 } 538 }
539 } 539 }
540 if (power_of_two_plus_one) { 540 if (power_of_two_plus_one) {
541 if (base != NULL) { 541 if (base != nullptr) {
542 // If the scale requires explicitly using the index as the base, but a 542 // If the scale requires explicitly using the index as the base, but a
543 // base is already part of the match, then the (1 << N + 1) scale factor 543 // base is already part of the match, then the (1 << N + 1) scale factor
544 // can't be folded into the match and the entire index * scale 544 // can't be folded into the match and the entire index * scale
545 // calculation must be computed separately. 545 // calculation must be computed separately.
546 index = scale_expression; 546 index = scale_expression;
547 scale = 0; 547 scale = 0;
548 } else { 548 } else {
549 base = index; 549 base = index;
550 } 550 }
551 } 551 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 Node* branch_; 608 Node* branch_;
609 Node* if_true_; 609 Node* if_true_;
610 Node* if_false_; 610 Node* if_false_;
611 }; 611 };
612 612
613 } // namespace compiler 613 } // namespace compiler
614 } // namespace internal 614 } // namespace internal
615 } // namespace v8 615 } // namespace v8
616 616
617 #endif // V8_COMPILER_NODE_MATCHERS_H_ 617 #endif // V8_COMPILER_NODE_MATCHERS_H_
OLDNEW
« no previous file with comments | « src/compiler/node-cache.h ('k') | src/compiler/node-properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698