<p>Just as an FYI to Stepan, I'm going to try to fix this, just wanted bots to recover in the mean time...</p>
<div class="gmail_quote">On Apr 25, 2012 10:52 AM, "Eric Christopher" <<a href="mailto:echristo@apple.com">echristo@apple.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: echristo<br>
Date: Wed Apr 25 12:51:00 2012<br>
New Revision: 155562<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=155562&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=155562&view=rev</a><br>
Log:<br>
Revert "First implementation of:"<br>
<br>
This reverts commit 76271a3366731d4c372fdebcd8d3437e6e09a61b.<br>
<br>
as it's breaking the bots.<br>
<br>
Removed:<br>
llvm/trunk/include/llvm/ADT/FlatArrayMap.h<br>
llvm/trunk/include/llvm/ADT/MultiImplMap.h<br>
llvm/trunk/include/llvm/ADT/SmallMap.h<br>
llvm/trunk/unittests/ADT/SmallMapTest.cpp<br>
Modified:<br>
llvm/trunk/docs/ProgrammersManual.html<br>
<br>
Modified: llvm/trunk/docs/ProgrammersManual.html<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=155562&r1=155561&r2=155562&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=155562&r1=155561&r2=155562&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/docs/ProgrammersManual.html (original)<br>
+++ llvm/trunk/docs/ProgrammersManual.html Wed Apr 25 12:51:00 2012<br>
@@ -95,9 +95,6 @@<br>
<li><a href="#dss_stringmap">"llvm/ADT/StringMap.h"</a></li><br>
<li><a href="#dss_indexedmap">"llvm/ADT/IndexedMap.h"</a></li><br>
<li><a href="#dss_densemap">"llvm/ADT/DenseMap.h"</a></li><br>
- <li><a href="#dss_multiimplmap">"llvm/ADT/MultiImplMap.h"</a></li><br>
- <li><a href="#dss_flatarraymap">"llvm/ADT/FlatArrayMap.h"</a></li><br>
- <li><a href="#dss_smallmap">"llvm/ADT/SmallMap.h"</a></li><br>
<li><a href="#dss_valuemap">"llvm/ADT/ValueMap.h"</a></li><br>
<li><a href="#dss_intervalmap">"llvm/ADT/IntervalMap.h"</a></li><br>
<li><a href="#dss_map"><map></a></li><br>
@@ -1815,84 +1812,6 @@<br>
<br>
<!-- _______________________________________________________________________ --><br>
<h4><br>
- <a name="dss_multiimplmap">"llvm/ADT/MultiImplMap.h"</a><br>
-</h4><br>
-<br>
-<div><br>
-<br>
-<p><br>
-MultiImplMap is map that has two modes, one for small amount of elements and<br>
-one for big amount. User should set map implementation for both of them.<br>
-User also should set the maximum possible number of elements for small mode.<br>
-</p><br>
-<br>
-<p><br>
-If user want to use MultiImplMap instead of<br>
-<a href="#dss_densemap">DenseMap</a>, he should pass template parameter<br>
-DenseMapCompatible = true. Note, that in this case map implementations<br>
-should present additional DenseMap specific methods (see below):<br>
-<code>isPointerIntoBucketsArray</code>, <code>getPointerIntoBucketsArray</code><br>
-and <code>FindAndConstruct</code>.<br>
-</p><br>
-<br>
-<p><br>
-Initially MultiImplMap uses small mode and small map implementation. It<br>
-triggered to the big mode when the number of contained elements exceeds<br>
-maximum possible elements for small mode.<br>
-</p><br>
-<br>
-</div><br>
-<br>
-<!-- _______________________________________________________________________ --><br>
-<h4><br>
- <a name="dss_flatarraymap">"llvm/ADT/FlatArrayMap.h"</a><br>
-</h4><br>
-<br>
-<div><br>
-<br>
-<p><br>
-FlatArrayMap optimized for small amount of elements. It uses flat array<br>
-implementation inside:<br>
-</p><br>
-<pre>[ key0, value0, key1, value1, ... keyN, valueN ]</pre><br>
-<br>
-<br>
-<p><br>
-User should pass key type, mapped type (type of value), and maximum<br>
-number of elements.<br>
-</p><br>
-<br>
-<p><br>
-After maximum number of elements is reached, map declines any further<br>
-attempts to insert new elements ("insert" method returns <end(),<br>
-false>).<br>
-</p><br>
-<br>
-<p><br>
-FlatArrayMap has interface that is compatible with<br>
-<a href="#dss_densemap">DenseMap</a>, so user can replace it with DenseMap<br>
-without any code changing and vice versa.<br>
-</p><br>
-<br>
-</div><br>
-<br>
-<!-- _______________________________________________________________________ --><br>
-<h4><br>
- <a name="dss_smallmap">"llvm/ADT/SmallMap.h"</a><br>
-</h4><br>
-<br>
-<div><br>
-<br>
-<p><br>
-SmallMap is wrapper around <a href="#dss_multiimplmap">MultiImplMap</a>.<br>
-It uses <a href="#dss_flatarraymap">FlatArrayMap</a> for small mode, and<br>
-<a href="#dss_densemap">DenseMap</a> for big mode.<br>
-</p><br>
-<br>
-</div><br>
-<br>
-<!-- _______________________________________________________________________ --><br>
-<h4><br>
<a name="dss_intervalmap">"llvm/ADT/IntervalMap.h"</a><br>
</h4><br>
<br>
<br>
Removed: llvm/trunk/include/llvm/ADT/FlatArrayMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FlatArrayMap.h?rev=155561&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FlatArrayMap.h?rev=155561&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/FlatArrayMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/FlatArrayMap.h (removed)<br>
@@ -1,323 +0,0 @@<br>
-//===- llvm/ADT/FlatArrayMap.h - 'Normally small' pointer set ----*- C++ -*-==//<br>
-//<br>
-// The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-//<br>
-// This file defines the FlatArrayMap class.<br>
-// See FlatArrayMap doxygen comments for more details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#ifndef FLATARRAYMAP_H_<br>
-#define FLATARRAYMAP_H_<br>
-<br>
-#include <algorithm><br>
-#include <utility><br>
-#include "llvm/Support/type_traits.h"<br>
-<br>
-namespace llvm {<br>
-<br>
- template <typename KeyTy, typename MappedTy><br>
- struct FlatArrayMapTypes {<br>
- typedef KeyTy key_type;<br>
- typedef MappedTy mapped_type;<br>
- typedef typename std::pair<key_type, mapped_type> value_type;<br>
- };<br>
-<br>
- template<typename KeyTy, typename MappedTy, bool IsConst = false><br>
- class FlatArrayMapIterator;<br>
-<br>
- //===--------------------------------------------------------------------===//<br>
- /// FlatArrayMap presents map container interface.<br>
- /// It uses flat array implementation inside:<br>
- /// [ <key0, value0>, <key1, value1>, ... <keyN, valueN> ]<br>
- /// It works fast for small amount of elements.<br>
- /// User should pass key type, mapped type (type of value), and maximum<br>
- /// number of elements.<br>
- /// After maximum number of elements is reached, map declines any farther<br>
- /// attempts to insert new elements ("insert" method returns <end(),false>).<br>
- ///<br>
- template <typename KeyTy, typename MappedTy, unsigned MaxArraySize><br>
- class FlatArrayMap {<br>
- public:<br>
- typedef FlatArrayMapTypes<KeyTy, MappedTy> Types;<br>
-<br>
- typedef typename Types::key_type key_type;<br>
- typedef typename Types::mapped_type mapped_type;<br>
- typedef typename Types::value_type value_type;<br>
-<br>
- typedef FlatArrayMapIterator<KeyTy, MappedTy> iterator;<br>
- typedef FlatArrayMapIterator<KeyTy, MappedTy, true> const_iterator;<br>
-<br>
- typedef FlatArrayMap<KeyTy, MappedTy, MaxArraySize> self;<br>
-<br>
- private:<br>
-<br>
- enum { BadIndex = ~0UL };<br>
-<br>
- key_type EmptyKey;<br>
- mapped_type EmptyValue;<br>
-<br>
- value_type Array[MaxArraySize + 1];<br>
- unsigned NumElements;<br>
-<br>
- unsigned findFor(const KeyTy Ptr) const {<br>
- // Linear search for the item.<br>
- for (const value_type *APtr = Array, *E = Array + NumElements;<br>
- APtr != E; ++APtr) {<br>
- if (APtr->first == Ptr) {<br>
- return APtr - Array;<br>
- }<br>
- }<br>
- return BadIndex;<br>
- }<br>
-<br>
- bool lookupFor(const KeyTy &Ptr, const value_type*& Found) const {<br>
- unsigned FoundIdx = findFor(Ptr);<br>
- if (FoundIdx != BadIndex) {<br>
- Found = Array + FoundIdx;<br>
- return true;<br>
- }<br>
- return false;<br>
- }<br>
-<br>
- bool lookupFor(const KeyTy &Ptr, value_type*& Found) {<br>
- unsigned FoundIdx = findFor(Ptr);<br>
- if (FoundIdx != BadIndex) {<br>
- Found = Array + FoundIdx;<br>
- return true;<br>
- }<br>
- return false;<br>
- }<br>
-<br>
-<br>
- void copyFrom(const self &RHS) {<br>
- memcpy(Array, RHS.Array, sizeof(value_type) * (MaxArraySize + 1));<br>
- NumElements = RHS.NumElements;<br>
- }<br>
-<br>
- void init () {<br>
- memset(Array + MaxArraySize, 0, sizeof(value_type));<br>
- NumElements = 0;<br>
- }<br>
-<br>
- bool insertInternal(KeyTy Ptr, MappedTy Val, value_type*& Item) {<br>
- // Check to see if it is already in the set.<br>
- value_type *Found;<br>
- if (lookupFor(Ptr, Found)) {<br>
- Item = Found;<br>
- return false;<br>
- }<br>
- if (NumElements < MaxArraySize) {<br>
- unsigned Idx = NumElements++;<br>
- Array[Idx] = std::make_pair(Ptr, Val);<br>
- Item = Array + Idx;<br>
- return true;<br>
- }<br>
- Item = Array + MaxArraySize; // return end()<br>
- return false;<br>
- }<br>
-<br>
- public:<br>
-<br>
- // Constructors<br>
-<br>
- FlatArrayMap() : EmptyKey(), EmptyValue() {<br>
- init();<br>
- }<br>
-<br>
- FlatArrayMap(const self &that) :<br>
- EmptyKey(), EmptyValue() {<br>
- copyFrom(that);<br>
- }<br>
-<br>
- template<typename It><br>
- FlatArrayMap(It I, It E) :<br>
- EmptyKey(), EmptyValue() {<br>
- init();<br>
- insert(I, E);<br>
- }<br>
-<br>
- // Size<br>
-<br>
- unsigned size() const {<br>
- return NumElements;<br>
- }<br>
-<br>
- bool empty() const {<br>
- return !NumElements;<br>
- }<br>
-<br>
- // Iterators<br>
-<br>
- iterator begin() {<br>
- return iterator(Array);<br>
- }<br>
- const_iterator begin() const {<br>
- return const_iterator(Array);<br>
- }<br>
-<br>
- iterator end() {<br>
- return iterator(Array + MaxArraySize);<br>
- }<br>
- const_iterator end() const {<br>
- return const_iterator(Array + MaxArraySize);<br>
- }<br>
-<br>
- // Modifiers<br>
-<br>
- void clear() {<br>
- for (unsigned i = 0; i < NumElements; ++i) {<br>
- Array[i].first = EmptyKey;<br>
- Array[i].second = EmptyValue;<br>
- }<br>
- NumElements = 0;<br>
- }<br>
-<br>
- // The map container is extended by inserting a single new element.<br>
- // The behavior is the same as the std::map::insert, except the<br>
- // case when maximum number of elements is reached;<br>
- // in this case map declines any farther attempts<br>
- // to insert new elements ("insert" method returns <end(),false>).<br>
- std::pair<iterator, bool> insert(const value_type& KV) {<br>
- value_type* Item;<br>
- bool Res = insertInternal(KV.first, KV.second, Item);<br>
- return std::make_pair(iterator(Item), Res);<br>
- }<br>
-<br>
- template <typename IterT><br>
- void insert(IterT I, IterT E) {<br>
- for (; I != E; ++I)<br>
- insert(*I);<br>
- }<br>
-<br>
- void erase(key_type K) {<br>
- unsigned Found = findFor(K);<br>
- if (Found != BadIndex) {<br>
- value_type *APtr = Array + Found;<br>
- value_type *E = Array + NumElements;<br>
- *APtr = E[-1];<br>
- E[-1].first.~key_type();<br>
- E[-1].second.~mapped_type();<br>
- --NumElements;<br>
- }<br>
- }<br>
-<br>
- void erase(iterator i) {<br>
- erase(i->first);<br>
- }<br>
-<br>
- void swap(self& RHS) {<br>
- std::swap_ranges(Array, Array+MaxArraySize, RHS.Array);<br>
- std::swap(this->NumElements, RHS.NumElements);<br>
- }<br>
-<br>
- // Search operations<br>
-<br>
- iterator find(const key_type& K) {<br>
- value_type *Found;<br>
- if (lookupFor(K, Found))<br>
- return iterator(Found);<br>
- return end();<br>
- }<br>
-<br>
- const_iterator find(const key_type& K) const {<br>
- const value_type *Found;<br>
- if (lookupFor(K, Found))<br>
- return const_iterator(Found);<br>
- return end();<br>
- }<br>
-<br>
- bool count(const key_type& K) const {<br>
- return find(K) != end();<br>
- }<br>
-<br>
- mapped_type &operator[](const key_type &Key) {<br>
- std::pair<iterator, bool> res = insert(Key, mapped_type());<br>
- return res.first->second;<br>
- }<br>
-<br>
- // Other operations<br>
-<br>
- self& operator=(const self& other) {<br>
- clear();<br>
- copyFrom(other);<br>
- return *this;<br>
- }<br>
-<br>
- /// isPointerIntoBucketsArray - Return true if the specified pointer points<br>
- /// somewhere into the map's array of buckets (i.e. either to a key or<br>
- /// value).<br>
- bool isPointerIntoBucketsArray(const void *Ptr) const {<br>
- return Ptr >= Array && Ptr < Array + NumElements;<br>
- }<br>
-<br>
- /// getPointerIntoBucketsArray() - Return an opaque pointer into the buckets<br>
- /// array.<br>
- const void *getPointerIntoBucketsArray() const { return Array; }<br>
- };<br>
-<br>
- template<typename KeyTy, typename MappedTy, bool IsConst><br>
- class FlatArrayMapIterator {<br>
-<br>
- typedef FlatArrayMapTypes<KeyTy, MappedTy> Types;<br>
-<br>
- typedef typename conditional<IsConst,<br>
- const typename Types::value_type,<br>
- typename Types::value_type>::type value_type;<br>
- typedef value_type *pointer;<br>
- typedef value_type &reference;<br>
-<br>
- typedef FlatArrayMapIterator<KeyTy, MappedTy, IsConst> self;<br>
- typedef FlatArrayMapIterator<KeyTy, MappedTy, false> non_const_self;<br>
- typedef FlatArrayMapIterator<KeyTy, MappedTy, true> const_self;<br>
-<br>
- friend class FlatArrayMapIterator<KeyTy, MappedTy, false>;<br>
- friend class FlatArrayMapIterator<KeyTy, MappedTy, true>;<br>
-<br>
- pointer TheBucket;<br>
-<br>
- public:<br>
-<br>
- FlatArrayMapIterator() : TheBucket(0) {}<br>
-<br>
- explicit FlatArrayMapIterator(pointer BP) :<br>
- TheBucket(BP) {}<br>
-<br>
- // If IsConst is true this is a converting constructor from iterator to<br>
- // const_iterator and the default copy constructor is used.<br>
- // Otherwise this is a copy constructor for iterator.<br>
- FlatArrayMapIterator(const non_const_self& I)<br>
- : TheBucket(I.TheBucket) {}<br>
-<br>
- bool operator==(const const_self &RHS) const {<br>
- return TheBucket->first == RHS.TheBucket->first;<br>
- }<br>
- bool operator!=(const const_self &RHS) const {<br>
- return TheBucket->first != RHS.TheBucket->first;<br>
- }<br>
-<br>
- reference operator*() const {<br>
- return *TheBucket;<br>
- }<br>
-<br>
- pointer operator->() const {<br>
- return TheBucket;<br>
- }<br>
-<br>
- inline self& operator++() { // Preincrement<br>
- ++TheBucket;<br>
- return *this;<br>
- }<br>
-<br>
- self operator++(int) { // Postincrement<br>
- FlatArrayMapIterator tmp = *this; ++*this; return tmp;<br>
- }<br>
- };<br>
-}<br>
-<br>
-#endif /* FLATARRAYMAP_H_ */<br>
<br>
Removed: llvm/trunk/include/llvm/ADT/MultiImplMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/MultiImplMap.h?rev=155561&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/MultiImplMap.h?rev=155561&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/MultiImplMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/MultiImplMap.h (removed)<br>
@@ -1,550 +0,0 @@<br>
-//===- llvm/ADT/MultiImplMap.h - 'Normally small' pointer set ----*- C++ -*-==//<br>
-//<br>
-// The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-//<br>
-// This file defines the MultiImplMap class.<br>
-// MultiImplMap presents map container interface.<br>
-// It has two modes, one for small amount of elements and one for big amount.<br>
-// User should set map implementation for both of them. User also should<br>
-// set the maximum possible number of elements for small mode.<br>
-// If user want to use MultiImplMap instead of DenseMap, he should pass<br>
-// DenseMapCompatible = true. Note that in this case map implementations should<br>
-// present additional DenseMap specific methods (see below).<br>
-// Initially MultiImplMap uses small mode and small map implementation.<br>
-// It triggered to the big mode when number of contained elements exceeds<br>
-// maximum possible elements for small mode.<br>
-//<br>
-// Types that should be defined in nested map class:<br>
-//<br>
-// key_type;<br>
-// mapped_type;<br>
-// value_type; // std::pair<key_type, mapped_type><br>
-// // or std::pair<const key_type, mapped_type><br>
-// iterator;<br>
-// const_iterator;<br>
-//<br>
-// Map implementation should provide the next interface:<br>
-//<br>
-// // Constructors<br>
-// (default constructor)<br>
-// (copy constructor)<br>
-//<br>
-// // Size<br>
-// unsigned size() const;<br>
-// bool empty() const;<br>
-//<br>
-// // Iterators<br>
-// iterator begin();<br>
-// const_iterator begin();<br>
-// iterator end();<br>
-// const_iterator end();<br>
-//<br>
-// // Modifiers<br>
-// void clear();<br>
-// std::pair<iterator, bool> insert(const value_type& KV);<br>
-// template <typename IterT><br>
-// void insert(IterT I, IterT E);<br>
-// void erase(key_type K);<br>
-// void erase(iterator i);<br>
-// void swap(MultiImplMap& rhs);<br>
-//<br>
-// // Search operations<br>
-// iterator find(const key_type& K);<br>
-// const_iterator find(const key_type& K) const;<br>
-// bool count(const key_type& K) const;<br>
-// mapped_type &operator[](const key_type &Key);<br>
-//<br>
-// // Other operations<br>
-// self& operator=(const self& other);<br>
-//<br>
-// // If DenseMapCompatible == true, you also should present next methods.<br>
-// // See DenseMap comments for more details about its behavior.<br>
-// bool isPointerIntoBucketsArray(const void *Ptr) const;<br>
-// const void *getPointerIntoBucketsArray() const;<br>
-// value_type& FindAndConstruct(const key_type &Key);<br>
-//<br>
-// The list of methods that should be implemented in nested map iterator class:<br>
-//<br>
-// (conversion constructor from non-constant iterator)<br>
-//<br>
-// bool operator==(const const_iterator& rhs) const;<br>
-// bool operator!=(const const_iterator& rhs) const;<br>
-// reference operator*() const;<br>
-// pointer operator->() const;<br>
-// inline self& operator++();<br>
-//<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#ifndef MULTIIMPLEMENTATIONMAP_H_<br>
-#define MULTIIMPLEMENTATIONMAP_H_<br>
-<br>
-<br>
-#include <algorithm><br>
-#include <utility><br>
-#include "llvm/ADT/DenseMap.h"<br>
-#include "llvm/ADT/FlatArrayMap.h"<br>
-#include "llvm/Support/type_traits.h"<br>
-<br>
-namespace llvm {<br>
-<br>
- template<class SmallMapTy, class BigMapTy, bool IsConst = false><br>
- class MultiImplMapIterator;<br>
-<br>
- template<class SmallMapTy, class BigMapTy><br>
- struct MultiImplMapIteratorsFactory;<br>
-<br>
- template<class SmallMapTy, class BigMapTy><br>
- struct MultiImplMapTypes {<br>
- typedef typename SmallMapTy::key_type key_type;<br>
- typedef typename SmallMapTy::mapped_type mapped_type;<br>
- typedef typename std::pair<key_type, mapped_type> value_type;<br>
- };<br>
-<br>
- //===--------------------------------------------------------------------===//<br>
- /// MultiImplMap is map that has two modes, one for small amount of<br>
- /// elements and one for big amount.<br>
- /// User should set map implementation for both of them. User also should<br>
- /// set the maximum possible number of elements for small mode.<br>
- /// If user want to use MultiImplMap instead of DenseMap, he should pass<br>
- /// DenseMapCompatible = true.<br>
- /// Initially MultiImplMap uses small mode and small map implementation.<br>
- /// It triggered to the big mode when number of contained elements exceeds<br>
- /// maximum possible elements for small mode.<br>
- template<class SmallMapTy, class BigMapTy, unsigned MaxSmallN,<br>
- bool DenseMapCompatible = false,<br>
- class ItFactory =<br>
- MultiImplMapIteratorsFactory<SmallMapTy, BigMapTy> ><br>
- class MultiImplMap {<br>
-<br>
- protected:<br>
- SmallMapTy SmallMap;<br>
- BigMapTy BigMap;<br>
- bool UseSmall;<br>
- enum { MaxSmallSize = MaxSmallN };<br>
-<br>
- public:<br>
- typedef MultiImplMapTypes<SmallMapTy, BigMapTy> Types;<br>
-<br>
- typedef typename Types::key_type key_type;<br>
- typedef typename Types::mapped_type mapped_type;<br>
- typedef typename Types::value_type value_type;<br>
-<br>
- typedef typename ItFactory::iterator iterator;<br>
- typedef typename ItFactory::const_iterator const_iterator;<br>
-<br>
- typedef std::pair<iterator, bool> ins_res;<br>
-<br>
- typedef typename std::pair<typename SmallMapTy::iterator, bool><br>
- small_ins_res;<br>
-<br>
- typedef typename std::pair<typename BigMapTy::iterator, bool><br>
- big_ins_res;<br>
-<br>
- typedef MultiImplMap<SmallMapTy, BigMapTy, MaxSmallN> self;<br>
-<br>
- MultiImplMap() : UseSmall(true) {}<br>
-<br>
- MultiImplMap(const self& other) {<br>
- if (other.UseSmall) {<br>
- SmallMap = other.SmallMap;<br>
- UseSmall = true;<br>
- } else {<br>
- if (other.size() <= MaxSmallN) {<br>
- SmallMap.insert(other.BigMap.begin(), other.BigMap.end());<br>
- UseSmall = true;<br>
- } else {<br>
- BigMap = other.BigMap;<br>
- UseSmall = false;<br>
- }<br>
- }<br>
- }<br>
-<br>
- // Size<br>
-<br>
- unsigned size() const {<br>
- if (UseSmall)<br>
- return SmallMap.size();<br>
- return BigMap.size();<br>
- }<br>
-<br>
- bool empty() const {<br>
- if (UseSmall)<br>
- return SmallMap.empty();<br>
- return BigMap.empty();<br>
- }<br>
-<br>
- // Iterators<br>
-<br>
- iterator begin() {<br>
- if (UseSmall)<br>
- return ItFactory::begin(SmallMap);<br>
- return ItFactory::begin(BigMap);<br>
- }<br>
- const_iterator begin() const {<br>
- if (UseSmall)<br>
- return ItFactory::begin(SmallMap);<br>
- return ItFactory::begin(BigMap);<br>
- }<br>
-<br>
- iterator end() {<br>
- if (UseSmall)<br>
- return ItFactory::end(SmallMap);<br>
- return ItFactory::end(BigMap);<br>
- }<br>
- const_iterator end() const {<br>
- if (UseSmall)<br>
- return ItFactory::end(SmallMap);<br>
- return ItFactory::end(BigMap);<br>
- }<br>
-<br>
- // Modifiers<br>
-<br>
- void clear() {<br>
- if (UseSmall)<br>
- SmallMap.clear();<br>
- else<br>
- BigMap.clear();<br>
- }<br>
-<br>
- std::pair<iterator, bool> insert(const value_type& KV) {<br>
- if (UseSmall) {<br>
- if (SmallMap.size() < MaxSmallSize) {<br>
- small_ins_res Res = SmallMap.insert(KV);<br>
- return std::make_pair(ItFactory::it(SmallMap, Res.first), Res.second);<br>
- }<br>
-<br>
- // Move all to big map.<br>
- BigMap.insert(SmallMap.begin(), SmallMap.end());<br>
- SmallMap.clear();<br>
-<br>
- UseSmall = false;<br>
- }<br>
- big_ins_res Res = BigMap.insert(KV);<br>
- return std::make_pair(ItFactory::it(BigMap, Res.first), Res.second);<br>
- }<br>
-<br>
- template <typename OtherValTy><br>
- std::pair<iterator, bool> insert(const OtherValTy& OtherKV) {<br>
- const value_type* KV = reinterpret_cast<const value_type*>(<br>
- reinterpret_cast<const void*>(OtherKV));<br>
- return insert(*KV);<br>
- }<br>
-<br>
- template <typename IterT><br>
- void insert(IterT I, IterT E) {<br>
- for (; I != E; ++I)<br>
- insert(*I);<br>
- }<br>
-<br>
- void erase(key_type K) {<br>
- if (UseSmall)<br>
- SmallMap.erase(K);<br>
- else<br>
- BigMap.erase(K);<br>
- }<br>
-<br>
- void erase(iterator i) {<br>
- erase(i->first);<br>
- }<br>
-<br>
- void swap(MultiImplMap& rhs) {<br>
- SmallMap.swap(rhs.SmallMap);<br>
- BigMap.swap(rhs.BigMap);<br>
- std::swap(UseSmall, rhs.UseSmall);<br>
- }<br>
-<br>
- // Search operations<br>
-<br>
- iterator find(const key_type& K) {<br>
- if (UseSmall)<br>
- return ItFactory::it(SmallMap, SmallMap.find(K));<br>
- return ItFactory::it(BigMap, BigMap.find(K));<br>
- }<br>
-<br>
- const_iterator find(const key_type& K) const {<br>
- if (UseSmall)<br>
- return ItFactory::const_it(SmallMap, SmallMap.find(K));<br>
- return ItFactory::const_it(BigMap, BigMap.find(K));<br>
- }<br>
-<br>
- bool count(const key_type& K) const {<br>
- return find(K) != end();<br>
- }<br>
-<br>
- mapped_type &operator[](const key_type &Key) {<br>
- ins_res res = insert(std::make_pair(Key, mapped_type()));<br>
- return res.first->second;<br>
- }<br>
-<br>
- // Other operations<br>
-<br>
- self& operator=(const self& other) {<br>
- if (other.isSmall()) {<br>
- SmallMap = other.SmallMap;<br>
- if (!UseSmall) {<br>
- BigMap.clear();<br>
- UseSmall = true;<br>
- }<br>
- return *this;<br>
- }<br>
- if (UseSmall) {<br>
- SmallMap.clear();<br>
- UseSmall = false;<br>
- }<br>
- BigMap = other.BigMap;<br>
- return *this;<br>
- }<br>
-<br>
- // Utilities<br>
-<br>
- bool isSmall()const {<br>
- return UseSmall;<br>
- }<br>
-<br>
- SmallMapTy& getSmallMap() {<br>
- return SmallMap;<br>
- }<br>
-<br>
- const SmallMapTy& getSmallMap() const {<br>
- return SmallMap;<br>
- }<br>
-<br>
- BigMapTy& getBigMap() {<br>
- return BigMap;<br>
- }<br>
-<br>
- const BigMapTy& getBigMap() const {<br>
- return BigMap;<br>
- }<br>
- };<br>
-<br>
- template<class SmallMapTy, class BigMapTy, unsigned MaxSmallN><br>
- class MultiImplMap<SmallMapTy, BigMapTy, MaxSmallN, true> :<br>
- public MultiImplMap<SmallMapTy, BigMapTy, MaxSmallN, false><br>
- {<br>
- public:<br>
- typedef MultiImplMap<SmallMapTy, BigMapTy, MaxSmallN, false> ParentTy;<br>
- typedef typename ParentTy::Types Types;<br>
-<br>
- typedef typename Types::key_type key_type;<br>
- typedef typename Types::mapped_type mapped_type;<br>
- typedef typename Types::value_type value_type;<br>
- typedef typename ParentTy::iterator iterator;<br>
-<br>
- /// isPointerIntoBucketsArray - Return true if the specified pointer points<br>
- /// somewhere into the DenseMap's array of buckets (i.e. either to a key or<br>
- /// value).<br>
- bool isPointerIntoBucketsArray(const void *Ptr) const {<br>
- if (this->UseSmall)<br>
- return this->SmallMap.isPointerIntoBucketsArray(Ptr);<br>
- return this->BigMap.isPointerIntoBucketsArray(Ptr);<br>
- }<br>
-<br>
- /// getPointerIntoBucketsArray() - Return an opaque pointer into the buckets<br>
- /// array. In conjunction with the previous method, this can be used to<br>
- /// determine whether an insertion caused the map to reallocate data.<br>
- const void *getPointerIntoBucketsArray() const {<br>
- if (this->UseSmall)<br>
- return this->SmallMap.getPointerIntoBucketsArray();<br>
- return this->BigMap.getPointerIntoBucketsArray();<br>
- }<br>
-<br>
- value_type& FindAndConstruct(const key_type &Key) {<br>
- std::pair<iterator, bool> Res =<br>
- this->insert(std::make_pair(Key, mapped_type()));<br>
- return *Res.first;<br>
- }<br>
- };<br>
-<br>
- template<class SmallMapTy, class BigMapTy, bool IsConst><br>
- class MultiImplMapIterator {<br>
- public:<br>
-<br>
- typedef MultiImplMapTypes<SmallMapTy, BigMapTy> Types;<br>
-<br>
- typedef typename Types::mapped_type mapped_type;<br>
-<br>
- typedef typename conditional<IsConst,<br>
- const typename Types::value_type,<br>
- typename Types::value_type>::type value_type;<br>
-<br>
- typedef typename conditional<IsConst,<br>
- typename SmallMapTy::const_iterator,<br>
- typename SmallMapTy::iterator>::type<br>
- small_iterator;<br>
-<br>
- typedef typename conditional<IsConst,<br>
- typename BigMapTy::const_iterator,<br>
- typename BigMapTy::iterator>::type<br>
- big_iterator;<br>
-<br>
- typedef typename conditional<IsConst, const void*, void*>::type void_ptr_ty;<br>
-<br>
- typedef value_type *pointer;<br>
- typedef value_type &reference;<br>
-<br>
- typedef MultiImplMapIterator<SmallMapTy, BigMapTy, IsConst> self;<br>
-<br>
- typedef MultiImplMapIterator<SmallMapTy, BigMapTy, false> non_const_self;<br>
- typedef MultiImplMapIterator<SmallMapTy, BigMapTy, true> const_self;<br>
-<br>
- friend class MultiImplMapIterator<SmallMapTy, BigMapTy, true>;<br>
- friend class MultiImplMapIterator<SmallMapTy, BigMapTy, false>;<br>
-<br>
- protected:<br>
-<br>
- template <typename OtherValTy><br>
- static value_type* toValueTypePtr(OtherValTy& ValTyRef) {<br>
- return reinterpret_cast<value_type*>(<br>
- reinterpret_cast<void_ptr_ty>(&ValTyRef));<br>
- }<br>
-<br>
- template <typename OtherValTy><br>
- static value_type& toValueTypeRef(OtherValTy& ValTyRef) {<br>
- return *reinterpret_cast<value_type*>(<br>
- reinterpret_cast<void_ptr_ty>(&ValTyRef));<br>
- }<br>
-<br>
- small_iterator SmallIt;<br>
- big_iterator BigIt;<br>
- bool UseSmall;<br>
-<br>
- public:<br>
-<br>
- MultiImplMapIterator() : UseSmall(true) {}<br>
- MultiImplMapIterator(small_iterator It) : SmallIt(It), UseSmall(true) {}<br>
- MultiImplMapIterator(big_iterator It) : BigIt(It), UseSmall(false) {}<br>
- MultiImplMapIterator(const non_const_self& src) :<br>
- SmallIt(src.SmallIt), BigIt(src.BigIt), UseSmall(src.UseSmall) {}<br>
-<br>
- bool operator==(const const_self& rhs) const {<br>
- if (UseSmall != rhs.UseSmall)<br>
- return false;<br>
- if (UseSmall)<br>
- return SmallIt == rhs.SmallIt;<br>
- return BigIt == rhs.BigIt;<br>
- }<br>
-<br>
- bool operator!=(const const_self& rhs) const {<br>
- if (UseSmall != rhs.UseSmall)<br>
- return true;<br>
- if (UseSmall)<br>
- return SmallIt != rhs.SmallIt;<br>
- return BigIt != rhs.BigIt;<br>
- }<br>
-<br>
- reference operator*() const {<br>
- return UseSmall ? toValueTypeRef(*SmallIt) : toValueTypeRef(*BigIt);;<br>
- }<br>
-<br>
- pointer operator->() const {<br>
- return UseSmall ? toValueTypePtr(*SmallIt) : toValueTypePtr(*BigIt);<br>
- }<br>
-<br>
- // Preincrement<br>
- inline self& operator++() {<br>
- if (UseSmall) ++SmallIt;<br>
- return *this;<br>
- }<br>
-<br>
- // Postincrement<br>
- self operator++(int) {<br>
- self tmp = *this; ++*this; return tmp;<br>
- }<br>
- };<br>
-<br>
- template<class SmallMapTy, class BigMapTy><br>
- struct MultiImplMapIteratorsFactory {<br>
-<br>
- typedef MultiImplMapIterator<SmallMapTy, BigMapTy, false> iterator;<br>
- typedef MultiImplMapIterator<SmallMapTy, BigMapTy, true> const_iterator;<br>
-<br>
- template<class MapImpl, class ItTy><br>
- static iterator it(MapImpl& impl, ItTy it) {<br>
- return iterator(it);<br>
- }<br>
- template<class MapImpl, class ConstItTy><br>
- static const_iterator const_it(const MapImpl& impl, ConstItTy it) {<br>
- return const_iterator(it);<br>
- }<br>
- template<class MapImpl><br>
- static iterator begin(MapImpl& impl) {<br>
- return iterator(impl.begin());<br>
- }<br>
- template<class MapImpl><br>
- static const_iterator begin(const MapImpl& impl) {<br>
- return const_iterator(impl.begin());<br>
- }<br>
- template<class MapImpl><br>
- static iterator end(MapImpl& impl) {<br>
- return iterator(impl.end());<br>
- }<br>
- template<class MapImpl><br>
- static const_iterator end(const MapImpl& impl) {<br>
- return const_iterator(impl.end());<br>
- }<br>
- };<br>
-<br>
- template<typename KeyTy, typename MappedTy, unsigned MaxArraySize,<br>
- typename KeyInfoT><br>
- struct MultiImplMapIteratorsFactory<<br>
- FlatArrayMap<KeyTy, MappedTy, MaxArraySize>,<br>
- DenseMap<KeyTy, MappedTy, KeyInfoT> ><br>
- {<br>
-<br>
- typedef FlatArrayMap<KeyTy, MappedTy, MaxArraySize> SmallMapTy;<br>
- typedef DenseMap<KeyTy, MappedTy, KeyInfoT> BigMapTy;<br>
-<br>
- typedef DenseMapIterator<KeyTy, MappedTy, KeyInfoT, false><br>
- iterator;<br>
- typedef DenseMapIterator<KeyTy, MappedTy, KeyInfoT, true><br>
- const_iterator;<br>
-<br>
- static iterator it(SmallMapTy& impl, typename SmallMapTy::iterator it) {<br>
- return iterator(&(*it), &(*impl.end()));<br>
- }<br>
- static const_iterator const_it(<br>
- const SmallMapTy& impl, typename SmallMapTy::const_iterator it) {<br>
- return const_iterator(&(*it), &(*impl.end()));<br>
- }<br>
- static iterator it(BigMapTy& impl, typename BigMapTy::iterator it) {<br>
- return it;<br>
- }<br>
- static const_iterator const_it(<br>
- const BigMapTy& impl, typename BigMapTy::const_iterator it) {<br>
- return it;<br>
- }<br>
- static iterator begin(SmallMapTy& impl) {<br>
- return it(impl, impl.begin());<br>
- }<br>
- static const_iterator begin(const SmallMapTy& impl) {<br>
- return it(impl, impl.begin());<br>
- }<br>
- static iterator begin(BigMapTy& impl) {<br>
- return impl.begin();<br>
- }<br>
- static const_iterator begin(const BigMapTy& impl) {<br>
- return impl.begin();<br>
- }<br>
- static iterator end(SmallMapTy& impl) {<br>
- return it(impl, impl.end());<br>
- }<br>
- static const_iterator end(const SmallMapTy& impl) {<br>
- return const_it(impl, impl.end());<br>
- }<br>
- static iterator end(BigMapTy& impl) {<br>
- return impl.end();<br>
- }<br>
- static const_iterator end(const BigMapTy& impl) {<br>
- return impl.end();<br>
- }<br>
- };<br>
-}<br>
-<br>
-#endif /* MULTIIMPLEMENTATIONMAP_H_ */<br>
<br>
Removed: llvm/trunk/include/llvm/ADT/SmallMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallMap.h?rev=155561&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallMap.h?rev=155561&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/SmallMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/SmallMap.h (removed)<br>
@@ -1,37 +0,0 @@<br>
-//===- llvm/ADT/SmallMap.h - 'Normally small' pointer set -------*- C++ -*-===//<br>
-//<br>
-// The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-//<br>
-// This file defines the SmallMap class.<br>
-// SmallMap is DenseMap compatible MultiImplMap.<br>
-// It uses FlatArrayMap for small mode, and DenseMap for big mode.<br>
-// See MultiMapImpl comments for more details on the algorithm is used.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#ifndef SMALLPTRMAP_H_<br>
-#define SMALLPTRMAP_H_<br>
-<br>
-#include "llvm/ADT/DenseMap.h"<br>
-#include "llvm/ADT/FlatArrayMap.h"<br>
-#include "llvm/ADT/MultiImplMap.h"<br>
-<br>
-namespace llvm {<br>
-<br>
- //===--------------------------------------------------------------------===//<br>
- /// SmallMap is wrapper around MultiImplMap. It uses FlatArrayMap for<br>
- /// small mode, and DenseMap for big mode.<br>
- template <typename KeyTy, typename MappedTy, unsigned N = 16><br>
- class SmallMap : public MultiImplMap<<br>
- FlatArrayMap<KeyTy, MappedTy, N>,<br>
- DenseMap<KeyTy, MappedTy>,<br>
- N, true> {<br>
- };<br>
-}<br>
-<br>
-#endif /* SMALLPTRMAP_H_ */<br>
<br>
Removed: llvm/trunk/unittests/ADT/SmallMapTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SmallMapTest.cpp?rev=155561&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SmallMapTest.cpp?rev=155561&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ADT/SmallMapTest.cpp (original)<br>
+++ llvm/trunk/unittests/ADT/SmallMapTest.cpp (removed)<br>
@@ -1,133 +0,0 @@<br>
-//===- llvm/unittest/ADT/SmallMapTest.cpp ------------------------------===//<br>
-//<br>
-// The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-//<br>
-// SmallMap unit tests.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include "gtest/gtest.h"<br>
-#include "llvm/ADT/SmallMap.h"<br>
-<br>
-using namespace llvm;<br>
-<br>
-// SmallMap test.<br>
-TEST(SmallMapTest, GeneralTest) {<br>
-<br>
- int buf[10];<br>
-<br>
- SmallMap<int *, int, 3> a;<br>
- SmallMap<int *, int, 3> b;<br>
- SmallMap<int *, int, 3>::iterator found;<br>
- std::pair<SmallMap<int *, int, 3>::iterator, bool> insRes;<br>
- SmallMap<int *, int, 3>::const_iterator foundc;<br>
-<br>
- a.insert(std::make_pair(&buf[0], 0));<br>
- insRes = a.insert(std::make_pair(&buf[1], 1));<br>
- EXPECT_TRUE(insRes.second);<br>
-<br>
- // Check insertion, looking up, and data editing in small mode.<br>
- insRes = a.insert(std::make_pair(&buf[1], 6));<br>
- EXPECT_FALSE(insRes.second);<br>
- EXPECT_EQ(insRes.first->second, 1);<br>
- insRes.first->second = 5;<br>
- found = a.find(&buf[1]);<br>
- EXPECT_NE(found, a.end());<br>
- EXPECT_EQ(found->second, 5);<br>
- a[&buf[1]] = 10;<br>
- EXPECT_EQ(found->second, 10);<br>
- // Check "not found" case.<br>
- found = a.find(&buf[8]);<br>
- EXPECT_EQ(found, a.end());<br>
-<br>
- // Check increment for small mode.<br>
- found = a.begin();<br>
- ++found;<br>
- EXPECT_EQ(found->second, 10);<br>
-<br>
- b.insert(std::make_pair(&buf[2], 2));<br>
-<br>
- std::swap(a, b);<br>
- a.swap(b);<br>
- std::swap(a, b);<br>
-<br>
- EXPECT_EQ(1U, a.size());<br>
- EXPECT_EQ(2U, b.size());<br>
- EXPECT_TRUE(a.count(&buf[2]));<br>
- EXPECT_TRUE(b.count(&buf[0]));<br>
- EXPECT_TRUE(b.count(&buf[1]));<br>
-<br>
- insRes = b.insert(std::make_pair(&buf[3], 3));<br>
- EXPECT_TRUE(insRes.second);<br>
-<br>
- // Check insertion, looking up, and data editing in big mode.<br>
- insRes = b.insert(std::make_pair(&buf[3], 6));<br>
- EXPECT_FALSE(insRes.second);<br>
- EXPECT_EQ(insRes.first->second, 3);<br>
- insRes.first->second = 7;<br>
- found = b.find(&buf[3]);<br>
- EXPECT_EQ(found->second, 7);<br>
- b[&buf[3]] = 14;<br>
- EXPECT_EQ(found->second, 14);<br>
- // Check constant looking up.<br>
- foundc = b.find(&buf[3]);<br>
- EXPECT_EQ(foundc->first, &buf[3]);<br>
- EXPECT_EQ(foundc->second, 14);<br>
- // Check not found case.<br>
- found = b.find(&buf[8]);<br>
- EXPECT_EQ(found, b.end());<br>
-<br>
- // Check increment for big mode.<br>
- found = b.find(&buf[1]);<br>
- ++found;<br>
- EXPECT_EQ(found->second, 14);<br>
-<br>
- std::swap(a, b);<br>
- a.swap(b);<br>
- std::swap(a, b);<br>
-<br>
- EXPECT_EQ(3U, a.size());<br>
- EXPECT_EQ(1U, b.size());<br>
- EXPECT_TRUE(a.count(&buf[0]));<br>
- EXPECT_TRUE(a.count(&buf[1]));<br>
- EXPECT_TRUE(a.count(&buf[3]));<br>
- EXPECT_TRUE(b.count(&buf[2]));<br>
- EXPECT_EQ(b.find(&buf[2])->second, 2);<br>
-<br>
- std::swap(a, b);<br>
- a.swap(b);<br>
- std::swap(a, b);<br>
-<br>
- EXPECT_EQ(1U, a.size());<br>
- EXPECT_EQ(3U, b.size());<br>
- EXPECT_TRUE(a.count(&buf[2]));<br>
- EXPECT_TRUE(b.count(&buf[0]));<br>
- EXPECT_TRUE(b.count(&buf[1]));<br>
- EXPECT_TRUE(b.count(&buf[3]));<br>
-<br>
- a.insert(std::make_pair(&buf[4], 4));<br>
- a.insert(std::make_pair(&buf[5], 5));<br>
- a.insert(std::make_pair(&buf[6], 6));<br>
-<br>
- std::swap(b, a);<br>
-<br>
- EXPECT_EQ(3U, a.size());<br>
- EXPECT_EQ(4U, b.size());<br>
- EXPECT_TRUE(b.count(&buf[2]));<br>
- EXPECT_TRUE(b.count(&buf[4]));<br>
- EXPECT_TRUE(b.count(&buf[5]));<br>
- EXPECT_TRUE(b.count(&buf[6]));<br>
- EXPECT_TRUE(a.count(&buf[0]));<br>
- EXPECT_TRUE(a.count(&buf[1]));<br>
- EXPECT_TRUE(a.count(&buf[3]));<br>
-<br>
- // Check findAndConstruct<br>
- SmallMap<int *, int, 3>::value_type Buf7;<br>
- Buf7 = a.FindAndConstruct(&buf[7]);<br>
- EXPECT_EQ(Buf7.second, 0);<br>
-}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>