diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-01 22:55:40 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-01 22:55:40 +0000 |
commit | 551ccae044b0ff658fe629dd67edd5ffe75d10e8 (patch) | |
tree | d7fa643a1f1f12dbc4ee049bcc7a032a49b17d51 /include/Support | |
parent | ed543731fb385b55750d0c514d130a810339d739 (diff) |
Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/Support')
41 files changed, 0 insertions, 6173 deletions
diff --git a/include/Support/Annotation.h b/include/Support/Annotation.h deleted file mode 100644 index efca20a3ec..0000000000 --- a/include/Support/Annotation.h +++ /dev/null @@ -1,217 +0,0 @@ -//===-- Support/Annotation.h - Annotation classes ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the declarations for two classes: Annotation & Annotable. -// Using these two simple classes, anything that derives from Annotable can have -// Annotation subclasses attached to them, ready for easy retrieval. -// -// Annotations are designed to be easily attachable to various classes. -// -// The AnnotationManager class is essential for using these classes. It is -// responsible for turning Annotation name strings into tokens [unique id #'s] -// that may be used to search for and create annotations. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_ANNOTATION_H -#define SUPPORT_ANNOTATION_H - -#include <string> -#include <cassert> - -namespace llvm { - -class AnnotationID; -class Annotation; -class Annotable; -class AnnotationManager; - -//===----------------------------------------------------------------------===// -// -// AnnotationID - This class is a thin wrapper around an unsigned integer that -// is used to hopefully prevent errors using AnnotationID's. They may be copied -// freely around and passed byvalue with little or no overhead. -// -class AnnotationID { - friend class AnnotationManager; - unsigned ID; - - AnnotationID(); // Default ctor is disabled - inline AnnotationID(unsigned i) : ID(i) {} // Only creatable from AnnMgr -public: - inline AnnotationID(const AnnotationID &A) : ID(A.ID) {} - - inline bool operator==(const AnnotationID &A) const { - return A.ID == ID; - } - inline bool operator<(const AnnotationID &A) const { - return ID < A.ID; - } -}; - - -//===----------------------------------------------------------------------===// -// -// Annotation Class - This class serves as a base class for any specific -// annotations that you might need. Simply subclass this to add extra -// information to the annotations. -// -class Annotation { - friend class Annotable; // Annotable manipulates Next list - AnnotationID ID; // ID number, as obtained from AnnotationManager - Annotation *Next; // The next annotation in the linked list -public: - inline Annotation(AnnotationID id) : ID(id), Next(0) {} - virtual ~Annotation(); // Designed to be subclassed - - // getID - Return the unique ID# of this annotation - inline AnnotationID getID() const { return ID; } - - // getNext - Return the next annotation in the list... - inline Annotation *getNext() const { return Next; } -}; - - -//===----------------------------------------------------------------------===// -// -// Annotable - This class is used as a base class for all objects that would -// like to have annotation capability. One notable subclass is Value, which -// means annotations can be attached to almost everything in LLVM. -// -// Annotable objects keep their annotation list sorted as annotations are -// inserted and deleted. This is used to ensure that annotations with identical -// ID#'s are stored sequentially. -// -class Annotable { - mutable Annotation *AnnotationList; - - Annotable(const Annotable &); // Do not implement - void operator=(const Annotable &); // Do not implement -public: - Annotable() : AnnotationList(0) {} - ~Annotable(); - - // getAnnotation - Search the list for annotations of the specified ID. The - // pointer returned is either null (if no annotations of the specified ID - // exist), or it points to the first element of a potentially list of elements - // with identical ID #'s. - // - Annotation *getAnnotation(AnnotationID ID) const { - for (Annotation *A = AnnotationList; A; A = A->getNext()) - if (A->getID() == ID) return A; - return 0; - } - - // getOrCreateAnnotation - Search through the annotation list, if there is - // no annotation with the specified ID, then use the AnnotationManager to - // create one. - // - inline Annotation *getOrCreateAnnotation(AnnotationID ID) const; - - // addAnnotation - Insert the annotation into the list in a sorted location. - // - void addAnnotation(Annotation *A) const { - assert(A->Next == 0 && "Annotation already in list?!?"); - - Annotation **AL = &AnnotationList; - while (*AL && (*AL)->ID < A->getID()) // Find where to insert annotation - AL = &((*AL)->Next); - A->Next = *AL; // Link the annotation in - *AL = A; - } - - // unlinkAnnotation - Remove the first annotation of the specified ID... and - // then return the unlinked annotation. The annotation object is not deleted. - // - inline Annotation *unlinkAnnotation(AnnotationID ID) const { - for (Annotation **A = &AnnotationList; *A; A = &((*A)->Next)) - if ((*A)->getID() == ID) { - Annotation *Ret = *A; - *A = Ret->Next; - Ret->Next = 0; - return Ret; - } - return 0; - } - - // deleteAnnotation - Delete the first annotation of the specified ID in the - // list. Unlink unlinkAnnotation, this actually deletes the annotation object - // - bool deleteAnnotation(AnnotationID ID) const { - Annotation *A = unlinkAnnotation(ID); - delete A; - return A != 0; - } -}; - - -//===----------------------------------------------------------------------===// -// -// AnnotationManager - This class is primarily responsible for maintaining a -// one-to-one mapping between string Annotation names and Annotation ID numbers. -// -// Compared to the rest of the Annotation system, these mapping methods are -// relatively slow, so they should be avoided by locally caching Annotation -// ID #'s. These methods are safe to call at any time, even by static ctors, so -// they should be used by static ctors most of the time. -// -// This class also provides support for annotations that are created on demand -// by the Annotable::getOrCreateAnnotation method. To get this to work, simply -// register an annotation handler -// -struct AnnotationManager { - typedef Annotation *(*Factory)(AnnotationID, const Annotable *, void*); - - //===--------------------------------------------------------------------===// - // Basic ID <-> Name map functionality - - static AnnotationID getID(const std::string &Name); // Name -> ID - static const std::string &getName(AnnotationID ID); // ID -> Name - - // getID - Name -> ID + registration of a factory function for demand driven - // annotation support. - static AnnotationID getID(const std::string &Name, Factory Fact, - void *Data = 0); - - //===--------------------------------------------------------------------===// - // Annotation creation on demand support... - - // registerAnnotationFactory - This method is used to register a callback - // function used to create an annotation on demand if it is needed by the - // Annotable::getOrCreateAnnotation method. - // - static void registerAnnotationFactory(AnnotationID ID, Factory Func, - void *ExtraData = 0); - - // createAnnotation - Create an annotation of the specified ID for the - // specified object, using a register annotation creation function. - // - static Annotation *createAnnotation(AnnotationID ID, const Annotable *Obj); -}; - - - -// getOrCreateAnnotation - Search through the annotation list, if there is -// no annotation with the specified ID, then use the AnnotationManager to -// create one. -// -inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const { - Annotation *A = getAnnotation(ID); // Fast path, check for preexisting ann - if (A) return A; - - // No annotation found, ask the annotation manager to create an annotation... - A = AnnotationManager::createAnnotation(ID, this); - assert(A && "AnnotationManager could not create annotation!"); - addAnnotation(A); - return A; -} - -} // End namespace llvm - -#endif diff --git a/include/Support/BitSetVector.h b/include/Support/BitSetVector.h deleted file mode 100644 index 276af0a68a..0000000000 --- a/include/Support/BitSetVector.h +++ /dev/null @@ -1,272 +0,0 @@ -//===-- BitVectorSet.h - A bit-vector representation of sets ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This is an implementation of the bit-vector representation of sets. Unlike -// vector<bool>, this allows much more efficient parallel set operations on -// bits, by using the bitset template. The bitset template unfortunately can -// only represent sets with a size chosen at compile-time. We therefore use a -// vector of bitsets. The maxmimum size of our sets (i.e., the size of the -// universal set) can be chosen at creation time. -// -// External functions: -// -// bool Disjoint(const BitSetVector& set1, const BitSetVector& set2): -// Tests if two sets have an empty intersection. -// This is more efficient than !(set1 & set2).any(). -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_BITSETVECTOR_H -#define SUPPORT_BITSETVECTOR_H - -#include <bitset> -#include <vector> -#include <functional> -#include <iostream> - -namespace llvm { - -class BitSetVector { - enum { BITSET_WORDSIZE = sizeof(long)*8 }; - - // Types used internal to the representation - typedef std::bitset<BITSET_WORDSIZE> bitword; - typedef bitword::reference reference; - - // Data used in the representation - std::vector<bitword> bitsetVec; - unsigned maxSize; - -private: - // Utility functions for the representation - static unsigned NumWords(unsigned Size) { - return (Size+BITSET_WORDSIZE-1)/BITSET_WORDSIZE; - } - static unsigned LastWordSize(unsigned Size) { return Size % BITSET_WORDSIZE; } - - // Clear the unused bits in the last word. - // The unused bits are the high (BITSET_WORDSIZE - LastWordSize()) bits - void ClearUnusedBits() { - unsigned long usedBits = (1U << LastWordSize(size())) - 1; - bitsetVec.back() &= bitword(usedBits); - } - - const bitword& getWord(unsigned i) const { return bitsetVec[i]; } - bitword& getWord(unsigned i) { return bitsetVec[i]; } - - friend bool Disjoint(const BitSetVector& set1, - const BitSetVector& set2); - - BitSetVector(); // do not implement! - -public: - class iterator; - /// - /// Constructor: create a set of the maximum size maxSetSize. - /// The set is initialized to empty. - /// - BitSetVector(unsigned maxSetSize) - : bitsetVec(NumWords(maxSetSize)), maxSize(maxSetSize) { } - - /// size - Return the number of bits tracked by this bit vector... - unsigned size() const { return maxSize; } - - /// - /// Modifier methods: reset, set for entire set, operator[] for one element. - /// - void reset() { - for (unsigned i=0, N = bitsetVec.size(); i < N; ++i) - bitsetVec[i].reset(); - } - void set() { - for (unsigned i=0, N = bitsetVec.size(); i < N; ++i) // skip last word - bitsetVec[i].set(); - ClearUnusedBits(); - } - reference operator[](unsigned n) { - assert(n < size() && "BitSetVector: Bit number out of range"); - unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE; - return bitsetVec[ndiv][nmod]; - } - iterator begin() { return iterator::begin(*this); } - iterator end() { return iterator::end(*this); } - - /// - /// Comparison operations: equal, not equal - /// - bool operator == (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal == comparison"); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - if (getWord(i) != set2.getWord(i)) - return false; - return true; - } - bool operator != (const BitSetVector& set2) const { - return ! (*this == set2); - } - - /// - /// Set membership operations: single element, any, none, count - /// - bool test(unsigned n) const { - assert(n < size() && "BitSetVector: Bit number out of range"); - unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE; - return bitsetVec[ndiv].test(nmod); - } - bool any() const { - for (unsigned i = 0; i < bitsetVec.size(); ++i) - if (bitsetVec[i].any()) - return true; - return false; - } - bool none() const { - return ! any(); - } - unsigned count() const { - unsigned n = 0; - for (unsigned i = 0; i < bitsetVec.size(); ++i) - n += bitsetVec[i].count(); - return n; - } - bool all() const { - return (count() == size()); - } - - /// - /// Set operations: intersection, union, disjoint union, complement. - /// - BitSetVector operator& (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) & set2.getWord(i); - return result; - } - BitSetVector operator| (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) | set2.getWord(i); - return result; - } - BitSetVector operator^ (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) ^ set2.getWord(i); - return result; - } - BitSetVector operator~ () const { - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - (result.getWord(i) = getWord(i)).flip(); - result.ClearUnusedBits(); - return result; - } - - /// - /// Printing and debugging support - /// - void print(std::ostream &O) const; - void dump() const { print(std::cerr); } - -public: - // - // An iterator to enumerate the bits in a BitSetVector. - // Eventually, this needs to inherit from bidirectional_iterator. - // But this iterator may not be as useful as I once thought and - // may just go away. - // - class iterator { - unsigned currentBit; - unsigned currentWord; - BitSetVector* bitvec; - iterator(unsigned B, unsigned W, BitSetVector& _bitvec) - : currentBit(B), currentWord(W), bitvec(&_bitvec) { } - public: - iterator(BitSetVector& _bitvec) - : currentBit(0), currentWord(0), bitvec(&_bitvec) { } - iterator(const iterator& I) - : currentBit(I.currentBit),currentWord(I.currentWord),bitvec(I.bitvec) { } - iterator& operator=(const iterator& I) { - currentWord = I.currentWord; - currentBit = I.currentBit; - bitvec = I.bitvec; - return *this; - } - - // Increment and decrement operators (pre and post) - iterator& operator++() { - if (++currentBit == BITSET_WORDSIZE) - { currentBit = 0; if (currentWord < bitvec->size()) ++currentWord; } - return *this; - } - iterator& operator--() { - if (currentBit == 0) { - currentBit = BITSET_WORDSIZE-1; - currentWord = (currentWord == 0)? bitvec->size() : --currentWord; - } - else - --currentBit; - return *this; - } - iterator operator++(int) { iterator copy(*this); ++*this; return copy; } - iterator operator--(int) { iterator copy(*this); --*this; return copy; } - - // Dereferencing operators - reference operator*() { - assert(currentWord < bitvec->size() && - "Dereferencing iterator past the end of a BitSetVector"); - return bitvec->getWord(currentWord)[currentBit]; - } - - // Comparison operator - bool operator==(const iterator& I) { - return (I.bitvec == bitvec && - I.currentWord == currentWord && I.currentBit == currentBit); - } - - protected: - static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); } - static iterator end(BitSetVector& _bitvec) { return iterator(0, - _bitvec.size(), _bitvec); } - friend class BitSetVector; - }; -}; - - -inline void BitSetVector::print(std::ostream& O) const -{ - for (std::vector<bitword>::const_iterator - I=bitsetVec.begin(), E=bitsetVec.end(); I != E; ++I) - O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", "); -} - -inline std::ostream& operator<< (std::ostream& O, const BitSetVector& bset) -{ - bset.print(O); - return O; -}; - - -/// -/// Optimized versions of fundamental comparison operations -/// -inline bool Disjoint(const BitSetVector& set1, - const BitSetVector& set2) -{ - assert(set1.size() == set2.size() && "Illegal intersection"); - for (unsigned i = 0; i < set1.bitsetVec.size(); ++i) - if ((set1.getWord(i) & set2.getWord(i)).any()) - return false; - return true; -} - -} // End llvm namespace -#endif diff --git a/include/Support/Casting.h b/include/Support/Casting.h deleted file mode 100644 index abc80aac7a..0000000000 --- a/include/Support/Casting.h +++ /dev/null @@ -1,301 +0,0 @@ -//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the isa<X>(), cast<X>(), dyn_cast<X>(), cast_or_null<X>(), -// and dyn_cast_or_null<X>() templates. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_CASTING_H -#define SUPPORT_CASTING_H - -namespace llvm { - -//===----------------------------------------------------------------------===// -// isa<x> Support Templates -//===----------------------------------------------------------------------===// - -template<typename FromCl> struct isa_impl_cl; - -// Define a template that can be specialized by smart pointers to reflect the -// fact that they are automatically dereferenced, and are not involved with the -// template selection process... the default implementation is a noop. -// -template<typename From> struct simplify_type { - typedef From SimpleType; // The real type this represents... - - // An accessor to get the real value... - static SimpleType &getSimplifiedValue(From &Val) { return Val; } -}; - -template<typename From> struct simplify_type<const From> { - typedef const From SimpleType; - static SimpleType &getSimplifiedValue(const From &Val) { - return simplify_type<From>::getSimplifiedValue(static_cast<From&>(Val)); - } -}; - - -// isa<X> - Return true if the parameter to the template is an instance of the -// template type argument. Used like this: -// -// if (isa<Type*>(myVal)) { ... } -// -template <typename To, typename From> -inline bool isa_impl(const From &Val) { - return To::classof(&Val); -} - -template<typename To, typename From, typename SimpleType> -struct isa_impl_wrap { - // When From != SimplifiedType, we can simplify the type some more by using - // the simplify_type template. - static bool doit(const From &Val) { - return isa_impl_cl<const SimpleType>::template - isa<To>(simplify_type<const From>::getSimplifiedValue(Val)); - } -}; - -template<typename To, typename FromTy> -struct isa_impl_wrap<To, const FromTy, const FromTy> { - // When From == SimpleType, we are as simple as we are going to get. - static bool doit(const FromTy &Val) { - return isa_impl<To,FromTy>(Val); - } -}; - -// isa_impl_cl - Use class partial specialization to transform types to a single -// canonical form for isa_impl. -// -template<typename FromCl> -struct isa_impl_cl { - template<class ToCl> - static bool isa(const FromCl &Val) { - return isa_impl_wrap<ToCl,const FromCl, - typename simplify_type<const FromCl>::SimpleType>::doit(Val); - } -}; - -// Specialization used to strip const qualifiers off of the FromCl type... -template<typename FromCl> -struct isa_impl_cl<const FromCl> { - template<class ToCl> - static bool isa(const FromCl &Val) { - return isa_impl_cl<FromCl>::template isa<ToCl>(Val); - } -}; - -// Define pointer traits in terms of base traits... -template<class FromCl> -struct isa_impl_cl<FromCl*> { - template<class ToCl> - static bool isa(FromCl *Val) { - return isa_impl_cl<FromCl>::template isa<ToCl>(*Val); - } -}; - -// Define reference traits in terms of base traits... -template<class FromCl> -struct isa_impl_cl<FromCl&> { - template<class ToCl> - static bool isa(FromCl &Val) { - return isa_impl_cl<FromCl>::template isa<ToCl>(&Val); - } -}; - -template <class X, class Y> -inline bool isa(const Y &Val) { - return isa_impl_cl<Y>::template isa<X>(Val); -} - -//===----------------------------------------------------------------------===// -// cast<x> Support Templates -//===----------------------------------------------------------------------===// - -template<class To, class From> struct cast_retty; - - -// Calculate what type the 'cast' function should return, based on a requested -// type of To and a source type of From. -template<class To, class From> struct cast_retty_impl { - typedef To& ret_type; // Normal case, return Ty& -}; -template<class To, class From> struct cast_retty_impl<To, const From> { - typedef const To &ret_type; // Normal case, return Ty& -}; - -template<class To, class From> struct cast_retty_impl<To, From*> { - typedef To* ret_type; // Pointer arg case, return Ty* -}; - -template<class To, class From> struct cast_retty_impl<To, const From*> { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* -}; - -template<class To, class From> struct cast_retty_impl<To, const From*const> { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* -}; - - -template<class To, class From, class SimpleFrom> -struct cast_retty_wrap { - // When the simplified type and the from type are not the same, use the type - // simplifier to reduce the type, then reuse cast_retty_impl to get the - // resultant type. - typedef typename cast_retty<To, SimpleFrom>::ret_type ret_type; -}; - -template<class To, class FromTy> -struct cast_retty_wrap<To, FromTy, FromTy> { - // When the simplified type is equal to the from type, use it directly. - typedef typename cast_retty_impl<To,FromTy>::ret_type ret_type; -}; - -template<class To, class From> -struct cast_retty { - typedef typename cast_retty_wrap<To, From, - typename simplify_type<From>::SimpleType>::ret_type ret_type; -}; - -// Ensure the non-simple values are converted using the simplify_type template -// that may be specialized by smart pointers... -// -template<class To, class From, class SimpleFrom> struct cast_convert_val { - // This is not a simple type, use the template to simplify it... - static typename cast_retty<To, From>::ret_type doit(const From &Val) { - return cast_convert_val<To, SimpleFrom, - typename simplify_type<SimpleFrom>::SimpleType>::doit( - simplify_type<From>::getSimplifiedValue(Val)); - } -}; - -template<class To, class FromTy> struct cast_convert_val<To,FromTy,FromTy> { - // This _is_ a simple type, just cast it. - static typename cast_retty<To, FromTy>::ret_type doit(const FromTy &Val) { - return reinterpret_cast<typename cast_retty<To, FromTy>::ret_type>( - const_cast<FromTy&>(Val)); - } -}; - - - -// cast<X> - Return the argument parameter cast to the specified type. This -// casting operator asserts that the type is correct, so it does not ret |