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

Side by Side Diff: src/compiler/register-allocator.h

Issue 1312473018: [turbofan] Greedy: live range grouping. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/greedy-allocator.cc ('k') | src/compiler/register-allocator.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 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_REGISTER_ALLOCATOR_H_ 5 #ifndef V8_REGISTER_ALLOCATOR_H_
6 #define V8_REGISTER_ALLOCATOR_H_ 6 #define V8_REGISTER_ALLOCATOR_H_
7 7
8 #include "src/compiler/instruction.h" 8 #include "src/compiler/instruction.h"
9 #include "src/ostreams.h" 9 #include "src/ostreams.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 LifetimePosition const pos_; 268 LifetimePosition const pos_;
269 uint32_t flags_; 269 uint32_t flags_;
270 270
271 DISALLOW_COPY_AND_ASSIGN(UsePosition); 271 DISALLOW_COPY_AND_ASSIGN(UsePosition);
272 }; 272 };
273 273
274 274
275 class SpillRange; 275 class SpillRange;
276 class RegisterAllocationData; 276 class RegisterAllocationData;
277 class TopLevelLiveRange; 277 class TopLevelLiveRange;
278 class LiveRangeGroup;
278 279
279 // Representation of SSA values' live ranges as a collection of (continuous) 280 // Representation of SSA values' live ranges as a collection of (continuous)
280 // intervals over the instruction ordering. 281 // intervals over the instruction ordering.
281 class LiveRange : public ZoneObject { 282 class LiveRange : public ZoneObject {
282 public: 283 public:
283 UseInterval* first_interval() const { return first_interval_; } 284 UseInterval* first_interval() const { return first_interval_; }
284 UsePosition* first_pos() const { return first_pos_; } 285 UsePosition* first_pos() const { return first_pos_; }
285 TopLevelLiveRange* TopLevel() { return top_level_; } 286 TopLevelLiveRange* TopLevel() { return top_level_; }
286 const TopLevelLiveRange* TopLevel() const { return top_level_; } 287 const TopLevelLiveRange* TopLevel() const { return top_level_; }
287 288
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 378
378 void ConvertUsesToOperand(const InstructionOperand& op, 379 void ConvertUsesToOperand(const InstructionOperand& op,
379 const InstructionOperand& spill_op); 380 const InstructionOperand& spill_op);
380 void SetUseHints(int register_index); 381 void SetUseHints(int register_index);
381 void UnsetUseHints() { SetUseHints(kUnassignedRegister); } 382 void UnsetUseHints() { SetUseHints(kUnassignedRegister); }
382 383
383 // Used solely by the Greedy Allocator: 384 // Used solely by the Greedy Allocator:
384 unsigned GetSize(); 385 unsigned GetSize();
385 float weight() const { return weight_; } 386 float weight() const { return weight_; }
386 void set_weight(float weight) { weight_ = weight; } 387 void set_weight(float weight) { weight_ = weight; }
388 LiveRangeGroup* group() const { return group_; }
389 void set_group(LiveRangeGroup* group) { group_ = group; }
387 390
388 static const int kInvalidSize = -1; 391 static const int kInvalidSize = -1;
389 static const float kInvalidWeight; 392 static const float kInvalidWeight;
390 static const float kMaxWeight; 393 static const float kMaxWeight;
391 394
392 private: 395 private:
393 friend class TopLevelLiveRange; 396 friend class TopLevelLiveRange;
394 explicit LiveRange(int relative_id, MachineType machine_type, 397 explicit LiveRange(int relative_id, MachineType machine_type,
395 TopLevelLiveRange* top_level); 398 TopLevelLiveRange* top_level);
396 399
(...skipping 27 matching lines...) Expand all
424 427
425 // greedy: the number of LifetimePositions covered by this range. Used to 428 // greedy: the number of LifetimePositions covered by this range. Used to
426 // prioritize selecting live ranges for register assignment, as well as 429 // prioritize selecting live ranges for register assignment, as well as
427 // in weight calculations. 430 // in weight calculations.
428 int size_; 431 int size_;
429 432
430 // greedy: a metric for resolving conflicts between ranges with an assigned 433 // greedy: a metric for resolving conflicts between ranges with an assigned
431 // register and ranges that intersect them and need a register. 434 // register and ranges that intersect them and need a register.
432 float weight_; 435 float weight_;
433 436
437 // greedy: groupping
438 LiveRangeGroup* group_;
439
434 DISALLOW_COPY_AND_ASSIGN(LiveRange); 440 DISALLOW_COPY_AND_ASSIGN(LiveRange);
435 }; 441 };
436 442
437 443
444 class LiveRangeGroup final : public ZoneObject {
445 public:
446 explicit LiveRangeGroup(Zone* zone) : ranges_(zone) {}
447 ZoneVector<LiveRange*>& ranges() { return ranges_; }
448 const ZoneVector<LiveRange*>& ranges() const { return ranges_; }
449
450 // TODO(mtrofin): populate assigned register and use in weight calculation.
451 int assigned_register() const { return assigned_register_; }
452 void set_assigned_register(int reg) { assigned_register_ = reg; }
453
454 private:
455 ZoneVector<LiveRange*> ranges_;
456 int assigned_register_;
457 DISALLOW_COPY_AND_ASSIGN(LiveRangeGroup);
458 };
459
460
438 class TopLevelLiveRange final : public LiveRange { 461 class TopLevelLiveRange final : public LiveRange {
439 public: 462 public:
440 explicit TopLevelLiveRange(int vreg, MachineType machine_type); 463 explicit TopLevelLiveRange(int vreg, MachineType machine_type);
441 int spill_start_index() const { return spill_start_index_; } 464 int spill_start_index() const { return spill_start_index_; }
442 465
443 bool IsFixed() const { return vreg_ < 0; } 466 bool IsFixed() const { return vreg_ < 0; }
444 467
445 bool is_phi() const { return IsPhiField::decode(bits_); } 468 bool is_phi() const { return IsPhiField::decode(bits_); }
446 void set_is_phi(bool value) { bits_ = IsPhiField::update(bits_, value); } 469 void set_is_phi(bool value) { bits_ = IsPhiField::update(bits_, value); }
447 470
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 RegisterAllocationData* const data_; 1075 RegisterAllocationData* const data_;
1053 1076
1054 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector); 1077 DISALLOW_COPY_AND_ASSIGN(LiveRangeConnector);
1055 }; 1078 };
1056 1079
1057 } // namespace compiler 1080 } // namespace compiler
1058 } // namespace internal 1081 } // namespace internal
1059 } // namespace v8 1082 } // namespace v8
1060 1083
1061 #endif // V8_REGISTER_ALLOCATOR_H_ 1084 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/greedy-allocator.cc ('k') | src/compiler/register-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698