@@ -40,49 +40,43 @@ class LiveStacks {
4040 // /
4141 VNInfo::Allocator VNInfoAllocator;
4242
43- // / S2IMap - Stack slot indices to live interval mapping.
44- using SS2IntervalMap = std::unordered_map<int , LiveInterval>;
45- SS2IntervalMap S2IMap;
46-
47- // / S2RCMap - Stack slot indices to register class mapping.
48- std::map<int , const TargetRegisterClass *> S2RCMap;
43+ int StartIdx = -1 ;
44+ SmallVector<LiveInterval *> S2LI;
45+ SmallVector<const TargetRegisterClass *> S2RC;
4946
5047public:
51- using iterator = SS2IntervalMap ::iterator;
52- using const_iterator = SS2IntervalMap ::const_iterator;
48+ using iterator = SmallVector<LiveInterval *> ::iterator;
49+ using const_iterator = SmallVector<LiveInterval *> ::const_iterator;
5350
54- const_iterator begin () const { return S2IMap .begin (); }
55- const_iterator end () const { return S2IMap .end (); }
56- iterator begin () { return S2IMap .begin (); }
57- iterator end () { return S2IMap .end (); }
51+ const_iterator begin () const { return S2LI .begin (); }
52+ const_iterator end () const { return S2LI .end (); }
53+ iterator begin () { return S2LI .begin (); }
54+ iterator end () { return S2LI .end (); }
5855
59- unsigned getNumIntervals () const { return (unsigned )S2IMap.size (); }
56+ unsigned getStartIdx () const { return StartIdx; }
57+ unsigned getNumIntervals () const { return (unsigned )S2LI.size (); }
6058
6159 LiveInterval &getOrCreateInterval (int Slot, const TargetRegisterClass *RC);
6260
6361 LiveInterval &getInterval (int Slot) {
6462 assert (Slot >= 0 && " Spill slot indice must be >= 0" );
65- SS2IntervalMap::iterator I = S2IMap.find (Slot);
66- assert (I != S2IMap.end () && " Interval does not exist for stack slot" );
67- return I->second ;
63+ return *S2LI[Slot - StartIdx];
6864 }
6965
7066 const LiveInterval &getInterval (int Slot) const {
7167 assert (Slot >= 0 && " Spill slot indice must be >= 0" );
72- SS2IntervalMap::const_iterator I = S2IMap.find (Slot);
73- assert (I != S2IMap.end () && " Interval does not exist for stack slot" );
74- return I->second ;
68+ return *S2LI[Slot - StartIdx];
7569 }
7670
77- bool hasInterval (int Slot) const { return S2IMap.count (Slot); }
71+ bool hasInterval (int Slot) const {
72+ if (Slot < StartIdx || StartIdx == -1 )
73+ return false ;
74+ return !getInterval (Slot).empty ();
75+ }
7876
7977 const TargetRegisterClass *getIntervalRegClass (int Slot) const {
8078 assert (Slot >= 0 && " Spill slot indice must be >= 0" );
81- std::map<int , const TargetRegisterClass *>::const_iterator I =
82- S2RCMap.find (Slot);
83- assert (I != S2RCMap.end () &&
84- " Register class info does not exist for stack slot" );
85- return I->second ;
79+ return S2RC[Slot - StartIdx];
8680 }
8781
8882 VNInfo::Allocator &getVNInfoAllocator () { return VNInfoAllocator; }
0 commit comments