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

Side by Side Diff: src/IceRegAlloc.h

Issue 642603005: Subzero: Translation-time improvements in the register allocator. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 6 years, 2 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 | « no previous file | 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
1 //===- subzero/src/IceRegAlloc.h - Linear-scan reg. allocation --*- C++ -*-===// 1 //===- subzero/src/IceRegAlloc.h - Linear-scan reg. allocation --*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares the data structures used during linear-scan 10 // This file declares the data structures used during linear-scan
(...skipping 23 matching lines...) Expand all
34 return range().endsBefore(Other.range()); 34 return range().endsBefore(Other.range());
35 } 35 }
36 bool overlaps(const LiveRangeWrapper &Other) const { 36 bool overlaps(const LiveRangeWrapper &Other) const {
37 const bool UseTrimmed = true; 37 const bool UseTrimmed = true;
38 return range().overlaps(Other.range(), UseTrimmed); 38 return range().overlaps(Other.range(), UseTrimmed);
39 } 39 }
40 bool overlapsStart(const LiveRangeWrapper &Other) const { 40 bool overlapsStart(const LiveRangeWrapper &Other) const {
41 const bool UseTrimmed = true; 41 const bool UseTrimmed = true;
42 return range().overlapsInst(Other.range().getStart(), UseTrimmed); 42 return range().overlapsInst(Other.range().getStart(), UseTrimmed);
43 } 43 }
44 Variable *const Var; 44 Variable *Var;
45 void dump(const Cfg *Func) const; 45 void dump(const Cfg *Func) const;
46 46
47 private: 47 private:
48 // LiveRangeWrapper(const LiveRangeWrapper &) = delete; 48 // LiveRangeWrapper(const LiveRangeWrapper &) = delete;
49 LiveRangeWrapper &operator=(const LiveRangeWrapper &) = delete; 49 // LiveRangeWrapper &operator=(const LiveRangeWrapper &) = delete;
50 }; 50 };
51 51
52 class LinearScan { 52 class LinearScan {
53 public: 53 public:
54 LinearScan(Cfg *Func) : Func(Func) {} 54 LinearScan(Cfg *Func) : Func(Func) {}
55 void scan(const llvm::SmallBitVector &RegMask); 55 void scan(const llvm::SmallBitVector &RegMask);
56 void dump(Cfg *Func) const; 56 void dump(Cfg *Func) const;
57 57
58 private: 58 private:
59 Cfg *const Func; 59 Cfg *const Func;
60 // RangeCompare is the comparator for sorting an LiveRangeWrapper 60 typedef std::vector<LiveRangeWrapper> OrderedRanges;
61 // by starting point in a std::set<>. Ties are broken by variable
62 // number so that sorting is stable.
63 struct RangeCompare {
64 bool operator()(const LiveRangeWrapper &L,
65 const LiveRangeWrapper &R) const {
66 InstNumberT Lstart = L.Var->getLiveRange().getStart();
67 InstNumberT Rstart = R.Var->getLiveRange().getStart();
68 if (Lstart == Rstart)
69 return L.Var->getIndex() < R.Var->getIndex();
70 return Lstart < Rstart;
71 }
72 };
73 typedef std::set<LiveRangeWrapper, RangeCompare> OrderedRanges;
74 typedef std::list<LiveRangeWrapper> UnorderedRanges; 61 typedef std::list<LiveRangeWrapper> UnorderedRanges;
75 OrderedRanges Unhandled; 62 OrderedRanges Unhandled;
76 // UnhandledPrecolored is a subset of Unhandled, specially collected 63 // UnhandledPrecolored is a subset of Unhandled, specially collected
77 // for faster processing. 64 // for faster processing.
78 OrderedRanges UnhandledPrecolored; 65 OrderedRanges UnhandledPrecolored;
79 UnorderedRanges Active, Inactive, Handled; 66 UnorderedRanges Active, Inactive, Handled;
80 LinearScan(const LinearScan &) = delete; 67 LinearScan(const LinearScan &) = delete;
81 LinearScan &operator=(const LinearScan &) = delete; 68 LinearScan &operator=(const LinearScan &) = delete;
82 }; 69 };
83 70
84 } // end of namespace Ice 71 } // end of namespace Ice
85 72
86 #endif // SUBZERO_SRC_ICEREGALLOC_H 73 #endif // SUBZERO_SRC_ICEREGALLOC_H
OLDNEW
« no previous file with comments | « no previous file | src/IceRegAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698