diff options
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/APFloat.h | 51 | ||||
-rw-r--r-- | include/llvm/ADT/APInt.h | 8 | ||||
-rw-r--r-- | include/llvm/ADT/IntervalMap.h | 4 | ||||
-rw-r--r-- | include/llvm/ADT/NullablePtr.h | 52 | ||||
-rw-r--r-- | include/llvm/ADT/SmallBitVector.h | 34 | ||||
-rw-r--r-- | include/llvm/ADT/StringRef.h | 6 | ||||
-rw-r--r-- | include/llvm/ADT/Triple.h | 9 |
7 files changed, 79 insertions, 85 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index ffd8975..43a7866 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -21,9 +21,6 @@ namespace llvm { -/// A signed type to represent a floating point numbers unbiased exponent. -typedef signed short exponent_t; - struct fltSemantics; class APSInt; class StringRef; @@ -120,11 +117,14 @@ enum lostFraction { // Example of truncated bits: /// New formats: x87 in single and double precision mode (IEEE apart from /// extended exponent range) (hard). /// -/// New operations: sqrt, IEEE remainder, C90 fmod, nextafter, nexttoward. +/// New operations: sqrt, IEEE remainder, C90 fmod, nexttoward. /// class APFloat { public: + /// A signed type to represent a floating point numbers unbiased exponent. + typedef signed short ExponentType; + /// \name Floating Point Semantics. /// @{ @@ -191,7 +191,6 @@ public: APFloat(const fltSemantics &); // Default construct to 0.0 APFloat(const fltSemantics &, StringRef); APFloat(const fltSemantics &, integerPart); - APFloat(const fltSemantics &, fltCategory, bool negative); APFloat(const fltSemantics &, uninitializedTag); APFloat(const fltSemantics &, const APInt &); explicit APFloat(double d); @@ -211,14 +210,18 @@ public: /// /// \param Negative True iff the number should be negative. static APFloat getZero(const fltSemantics &Sem, bool Negative = false) { - return APFloat(Sem, fcZero, Negative); + APFloat Val(Sem, uninitialized); + Val.makeZero(Negative); + return Val; } /// Factory for Positive and Negative Infinity. /// /// \param Negative True iff the number should be negative. static APFloat getInf(const fltSemantics &Sem, bool Negative = false) { - return APFloat(Sem, fcInfinity, Negative); + APFloat Val(Sem, uninitialized); + Val.makeInf(Negative); + return Val; } /// Factory for QNaN values. @@ -300,6 +303,8 @@ public: /// IEEE-754R 5.3.1: nextUp/nextDown. opStatus next(bool nextDown); + /// @} + /// \name Sign operations. /// @{ @@ -359,10 +364,7 @@ public: /// /// This implies that the current value of the float is not zero, subnormal, /// infinite, or NaN following the definition of normality from IEEE-754R. - /// - /// The current implementation of isNormal() differs from this by treating - /// subnormal values as normal values. - bool isIEEENormal() const { return !isDenormal() && isNormal(); } + bool isNormal() const { return !isDenormal() && isFiniteNonZero(); } /// Returns true if and only if the current value is zero, subnormal, or /// normal. @@ -394,10 +396,18 @@ public: fltCategory getCategory() const { return category; } const fltSemantics &getSemantics() const { return *semantics; } bool isNonZero() const { return category != fcZero; } - bool isNormal() const { return category == fcNormal; } + bool isFiniteNonZero() const { return isFinite() && !isZero(); } bool isPosZero() const { return isZero() && !isNegative(); } bool isNegZero() const { return isZero() && isNegative(); } + /// Returns true if and only if the number has the smallest possible non-zero + /// magnitude in the current semantics. + bool isSmallest() const; + + /// Returns true if and only if the number has the largest possible finite + /// magnitude in the current semantics. + bool isLargest() const; + /// @} APFloat &operator=(const APFloat &); @@ -491,24 +501,15 @@ private: void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0); static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative, const APInt *fill); - - /// @} - - /// \name Special value queries only useful internally to APFloat - /// @{ - - /// Returns true if and only if the number has the smallest possible non-zero - /// magnitude in the current semantics. - bool isSmallest() const; - /// Returns true if and only if the number has the largest possible finite - /// magnitude in the current semantics. - bool isLargest() const; + void makeInf(bool Neg = false); + void makeZero(bool Neg = false); /// @} /// \name Miscellany /// @{ + bool convertFromStringSpecials(StringRef str); opStatus normalize(roundingMode, lostFraction); opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); cmpResult compareAbsoluteValue(const APFloat &) const; @@ -557,7 +558,7 @@ private: } significand; /// The signed unbiased exponent of the value. - exponent_t exponent; + ExponentType exponent; /// What kind of floating point number this is. /// diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index e5797b8..625a6db 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -337,13 +337,17 @@ public: /// \brief Determine if all bits are set /// /// This checks to see if the value has all bits of the APInt are set or not. - bool isAllOnesValue() const { return countPopulation() == BitWidth; } + bool isAllOnesValue() const { + if (isSingleWord()) + return VAL == ~integerPart(0) >> (APINT_BITS_PER_WORD - BitWidth); + return countPopulationSlowCase() == BitWidth; + } /// \brief Determine if this is the largest unsigned value. /// /// This checks to see if the value of this APInt is the maximum unsigned /// value for the APInt's bit width. - bool isMaxValue() const { return countPopulation() == BitWidth; } + bool isMaxValue() const { return isAllOnesValue(); } /// \brief Determine if this is the largest signed value. /// diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h index 44a61ff..1ca3288 100644 --- a/include/llvm/ADT/IntervalMap.h +++ b/include/llvm/ADT/IntervalMap.h @@ -612,7 +612,7 @@ public: /// insertFrom - Add mapping of [a;b] to y if possible, coalescing as much as /// possible. This may cause the node to grow by 1, or it may cause the node /// to shrink because of coalescing. -/// @param i Starting index = insertFrom(0, size, a) +/// @param Pos Starting index = insertFrom(0, size, a) /// @param Size Number of elements in node. /// @param a Interval start. /// @param b Interval stop. @@ -1956,7 +1956,7 @@ iterator::eraseNode(unsigned Level) { /// overflow - Distribute entries of the current node evenly among /// its siblings and ensure that the current node is not full. /// This may require allocating a new node. -/// @param NodeT The type of node at Level (Leaf or Branch). +/// @tparam NodeT The type of node at Level (Leaf or Branch). /// @param Level path index of the overflowing node. /// @return True when the tree height was changed. template <typename KeyT, typename ValT, unsigned N, typename Traits> diff --git a/include/llvm/ADT/NullablePtr.h b/include/llvm/ADT/NullablePtr.h deleted file mode 100644 index 8ddfd5d..0000000 --- a/include/llvm/ADT/NullablePtr.h +++ /dev/null @@ -1,52 +0,0 @@ -//===- llvm/ADT/NullablePtr.h - A pointer that allows null ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines and implements the NullablePtr class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_NULLABLEPTR_H -#define LLVM_ADT_NULLABLEPTR_H - -#include <cassert> -#include <cstddef> - -namespace llvm { -/// NullablePtr pointer wrapper - NullablePtr is used for APIs where a -/// potentially-null pointer gets passed around that must be explicitly handled -/// in lots of places. By putting a wrapper around the null pointer, it makes -/// it more likely that the null pointer case will be handled correctly. -template<class T> -class NullablePtr { - T *Ptr; -public: - NullablePtr(T *P = 0) : Ptr(P) {} - - bool isNull() const { return Ptr == 0; } - bool isNonNull() const { return Ptr != 0; } - - /// get - Return the pointer if it is non-null. - const T *get() const { - assert(Ptr && "Pointer wasn't checked for null!"); - return Ptr; - } - - /// get - Return the pointer if it is non-null. - T *get() { - assert(Ptr && "Pointer wasn't checked for null!"); - return Ptr; - } - - T *getPtrOrNull() { return Ptr; } - const T *getPtrOrNull() const { return Ptr; } -}; - -} // end namespace llvm - -#endif diff --git a/include/llvm/ADT/SmallBitVector.h b/include/llvm/ADT/SmallBitVector.h index fe9bef9..86949b2 100644 --- a/include/llvm/ADT/SmallBitVector.h +++ b/include/llvm/ADT/SmallBitVector.h @@ -426,6 +426,40 @@ public: return *this; } + /// reset - Reset bits that are set in RHS. Same as *this &= ~RHS. + SmallBitVector &reset(const SmallBitVector &RHS) { + if (isSmall() && RHS.isSmall()) + setSmallBits(getSmallBits() & ~RHS.getSmallBits()); + else if (!isSmall() && !RHS.isSmall()) + getPointer()->reset(*RHS.getPointer()); + else + for (unsigned i = 0, e = std::min(size(), RHS.size()); i != e; ++i) + if (RHS.test(i)) + reset(i); + + return *this; + } + + /// test - Check if (This - RHS) is zero. + /// This is the same as reset(RHS) and any(). + bool test(const SmallBitVector &RHS) const { + if (isSmall() && RHS.isSmall()) + return (getSmallBits() & ~RHS.getSmallBits()) != 0; + if (!isSmall() && !RHS.isSmall()) + return getPointer()->test(*RHS.getPointer()); + + unsigned i, e; + for (i = 0, e = std::min(size(), RHS.size()); i != e; ++i) + if (test(i) && !RHS.test(i)) + return true; + + for (e = size(); i != e; ++i) + if (test(i)) + return true; + + return false; + } + SmallBitVector &operator|=(const SmallBitVector &RHS) { resize(std::max(size(), RHS.size())); if (isSmall()) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index d013d05..3e1e24c 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -19,7 +19,7 @@ #include <utility> namespace llvm { - template<typename T> + template <typename T> class SmallVectorImpl; class APInt; class hash_code; @@ -548,6 +548,10 @@ namespace llvm { template <typename T> struct isPodLike; template <> struct isPodLike<StringRef> { static const bool value = true; }; + /// Construct a string ref from a boolean. + inline StringRef toStringRef(bool B) { + return StringRef(B ? "true" : "false"); + } } #endif diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 41e463d..8d968e8 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -55,6 +55,7 @@ public: msp430, // MSP430: msp430 ppc, // PPC: powerpc ppc64, // PPC64: powerpc64, ppu + ppc64le, // PPC64LE: powerpc64le r600, // R600: AMD GPUs HD2XXX - HD6XXX sparc, // Sparc: sparc sparcv9, // Sparcv9: Sparcv9 @@ -64,7 +65,6 @@ public: x86, // X86: i[3-9]86 x86_64, // X86-64: amd64, x86_64 xcore, // XCore: xcore - mblaze, // MBlaze: mblaze nvptx, // NVPTX: 32-bit nvptx64, // NVPTX: 64-bit le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten) @@ -81,7 +81,8 @@ public: BGP, BGQ, Freescale, - IBM + IBM, + NVIDIA }; enum OSType { UnknownOS, @@ -107,7 +108,9 @@ public: NaCl, // Native Client CNK, // BG/P Compute-Node Kernel Bitrig, - AIX + AIX, + CUDA, // NVIDIA CUDA + NVCL // NVIDIA OpenCL }; enum EnvironmentType { UnknownEnvironment, |