mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	IntegersSubsetMapping:
Changed type of Items collection: from std::vector to std::list. Also some small fixes made in IntegersSubset.h, IntegersSubsetMapping.h and IntegersSubsetTest.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157987 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -293,7 +293,7 @@ protected: | |||||||
| public: | public: | ||||||
|    |    | ||||||
|   template<class RangesCollectionTy> |   template<class RangesCollectionTy> | ||||||
|   IntegersSubsetGeneric(const RangesCollectionTy& Links) { |   explicit IntegersSubsetGeneric(const RangesCollectionTy& Links) { | ||||||
|     assert(Links.size() && "Empty ranges are not allowed."); |     assert(Links.size() && "Empty ranges are not allowed."); | ||||||
|     for (typename RangesCollectionTy::const_iterator i = Links.begin(), |     for (typename RangesCollectionTy::const_iterator i = Links.begin(), | ||||||
|          e = Links.end(); i != e; ++i) { |          e = Links.end(); i != e; ++i) { | ||||||
| @@ -459,9 +459,8 @@ public: | |||||||
|   IntegersSubset(Constant *C) : ParentTy(rangesFromConstant(C)), |   IntegersSubset(Constant *C) : ParentTy(rangesFromConstant(C)), | ||||||
|                                 Holder(C) {} |                                 Holder(C) {} | ||||||
|    |    | ||||||
|   // implicit |  | ||||||
|   template<class RangesCollectionTy> |   template<class RangesCollectionTy> | ||||||
|   IntegersSubset(const RangesCollectionTy& Src) : ParentTy(Src) { |   explicit IntegersSubset(const RangesCollectionTy& Src) : ParentTy(Src) { | ||||||
|     std::vector<Constant*> Elts; |     std::vector<Constant*> Elts; | ||||||
|     Elts.reserve(Src.size()); |     Elts.reserve(Src.size()); | ||||||
|     for (typename RangesCollectionTy::const_iterator i = Src.begin(), |     for (typename RangesCollectionTy::const_iterator i = Src.begin(), | ||||||
|   | |||||||
| @@ -49,7 +49,7 @@ public: | |||||||
|  |  | ||||||
| protected: | protected: | ||||||
|  |  | ||||||
|   typedef std::vector<Cluster> CaseItems; |   typedef std::list<Cluster> CaseItems; | ||||||
|   typedef typename CaseItems::iterator CaseItemIt; |   typedef typename CaseItems::iterator CaseItemIt; | ||||||
|   typedef typename CaseItems::const_iterator CaseItemConstIt; |   typedef typename CaseItems::const_iterator CaseItemConstIt; | ||||||
|    |    | ||||||
| @@ -87,7 +87,12 @@ protected: | |||||||
|    |    | ||||||
|   void sort() { |   void sort() { | ||||||
|     if (!Sorted) { |     if (!Sorted) { | ||||||
|       std::sort(Items.begin(), Items.end(), ClustersCmp()); |       std::vector<Cluster> clustersVector; | ||||||
|  |       clustersVector.reserve(Items.size()); | ||||||
|  |       clustersVector.insert(clustersVector.begin(), Items.begin(), Items.end()); | ||||||
|  |       std::sort(clustersVector.begin(), clustersVector.end(), ClustersCmp()); | ||||||
|  |       Items.clear(); | ||||||
|  |       Items.insert(Items.begin(), clustersVector.begin(), clustersVector.end()); | ||||||
|       Sorted = true; |       Sorted = true; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @@ -104,7 +109,6 @@ public: | |||||||
|   typedef std::list<Case> Cases; |   typedef std::list<Case> Cases; | ||||||
|    |    | ||||||
|   IntegersSubsetMapping() { |   IntegersSubsetMapping() { | ||||||
|     Items.reserve(32); |  | ||||||
|     Sorted = false; |     Sorted = false; | ||||||
|   } |   } | ||||||
|    |    | ||||||
| @@ -112,7 +116,7 @@ public: | |||||||
|     if (Items.empty()) |     if (Items.empty()) | ||||||
|       return true; |       return true; | ||||||
|     sort(); |     sort(); | ||||||
|     for (CaseItemIt i = Items.begin(), j = i+1, e = Items.end(); |     for (CaseItemIt j = Items.begin(), i = j++, e = Items.end(); | ||||||
|          j != e; i = j++) { |          j != e; i = j++) { | ||||||
|       if (isIntersected(i, j) && i->second != j->second) { |       if (isIntersected(i, j) && i->second != j->second) { | ||||||
|         errItem = j; |         errItem = j; | ||||||
| @@ -132,8 +136,8 @@ public: | |||||||
|     const IntTy *High = &OldItems.begin()->first.getHigh(); |     const IntTy *High = &OldItems.begin()->first.getHigh(); | ||||||
|     unsigned Weight = 1; |     unsigned Weight = 1; | ||||||
|     SuccessorClass *Successor = OldItems.begin()->second; |     SuccessorClass *Successor = OldItems.begin()->second; | ||||||
|     for (CaseItemIt i = OldItems.begin(), j = i+1, e = OldItems.end(); |     for (CaseItemIt j = OldItems.begin(), i = j++, e = OldItems.end(); | ||||||
|         j != e; i = j++) { |          j != e; i = j++) { | ||||||
|       if (isJoinable(i, j)) { |       if (isJoinable(i, j)) { | ||||||
|         const IntTy *CurHigh = &j->first.getHigh(); |         const IntTy *CurHigh = &j->first.getHigh(); | ||||||
|         ++Weight; |         ++Weight; | ||||||
| @@ -176,7 +180,7 @@ public: | |||||||
|    |    | ||||||
|   /// Adds all ranges and values from given ranges set to the current |   /// Adds all ranges and values from given ranges set to the current | ||||||
|   /// mapping. |   /// mapping. | ||||||
|   void add(const IntegersSubset &CRS, SuccessorClass *S = 0) { |   void add(const IntegersSubsetTy &CRS, SuccessorClass *S = 0) { | ||||||
|     for (unsigned i = 0, e = CRS.getNumItems(); i < e; ++i) { |     for (unsigned i = 0, e = CRS.getNumItems(); i < e; ++i) { | ||||||
|       RangeTy R = CRS.getItem(i); |       RangeTy R = CRS.getItem(i); | ||||||
|       add(R, S); |       add(R, S); | ||||||
| @@ -197,7 +201,7 @@ public: | |||||||
|    |    | ||||||
|   /// Builds the finalized case objects ignoring successor values, as though |   /// Builds the finalized case objects ignoring successor values, as though | ||||||
|   /// all ranges belongs to the same successor. |   /// all ranges belongs to the same successor. | ||||||
|   IntegersSubset getCase() { |   IntegersSubsetTy getCase() { | ||||||
|     RangesCollection Ranges; |     RangesCollection Ranges; | ||||||
|     for (RangeIterator i = this->begin(); i != this->end(); ++i) |     for (RangeIterator i = this->begin(); i != this->end(); ++i) | ||||||
|       Ranges.push_back(i->first); |       Ranges.push_back(i->first); | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ namespace { | |||||||
|   class Int : public APInt { |   class Int : public APInt { | ||||||
|   public: |   public: | ||||||
|     Int(uint64_t V) : APInt(64, V) {} |     Int(uint64_t V) : APInt(64, V) {} | ||||||
|  |     Int(const APInt& Src) : APInt(Src) {} | ||||||
|     bool operator < (const APInt& RHS) const { return ult(RHS); } |     bool operator < (const APInt& RHS) const { return ult(RHS); } | ||||||
|     bool operator > (const APInt& RHS) const { return ugt(RHS); } |     bool operator > (const APInt& RHS) const { return ugt(RHS); } | ||||||
|     bool operator <= (const APInt& RHS) const { return ule(RHS); } |     bool operator <= (const APInt& RHS) const { return ule(RHS); } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user