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

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: Jan's third-round comments 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
« no previous file with comments | « src/IceOperand.cpp ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bool overlapsStart(const LiveRangeWrapper &Other) const {
40 return range().overlaps(Other.range().getStart());
41 }
42 Variable *const Var;
43 void dump(const Cfg *Func) const;
44
45 private:
46 // LiveRangeWrapper(const LiveRangeWrapper &) LLVM_DELETED_FUNCTION;
47 LiveRangeWrapper &operator=(const LiveRangeWrapper &) LLVM_DELETED_FUNCTION;
48 };
49
50 class LinearScan {
51 public:
52 LinearScan(Cfg *Func) : Func(Func) {}
53 void scan(const llvm::SmallBitVector &RegMask);
54 void dump(Cfg *Func) const;
55
56 private:
57 Cfg *const Func;
58 // RangeCompare is the comparator for sorting an LiveRangeWrapper
59 // by starting point in a std::set<>. Ties are broken by variable
60 // number so that sorting is stable.
61 struct RangeCompare {
62 bool operator()(const LiveRangeWrapper &L,
63 const LiveRangeWrapper &R) const {
64 InstNumberT Lstart = L.Var->getLiveRange().getStart();
65 InstNumberT Rstart = R.Var->getLiveRange().getStart();
66 if (Lstart == Rstart)
67 return L.Var->getIndex() < R.Var->getIndex();
68 return Lstart < Rstart;
69 }
70 };
71 typedef std::set<LiveRangeWrapper, RangeCompare> OrderedRanges;
72 typedef std::list<LiveRangeWrapper> UnorderedRanges;
73 OrderedRanges Unhandled;
74 UnorderedRanges Active, Inactive, Handled;
75 LinearScan(const LinearScan &) LLVM_DELETED_FUNCTION;
76 LinearScan &operator=(const LinearScan &) LLVM_DELETED_FUNCTION;
77 };
78
79 } // end of namespace Ice
80
81 #endif // SUBZERO_SRC_ICEREGALLOC_H
OLDNEW
« no previous file with comments | « src/IceOperand.cpp ('k') | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698