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

Unified Diff: src/compiler/greedy-allocator.h

Issue 1184183002: Separate greedy regalloc in its own files (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | src/compiler/greedy-allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/greedy-allocator.h
diff --git a/src/compiler/greedy-allocator.h b/src/compiler/greedy-allocator.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bc7ce343d778dbd2126bb4adb0d6ecf1e4ade27
--- /dev/null
+++ b/src/compiler/greedy-allocator.h
@@ -0,0 +1,66 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_GREEDY_ALLOCATOR_H_
+#define V8_GREEDY_ALLOCATOR_H_
+
+#include "src/compiler/register-allocator.h"
+#include "src/zone-containers.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+class CoalescedLiveRanges;
+
+
+// A variant of the LLVM Greedy Register Allocator. See
+// http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html
+class GreedyAllocator final : public RegisterAllocator {
+ public:
+ explicit GreedyAllocator(RegisterAllocationData* data, RegisterKind kind,
+ Zone* local_zone);
+
+ void AllocateRegisters();
+
+ private:
+ LifetimePosition GetSplittablePos(LifetimePosition pos);
+ const RegisterConfiguration* config() const { return data()->config(); }
+ Zone* local_zone() const { return local_zone_; }
+
+ int GetHintedRegister(LiveRange* range);
+
+ typedef ZonePriorityQueue<std::pair<unsigned, LiveRange*>> PQueue;
+
+ unsigned GetLiveRangeSize(LiveRange* range);
+ void Enqueue(LiveRange* range);
+
+ void Evict(LiveRange* range);
+ float CalculateSpillWeight(LiveRange* range);
+ float CalculateMaxSpillWeight(const ZoneSet<LiveRange*>& ranges);
+
+
+ bool TryAllocate(LiveRange* current, ZoneSet<LiveRange*>* conflicting);
+ bool TryAllocatePhysicalRegister(unsigned reg_id, LiveRange* range,
+ ZoneSet<LiveRange*>* conflicting);
+ bool HandleSpillOperands(LiveRange* range);
+ void AllocateBlockedRange(LiveRange* current, LifetimePosition pos,
+ bool spill);
+
+ LiveRange* SpillBetweenUntil(LiveRange* range, LifetimePosition start,
+ LifetimePosition until, LifetimePosition end);
+ void AssignRangeToRegister(int reg_id, LiveRange* range);
+
+ LifetimePosition FindProgressingSplitPosition(LiveRange* range,
+ bool* is_spill_pos);
+
+ Zone* local_zone_;
+ ZoneVector<CoalescedLiveRanges*> allocations_;
+ PQueue queue_;
+ DISALLOW_COPY_AND_ASSIGN(GreedyAllocator);
+};
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+#endif // V8_GREEDY_ALLOCATOR_H_
« no previous file with comments | « BUILD.gn ('k') | src/compiler/greedy-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698