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

Side by Side Diff: src/IceRegAlloc.h

Issue 300563003: Subzero: Initial O2 lowering (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 //===- subzero/src/IceRegAlloc.h - Linear-scan reg. allocation --*- C++ -*-===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the data structures used during linear-scan
11 // register allocation. This includes LiveRangeWrapper which
12 // encapsulates a variable and its live range, and LinearScan which
13 // holds the various work queues for the linear-scan algorithm.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef SUBZERO_SRC_ICEREGALLOC_H
18 #define SUBZERO_SRC_ICEREGALLOC_H
19
20 #include "IceDefs.h"
21 #include "IceTypes.h"
22
23 namespace Ice {
24
25 // Currently this just wraps a Variable pointer, so in principle we
26 // could use containers of Variable* instead of LiveRangeWrapper. But
27 // in the future, we may want to do more complex things such as live
28 // range splitting, and keeping a wrapper should make that simpler.
29 class LiveRangeWrapper {
30 public:
31 LiveRangeWrapper(Variable *Var) : Var(Var) {}
32 const LiveRange &range() const { return Var->getLiveRange(); }
33 bool endsBefore(const LiveRangeWrapper &Other) const {
34 return range().endsBefore(Other.range());
35 }
36 bool overlaps(const LiveRangeWrapper &Other) const {
37 return range().overlaps(Other.range());
38 }
39 Variable *const Var;
40 void dump(const Cfg *Func) const;
41
42 private:
43 // LiveRangeWrapper(const LiveRangeWrapper &) LLVM_DELETED_FUNCTION;
44 LiveRangeWrapper &operator=(const LiveRangeWrapper &) LLVM_DELETED_FUNCTION;
45 };
46
47 class LinearScan {
48 public:
49 LinearScan(Cfg *Func) : Func(Func) {}
50 void scan(const llvm::SmallBitVector &RegMask);
51 void dump(Cfg *Func) const;
52
53 private:
54 Cfg *const Func;
55 // RangeCompare is the comparator for sorting an LiveRangeWrapper
56 // by starting point in a std::set<>. Ties are broken by variable
57 // number so that sorting is stable.
58 struct RangeCompare {
59 bool operator()(const LiveRangeWrapper &L,
60 const LiveRangeWrapper &R) const {
61 int32_t Lstart = L.Var->getLiveRange().getStart();
62 int32_t Rstart = R.Var->getLiveRange().getStart();
63 if (Lstart == Rstart)
64 return L.Var->getIndex() < R.Var->getIndex();
65 return Lstart < Rstart;
66 }
67 };
68 typedef std::set<LiveRangeWrapper, RangeCompare> OrderedRanges;
69 typedef std::list<LiveRangeWrapper> UnorderedRanges;
70 OrderedRanges Unhandled;
71 UnorderedRanges Active, Inactive, Handled;
72 LinearScan(const LinearScan &) LLVM_DELETED_FUNCTION;
73 LinearScan &operator=(const LinearScan &) LLVM_DELETED_FUNCTION;
74 };
75
76 } // end of namespace Ice
77
78 #endif // SUBZERO_SRC_ICEREGALLOC_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698