diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-03-03 17:27:15 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-03-03 17:27:15 +0000 |
commit | 8230c40430a1325b5cc5bc0221931487b4bd573c (patch) | |
tree | 836a05cff50ca46176117b86029f061fa4db54f0 /include/llvm/ADT | |
parent | f25ddd991a5601d0101602c4c263a58c7af4b8a2 (diff) | |
download | FreeBSD-src-8230c40430a1325b5cc5bc0221931487b4bd573c.zip FreeBSD-src-8230c40430a1325b5cc5bc0221931487b4bd573c.tar.gz |
Update LLVM to 97654.
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/APFloat.h | 32 | ||||
-rw-r--r-- | include/llvm/ADT/APInt.h | 28 | ||||
-rw-r--r-- | include/llvm/ADT/DeltaAlgorithm.h | 2 | ||||
-rw-r--r-- | include/llvm/ADT/ScopedHashTable.h | 69 | ||||
-rw-r--r-- | include/llvm/ADT/StringRef.h | 16 | ||||
-rw-r--r-- | include/llvm/ADT/Triple.h | 1 |
6 files changed, 115 insertions, 33 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index f81109a..861b7b9 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -173,11 +173,16 @@ namespace llvm { fcZero }; + enum uninitializedTag { + uninitialized + }; + // Constructors. APFloat(const fltSemantics &); // Default construct to 0.0 APFloat(const fltSemantics &, const StringRef &); APFloat(const fltSemantics &, integerPart); - APFloat(const fltSemantics &, fltCategory, bool negative, unsigned type=0); + APFloat(const fltSemantics &, fltCategory, bool negative); + APFloat(const fltSemantics &, uninitializedTag); explicit APFloat(double d); explicit APFloat(float f); explicit APFloat(const APInt &, bool isIEEE = false); @@ -199,7 +204,26 @@ namespace llvm { /// default. The value is truncated as necessary. static APFloat getNaN(const fltSemantics &Sem, bool Negative = false, unsigned type = 0) { - return APFloat(Sem, fcNaN, Negative, type); + if (type) { + APInt fill(64, type); + return getQNaN(Sem, Negative, &fill); + } else { + return getQNaN(Sem, Negative, 0); + } + } + + /// getQNan - Factory for QNaN values. + static APFloat getQNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, false, Negative, payload); + } + + /// getSNan - Factory for SNaN values. + static APFloat getSNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, true, Negative, payload); } /// getLargest - Returns the largest finite number in the given @@ -350,7 +374,9 @@ namespace llvm { opStatus modSpecials(const APFloat &); /* Miscellany. */ - void makeNaN(unsigned = 0); + static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative, + const APInt *fill); + void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0); opStatus normalize(roundingMode, lostFraction); opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); cmpResult compareAbsoluteValue(const APFloat &) const; diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 88aa995..3f67ffb 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -150,7 +150,17 @@ class APInt { return isSingleWord() ? VAL : pVal[whichWord(bitPosition)]; } + /// Converts a string into a number. The string must be non-empty + /// and well-formed as a number of the given base. The bit-width + /// must be sufficient to hold the result. + /// /// This is used by the constructors that take string arguments. + /// + /// StringRef::getAsInteger is superficially similar but (1) does + /// not assume that the string is well-formed and (2) grows the + /// result to hold the input. + /// + /// @param radix 2, 8, 10, or 16 /// @brief Convert a char array into an APInt void fromString(unsigned numBits, const StringRef &str, uint8_t radix); @@ -571,6 +581,21 @@ public: /// @brief Bitwise OR assignment operator. APInt& operator|=(const APInt& RHS); + /// Performs a bitwise OR operation on this APInt and RHS. RHS is + /// logically zero-extended or truncated to match the bit-width of + /// the LHS. + /// + /// @brief Bitwise OR assignment operator. + APInt& operator|=(uint64_t RHS) { + if (isSingleWord()) { + VAL |= RHS; + clearUnusedBits(); + } else { + pVal[0] |= RHS; + } + return *this; + } + /// Performs a bitwise XOR operation on this APInt and RHS. The result is /// assigned to *this. /// @returns *this after XORing with RHS. @@ -1308,6 +1333,9 @@ public: /// Set the given bit of a bignum. Zero-based. static void tcSetBit(integerPart *, unsigned int bit); + /// Clear the given bit of a bignum. Zero-based. + static void tcClearBit(integerPart *, unsigned int bit); + /// Returns the bit number of the least or most significant set bit /// of a number. If the input number has no bits set -1U is /// returned. diff --git a/include/llvm/ADT/DeltaAlgorithm.h b/include/llvm/ADT/DeltaAlgorithm.h index 1facfa0..45ba198 100644 --- a/include/llvm/ADT/DeltaAlgorithm.h +++ b/include/llvm/ADT/DeltaAlgorithm.h @@ -52,7 +52,7 @@ private: /// \return - The test result. bool GetTestResult(const changeset_ty &Changes); - /// Split - Partition a set of changes \arg Sinto one or two subsets. + /// Split - Partition a set of changes \arg S into one or two subsets. void Split(const changeset_ty &S, changesetlist_ty &Res); /// Delta - Minimize a set of \arg Changes which has been partioned into diff --git a/include/llvm/ADT/ScopedHashTable.h b/include/llvm/ADT/ScopedHashTable.h index d538295..f325e2b 100644 --- a/include/llvm/ADT/ScopedHashTable.h +++ b/include/llvm/ADT/ScopedHashTable.h @@ -36,10 +36,10 @@ namespace llvm { -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTable; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableVal { ScopedHashTableVal *NextInScope; ScopedHashTableVal *NextForKey; @@ -61,35 +61,39 @@ public: ScopedHashTableVal *getNextInScope() { return NextInScope; } }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableScope { /// HT - The hashtable that we are active for. - ScopedHashTable<K, V> &HT; + ScopedHashTable<K, V, KInfo> &HT; /// PrevScope - This is the scope that we are shadowing in HT. ScopedHashTableScope *PrevScope; /// LastValInScope - This is the last value that was inserted for this scope /// or null if none have been inserted yet. - ScopedHashTableVal<K,V> *LastValInScope; + ScopedHashTableVal<K, V, KInfo> *LastValInScope; void operator=(ScopedHashTableScope&); // DO NOT IMPLEMENT ScopedHashTableScope(ScopedHashTableScope&); // DO NOT IMPLEMENT public: - ScopedHashTableScope(ScopedHashTable<K, V> &HT); + ScopedHashTableScope(ScopedHashTable<K, V, KInfo> &HT); ~ScopedHashTableScope(); private: - friend class ScopedHashTable<K, V>; - ScopedHashTableVal<K, V> *getLastValInScope() { return LastValInScope; } - void setLastValInScope(ScopedHashTableVal<K,V> *Val) { LastValInScope = Val; } + friend class ScopedHashTable<K, V, KInfo>; + ScopedHashTableVal<K, V, KInfo> *getLastValInScope() { + return LastValInScope; + } + void setLastValInScope(ScopedHashTableVal<K, V, KInfo> *Val) { + LastValInScope = Val; + } }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableIterator { - ScopedHashTableVal<K,V> *Node; + ScopedHashTableVal<K, V, KInfo> *Node; public: - ScopedHashTableIterator(ScopedHashTableVal<K,V> *node) : Node(node){} + ScopedHashTableIterator(ScopedHashTableVal<K, V, KInfo> *node) : Node(node) {} V &operator*() const { assert(Node && "Dereference end()"); @@ -117,35 +121,43 @@ public: }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo> class ScopedHashTable { - DenseMap<K, ScopedHashTableVal<K,V>*> TopLevelMap; - ScopedHashTableScope<K, V> *CurScope; + DenseMap<K, ScopedHashTableVal<K, V, KInfo>*, KInfo> TopLevelMap; + ScopedHashTableScope<K, V, KInfo> *CurScope; ScopedHashTable(const ScopedHashTable&); // NOT YET IMPLEMENTED void operator=(const ScopedHashTable&); // NOT YET IMPLEMENTED - friend class ScopedHashTableScope<K, V>; + friend class ScopedHashTableScope<K, V, KInfo>; public: ScopedHashTable() : CurScope(0) {} ~ScopedHashTable() { assert(CurScope == 0 && TopLevelMap.empty() && "Scope imbalance!"); } + bool count(const K &Key) const { + return TopLevelMap.count(Key); + } + + V lookup(const K &Key) { + return TopLevelMap[Key].getValue(); + } + void insert(const K &Key, const V &Val) { assert(CurScope && "No scope active!"); - ScopedHashTableVal<K,V> *&KeyEntry = TopLevelMap[Key]; + ScopedHashTableVal<K, V, KInfo> *&KeyEntry = TopLevelMap[Key]; - KeyEntry = new ScopedHashTableVal<K,V>(CurScope->getLastValInScope(), - KeyEntry, Key, Val); + KeyEntry= new ScopedHashTableVal<K, V, KInfo>(CurScope->getLastValInScope(), + KeyEntry, Key, Val); CurScope->setLastValInScope(KeyEntry); } - typedef ScopedHashTableIterator<K, V> iterator; + typedef ScopedHashTableIterator<K, V, KInfo> iterator; iterator end() { return iterator(0); } iterator begin(const K &Key) { - typename DenseMap<K, ScopedHashTableVal<K,V>*>::iterator I = + typename DenseMap<K, ScopedHashTableVal<K, V, KInfo>*, KInfo>::iterator I = TopLevelMap.find(Key); if (I == TopLevelMap.end()) return end(); return iterator(I->second); @@ -154,28 +166,29 @@ public: /// ScopedHashTableScope ctor - Install this as the current scope for the hash /// table. -template <typename K, typename V> -ScopedHashTableScope<K, V>::ScopedHashTableScope(ScopedHashTable<K, V> &ht) - : HT(ht) { +template <typename K, typename V, typename KInfo> +ScopedHashTableScope<K, V, KInfo>:: + ScopedHashTableScope(ScopedHashTable<K, V, KInfo> &ht) : HT(ht) { PrevScope = HT.CurScope; HT.CurScope = this; LastValInScope = 0; } -template <typename K, typename V> -ScopedHashTableScope<K, V>::~ScopedHashTableScope() { +template <typename K, typename V, typename KInfo> +ScopedHashTableScope<K, V, KInfo>::~ScopedHashTableScope() { assert(HT.CurScope == this && "Scope imbalance!"); HT.CurScope = PrevScope; // Pop and delete all values corresponding to this scope. - while (ScopedHashTableVal<K, V> *ThisEntry = LastValInScope) { + while (ScopedHashTableVal<K, V, KInfo> *ThisEntry = LastValInScope) { // Pop this value out of the TopLevelMap. if (ThisEntry->getNextForKey() == 0) { assert(HT.TopLevelMap[ThisEntry->getKey()] == ThisEntry && "Scope imbalance!"); HT.TopLevelMap.erase(ThisEntry->getKey()); } else { - ScopedHashTableVal<K,V> *&KeyEntry = HT.TopLevelMap[ThisEntry->getKey()]; + ScopedHashTableVal<K, V, KInfo> *&KeyEntry = + HT.TopLevelMap[ThisEntry->getKey()]; assert(KeyEntry == ThisEntry && "Scope imbalance!"); KeyEntry = ThisEntry->getNextForKey(); } diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 3064af3..9257770 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -18,6 +18,7 @@ namespace llvm { template<typename T> class SmallVectorImpl; + class APInt; /// StringRef - Represent a constant reference to a string, i.e. a character /// array and a length, which need not be null terminated. @@ -273,6 +274,19 @@ namespace llvm { // TODO: Provide overloads for int/unsigned that check for overflow. + /// getAsInteger - Parse the current string as an integer of the + /// specified radix, or of an autosensed radix if the radix given + /// is 0. The current value in Result is discarded, and the + /// storage is changed to be wide enough to store the parsed + /// integer. + /// + /// Returns true if the string does not solely consist of a valid + /// non-empty number in the appropriate base. + /// + /// APInt::fromString is superficially similar but assumes the + /// string is well-formed in the given radix. + bool getAsInteger(unsigned Radix, APInt &Result) const; + /// @} /// @name Substring Operations /// @{ @@ -355,7 +369,7 @@ namespace llvm { /// \param A - Where to put the substrings. /// \param Separator - The string to split on. /// \param MaxSplit - The maximum number of times the string is split. - /// \parm KeepEmpty - True if empty substring should be added. + /// \param KeepEmpty - True if empty substring should be added. void split(SmallVectorImpl<StringRef> &A, StringRef Separator, int MaxSplit = -1, bool KeepEmpty = true) const; diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 8798b0e..be31ea0 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -73,6 +73,7 @@ public: x86, // X86: i[3-9]86 x86_64, // X86-64: amd64, x86_64 xcore, // XCore: xcore + mblaze, // MBlaze: mblaze InvalidArch }; |