diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-23 14:19:52 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-23 14:19:52 +0000 |
commit | 9643cca39fb9fb3b49a8912926de98acf882283c (patch) | |
tree | 22cc59e4b240d84c3a5a60531119c4eca914a256 /include/llvm | |
parent | 1adacceba9c9ee0f16e54388e56c9a249b296f75 (diff) | |
download | FreeBSD-src-9643cca39fb9fb3b49a8912926de98acf882283c.zip FreeBSD-src-9643cca39fb9fb3b49a8912926de98acf882283c.tar.gz |
Update LLVM to r84949.
Diffstat (limited to 'include/llvm')
58 files changed, 1752 insertions, 452 deletions
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index 4d7e7ae..30d998f 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -125,6 +125,7 @@ namespace llvm { public: /* We support the following floating point semantics. */ + static const fltSemantics IEEEhalf; static const fltSemantics IEEEsingle; static const fltSemantics IEEEdouble; static const fltSemantics IEEEquad; @@ -321,12 +322,14 @@ namespace llvm { opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int, roundingMode); + APInt convertHalfAPFloatToAPInt() const; APInt convertFloatAPFloatToAPInt() const; APInt convertDoubleAPFloatToAPInt() const; APInt convertQuadrupleAPFloatToAPInt() const; APInt convertF80LongDoubleAPFloatToAPInt() const; APInt convertPPCDoubleDoubleAPFloatToAPInt() const; void initFromAPInt(const APInt& api, bool isIEEE = false); + void initFromHalfAPInt(const APInt& api); void initFromFloatAPInt(const APInt& api); void initFromDoubleAPInt(const APInt& api); void initFromQuadrupleAPInt(const APInt &api); diff --git a/include/llvm/ADT/DenseMapInfo.h b/include/llvm/ADT/DenseMapInfo.h index 52ac5f9..2f241c5 100644 --- a/include/llvm/ADT/DenseMapInfo.h +++ b/include/llvm/ADT/DenseMapInfo.h @@ -76,7 +76,7 @@ template<> struct DenseMapInfo<unsigned long> { static inline unsigned long getEmptyKey() { return ~0UL; } static inline unsigned long getTombstoneKey() { return ~0UL - 1L; } static unsigned getHashValue(const unsigned long& Val) { - return Val * 37UL; + return (unsigned)(Val * 37UL); } static bool isPod() { return true; } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { @@ -89,7 +89,7 @@ template<> struct DenseMapInfo<unsigned long long> { static inline unsigned long long getEmptyKey() { return ~0ULL; } static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return (unsigned)Val * 37ULL; + return (unsigned)(Val * 37ULL); } static bool isPod() { return true; } static bool isEqual(const unsigned long long& LHS, diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index c62c47d..26090ce 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -19,7 +19,6 @@ #include "llvm/Support/DataTypes.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include <iterator> namespace llvm { class APFloat; diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index 3d1993c..899823d 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -16,6 +16,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/StringRef.h" #include <cctype> #include <cstdio> #include <string> @@ -216,14 +217,18 @@ void SplitString(const std::string &Source, std::vector<std::string> &OutFragments, const char *Delimiters = " \t\n\v\f\r"); -/// UnescapeString - Modify the argument string, turning two character sequences -/// like '\\' 'n' into '\n'. This handles: \e \a \b \f \n \r \t \v \' \\ and -/// \num (where num is a 1-3 byte octal value). -void UnescapeString(std::string &Str); - -/// EscapeString - Modify the argument string, turning '\\' and anything that -/// doesn't satisfy std::isprint into an escape sequence. -void EscapeString(std::string &Str); +/// HashString - Hash funtion for strings. +/// +/// This is the Bernstein hash function. +// +// FIXME: Investigate whether a modified bernstein hash function performs +// better: http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx +// X*33+c -> X*33^c +static inline unsigned HashString(StringRef Str, unsigned Result = 0) { + for (unsigned i = 0, e = Str.size(); i != e; ++i) + Result = Result * 33 + Str[i]; + return Result; +} } // End llvm namespace diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index aa7d577..2fa5c66 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -29,7 +29,7 @@ namespace llvm { typedef const char *iterator; static const size_t npos = ~size_t(0); typedef size_t size_type; - + private: /// The start of the string, in an external buffer. const char *Data; @@ -45,15 +45,15 @@ namespace llvm { /*implicit*/ StringRef() : Data(0), Length(0) {} /// Construct a string ref from a cstring. - /*implicit*/ StringRef(const char *Str) + /*implicit*/ StringRef(const char *Str) : Data(Str) { if (Str) Length = ::strlen(Str); else Length = 0; } - + /// Construct a string ref from a pointer and length. - /*implicit*/ StringRef(const char *data, unsigned length) + /*implicit*/ StringRef(const char *data, size_t length) : Data(data), Length(length) {} /// Construct a string ref from an std::string. - /*implicit*/ StringRef(const std::string &Str) + /*implicit*/ StringRef(const std::string &Str) : Data(Str.c_str()), Length(Str.length()) {} /// @} @@ -83,7 +83,7 @@ namespace llvm { assert(!empty()); return Data[0]; } - + /// back - Get the last character in the string. char back() const { assert(!empty()); @@ -93,7 +93,7 @@ namespace llvm { /// equals - Check for string equality, this is more efficient than /// compare() when the relative ordering of inequal strings isn't needed. bool equals(const StringRef &RHS) const { - return (Length == RHS.Length && + return (Length == RHS.Length && memcmp(Data, RHS.Data, RHS.Length) == 0); } @@ -117,9 +117,9 @@ namespace llvm { /// @name Operator Overloads /// @{ - char operator[](size_t Index) const { + char operator[](size_t Index) const { assert(Index < Length && "Invalid index!"); - return Data[Index]; + return Data[Index]; } /// @} @@ -135,7 +135,7 @@ namespace llvm { /// @{ /// startswith - Check if this string starts with the given \arg Prefix. - bool startswith(const StringRef &Prefix) const { + bool startswith(const StringRef &Prefix) const { return substr(0, Prefix.Length).equals(Prefix); } @@ -164,7 +164,7 @@ namespace llvm { /// \return - The index of the first occurence of \arg Str, or npos if not /// found. size_t find(const StringRef &Str) const; - + /// rfind - Search for the last character \arg C in the string. /// /// \return - The index of the last occurence of \arg C, or npos if not @@ -179,29 +179,29 @@ namespace llvm { } return npos; } - + /// rfind - Search for the last string \arg Str in the string. /// /// \return - The index of the last occurence of \arg Str, or npos if not /// found. size_t rfind(const StringRef &Str) const; - + /// find_first_of - Find the first instance of the specified character or /// return npos if not in string. Same as find. size_type find_first_of(char C) const { return find(C); } - + /// find_first_of - Find the first character from the string 'Chars' in the /// current string or return npos if not in string. size_type find_first_of(StringRef Chars) const; - + /// find_first_not_of - Find the first character in the string that is not /// in the string 'Chars' or return npos if all are in string. Same as find. size_type find_first_not_of(StringRef Chars) const; - + /// @} /// @name Helpful Algorithms /// @{ - + /// count - Return the number of occurrences of \arg C in the string. size_t count(char C) const { size_t Count = 0; @@ -210,11 +210,11 @@ namespace llvm { ++Count; return Count; } - + /// count - Return the number of non-overlapped occurrences of \arg Str in /// the string. size_t count(const StringRef &Str) const; - + /// getAsInteger - Parse the current string as an integer of the specified /// radix. If Radix is specified as zero, this does radix autosensing using /// extended C rules: 0 is octal, 0x is hex, 0b is binary. @@ -229,7 +229,7 @@ namespace llvm { bool getAsInteger(unsigned Radix, unsigned &Result) const; // TODO: Provide overloads for int/unsigned that check for overflow. - + /// @} /// @name Substring Operations /// @{ @@ -308,24 +308,24 @@ namespace llvm { return LHS.equals(RHS); } - inline bool operator!=(const StringRef &LHS, const StringRef &RHS) { + inline bool operator!=(const StringRef &LHS, const StringRef &RHS) { return !(LHS == RHS); } - + inline bool operator<(const StringRef &LHS, const StringRef &RHS) { - return LHS.compare(RHS) == -1; + return LHS.compare(RHS) == -1; } inline bool operator<=(const StringRef &LHS, const StringRef &RHS) { - return LHS.compare(RHS) != 1; + return LHS.compare(RHS) != 1; } inline bool operator>(const StringRef &LHS, const StringRef &RHS) { - return LHS.compare(RHS) == 1; + return LHS.compare(RHS) == 1; } inline bool operator>=(const StringRef &LHS, const StringRef &RHS) { - return LHS.compare(RHS) != -1; + return LHS.compare(RHS) != -1; } /// @} diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 89736bc..7fb0014 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -95,7 +95,8 @@ public: NetBSD, OpenBSD, Solaris, - Win32 + Win32, + Haiku }; private: diff --git a/include/llvm/ADT/ValueMap.h b/include/llvm/ADT/ValueMap.h new file mode 100644 index 0000000..14f2100 --- /dev/null +++ b/include/llvm/ADT/ValueMap.h @@ -0,0 +1,365 @@ +//===- llvm/ADT/ValueMap.h - Safe map from Values to data -------*- 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 the ValueMap class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_VALUEMAP_H +#define LLVM_ADT_VALUEMAP_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/ValueHandle.h" +#include "llvm/Support/type_traits.h" +#include "llvm/System/Mutex.h" + +#include <iterator> + +namespace llvm { + +template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT> +class ValueMapCallbackVH; + +template<typename DenseMapT, typename KeyT> +class ValueMapIterator; +template<typename DenseMapT, typename KeyT> +class ValueMapConstIterator; + +template<typename KeyT> +struct ValueMapConfig { + /// If FollowRAUW is true, the ValueMap will update mappings on RAUW. If it's + /// false, the ValueMap will leave the original mapping in place. + enum { FollowRAUW = true }; + + // All methods will be called with a first argument of type ExtraData. The + // default implementations in this class take a templated first argument so + // that users' subclasses can use any type they want without having to + // override all the defaults. + struct ExtraData {}; + + template<typename ExtraDataT> + static void onRAUW(const ExtraDataT &Data, KeyT Old, KeyT New) {} + template<typename ExtraDataT> + static void onDeleted(const ExtraDataT &Data, KeyT Old) {} + + /// Returns a mutex that should be acquired around any changes to the map. + /// This is only acquired from the CallbackVH (and held around calls to onRAUW + /// and onDeleted) and not inside other ValueMap methods. NULL means that no + /// mutex is necessary. + template<typename ExtraDataT> + static sys::Mutex *getMutex(const ExtraDataT &Data) { return NULL; } +}; + +/// ValueMap maps Value* or any subclass to an arbitrary other +/// type. It provides the DenseMap interface. When the key values are +/// deleted or RAUWed, ValueMap relies on the Config to decide what to +/// do. Config parameters should inherit from ValueMapConfig<KeyT> to +/// get default implementations of all the methods ValueMap uses. +/// +/// By default, when a key is RAUWed from V1 to V2, the old mapping +/// V1->target is removed, and a new mapping V2->target is added. If +/// V2 already existed, its old target is overwritten. When a key is +/// deleted, its mapping is removed. You can override Config to get +/// called back on each event. +template<typename KeyT, typename ValueT, typename Config = ValueMapConfig<KeyT>, + typename ValueInfoT = DenseMapInfo<ValueT> > +class ValueMap { + friend class ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT>; + typedef ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> ValueMapCVH; + typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>, + ValueInfoT> MapT; + typedef typename Config::ExtraData ExtraData; + MapT Map; + ExtraData Data; +public: + typedef KeyT key_type; + typedef ValueT mapped_type; + typedef std::pair<KeyT, ValueT> value_type; + + ValueMap(const ValueMap& Other) : Map(Other.Map), Data(Other.Data) {} + + explicit ValueMap(unsigned NumInitBuckets = 64) + : Map(NumInitBuckets), Data() {} + explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64) + : Map(NumInitBuckets), Data(Data) {} + + ~ValueMap() {} + + typedef ValueMapIterator<MapT, KeyT> iterator; + typedef ValueMapConstIterator<MapT, KeyT> const_iterator; + inline iterator begin() { return iterator(Map.begin()); } + inline iterator end() { return iterator(Map.end()); } + inline const_iterator begin() const { return const_iterator(Map.begin()); } + inline const_iterator end() const { return const_iterator(Map.end()); } + + bool empty() const { return Map.empty(); } + unsigned size() const { return Map.size(); } + + /// Grow the map so that it has at least Size buckets. Does not shrink + void resize(size_t Size) { Map.resize(Size); } + + void clear() { Map.clear(); } + + /// count - Return true if the specified key is in the map. + bool count(const KeyT &Val) const { + return Map.count(Wrap(Val)); + } + + iterator find(const KeyT &Val) { + return iterator(Map.find(Wrap(Val))); + } + const_iterator find(const KeyT &Val) const { + return const_iterator(Map.find(Wrap(Val))); + } + + /// lookup - Return the entry for the specified key, or a default + /// constructed value if no such entry exists. + ValueT lookup(const KeyT &Val) const { + return Map.lookup(Wrap(Val)); + } + + // Inserts key,value pair into the map if the key isn't already in the map. + // If the key is already in the map, it returns false and doesn't update the + // value. + std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) { + std::pair<typename MapT::iterator, bool> map_result= + Map.insert(std::make_pair(Wrap(KV.first), KV.second)); + return std::make_pair(iterator(map_result.first), map_result.second); + } + + /// insert - Range insertion of pairs. + template<typename InputIt> + void insert(InputIt I, InputIt E) { + for (; I != E; ++I) + insert(*I); + } + + + bool erase(const KeyT &Val) { + return Map.erase(Wrap(Val)); + } + bool erase(iterator I) { + return Map.erase(I.base()); + } + + value_type& FindAndConstruct(const KeyT &Key) { + return Map.FindAndConstruct(Wrap(Key)); + } + + ValueT &operator[](const KeyT &Key) { + return Map[Wrap(Key)]; + } + + ValueMap& operator=(const ValueMap& Other) { + Map = Other.Map; + Data = Other.Data; + return *this; + } + + /// isPointerIntoBucketsArray - Return true if the specified pointer points + /// somewhere into the ValueMap's array of buckets (i.e. either to a key or + /// value in the ValueMap). + bool isPointerIntoBucketsArray(const void *Ptr) const { + return Map.isPointerIntoBucketsArray(Ptr); + } + + /// getPointerIntoBucketsArray() - Return an opaque pointer into the buckets + /// array. In conjunction with the previous method, this can be used to + /// determine whether an insertion caused the ValueMap to reallocate. + const void *getPointerIntoBucketsArray() const { + return Map.getPointerIntoBucketsArray(); + } + +private: + ValueMapCVH Wrap(KeyT key) const { + // The only way the resulting CallbackVH could try to modify *this (making + // the const_cast incorrect) is if it gets inserted into the map. But then + // this function must have been called from a non-const method, making the + // const_cast ok. + return ValueMapCVH(key, const_cast<ValueMap*>(this)); + } +}; + +template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT> +class ValueMapCallbackVH : public CallbackVH { + friend class ValueMap<KeyT, ValueT, Config, ValueInfoT>; + friend class DenseMapInfo<ValueMapCallbackVH>; + typedef ValueMap<KeyT, ValueT, Config, ValueInfoT> ValueMapT; + typedef typename llvm::remove_pointer<KeyT>::type KeySansPointerT; + + ValueMapT *Map; + + ValueMapCallbackVH(KeyT Key, ValueMapT *Map) + : CallbackVH(const_cast<Value*>(static_cast<const Value*>(Key))), + Map(Map) {} + +public: + KeyT Unwrap() const { return cast_or_null<KeySansPointerT>(getValPtr()); } + + virtual void deleted() { + // Make a copy that won't get changed even when *this is destroyed. + ValueMapCallbackVH Copy(*this); + sys::Mutex *M = Config::getMutex(Copy.Map->Data); + if (M) + M->acquire(); + Config::onDeleted(Copy.Map->Data, Copy.Unwrap()); // May destroy *this. + Copy.Map->Map.erase(Copy); // Definitely destroys *this. + if (M) + M->release(); + } + virtual void allUsesReplacedWith(Value *new_key) { + assert(isa<KeySansPointerT>(new_key) && + "Invalid RAUW on key of ValueMap<>"); + // Make a copy that won't get changed even when *this is destroyed. + ValueMapCallbackVH Copy(*this); + sys::Mutex *M = Config::getMutex(Copy.Map->Data); + if (M) + M->acquire(); + + KeyT typed_new_key = cast<KeySansPointerT>(new_key); + // Can destroy *this: + Config::onRAUW(Copy.Map->Data, Copy.Unwrap(), typed_new_key); + if (Config::FollowRAUW) { + typename ValueMapT::MapT::iterator I = Copy.Map->Map.find(Copy); + // I could == Copy.Map->Map.end() if the onRAUW callback already + // removed the old mapping. + if (I != Copy.Map->Map.end()) { + ValueT Target(I->second); + Copy.Map->Map.erase(I); // Definitely destroys *this. + Copy.Map->insert(std::make_pair(typed_new_key, Target)); + } + } + if (M) + M->release(); + } +}; + +template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT> +struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> > { + typedef ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> VH; + typedef DenseMapInfo<KeyT> PointerInfo; + + static inline VH getEmptyKey() { + return VH(PointerInfo::getEmptyKey(), NULL); + } + static inline VH getTombstoneKey() { + return VH(PointerInfo::getTombstoneKey(), NULL); + } + static unsigned getHashValue(const VH &Val) { + return PointerInfo::getHashValue(Val.Unwrap()); + } + static bool isEqual(const VH &LHS, const VH &RHS) { + return LHS == RHS; + } + static bool isPod() { return false; } +}; + + +template<typename DenseMapT, typename KeyT> +class ValueMapIterator : + public std::iterator<std::forward_iterator_tag, + std::pair<KeyT, typename DenseMapT::mapped_type>, + ptrdiff_t> { + typedef typename DenseMapT::iterator BaseT; + typedef typename DenseMapT::mapped_type ValueT; + BaseT I; +public: + ValueMapIterator() : I() {} + + ValueMapIterator(BaseT I) : I(I) {} + + BaseT base() const { return I; } + + struct ValueTypeProxy { + const KeyT first; + ValueT& second; + ValueTypeProxy *operator->() { return this; } + operator std::pair<KeyT, ValueT>() const { + return std::make_pair(first, second); + } + }; + + ValueTypeProxy operator*() const { + ValueTypeProxy Result = {I->first.Unwrap(), I->second}; + return Result; + } + + ValueTypeProxy operator->() const { + return operator*(); + } + + bool operator==(const ValueMapIterator &RHS) const { + return I == RHS.I; + } + bool operator!=(const ValueMapIterator &RHS) const { + return I != RHS.I; + } + + inline ValueMapIterator& operator++() { // Preincrement + ++I; + return *this; + } + ValueMapIterator operator++(int) { // Postincrement + ValueMapIterator tmp = *this; ++*this; return tmp; + } +}; + +template<typename DenseMapT, typename KeyT> +class ValueMapConstIterator : + public std::iterator<std::forward_iterator_tag, + std::pair<KeyT, typename DenseMapT::mapped_type>, + ptrdiff_t> { + typedef typename DenseMapT::const_iterator BaseT; + typedef typename DenseMapT::mapped_type ValueT; + BaseT I; +public: + ValueMapConstIterator() : I() {} + ValueMapConstIterator(BaseT I) : I(I) {} + ValueMapConstIterator(ValueMapIterator<DenseMapT, KeyT> Other) + : I(Other.base()) {} + + BaseT base() const { return I; } + + struct ValueTypeProxy { + const KeyT first; + const ValueT& second; + ValueTypeProxy *operator->() { return this; } + operator std::pair<KeyT, ValueT>() const { + return std::make_pair(first, second); + } + }; + + ValueTypeProxy operator*() const { + ValueTypeProxy Result = {I->first.Unwrap(), I->second}; + return Result; + } + + ValueTypeProxy operator->() const { + return operator*(); + } + + bool operator==(const ValueMapConstIterator &RHS) const { + return I == RHS.I; + } + bool operator!=(const ValueMapConstIterator &RHS) const { + return I != RHS.I; + } + + inline ValueMapConstIterator& operator++() { // Preincrement + ++I; + return *this; + } + ValueMapConstIterator operator++(int) { // Postincrement + ValueMapConstIterator tmp = *this; ++*this; return tmp; + } +}; + +} // end namespace llvm + +#endif diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h index 6a479d1..435f8ea 100644 --- a/include/llvm/Analysis/CFGPrinter.h +++ b/include/llvm/Analysis/CFGPrinter.h @@ -15,6 +15,67 @@ #ifndef LLVM_ANALYSIS_CFGPRINTER_H #define LLVM_ANALYSIS_CFGPRINTER_H +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/Assembly/Writer.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/GraphWriter.h" + +namespace llvm { +template<> +struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits { + static std::string getGraphName(const Function *F) { + return "CFG for '" + F->getNameStr() + "' function"; + } + + static std::string getNodeLabel(const BasicBlock *Node, + const Function *Graph, + bool ShortNames) { + if (ShortNames && !Node->getName().empty()) + return Node->getNameStr() + ":"; + + std::string Str; + raw_string_ostream OS(Str); + + if (ShortNames) { + WriteAsOperand(OS, Node, false); + return OS.str(); + } + + if (Node->getName().empty()) { + WriteAsOperand(OS, Node, false); + OS << ":"; + } + + OS << *Node; + std::string OutStr = OS.str(); + if (OutStr[0] == '\n') OutStr.erase(OutStr.begin()); + + // Process string output to make it nicer... + for (unsigned i = 0; i != OutStr.length(); ++i) + if (OutStr[i] == '\n') { // Left justify + OutStr[i] = '\\'; + OutStr.insert(OutStr.begin()+i+1, 'l'); + } else if (OutStr[i] == ';') { // Delete comments! + unsigned Idx = OutStr.find('\n', i+1); // Find end of line + OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx); + --i; + } + + return OutStr; + } + + static std::string getEdgeSourceLabel(const BasicBlock *Node, + succ_const_iterator I) { + // Label source of conditional branches with "T" or "F" + if (const BranchInst *BI = dyn_cast<BranchInst>(Node->getTerminator())) + if (BI->isConditional()) + return (I == succ_begin(Node)) ? "T" : "F"; + return ""; + } +}; +} // End llvm namespace + namespace llvm { class FunctionPass; FunctionPass *createCFGPrinterPass (); diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index bcb6dee..287fe4f 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -51,9 +51,10 @@ #ifndef LLVM_ANALYSIS_CALLGRAPH_H #define LLVM_ANALYSIS_CALLGRAPH_H +#include "llvm/Function.h" +#include "llvm/Pass.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/Pass.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/IncludeFile.h" diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 9805c6c..78a16da 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -62,6 +62,10 @@ Constant *ConstantFoldCompareInstOperands(unsigned Predicate, LLVMContext &Context, const TargetData *TD = 0); +/// ConstantFoldLoadFromConstPtr - Return the value that a load from C would +/// produce if it is constant and determinable. If this is not determinable, +/// return null. +Constant *ConstantFoldLoadFromConstPtr(Constant *C, const TargetData *TD = 0); /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a /// getelementptr constantexpr, return the constant value being addressed by the diff --git a/include/llvm/Analysis/DomPrinter.h b/include/llvm/Analysis/DomPrinter.h new file mode 100644 index 0000000..0ed2899 --- /dev/null +++ b/include/llvm/Analysis/DomPrinter.h @@ -0,0 +1,30 @@ +//===-- DomPrinter.h - Dom printer external interface ------------*- 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 external functions that can be called to explicitly +// instantiate the dominance tree printer. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_DOMPRINTER_H +#define LLVM_ANALYSIS_DOMPRINTER_H + +namespace llvm { + class FunctionPass; + FunctionPass *createDomPrinterPass(); + FunctionPass *createDomOnlyPrinterPass(); + FunctionPass *createDomViewerPass(); + FunctionPass *createDomOnlyViewerPass(); + FunctionPass *createPostDomPrinterPass(); + FunctionPass *createPostDomOnlyPrinterPass(); + FunctionPass *createPostDomViewerPass(); + FunctionPass *createPostDomOnlyViewerPass(); +} // End llvm namespace + +#endif diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index f63e31c..59ce6e7 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -25,6 +25,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -824,26 +825,44 @@ public: /// DominatorTree GraphTraits specialization so the DominatorTree can be /// iterable by generic graph iterators. /// -template <> struct GraphTraits<DomTreeNode *> { +template <> struct GraphTraits<DomTreeNode*> { typedef DomTreeNode NodeType; typedef NodeType::iterator ChildIteratorType; static NodeType *getEntryNode(NodeType *N) { return N; } - static inline ChildIteratorType child_begin(NodeType* N) { + static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType* N) { + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } + + typedef df_iterator<DomTreeNode*> nodes_iterator; + + static nodes_iterator nodes_begin(DomTreeNode *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DomTreeNode *N) { + return df_end(getEntryNode(N)); + } }; template <> struct GraphTraits<DominatorTree*> - : public GraphTraits<DomTreeNode *> { + : public GraphTraits<DomTreeNode*> { static NodeType *getEntryNode(DominatorTree *DT) { return DT->getRootNode(); } + + static nodes_iterator nodes_begin(DominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DominatorTree *N) { + return df_end(getEntryNode(N)); + } }; diff --git a/include/llvm/Analysis/MallocHelper.h b/include/llvm/Analysis/MallocHelper.h index 0588dff..e0c4d2c 100644 --- a/include/llvm/Analysis/MallocHelper.h +++ b/include/llvm/Analysis/MallocHelper.h @@ -46,9 +46,9 @@ CallInst* extractMallocCallFromBitCast(Value* I); /// matches the malloc call IR generated by CallInst::CreateMalloc(). This /// means that it is a malloc call with one bitcast use AND the malloc call's /// size argument is: -/// 1. a constant not equal to the malloc's allocated type +/// 1. a constant not equal to the size of the malloced type /// or -/// 2. the result of a multiplication by the malloc's allocated type +/// 2. the result of a multiplication by the size of the malloced type /// Otherwise it returns NULL. /// The unique bitcast is needed to determine the type/size of the array /// allocation. @@ -66,18 +66,17 @@ const PointerType* getMallocType(const CallInst* CI); /// unique bitcast use, then return NULL. const Type* getMallocAllocatedType(const CallInst* CI); -/// getMallocArraySize - Returns the array size of a malloc call. The array -/// size is computated in 1 of 3 ways: -/// 1. If the element type if of size 1, then array size is the argument to +/// getMallocArraySize - Returns the array size of a malloc call. For array +/// mallocs, the size is computated in 1 of 3 ways: +/// 1. If the element type is of size 1, then array size is the argument to /// malloc. /// 2. Else if the malloc's argument is a constant, the array size is that /// argument divided by the element type's size. /// 3. Else the malloc argument must be a multiplication and the array size is /// the first operand of the multiplication. -/// This function returns constant 1 if: -/// 1. The malloc call's allocated type cannot be determined. -/// 2. IR wasn't created by a call to CallInst::CreateMalloc() with a non-NULL -/// ArraySize. +/// For non-array mallocs, the computed size is constant 1. +/// This function returns NULL for all mallocs whose array size cannot be +/// determined. Value* getMallocArraySize(CallInst* CI, LLVMContext &Context, const TargetData* TD); diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index 171cfdb..42a16e7 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -74,6 +74,21 @@ struct PostDominatorTree : public FunctionPass { FunctionPass* createPostDomTree(); +template <> struct GraphTraits<PostDominatorTree*> + : public GraphTraits<DomTreeNode*> { + static NodeType *getEntryNode(PostDominatorTree *DT) { + return DT->getRootNode(); + } + + static nodes_iterator nodes_begin(PostDominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(PostDominatorTree *N) { + return df_end(getEntryNode(N)); + } +}; + /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is /// used to compute the a post-dominance frontier. /// diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index b5479ba..a04189c 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -86,6 +86,10 @@ class MachineFrameInfo { // StackObject - Represent a single object allocated on the stack. struct StackObject { + // SPOffset - The offset of this object from the stack pointer on entry to + // the function. This field has no meaning for a variable sized element. + int64_t SPOffset; + // The size of this object on the stack. 0 means a variable sized object, // ~0ULL means a dead object. uint64_t Size; @@ -98,12 +102,14 @@ class MachineFrameInfo { // default, fixed objects are immutable unless marked otherwise. bool isImmutable; - // SPOffset - The offset of this object from the stack pointer on entry to - // the function. This field has no meaning for a variable sized element. - int64_t SPOffset; - - StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false) - : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {} + // isSpillSlot - If true, the stack object is used as spill slot. It + // cannot alias any other memory objects. + bool isSpillSlot; + + StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false, + bool isSS = false) + : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), + isSpillSlot(isSS) {} }; /// Objects - The list of stack objects allocated... @@ -352,6 +358,14 @@ public: return Objects[ObjectIdx+NumFixedObjects].isImmutable; } + /// isSpillSlotObjectIndex - Returns true if the specified index corresponds + /// to a spill slot.. + bool isSpillSlotObjectIndex(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;; + } + /// isDeadObjectIndex - Returns true if the specified index corresponds to /// a dead object. bool isDeadObjectIndex(int ObjectIdx) const { @@ -363,9 +377,9 @@ public: /// CreateStackObject - Create a new statically sized stack object, returning /// a nonnegative identifier to represent it. /// - int CreateStackObject(uint64_t Size, unsigned Alignment) { + int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS = false) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); - Objects.push_back(StackObject(Size, Alignment)); + Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); return (int)Objects.size()-NumFixedObjects-1; } diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index ba831ca..40260ea 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -267,6 +267,9 @@ public: void splice(iterator InsertPt, iterator MBBI) { BasicBlocks.splice(InsertPt, BasicBlocks, MBBI); } + void splice(iterator InsertPt, iterator MBBI, iterator MBBE) { + BasicBlocks.splice(InsertPt, BasicBlocks, MBBI, MBBE); + } void remove(iterator MBBI) { BasicBlocks.remove(MBBI); diff --git a/include/llvm/CodeGen/MachineLoopInfo.h b/include/llvm/CodeGen/MachineLoopInfo.h index 65ad4e4..d3df805 100644 --- a/include/llvm/CodeGen/MachineLoopInfo.h +++ b/include/llvm/CodeGen/MachineLoopInfo.h @@ -38,6 +38,17 @@ namespace llvm { class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> { public: MachineLoop(); + + /// getTopBlock - Return the "top" block in the loop, which is the first + /// block in the linear layout, ignoring any parts of the loop not + /// contiguous with the part the contains the header. + MachineBasicBlock *getTopBlock(); + + /// getBottomBlock - Return the "bottom" block in the loop, which is the last + /// block in the linear layout, ignoring any parts of the loop not + /// contiguous with the part the contains the header. + MachineBasicBlock *getBottomBlock(); + private: friend class LoopInfoBase<MachineBasicBlock, MachineLoop>; explicit MachineLoop(MachineBasicBlock *MBB) diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h index 5878d67..1b924f2 100644 --- a/include/llvm/CodeGen/MachineModuleInfo.h +++ b/include/llvm/CodeGen/MachineModuleInfo.h @@ -150,7 +150,8 @@ class MachineModuleInfo : public ImmutablePass { public: static char ID; // Pass identification, replacement for typeid - typedef SmallVector< std::pair< WeakMetadataVH, unsigned>, 4 > VariableDbgInfoMapTy; + typedef SmallVector< std::pair<TrackingVH<MDNode>, unsigned>, 4 > + VariableDbgInfoMapTy; VariableDbgInfoMapTy VariableDbgInfo; MachineModuleInfo(); diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 1e7115e..d0d6103 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -15,13 +15,13 @@ #ifndef LLVM_CODEGEN_PASSES_H #define LLVM_CODEGEN_PASSES_H +#include "llvm/Target/TargetMachine.h" #include <string> namespace llvm { class FunctionPass; class PassInfo; - class TargetMachine; class TargetLowering; class RegisterCoalescer; class raw_ostream; @@ -119,8 +119,9 @@ namespace llvm { /// FunctionPass *createLowerSubregsPass(); - /// createPostRAScheduler - under development. - FunctionPass *createPostRAScheduler(); + /// createPostRAScheduler - This pass performs post register allocation + /// scheduling. + FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel); /// BranchFolding Pass - This pass performs machine code CFG based /// optimizations to delete branches to branches, eliminate branches to diff --git a/include/llvm/CodeGen/PseudoSourceValue.h b/include/llvm/CodeGen/PseudoSourceValue.h index c6be645..7a9122d 100644 --- a/include/llvm/CodeGen/PseudoSourceValue.h +++ b/include/llvm/CodeGen/PseudoSourceValue.h @@ -39,6 +39,10 @@ namespace llvm { /// virtual bool isConstant(const MachineFrameInfo *) const; + /// isAliased - Test whether the memory pointed to by this + /// PseudoSourceValue may also be pointed to by an LLVM IR Value. + virtual bool isAliased(const MachineFrameInfo *) const; + /// classof - Methods for support type inquiry through isa, cast, and /// dyn_cast: /// diff --git a/include/llvm/CompilerDriver/Common.td b/include/llvm/CompilerDriver/Common.td index 5b7c543..79edb02 100644 --- a/include/llvm/CompilerDriver/Common.td +++ b/include/llvm/CompilerDriver/Common.td @@ -68,6 +68,9 @@ def not_empty; def default; def single_input_file; def multiple_input_files; +def any_switch_on; +def any_not_empty; +def any_empty; // Possible actions. @@ -76,7 +79,9 @@ def forward; def forward_as; def stop_compilation; def unpack_values; +def warning; def error; +def unset_option; // Increase/decrease the edge weight. def inc_weight; @@ -90,11 +95,16 @@ class PluginPriority<int p> { int priority = p; } -// Option list - used to specify aliases and sometimes help strings. +// Option list - a single place to specify options. class OptionList<list<dag> l> { list<dag> options = l; } +// Option preprocessor - actions taken during plugin loading. +class OptionPreprocessor<dag d> { + dag preprocessor = d; +} + // Map from suffixes to language names class LangToSuffixes<string str, list<string> lst> { diff --git a/include/llvm/CompilerDriver/Plugin.h b/include/llvm/CompilerDriver/Plugin.h index 9f9eee3..e9a2048 100644 --- a/include/llvm/CompilerDriver/Plugin.h +++ b/include/llvm/CompilerDriver/Plugin.h @@ -29,6 +29,11 @@ namespace llvmc { /// first. virtual int Priority() const { return 0; } + /// PreprocessOptions - The auto-generated function that performs various + /// consistency checks on options (like ensuring that -O2 and -O3 are not + /// used together). + virtual void PreprocessOptions() const = 0; + /// PopulateLanguageMap - The auto-generated function that fills in /// the language map (map from file extensions to language names). virtual void PopulateLanguageMap(LanguageMap&) const = 0; @@ -60,13 +65,10 @@ namespace llvmc { PluginLoader(); ~PluginLoader(); - /// PopulateLanguageMap - Fills in the language map by calling - /// PopulateLanguageMap methods of all plugins. - void PopulateLanguageMap(LanguageMap& langMap); - - /// PopulateCompilationGraph - Populates the compilation graph by - /// calling PopulateCompilationGraph methods of all plugins. - void PopulateCompilationGraph(CompilationGraph& tools); + /// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and + /// PopulateCompilationGraph methods of all plugins. This populates the + /// global language map and the compilation graph. + void RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const; private: // noncopyable diff --git a/include/llvm/Config/AsmParsers.def b/include/llvm/Config/AsmParsers.def new file mode 100644 index 0000000..63590b3 --- /dev/null +++ b/include/llvm/Config/AsmParsers.def @@ -0,0 +1,29 @@ +//===- llvm/Config/AsmParsers.def - LLVM Assembly Parsers -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file enumerates all of the assembly-language parsers +// supported by this build of LLVM. Clients of this file should define +// the LLVM_ASM_PARSER macro to be a function-like macro with a +// single parameter (the name of the target whose assembly can be +// generated); including this file will then enumerate all of the +// targets with assembly parsers. +// +// The set of targets supported by LLVM is generated at configuration +// time, at which point this header is generated. Do not modify this +// header directly. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASM_PARSER +# error Please define the macro LLVM_ASM_PARSER(TargetName) +#endif + +LLVM_ASM_PARSER(ARM) LLVM_ASM_PARSER(X86) + +#undef LLVM_ASM_PARSER diff --git a/include/llvm/Config/AsmPrinters.def b/include/llvm/Config/AsmPrinters.def new file mode 100644 index 0000000..953af51 --- /dev/null +++ b/include/llvm/Config/AsmPrinters.def @@ -0,0 +1,29 @@ +//===- llvm/Config/AsmPrinters.def - LLVM Assembly Printers -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file enumerates all of the assembly-language printers +// supported by this build of LLVM. Clients of this file should define +// the LLVM_ASM_PRINTER macro to be a function-like macro with a +// single parameter (the name of the target whose assembly can be +// generated); including this file will then enumerate all of the +// targets with assembly printers. +// +// The set of targets supported by LLVM is generated at configuration +// time, at which point this header is generated. Do not modify this +// header directly. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASM_PRINTER +# error Please define the macro LLVM_ASM_PRINTER(TargetName) +#endif + +LLVM_ASM_PRINTER(Blackfin) LLVM_ASM_PRINTER(SystemZ) LLVM_ASM_PRINTER(MSP430) LLVM_ASM_PRINTER(XCore) LLVM_ASM_PRINTER(PIC16) LLVM_ASM_PRINTER(CellSPU) LLVM_ASM_PRINTER(Mips) LLVM_ASM_PRINTER(ARM) LLVM_ASM_PRINTER(Alpha) LLVM_ASM_PRINTER(PowerPC) LLVM_ASM_PRINTER(Sparc) LLVM_ASM_PRINTER(X86) + +#undef LLVM_ASM_PRINTER diff --git a/include/llvm/Config/Targets.def b/include/llvm/Config/Targets.def new file mode 100644 index 0000000..2008c0c --- /dev/null +++ b/include/llvm/Config/Targets.def @@ -0,0 +1,28 @@ +/*===- llvm/Config/Targets.def - LLVM Target Architectures ------*- C++ -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This file enumerates all of the target architectures supported by *| +|* this build of LLVM. Clients of this file should define the *| +|* LLVM_TARGET macro to be a function-like macro with a single *| +|* parameter (the name of the target); including this file will then *| +|* enumerate all of the targets. *| +|* *| +|* The set of targets supported by LLVM is generated at configuration *| +|* time, at which point this header is generated. Do not modify this *| +|* header directly. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_TARGET +# error Please define the macro LLVM_TARGET(TargetName) +#endif + +LLVM_TARGET(CppBackend) LLVM_TARGET(MSIL) LLVM_TARGET(CBackend) LLVM_TARGET(Blackfin) LLVM_TARGET(SystemZ) LLVM_TARGET(MSP430) LLVM_TARGET(XCore) LLVM_TARGET(PIC16) LLVM_TARGET(CellSPU) LLVM_TARGET(Mips) LLVM_TARGET(ARM) LLVM_TARGET(Alpha) LLVM_TARGET(PowerPC) LLVM_TARGET(Sparc) LLVM_TARGET(X86) + +#undef LLVM_TARGET diff --git a/include/llvm/Config/config.h b/include/llvm/Config/config.h new file mode 100644 index 0000000..b5a8713 --- /dev/null +++ b/include/llvm/Config/config.h @@ -0,0 +1,612 @@ +/* include/llvm/Config/config.h. Generated from config.h.in by configure. */ +/* include/llvm/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */ + +/* Define if dlopen(0) will open the symbols of the program */ +#define CAN_DLOPEN_SELF 1 + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define if CBE is enabled for printf %a output */ +#define ENABLE_CBE_PRINTF_A 1 + +/* Define if position independent code is enabled */ +#define ENABLE_PIC 1 + +/* Define if threads enabled */ +#define ENABLE_THREADS 1 + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the `argz_append' function. */ +/* #undef HAVE_ARGZ_APPEND */ + +/* Define to 1 if you have the `argz_create_sep' function. */ +/* #undef HAVE_ARGZ_CREATE_SEP */ + +/* Define to 1 if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define to 1 if you have the `argz_insert' function. */ +/* #undef HAVE_ARGZ_INSERT */ + +/* Define to 1 if you have the `argz_next' function. */ +/* #undef HAVE_ARGZ_NEXT */ + +/* Define to 1 if you have the `argz_stringify' function. */ +/* #undef HAVE_ARGZ_STRINGIFY */ + +/* Define to 1 if you have the <assert.h> header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the `backtrace' function. */ +/* #undef HAVE_BACKTRACE */ + +/* Define to 1 if you have the `bcopy' function. */ +/* #undef HAVE_BCOPY */ + +/* Does not have bi-directional iterator */ +#define HAVE_BI_ITERATOR 0 + +/* Define to 1 if you have the `ceilf' function. */ +#define HAVE_CEILF 1 + +/* Define if the neat program is available */ +/* #undef HAVE_CIRCO */ + +/* Define to 1 if you have the `closedir' function. */ +#define HAVE_CLOSEDIR 1 + +/* Define to 1 if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the GNU dld library. */ +/* #undef HAVE_DLD */ + +/* Define to 1 if you have the <dld.h> header file. */ +/* #undef HAVE_DLD_H */ + +/* Define to 1 if you have the `dlerror' function. */ +#define HAVE_DLERROR 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define if dlopen() is available on this platform. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the <dl.h> header file. */ +/* #undef HAVE_DL_H */ + +/* Define if the dot program is available */ +/* #undef HAVE_DOT */ + +/* Define if the dotty program is available */ +/* #undef HAVE_DOTTY */ + +/* Define if you have the _dyld_func_lookup function. */ +/* #undef HAVE_DYLD */ + +/* Define to 1 if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if the system has the type `error_t'. */ +/* #undef HAVE_ERROR_T */ + +/* Define to 1 if you have the <execinfo.h> header file. */ +/* #undef HAVE_EXECINFO_H */ + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if the neat program is available */ +/* #undef HAVE_FDP */ + +/* Define if libffi is available on this platform. */ +/* #undef HAVE_FFI_CALL */ + +/* Define to 1 if you have the <ffi/ffi.h> header file. */ +/* #undef HAVE_FFI_FFI_H */ + +/* Define to 1 if you have the <ffi.h> header file. */ +/* #undef HAVE_FFI_H */ + +/* Set to 1 if the finite function is found in <ieeefp.h> */ +/* #undef HAVE_FINITE_IN_IEEEFP_H */ + +/* Define to 1 if you have the `floorf' function. */ +#define HAVE_FLOORF 1 + +/* Define to 1 if you have the `fmodf' function. */ +#define HAVE_FMODF 1 + +/* Does not have forward iterator */ +#define HAVE_FWD_ITERATOR 0 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getrlimit' function. */ +#define HAVE_GETRLIMIT 1 + +/* Define to 1 if you have the `getrusage' function. */ +#define HAVE_GETRUSAGE 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define if the Graphviz program is available */ +/* #undef HAVE_GRAPHVIZ */ + +/* Define if the gv program is available */ +/* #undef HAVE_GV */ + +/* Define to 1 if you have the `index' function. */ +/* #undef HAVE_INDEX */ + +/* Define to 1 if the system has the type `int64_t'. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isatty' function. */ +#define HAVE_ISATTY 1 + +/* Set to 1 if the isinf function is found in <cmath> */ +#define HAVE_ISINF_IN_CMATH 1 + +/* Set to 1 if the isinf function is found in <math.h> */ +#define HAVE_ISINF_IN_MATH_H 1 + +/* Set to 1 if the isnan function is found in <cmath> */ +#define HAVE_ISNAN_IN_CMATH 1 + +/* Set to 1 if the isnan function is found in <math.h> */ +#define HAVE_ISNAN_IN_MATH_H 1 + +/* Define if you have the libdl library or equivalent. */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `imagehlp' library (-limagehlp). */ +/* #undef HAVE_LIBIMAGEHLP */ + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Define to 1 if you have the `psapi' library (-lpsapi). */ +/* #undef HAVE_LIBPSAPI */ + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#define HAVE_LIBPTHREAD 1 + +/* Define to 1 if you have the `udis86' library (-ludis86). */ +/* #undef HAVE_LIBUDIS86 */ + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you can use -Wl,-export-dynamic. */ +#define HAVE_LINK_EXPORT_DYNAMIC 1 + +/* Define to 1 if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you can use -Wl,-R. to pass -R. to the linker, in order to add + the current directory to the dynamic linker search path. */ +#define HAVE_LINK_R 1 + +/* Define to 1 if you have the `longjmp' function. */ +#define HAVE_LONGJMP 1 + +/* Define to 1 if you have the <mach/mach.h> header file. */ +/* #undef HAVE_MACH_MACH_H */ + +/* Define to 1 if you have the <mach-o/dyld.h> header file. */ +/* #undef HAVE_MACH_O_DYLD_H */ + +/* Define if mallinfo() is available on this platform. */ +/* #undef HAVE_MALLINFO */ + +/* Define to 1 if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the <malloc/malloc.h> header file. */ +/* #undef HAVE_MALLOC_MALLOC_H */ + +/* Define to 1 if you have the `malloc_zone_statistics' function. */ +/* #undef HAVE_MALLOC_ZONE_STATISTICS */ + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkdtemp' function. */ +#define HAVE_MKDTEMP 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `mktemp' function. */ +#define HAVE_MKTEMP 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if mmap() uses MAP_ANONYMOUS to map anonymous pages, or undefine if + it uses MAP_ANON */ +/* #undef HAVE_MMAP_ANONYMOUS */ + +/* Define if mmap() can map files into memory */ +#define HAVE_MMAP_FILE + +/* define if the compiler implements namespaces */ +#define HAVE_NAMESPACES + +/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the `nearbyintf' function. */ +#define HAVE_NEARBYINTF 1 + +/* Define if the neat program is available */ +/* #undef HAVE_NEATO */ + +/* Define to 1 if you have the `opendir' function. */ +#define HAVE_OPENDIR 1 + +/* Define to 1 if you have the `powf' function. */ +#define HAVE_POWF 1 + +/* Define if libtool can extract symbol lists from object files. */ +#define HAVE_PRELOADED_SYMBOLS 1 + +/* Define to have the %a format string */ +#define HAVE_PRINTF_A 1 + +/* Have pthread_getspecific */ +#define HAVE_PTHREAD_GETSPECIFIC 1 + +/* Define to 1 if you have the <pthread.h> header file. */ +#define HAVE_PTHREAD_H 1 + +/* Have pthread_mutex_lock */ +#define HAVE_PTHREAD_MUTEX_LOCK 1 + +/* Have pthread_rwlock_init */ +#define HAVE_PTHREAD_RWLOCK_INIT 1 + +/* Define to 1 if srand48/lrand48/drand48 exist in <stdlib.h> */ +#define HAVE_RAND48 1 + +/* Define to 1 if you have the `readdir' function. */ +#define HAVE_READDIR 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `rindex' function. */ +/* #undef HAVE_RINDEX */ + +/* Define to 1 if you have the `rintf' function. */ +#define HAVE_RINTF 1 + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `roundf' function. */ +#define HAVE_ROUNDF 1 + +/* Define to 1 if you have the `sbrk' function. */ +#define HAVE_SBRK 1 + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setjmp' function. */ +#define HAVE_SETJMP 1 + +/* Define to 1 if you have the <setjmp.h> header file. */ +#define HAVE_SETJMP_H 1 + +/* Define to 1 if you have the `setrlimit' function. */ +#define HAVE_SETRLIMIT 1 + +/* Define if you have the shl_load function. */ +/* #undef HAVE_SHL_LOAD */ + +/* Define to 1 if you have the `siglongjmp' function. */ +#define HAVE_SIGLONGJMP 1 + +/* Define to 1 if you have the <signal.h> header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigsetjmp' function. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio.h> header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Set to 1 if the std::isinf function is found in <cmath> */ +/* #undef HAVE_STD_ISINF_IN_CMATH */ + +/* Set to 1 if the std::isnan function is found in <cmath> */ +#define HAVE_STD_ISNAN_IN_CMATH 1 + +/* Does not have std namespace iterator */ +#define HAVE_STD_ITERATOR 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strcmp' function. */ +#define HAVE_STRCMP 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strerror_s' function. */ +/* #undef HAVE_STRERROR_S */ + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strtof' function. */ +#define HAVE_STRTOF 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoq' function. */ +#define HAVE_STRTOQ 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the <sys/dl.h> header file. */ +/* #undef HAVE_SYS_DL_H */ + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the <sys/mman.h> header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if the neat program is available */ +/* #undef HAVE_TWOPI */ + +/* Define to 1 if the system has the type `uint64_t'. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <utime.h> header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if the system has the type `u_int64_t'. */ +/* #undef HAVE_U_INT64_T */ + +/* Define to 1 if you have the <windows.h> header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the `__dso_handle' function. */ +#define HAVE___DSO_HANDLE 1 + +/* Installation directory for binary executables */ +#define LLVM_BINDIR "/usr/local/bin" + +/* Time at which LLVM was configured */ +#define LLVM_CONFIGTIME "Sat Oct 17 00:31:27 CEST 2009" + +/* Installation directory for data files */ +#define LLVM_DATADIR "/usr/local/share/llvm" + +/* Installation directory for documentation */ +#define LLVM_DOCSDIR "/usr/local/docs/llvm" + +/* Installation directory for config files */ +#define LLVM_ETCDIR "/usr/local/etc/llvm" + +/* Host triple we were built on */ +#define LLVM_HOSTTRIPLE "x86_64-unknown-freebsd7.2" + +/* Installation directory for include files */ +#define LLVM_INCLUDEDIR "/usr/local/include" + +/* Installation directory for .info files */ +#define LLVM_INFODIR "/usr/local/info" + +/* Installation directory for libraries */ +#define LLVM_LIBDIR "/usr/local/lib" + +/* Installation directory for man pages */ +#define LLVM_MANDIR "/usr/local/man" + +/* Build multithreading support into LLVM */ +#define LLVM_MULTITHREADED 1 + +/* LLVM architecture name for the native architecture, if available */ +#define LLVM_NATIVE_ARCH X86Target + +/* Define if this is Unixish platform */ +#define LLVM_ON_UNIX 1 + +/* Define if this is Win32ish platform */ +/* #undef LLVM_ON_WIN32 */ + +/* Define to path to circo program if found or 'echo circo' otherwise */ +/* #undef LLVM_PATH_CIRCO */ + +/* Define to path to dot program if found or 'echo dot' otherwise */ +/* #undef LLVM_PATH_DOT */ + +/* Define to path to dotty program if found or 'echo dotty' otherwise */ +/* #undef LLVM_PATH_DOTTY */ + +/* Define to path to fdp program if found or 'echo fdp' otherwise */ +/* #undef LLVM_PATH_FDP */ + +/* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */ +/* #undef LLVM_PATH_GRAPHVIZ */ + +/* Define to path to gv program if found or 'echo gv' otherwise */ +/* #undef LLVM_PATH_GV */ + +/* Define to path to neato program if found or 'echo neato' otherwise */ +/* #undef LLVM_PATH_NEATO */ + +/* Define to path to twopi program if found or 'echo twopi' otherwise */ +/* #undef LLVM_PATH_TWOPI */ + +/* Installation prefix directory */ +#define LLVM_PREFIX "/usr/local" + +/* Define if the OS needs help to load dependent libraries for dlopen(). */ +#define LTDL_DLOPEN_DEPLIBS 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LTDL_OBJDIR ".libs/" + +/* Define to the name of the environment variable that determines the dynamic + library search path. */ +#define LTDL_SHLIBPATH_VAR "LD_LIBRARY_PATH" + +/* Define to the extension used for shared libraries, say, ".so". */ +#define LTDL_SHLIB_EXT ".so" + +/* Define to the system default library search path. */ +#define LTDL_SYSSEARCHPATH "/lib:/usr/lib" + +/* Define if /dev/zero should be used when mapping RWX memory, or undefine if + its not necessary */ +/* #undef NEED_DEV_ZERO_FOR_MMAP */ + +/* Define if dlsym() requires a leading underscore in symbol names. */ +/* #undef NEED_USCORE */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "llvm" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "llvm 2.7svn" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "-llvm-" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7svn" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if we have the oprofile JIT-support library */ +#define USE_OPROFILE 0 + +/* Define if use udis86 library */ +#define USE_UDIS86 0 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to a type to use for `error_t' if it is not otherwise available. */ +#define error_t int + +/* Define to `int' if <sys/types.h> does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +/* #undef size_t */ diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 7715286..2855fdc 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -22,15 +22,16 @@ #define LLVM_CONSTANTS_H #include "llvm/Constant.h" -#include "llvm/Type.h" #include "llvm/OperandTraits.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/SmallVector.h" +#include <vector> namespace llvm { class ArrayType; +class IntegerType; class StructType; class PointerType; class VectorType; diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h index 8d3a1d7..e895e73 100644 --- a/include/llvm/ExecutionEngine/JITEventListener.h +++ b/include/llvm/ExecutionEngine/JITEventListener.h @@ -67,8 +67,7 @@ public: virtual void NotifyFreeingMachineCode(const Function &F, void *OldPtr) {} }; -// These return NULL if support isn't available. -JITEventListener *createMacOSJITEventListener(); +// This returns NULL if support isn't available. JITEventListener *createOProfileJITEventListener(); } // end namespace llvm. diff --git a/include/llvm/ExecutionEngine/JITMemoryManager.h b/include/llvm/ExecutionEngine/JITMemoryManager.h index 9f6fb63..56851889 100644 --- a/include/llvm/ExecutionEngine/JITMemoryManager.h +++ b/include/llvm/ExecutionEngine/JITMemoryManager.h @@ -132,9 +132,11 @@ public: /// virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) = 0; - /// deallocateMemForFunction - Free JIT memory for the specified function. - /// This is never called when the JIT is currently emitting a function. - virtual void deallocateMemForFunction(const Function *F) = 0; + /// deallocateFunctionBody - Free the specified function body. The argument + /// must be the return value from a call to startFunctionBody() that hasn't + /// been deallocated yet. This is never called when the JIT is currently + /// emitting a function. + virtual void deallocateFunctionBody(void *Body) = 0; /// startExceptionTable - When we finished JITing the function, if exception /// handling is set, we emit the exception table. @@ -146,6 +148,12 @@ public: virtual void endExceptionTable(const Function *F, uint8_t *TableStart, uint8_t *TableEnd, uint8_t* FrameRegister) = 0; + /// deallocateExceptionTable - Free the specified exception table's memory. + /// The argument must be the return value from a call to startExceptionTable() + /// that hasn't been deallocated yet. This is never called when the JIT is + /// currently emitting an exception table. + virtual void deallocateExceptionTable(void *ET) = 0; + /// CheckInvariants - For testing only. Return true if all internal /// invariants are preserved, or return false and set ErrorStr to a helpful /// error message. diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index bc55031..d54870e 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -31,11 +31,11 @@ class InlineAsm : public Value { std::string AsmString, Constraints; bool HasSideEffects; - bool IsMsAsm; + bool IsAlignStack; InlineAsm(const FunctionType *Ty, const StringRef &AsmString, const StringRef &Constraints, bool hasSideEffects, - bool isMsAsm = false); + bool isAlignStack = false); virtual ~InlineAsm(); public: @@ -43,10 +43,10 @@ public: /// static InlineAsm *get(const FunctionType *Ty, const StringRef &AsmString, const StringRef &Constraints, bool hasSideEffects, - bool isMsAsm = false); + bool isAlignStack = false); bool hasSideEffects() const { return HasSideEffects; } - bool isMsAsm() const { return IsMsAsm; } + bool isAlignStack() const { return IsAlignStack; } /// getType - InlineAsm's are always pointers. /// diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index cc923de..45d366f 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -116,8 +116,7 @@ public: // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnaryInstruction *) { return true; } static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::Malloc || - I->getOpcode() == Instruction::Alloca || + return I->getOpcode() == Instruction::Alloca || I->getOpcode() == Instruction::Free || I->getOpcode() == Instruction::Load || I->getOpcode() == Instruction::VAArg || diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index e603c12..5c8fe3e 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -128,49 +128,48 @@ HANDLE_BINARY_INST(24, Xor , BinaryOperator) // Memory operators... FIRST_MEMORY_INST(25) -HANDLE_MEMORY_INST(25, Malloc, MallocInst) // Heap management instructions -HANDLE_MEMORY_INST(26, Free , FreeInst ) -HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management -HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs -HANDLE_MEMORY_INST(29, Store , StoreInst ) -HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst) - LAST_MEMORY_INST(30) +HANDLE_MEMORY_INST(25, Free , FreeInst ) // Heap management instructions +HANDLE_MEMORY_INST(26, Alloca, AllocaInst) // Stack management +HANDLE_MEMORY_INST(27, Load , LoadInst ) // Memory manipulation instrs +HANDLE_MEMORY_INST(28, Store , StoreInst ) +HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst) + LAST_MEMORY_INST(29) // Cast operators ... // NOTE: The order matters here because CastInst::isEliminableCastPair // NOTE: (see Instructions.cpp) encodes a table based on this ordering. - FIRST_CAST_INST(31) -HANDLE_CAST_INST(31, Trunc , TruncInst ) // Truncate integers -HANDLE_CAST_INST(32, ZExt , ZExtInst ) // Zero extend integers -HANDLE_CAST_INST(33, SExt , SExtInst ) // Sign extend integers -HANDLE_CAST_INST(34, FPToUI , FPToUIInst ) // floating point -> UInt -HANDLE_CAST_INST(35, FPToSI , FPToSIInst ) // floating point -> SInt -HANDLE_CAST_INST(36, UIToFP , UIToFPInst ) // UInt -> floating point -HANDLE_CAST_INST(37, SIToFP , SIToFPInst ) // SInt -> floating point -HANDLE_CAST_INST(38, FPTrunc , FPTruncInst ) // Truncate floating point -HANDLE_CAST_INST(39, FPExt , FPExtInst ) // Extend floating point -HANDLE_CAST_INST(40, PtrToInt, PtrToIntInst) // Pointer -> Integer -HANDLE_CAST_INST(41, IntToPtr, IntToPtrInst) // Integer -> Pointer -HANDLE_CAST_INST(42, BitCast , BitCastInst ) // Type cast - LAST_CAST_INST(42) + FIRST_CAST_INST(30) +HANDLE_CAST_INST(30, Trunc , TruncInst ) // Truncate integers +HANDLE_CAST_INST(31, ZExt , ZExtInst ) // Zero extend integers +HANDLE_CAST_INST(32, SExt , SExtInst ) // Sign extend integers +HANDLE_CAST_INST(33, FPToUI , FPToUIInst ) // floating point -> UInt +HANDLE_CAST_INST(34, FPToSI , FPToSIInst ) // floating point -> SInt +HANDLE_CAST_INST(35, UIToFP , UIToFPInst ) // UInt -> floating point +HANDLE_CAST_INST(36, SIToFP , SIToFPInst ) // SInt -> floating point +HANDLE_CAST_INST(37, FPTrunc , FPTruncInst ) // Truncate floating point +HANDLE_CAST_INST(38, FPExt , FPExtInst ) // Extend floating point +HANDLE_CAST_INST(39, PtrToInt, PtrToIntInst) // Pointer -> Integer +HANDLE_CAST_INST(40, IntToPtr, IntToPtrInst) // Integer -> Pointer +HANDLE_CAST_INST(41, BitCast , BitCastInst ) // Type cast + LAST_CAST_INST(41) // Other operators... - FIRST_OTHER_INST(43) -HANDLE_OTHER_INST(43, ICmp , ICmpInst ) // Integer comparison instruction -HANDLE_OTHER_INST(44, FCmp , FCmpInst ) // Floating point comparison instr. -HANDLE_OTHER_INST(45, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(46, Call , CallInst ) // Call a function -HANDLE_OTHER_INST(47, Select , SelectInst ) // select instruction -HANDLE_OTHER_INST(48, UserOp1, Instruction) // May be used internally in a pass -HANDLE_OTHER_INST(49, UserOp2, Instruction) // Internal to passes only -HANDLE_OTHER_INST(50, VAArg , VAArgInst ) // vaarg instruction -HANDLE_OTHER_INST(51, ExtractElement, ExtractElementInst)// extract from vector -HANDLE_OTHER_INST(52, InsertElement, InsertElementInst) // insert into vector -HANDLE_OTHER_INST(53, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. -HANDLE_OTHER_INST(54, ExtractValue, ExtractValueInst)// extract from aggregate -HANDLE_OTHER_INST(55, InsertValue, InsertValueInst) // insert into aggregate - - LAST_OTHER_INST(55) + FIRST_OTHER_INST(42) +HANDLE_OTHER_INST(42, ICmp , ICmpInst ) // Integer comparison instruction +HANDLE_OTHER_INST(43, FCmp , FCmpInst ) // Floating point comparison instr. +HANDLE_OTHER_INST(44, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(45, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(46, Select , SelectInst ) // select instruction +HANDLE_OTHER_INST(47, UserOp1, Instruction) // May be used internally in a pass +HANDLE_OTHER_INST(48, UserOp2, Instruction) // Internal to passes only +HANDLE_OTHER_INST(49, VAArg , VAArgInst ) // vaarg instruction +HANDLE_OTHER_INST(50, ExtractElement, ExtractElementInst)// extract from vector +HANDLE_OTHER_INST(51, InsertElement, InsertElementInst) // insert into vector +HANDLE_OTHER_INST(52, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. +HANDLE_OTHER_INST(53, ExtractValue, ExtractValueInst)// extract from aggregate +HANDLE_OTHER_INST(54, InsertValue, InsertValueInst) // insert into aggregate + + LAST_OTHER_INST(54) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index b28fcbb..dbeb9e1 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -37,8 +37,7 @@ class DominatorTree; // AllocationInst Class //===----------------------------------------------------------------------===// -/// AllocationInst - This class is the common base class of MallocInst and -/// AllocaInst. +/// AllocationInst - This class is the base class of AllocaInst. /// class AllocationInst : public UnaryInstruction { protected: @@ -85,56 +84,7 @@ public: // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const AllocationInst *) { return true; } static inline bool classof(const Instruction *I) { - return I->getOpcode() == Instruction::Alloca || - I->getOpcode() == Instruction::Malloc; - } - static inline bool classof(const Value *V) { - return isa<Instruction>(V) && classof(cast<Instruction>(V)); - } -}; - - -//===----------------------------------------------------------------------===// -// MallocInst Class -//===----------------------------------------------------------------------===// - -/// MallocInst - an instruction to allocated memory on the heap -/// -class MallocInst : public AllocationInst { -public: - explicit MallocInst(const Type *Ty, Value *ArraySize = 0, - const Twine &NameStr = "", - Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Malloc, - 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, Value *ArraySize, - const Twine &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {} - - MallocInst(const Type *Ty, const Twine &NameStr, - Instruction *InsertBefore = 0) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, const Twine &NameStr, - BasicBlock *InsertAtEnd) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {} - - MallocInst(const Type *Ty, Value *ArraySize, - unsigned Align, const Twine &NameStr, - BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, - Align, NameStr, InsertAtEnd) {} - MallocInst(const Type *Ty, Value *ArraySize, - unsigned Align, const Twine &NameStr = "", - Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, - Malloc, Align, NameStr, InsertBefore) {} - - virtual MallocInst *clone() const; - - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const MallocInst *) { return true; } - static inline bool classof(const Instruction *I) { - return (I->getOpcode() == Instruction::Malloc); + return I->getOpcode() == Instruction::Alloca; } static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); @@ -1042,12 +992,14 @@ public: /// constant 1. /// 2. Call malloc with that argument. /// 3. Bitcast the result of the malloc call to the specified type. - static Value *CreateMalloc(Instruction *InsertBefore, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize = 0, - const Twine &Name = ""); - static Value *CreateMalloc(BasicBlock *InsertAtEnd, const Type *IntPtrTy, - const Type *AllocTy, Value *ArraySize = 0, - const Twine &Name = ""); + static Instruction *CreateMalloc(Instruction *InsertBefore, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize = 0, + const Twine &Name = ""); + static Instruction *CreateMalloc(BasicBlock *InsertAtEnd, + const Type *IntPtrTy, const Type *AllocTy, + Value *ArraySize = 0, Function* MallocF = 0, + const Twine &Name = ""); ~CallInst(); @@ -1148,10 +1100,15 @@ public: } /// getCalledValue - Get a pointer to the function that is invoked by this - /// instruction + /// instruction. const Value *getCalledValue() const { return Op<0>(); } Value *getCalledValue() { return Op<0>(); } + /// setCalledFunction - Set the function called. + void setCalledFunction(Value* Fn) { + Op<0>() = Fn; + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const CallInst *) { return true; } static inline bool classof(const Instruction *I) { diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td index 38ac4c2..e6d8007 100644 --- a/include/llvm/Intrinsics.td +++ b/include/llvm/Intrinsics.td @@ -474,4 +474,3 @@ include "llvm/IntrinsicsARM.td" include "llvm/IntrinsicsCellSPU.td" include "llvm/IntrinsicsAlpha.td" include "llvm/IntrinsicsXCore.td" -include "llvm/IntrinsicsBlackfin.td" diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index a135f67..b9ffeb0 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -33,7 +33,6 @@ class LLVMContext { public: LLVMContextImpl* const pImpl; MetadataContext &getMetadata(); - bool RemoveDeadMetadata(); LLVMContext(); ~LLVMContext(); }; diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index e9a0542..3342ea8 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -16,6 +16,7 @@ #define LLVM_LINKALLPASSES_H #include "llvm/Analysis/AliasSetTracker.h" +#include "llvm/Analysis/DomPrinter.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Analysis/Passes.h" @@ -62,6 +63,10 @@ namespace { (void) llvm::createDeadInstEliminationPass(); (void) llvm::createDeadStoreEliminationPass(); (void) llvm::createDeadTypeEliminationPass(); + (void) llvm::createDomOnlyPrinterPass(); + (void) llvm::createDomPrinterPass(); + (void) llvm::createDomOnlyViewerPass(); + (void) llvm::createDomViewerPass(); (void) llvm::createEdgeProfilerPass(); (void) llvm::createOptimalEdgeProfilerPass(); (void) llvm::createFunctionInliningPass(); @@ -98,6 +103,10 @@ namespace { (void) llvm::createPromoteMemoryToRegisterPass(); (void) llvm::createDemoteRegisterToMemoryPass(); (void) llvm::createPruneEHPass(); + (void) llvm::createPostDomOnlyPrinterPass(); + (void) llvm::createPostDomPrinterPass(); + (void) llvm::createPostDomOnlyViewerPass(); + (void) llvm::createPostDomViewerPass(); (void) llvm::createRaiseAllocationsPass(); (void) llvm::createReassociatePass(); (void) llvm::createSCCPPass(); @@ -115,7 +124,6 @@ namespace { (void) llvm::createCondPropagationPass(); (void) llvm::createNullProfilerRSPass(); (void) llvm::createRSProfilingPass(); - (void) llvm::createIndMemRemPass(); (void) llvm::createInstCountPass(); (void) llvm::createCodeGenLICMPass(); (void) llvm::createCodeGenPreparePass(); diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 892f548..76ed3df 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -13,7 +13,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/MC/MCValue.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" #include <vector> // FIXME: Shouldn't be needed. @@ -22,8 +21,10 @@ namespace llvm { class raw_ostream; class MCAssembler; class MCContext; +class MCExpr; class MCSection; class MCSectionData; +class MCSymbol; class MCFragment : public ilist_node<MCFragment> { MCFragment(const MCFragment&); // DO NOT IMPLEMENT @@ -174,7 +175,7 @@ public: class MCFillFragment : public MCFragment { /// Value - Value to use for filling bytes. - MCValue Value; + const MCExpr *Value; /// ValueSize - The size (in bytes) of \arg Value to use when filling. unsigned ValueSize; @@ -183,10 +184,10 @@ class MCFillFragment : public MCFragment { uint64_t Count; public: - MCFillFragment(MCValue _Value, unsigned _ValueSize, uint64_t _Count, + MCFillFragment(const MCExpr &_Value, unsigned _ValueSize, uint64_t _Count, MCSectionData *SD = 0) : MCFragment(FT_Fill, SD), - Value(_Value), ValueSize(_ValueSize), Count(_Count) {} + Value(&_Value), ValueSize(_ValueSize), Count(_Count) {} /// @name Accessors /// @{ @@ -195,7 +196,7 @@ public: return ValueSize * Count; } - MCValue getValue() const { return Value; } + const MCExpr &getValue() const { return *Value; } unsigned getValueSize() const { return ValueSize; } @@ -211,15 +212,15 @@ public: class MCOrgFragment : public MCFragment { /// Offset - The offset this fragment should start at. - MCValue Offset; + const MCExpr *Offset; /// Value - Value to use for filling bytes. int8_t Value; public: - MCOrgFragment(MCValue _Offset, int8_t _Value, MCSectionData *SD = 0) + MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0) : MCFragment(FT_Org, SD), - Offset(_Offset), Value(_Value) {} + Offset(&_Offset), Value(_Value) {} /// @name Accessors /// @{ @@ -229,7 +230,7 @@ public: return ~UINT64_C(0); } - MCValue getOffset() const { return Offset; } + const MCExpr &getOffset() const { return *Offset; } uint8_t getValue() const { return Value; } @@ -294,10 +295,7 @@ public: uint64_t Offset; /// Value - The expression to eventually write into the fragment. - // - // FIXME: We could probably get away with requiring the client to pass in an - // owned reference whose lifetime extends past that of the fixup. - MCValue Value; + const MCExpr *Value; /// Size - The fixup size. unsigned Size; @@ -308,9 +306,9 @@ public: uint64_t FixedValue; public: - Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCValue &_Value, + Fixup(MCFragment &_Fragment, uint64_t _Offset, const MCExpr &_Value, unsigned _Size) - : Fragment(&_Fragment), Offset(_Offset), Value(_Value), Size(_Size), + : Fragment(&_Fragment), Offset(_Offset), Value(&_Value), Size(_Size), FixedValue(0) {} }; diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 955aa8b..fa20f45 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -15,10 +15,11 @@ #include "llvm/Support/Allocator.h" namespace llvm { - class MCValue; + class MCExpr; class MCSection; class MCSymbol; class StringRef; + class Twine; /// MCContext - Context object for machine code objects. This class owns all /// of the sections that it creates. @@ -33,11 +34,6 @@ namespace llvm { /// Symbols - Bindings of names to symbols. StringMap<MCSymbol*> Symbols; - /// SymbolValues - Bindings of symbols to values. - // - // FIXME: Is there a good reason to not just put this in the MCSymbol? - DenseMap<const MCSymbol*, MCValue> SymbolValues; - /// Allocator - Allocator object used for creating machine code objects. /// /// We use a bump pointer allocator to avoid the need to track all allocated @@ -63,7 +59,8 @@ namespace llvm { /// @param IsTemporary - Whether this symbol is an assembler temporary, /// which should not survive into the symbol table for the translation unit. MCSymbol *GetOrCreateSymbol(const StringRef &Name); - + MCSymbol *GetOrCreateSymbol(const Twine &Name); + /// CreateTemporarySymbol - Create a new temporary symbol with the specified /// @param Name. /// @@ -76,25 +73,11 @@ namespace llvm { MCSymbol *LookupSymbol(const StringRef &Name) const; /// @} - /// @name Symbol Value Table - /// @{ - - /// ClearSymbolValue - Erase a value binding for @arg Symbol, if one exists. - void ClearSymbolValue(const MCSymbol *Symbol); - - /// SetSymbolValue - Set the value binding for @arg Symbol to @arg Value. - void SetSymbolValue(const MCSymbol *Symbol, const MCValue &Value); - - /// GetSymbolValue - Return the current value for @arg Symbol, or null if - /// none exists. - const MCValue *GetSymbolValue(const MCSymbol *Symbol) const; - - /// @} void *Allocate(unsigned Size, unsigned Align = 8) { return Allocator.Allocate(Size, Align); } - void Deallocate(void *Ptr) { + void Deallocate(void *Ptr) { } }; diff --git a/include/llvm/MC/MCExpr.h b/include/llvm/MC/MCExpr.h index 19a32e7..7a2a0d5 100644 --- a/include/llvm/MC/MCExpr.h +++ b/include/llvm/MC/MCExpr.h @@ -62,14 +62,14 @@ public: /// /// @param Res - The absolute value, if evaluation succeeds. /// @result - True on success. - bool EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const; + bool EvaluateAsAbsolute(int64_t &Res) const; /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable /// value, i.e. an expression of the fixed form (a - b + constant). /// /// @param Res - The relocatable value, if evaluation succeeds. /// @result - True on success. - bool EvaluateAsRelocatable(MCContext &Ctx, MCValue &Res) const; + bool EvaluateAsRelocatable(MCValue &Res) const; /// @} @@ -121,9 +121,7 @@ public: static const MCSymbolRefExpr *Create(const MCSymbol *Symbol, MCContext &Ctx); static const MCSymbolRefExpr *Create(const StringRef &Name, MCContext &Ctx); - - - + /// @} /// @name Accessors /// @{ diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h index 5dd7d68..d08f0e5 100644 --- a/include/llvm/MC/MCSymbol.h +++ b/include/llvm/MC/MCSymbol.h @@ -20,6 +20,7 @@ namespace llvm { class MCAsmInfo; + class MCExpr; class MCSection; class MCContext; class raw_ostream; @@ -45,6 +46,9 @@ namespace llvm { /// absolute symbols. const MCSection *Section; + /// Value - If non-null, the value for a variable symbol. + const MCExpr *Value; + /// IsTemporary - True if this is an assembler temporary label, which /// typically does not survive in the .o file's symbol table. Usually /// "Lfoo" or ".foo". @@ -52,9 +56,9 @@ namespace llvm { private: // MCContext creates and uniques these. friend class MCContext; - MCSymbol(const StringRef &_Name, bool _IsTemporary) - : Name(_Name), Section(0), IsTemporary(_IsTemporary) {} - + MCSymbol(const StringRef &_Name, bool _IsTemporary) + : Name(_Name), Section(0), Value(0), IsTemporary(_IsTemporary) {} + MCSymbol(const MCSymbol&); // DO NOT IMPLEMENT void operator=(const MCSymbol&); // DO NOT IMPLEMENT public: @@ -69,6 +73,10 @@ namespace llvm { return IsTemporary; } + /// @} + /// @name Associated Sections + /// @{ + /// isDefined - Check if this symbol is defined (i.e., it has an address). /// /// Defined symbols are either absolute or in some section. @@ -105,6 +113,23 @@ namespace llvm { void setAbsolute() { Section = AbsolutePseudoSection; } /// @} + /// @name Variable Symbols + /// @{ + + /// isVariable - Check if this is a variable symbol. + bool isVariable() const { + return Value != 0; + } + + /// getValue() - Get the value for variable symbols, or null if the symbol + /// is not a variable. + const MCExpr *getValue() const { return Value; } + + void setValue(const MCExpr *Value) { + this->Value = Value; + } + + /// @} /// print - Print the value to the stream \arg OS. void print(raw_ostream &OS, const MCAsmInfo *MAI) const; diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index 13b97b9..c983015 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -13,46 +13,30 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_MDNODE_H -#define LLVM_MDNODE_H +#ifndef LLVM_METADATA_H +#define LLVM_METADATA_H -#include "llvm/User.h" +#include "llvm/Value.h" #include "llvm/Type.h" -#include "llvm/OperandTraits.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringMap.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ValueHandle.h" namespace llvm { class Constant; class Instruction; class LLVMContext; +class MetadataContextImpl; //===----------------------------------------------------------------------===// // MetadataBase - A base class for MDNode, MDString and NamedMDNode. -class MetadataBase : public User { -private: - /// ReservedSpace - The number of operands actually allocated. NumOperands is - /// the number actually in use. - unsigned ReservedSpace; - +class MetadataBase : public Value { protected: MetadataBase(const Type *Ty, unsigned scid) - : User(Ty, scid, NULL, 0), ReservedSpace(0) {} + : Value(Ty, scid) {} - void resizeOperands(unsigned NumOps); public: - /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. This always returns false because getNullValue will never - /// produce metadata. - virtual bool isNullValue() const { - return false; - } /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MetadataBase *) { return true; } @@ -68,32 +52,28 @@ public: /// MDString is always unnamd. class MDString : public MetadataBase { MDString(const MDString &); // DO NOT IMPLEMENT - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - unsigned getNumOperands(); // DO NOT IMPLEMENT StringRef Str; protected: - explicit MDString(LLVMContext &C, const char *begin, unsigned l) - : MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(begin, l) {} + explicit MDString(LLVMContext &C, StringRef S) + : MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(S) {} public: - // Do not allocate any space for operands. - void *operator new(size_t s) { - return User::operator new(s, 0); - } - static MDString *get(LLVMContext &Context, const StringRef &Str); + static MDString *get(LLVMContext &Context, StringRef Str); StringRef getString() const { return Str; } - unsigned length() const { return Str.size(); } + unsigned getLength() const { return Str.size(); } + typedef StringRef::iterator iterator; + /// begin() - Pointer to the first byte of the string. /// - const char *begin() const { return Str.begin(); } + iterator begin() const { return Str.begin(); } /// end() - Pointer to one byte past the end of the string. /// - const char *end() const { return Str.end(); } + iterator end() const { return Str.end(); } /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MDString *) { return true; } @@ -108,14 +88,12 @@ public: /// MDNode is always unnamed. class MDNode : public MetadataBase, public FoldingSetNode { MDNode(const MDNode &); // DO NOT IMPLEMENT - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - // getNumOperands - Make this only available for private uses. - unsigned getNumOperands() { return User::getNumOperands(); } friend class ElementVH; // Use CallbackVH to hold MDNOde elements. struct ElementVH : public CallbackVH { MDNode *Parent; + ElementVH() {} ElementVH(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {} ~ElementVH() {} @@ -130,61 +108,32 @@ class MDNode : public MetadataBase, public FoldingSetNode { // Replace each instance of F from the element list of this node with T. void replaceElement(Value *F, Value *T); - SmallVector<ElementVH, 4> Node; + ElementVH *Node; + unsigned NodeSize; protected: - explicit MDNode(LLVMContext &C, Value*const* Vals, unsigned NumVals); + explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals); public: - // Do not allocate any space for operands. - void *operator new(size_t s) { - return User::operator new(s, 0); - } // Constructors and destructors. static MDNode *get(LLVMContext &Context, - Value* const* Vals, unsigned NumVals); - - /// dropAllReferences - Remove all uses and clear node vector. - void dropAllReferences(); + Value *const *Vals, unsigned NumVals); /// ~MDNode - Destroy MDNode. ~MDNode(); /// getElement - Return specified element. Value *getElement(unsigned i) const { - assert (getNumElements() > i && "Invalid element number!"); + assert(i < getNumElements() && "Invalid element number!"); return Node[i]; } /// getNumElements - Return number of MDNode elements. - unsigned getNumElements() const { - return Node.size(); - } - - // Element access - typedef SmallVectorImpl<ElementVH>::const_iterator const_elem_iterator; - typedef SmallVectorImpl<ElementVH>::iterator elem_iterator; - /// elem_empty - Return true if MDNode is empty. - bool elem_empty() const { return Node.empty(); } - const_elem_iterator elem_begin() const { return Node.begin(); } - const_elem_iterator elem_end() const { return Node.end(); } - elem_iterator elem_begin() { return Node.begin(); } - elem_iterator elem_end() { return Node.end(); } - - /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. This always returns false because getNullValue will never - /// produce metadata. - virtual bool isNullValue() const { - return false; - } + unsigned getNumElements() const { return NodeSize; } /// Profile - calculate a unique identifier for this MDNode to collapse /// duplicates void Profile(FoldingSetNodeID &ID) const; - virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) { - llvm_unreachable("This should never be called because MDNodes have no ops"); - } - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MDNode *) { return true; } static bool classof(const Value *V) { @@ -193,23 +142,6 @@ public: }; //===----------------------------------------------------------------------===// -/// WeakMetadataVH - a weak value handle for metadata. -class WeakMetadataVH : public WeakVH { -public: - WeakMetadataVH() : WeakVH() {} - WeakMetadataVH(MetadataBase *M) : WeakVH(M) {} - WeakMetadataVH(const WeakMetadataVH &RHS) : WeakVH(RHS) {} - - operator Value*() const { - llvm_unreachable("WeakMetadataVH only handles Metadata"); - } - - operator MetadataBase*() const { - return dyn_cast_or_null<MetadataBase>(getValPtr()); - } -}; - -//===----------------------------------------------------------------------===// /// NamedMDNode - a tuple of other metadata. /// NamedMDNode is always named. All NamedMDNode element has a type of metadata. template<typename ValueSubClass, typename ItemParentClass> @@ -220,24 +152,17 @@ class NamedMDNode : public MetadataBase, public ilist_node<NamedMDNode> { friend class LLVMContextImpl; NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - // getNumOperands - Make this only available for private uses. - unsigned getNumOperands() { return User::getNumOperands(); } Module *Parent; - SmallVector<WeakMetadataVH, 4> Node; - typedef SmallVectorImpl<WeakMetadataVH>::iterator elem_iterator; + SmallVector<TrackingVH<MetadataBase>, 4> Node; + void setParent(Module *M) { Parent = M; } protected: - explicit NamedMDNode(LLVMContext &C, const Twine &N, MetadataBase*const* Vals, + explicit NamedMDNode(LLVMContext &C, const Twine &N, MetadataBase*const *Vals, unsigned NumVals, Module *M = 0); public: - // Do not allocate any space for operands. - void *operator new(size_t s) { - return User::operator new(s, 0); - } static NamedMDNode *Create(LLVMContext &C, const Twine &N, - MetadataBase*const*MDs, + MetadataBase *const *MDs, unsigned NumMDs, Module *M = 0) { return new NamedMDNode(C, N, MDs, NumMDs, M); } @@ -257,11 +182,10 @@ public: /// getParent - Get the module that holds this named metadata collection. inline Module *getParent() { return Parent; } inline const Module *getParent() const { return Parent; } - void setParent(Module *M) { Parent = M; } /// getElement - Return specified element. MetadataBase *getElement(unsigned i) const { - assert (getNumElements() > i && "Invalid element number!"); + assert(i < getNumElements() && "Invalid element number!"); return Node[i]; } @@ -272,30 +196,18 @@ public: /// addElement - Add metadata element. void addElement(MetadataBase *M) { - resizeOperands(0); - OperandList[NumOperands++] = M; - Node.push_back(WeakMetadataVH(M)); + Node.push_back(TrackingVH<MetadataBase>(M)); } - typedef SmallVectorImpl<WeakMetadataVH>::const_iterator const_elem_iterator; + typedef SmallVectorImpl<TrackingVH<MetadataBase> >::iterator elem_iterator; + typedef SmallVectorImpl<TrackingVH<MetadataBase> >::const_iterator + const_elem_iterator; bool elem_empty() const { return Node.empty(); } const_elem_iterator elem_begin() const { return Node.begin(); } const_elem_iterator elem_end() const { return Node.end(); } elem_iterator elem_begin() { return Node.begin(); } elem_iterator elem_end() { return Node.end(); } - /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. This always returns false because getNullValue will never - /// produce metadata. - virtual bool isNullValue() const { - return false; - } - - virtual void replaceUsesOfWithOnConstant(Value *, Value *, Use *) { - llvm_unreachable( - "This should never be called because NamedMDNodes have no ops"); - } - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const NamedMDNode *) { return true; } static bool classof(const Value *V) { @@ -310,61 +222,55 @@ public: /// must start with an alphabet. The regular expression used to check name /// is [a-zA-Z$._][a-zA-Z$._0-9]* class MetadataContext { -public: - typedef std::pair<unsigned, WeakVH> MDPairTy; - typedef SmallVector<MDPairTy, 2> MDMapTy; - typedef DenseMap<const Instruction *, MDMapTy> MDStoreTy; - friend class BitcodeReader; -private: - - /// MetadataStore - Collection of metadata used in this context. - MDStoreTy MetadataStore; - - /// MDHandlerNames - Map to hold metadata handler names. - StringMap<unsigned> MDHandlerNames; + // DO NOT IMPLEMENT + MetadataContext(MetadataContext&); + void operator=(MetadataContext&); + MetadataContextImpl *const pImpl; public: - /// RegisterMDKind - Register a new metadata kind and return its ID. + MetadataContext(); + ~MetadataContext(); + + /// registerMDKind - Register a new metadata kind and return its ID. /// A metadata kind can be registered only once. - unsigned RegisterMDKind(const char *Name); + unsigned registerMDKind(StringRef Name); /// getMDKind - Return metadata kind. If the requested metadata kind /// is not registered then return 0. - unsigned getMDKind(const char *Name); + unsigned getMDKind(StringRef Name) const; - /// validName - Return true if Name is a valid custom metadata handler name. - bool validName(const char *Name); + /// isValidName - Return true if Name is a valid custom metadata handler name. + static bool isValidName(StringRef Name); - /// getMD - Get the metadata of given kind attached with an Instruction. + /// getMD - Get the metadata of given kind attached to an Instruction. /// If the metadata is not found then return 0. MDNode *getMD(unsigned Kind, const Instruction *Inst); - /// getMDs - Get the metadata attached with an Instruction. - const MDMapTy *getMDs(const Instruction *Inst); + /// getMDs - Get the metadata attached to an Instruction. + void getMDs(const Instruction *Inst, + SmallVectorImpl<std::pair<unsigned, TrackingVH<MDNode> > > &MDs) const; - /// addMD - Attach the metadata of given kind with an Instruction. + /// addMD - Attach the metadata of given kind to an Instruction. void addMD(unsigned Kind, MDNode *Node, Instruction *Inst); /// removeMD - Remove metadata of given kind attached with an instuction. void removeMD(unsigned Kind, Instruction *Inst); - /// removeMDs - Remove all metadata attached with an instruction. - void removeMDs(const Instruction *Inst); + /// removeAllMetadata - Remove all metadata attached with an instruction. + void removeAllMetadata(Instruction *Inst); /// copyMD - If metadata is attached with Instruction In1 then attach /// the same metadata to In2. void copyMD(Instruction *In1, Instruction *In2); - /// getHandlerNames - Get handler names. This is used by bitcode - /// writer. - const StringMap<unsigned> *getHandlerNames(); + /// getHandlerNames - Populate client supplied smallvector using custome + /// metadata name and ID. + void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&) const; /// ValueIsDeleted - This handler is used to update metadata store /// when a value is deleted. void ValueIsDeleted(const Value *) {} - void ValueIsDeleted(const Instruction *Inst) { - removeMDs(Inst); - } + void ValueIsDeleted(Instruction *Inst); void ValueIsRAUWd(Value *V1, Value *V2); /// ValueIsCloned - This handler is used to update metadata store diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index f339481..690d080 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -20,14 +20,13 @@ #define LLVM_PASS_ANALYSIS_SUPPORT_H #include <vector> +#include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" namespace llvm { class StringRef; -// No need to include Pass.h, we are being included by it! - //===----------------------------------------------------------------------===// // AnalysisUsage - Represent the analysis usage information of a pass. This // tracks analyses that the pass REQUIRES (must be available when the pass diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index b5e581a..d7f3097 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -21,7 +21,7 @@ #ifndef LLVM_PASS_SUPPORT_H #define LLVM_PASS_SUPPORT_H -// No need to include Pass.h, we are being included by it! +#include "Pass.h" namespace llvm { diff --git a/include/llvm/Support/DataTypes.h b/include/llvm/Support/DataTypes.h new file mode 100644 index 0000000..0a763e0 --- /dev/null +++ b/include/llvm/Support/DataTypes.h @@ -0,0 +1,148 @@ +/* include/llvm/Support/DataTypes.h. Generated from DataTypes.h.in by configure. */ +/*===-- include/Support/DataTypes.h - Define fixed size types -----*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This file contains definitions to figure out the size of _HOST_ data types.*| +|* This file is important because different host OS's define different macros,*| +|* which makes portability tough. This file exports the following *| +|* definitions: *| +|* *| +|* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*| +|* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *| +|* *| +|* No library is required when using these functinons. *| +|* *| +|*===----------------------------------------------------------------------===*/ + +/* Please leave this file C-compatible. */ + +#ifndef SUPPORT_DATATYPES_H +#define SUPPORT_DATATYPES_H + +#define HAVE_SYS_TYPES_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_UINT64_T 1 +/* #undef HAVE_U_INT64_T */ + +#ifdef __cplusplus +#include <cmath> +#else +#include <math.h> +#endif + +#ifndef _MSC_VER + +/* Note that this header's correct operation depends on __STDC_LIMIT_MACROS + being defined. We would define it here, but in order to prevent Bad Things + happening when system headers or C++ STL headers include stdint.h before we + define it here, we define it on the g++ command line (in Makefile.rules). */ +#if !defined(__STDC_LIMIT_MACROS) +# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" +#endif + +#if !defined(__STDC_CONSTANT_MACROS) +# error "Must #define __STDC_CONSTANT_MACROS before " \ + "#including Support/DataTypes.h" +#endif + +/* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */ +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + +#ifdef _AIX +#include "llvm/Support/AIXDataTypesFix.h" +#endif + +/* Handle incorrect definition of uint64_t as u_int64_t */ +#ifndef HAVE_UINT64_T +#ifdef HAVE_U_INT64_T +typedef u_int64_t uint64_t; +#else +# error "Don't have a definition for uint64_t on this platform" +#endif +#endif + +#ifdef _OpenBSD_ +#define INT8_MAX 127 +#define INT8_MIN -128 +#define UINT8_MAX 255 +#define INT16_MAX 32767 +#define INT16_MIN -32768 +#define UINT16_MAX 65535 +#define INT32_MAX 2147483647 +#define INT32_MIN -2147483648 +#define UINT32_MAX 4294967295U +#endif + +#else /* _MSC_VER */ +/* Visual C++ doesn't provide standard integer headers, but it does provide + built-in data types. */ +#include <stdlib.h> +#include <stddef.h> +#include <sys/types.h> +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed int ssize_t; +#define INT8_MAX 127 +#define INT8_MIN -128 +#define UINT8_MAX 255 +#define INT16_MAX 32767 +#define INT16_MIN -32768 +#define UINT16_MAX 65535 +#define INT32_MAX 2147483647 +#define INT32_MIN -2147483648 +#define UINT32_MAX 4294967295U +#define INT8_C(C) C +#define UINT8_C(C) C +#define INT16_C(C) C +#define UINT16_C(C) C +#define INT32_C(C) C +#define UINT32_C(C) C ## U +#define INT64_C(C) ((int64_t) C ## LL) +#define UINT64_C(C) ((uint64_t) C ## ULL) +#endif /* _MSC_VER */ + +/* Set defaults for constants which we cannot find. */ +#if !defined(INT64_MAX) +# define INT64_MAX 9223372036854775807LL +#endif +#if !defined(INT64_MIN) +# define INT64_MIN ((-INT64_MAX)-1) +#endif +#if !defined(UINT64_MAX) +# define UINT64_MAX 0xffffffffffffffffULL +#endif + +#if __GNUC__ > 3 +#define END_WITH_NULL __attribute__((sentinel)) +#else +#define END_WITH_NULL +#endif + +#ifndef HUGE_VALF +#define HUGE_VALF (float)HUGE_VAL +#endif + +#endif /* SUPPORT_DATATYPES_H */ diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 1f65978..83df9ed 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -139,7 +139,7 @@ public: if (MDKind == 0) MDKind = Context.getMetadata().getMDKind("dbg"); if (MDKind == 0) - MDKind = Context.getMetadata().RegisterMDKind("dbg"); + MDKind = Context.getMetadata().registerMDKind("dbg"); CurDbgLocation = L; } @@ -429,10 +429,6 @@ public: // Instruction creation methods: Memory Instructions //===--------------------------------------------------------------------===// - MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0, - const Twine &Name = "") { - return Insert(new MallocInst(Ty, ArraySize), Name); - } AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0, const Twine &Name = "") { return Insert(new AllocaInst(Ty, ArraySize), Name); diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index 5d7c2f7..440657c 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -46,17 +46,17 @@ namespace llvm { /// /// Declare the class. Note that we derive from InstVisitor instantiated /// /// with _our new subclasses_ type. /// /// -/// struct CountMallocVisitor : public InstVisitor<CountMallocVisitor> { +/// struct CountAllocaVisitor : public InstVisitor<CountAllocaVisitor> { /// unsigned Count; -/// CountMallocVisitor() : Count(0) {} +/// CountAllocaVisitor() : Count(0) {} /// -/// void visitMallocInst(MallocInst &MI) { ++Count; } +/// void visitAllocaInst(AllocaInst &AI) { ++Count; } /// }; /// /// And this class would be used like this: -/// CountMallocVistor CMV; -/// CMV.visit(function); -/// NumMallocs = CMV.Count; +/// CountAllocaVisitor CAV; +/// CAV.visit(function); +/// NumAllocas = CAV.Count; /// /// The defined has 'visit' methods for Instruction, and also for BasicBlock, /// Function, and Module, which recursively process all contained instructions. @@ -165,7 +165,6 @@ public: RetTy visitUnreachableInst(UnreachableInst &I) { DELEGATE(TerminatorInst);} RetTy visitICmpInst(ICmpInst &I) { DELEGATE(CmpInst);} RetTy visitFCmpInst(FCmpInst &I) { DELEGATE(CmpInst);} - RetTy visitMallocInst(MallocInst &I) { DELEGATE(AllocationInst);} RetTy visitAllocaInst(AllocaInst &I) { DELEGATE(AllocationInst);} RetTy visitFreeInst(FreeInst &I) { DELEGATE(Instruction); } RetTy visitLoadInst(LoadInst &I) { DELEGATE(Instruction); } diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index e6363ff..a9872a7 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -238,6 +238,31 @@ template<> struct simplify_type<const AssertingVH<Value> > { template<> struct simplify_type<AssertingVH<Value> > : public simplify_type<const AssertingVH<Value> > {}; +// Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap. +template<typename T> +struct DenseMapInfo<AssertingVH<T> > { + typedef DenseMapInfo<T*> PointerInfo; + static inline AssertingVH<T> getEmptyKey() { + return AssertingVH<T>(PointerInfo::getEmptyKey()); + } + static inline T* getTombstoneKey() { + return AssertingVH<T>(PointerInfo::getTombstoneKey()); + } + static unsigned getHashValue(const AssertingVH<T> &Val) { + return PointerInfo::getHashValue(Val); + } + static bool isEqual(const AssertingVH<T> &LHS, const AssertingVH<T> &RHS) { + return LHS == RHS; + } + static bool isPod() { +#ifdef NDEBUG + return true; +#else + return false; +#endif + } +}; + /// TrackingVH - This is a value handle that tracks a Value (or Value subclass), /// even across RAUW operations. /// @@ -361,7 +386,7 @@ public: /// _before_ any of the uses have actually been replaced. If WeakVH were /// implemented as a CallbackVH, it would use this method to call /// setValPtr(new_value). AssertingVH would do nothing in this method. - virtual void allUsesReplacedWith(Value *new_value) {} + virtual void allUsesReplacedWith(Value *) {} }; // Specialize simplify_type to allow CallbackVH to participate in diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 8012b6f..e67ff85 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -216,6 +216,10 @@ public: /// write_hex - Output \arg N in hexadecimal, without any prefix or padding. raw_ostream &write_hex(unsigned long long N); + /// write_escaped - Output \arg Str, turning '\\', '\t', '\n', '"', and + /// anything that doesn't satisfy std::isprint into an escape sequence. + raw_ostream &write_escaped(StringRef Str); + raw_ostream &write(unsigned char C); raw_ostream &write(const char *Ptr, size_t Size); diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index 5f799b8..cfaae4b 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -87,6 +87,15 @@ struct is_base_of { sizeof(char) == sizeof(dont_use::base_of_helper<Base>((Derived*)0)); }; +// remove_pointer - Metafunction to turn Foo* into Foo. Defined in +// C++0x [meta.trans.ptr]. +template <typename T> struct remove_pointer { typedef T type; }; +template <typename T> struct remove_pointer<T*> { typedef T type; }; +template <typename T> struct remove_pointer<T*const> { typedef T type; }; +template <typename T> struct remove_pointer<T*volatile> { typedef T type; }; +template <typename T> struct remove_pointer<T*const volatile> { + typedef T type; }; + } #endif diff --git a/include/llvm/Target/TargetIntrinsicInfo.h b/include/llvm/Target/TargetIntrinsicInfo.h index c14275f..d70aa7e 100644 --- a/include/llvm/Target/TargetIntrinsicInfo.h +++ b/include/llvm/Target/TargetIntrinsicInfo.h @@ -25,35 +25,21 @@ class Type; /// TargetIntrinsicInfo - Interface to description of machine instruction set /// class TargetIntrinsicInfo { - - const char **Intrinsics; // Raw array to allow static init'n - unsigned NumIntrinsics; // Number of entries in the desc array - - TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT - void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT + TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT + void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT public: - TargetIntrinsicInfo(const char **desc, unsigned num); + TargetIntrinsicInfo(); virtual ~TargetIntrinsicInfo(); - unsigned getNumIntrinsics() const { return NumIntrinsics; } - - virtual Function *getDeclaration(Module *M, const char *BuiltinName) const { - return 0; - } - - // Returns the Function declaration for intrinsic BuiltinName. If the - // intrinsic can be overloaded, uses Tys to return the correct function. - virtual Function *getDeclaration(Module *M, const char *BuiltinName, - const Type **Tys, unsigned numTys) const { - return 0; - } + /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync". + virtual const char *getName(unsigned IntrID) const =0; - // Returns true if the Builtin can be overloaded. - virtual bool isOverloaded(Module *M, const char *BuiltinName) const { - return false; - } + /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown + /// names. + virtual unsigned lookupName(const char *Name, unsigned Len) const =0; - virtual unsigned getIntrinsicID(Function *F) const { return 0; } + /// Return the target intrinsic ID of a function, or 0. + virtual unsigned getIntrinsicID(Function *F) const; }; } // End llvm namespace diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 92b648c..1104635 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -74,9 +74,10 @@ namespace FileModel { // Code generation optimization level. namespace CodeGenOpt { enum Level { - Default, - None, - Aggressive + None, // -O0 + Less, // -O1 + Default, // -O2, -Os + Aggressive // -O3 }; } diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index e90fc6c..b7e8af9 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -641,24 +641,17 @@ public: virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF) const { } - /// saveScavengerRegister - Save the register so it can be used by the - /// register scavenger. Return true if the register was saved, false - /// otherwise. If this function does not save the register, the scavenger + /// saveScavengerRegister - Spill the register so it can be used by the + /// register scavenger. Return true if the register was spilled, false + /// otherwise. If this function does not spill the register, the scavenger /// will instead spill it to the emergency spill slot. /// virtual bool saveScavengerRegister(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, + MachineBasicBlock::iterator &UseMI, const TargetRegisterClass *RC, unsigned Reg) const {return false;} - /// restoreScavengerRegister - Restore a register saved by - /// saveScavengerRegister(). - /// - virtual void restoreScavengerRegister(MachineBasicBlock &MBB, - MachineBasicBlock::iterator I, - const TargetRegisterClass *RC, - unsigned Reg) const {} - /// eliminateFrameIndex - This method must be overriden to eliminate abstract /// frame indices from instructions which may use them. The instruction /// referenced by the iterator contains an MO_FrameIndex operand which must be diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 8042d23..395526f 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -387,6 +387,15 @@ namespace llvm { T.MCDisassemblerCtorFn = Fn; } + /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the + /// given target. + /// + /// Clients are responsible for ensuring that registration doesn't occur + /// while another thread is attempting to access the registry. Typically + /// this is done by initializing all targets at program startup. + /// + /// @param T - The target being registered. + /// @param Fn - A function to construct an MCInstPrinter for the target. static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn) { if (!T.MCInstPrinterCtorFn) @@ -395,7 +404,7 @@ namespace llvm { /// RegisterCodeEmitter - Register a MCCodeEmitter implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. diff --git a/include/llvm/Target/TargetSubtarget.h b/include/llvm/Target/TargetSubtarget.h index ac094f6..fd107e0 100644 --- a/include/llvm/Target/TargetSubtarget.h +++ b/include/llvm/Target/TargetSubtarget.h @@ -14,6 +14,8 @@ #ifndef LLVM_TARGET_TARGETSUBTARGET_H #define LLVM_TARGET_TARGETSUBTARGET_H +#include "llvm/Target/TargetMachine.h" + namespace llvm { class SDep; @@ -31,6 +33,10 @@ class TargetSubtarget { protected: // Can only create subclasses... TargetSubtarget(); public: + // AntiDepBreakMode - Type of anti-dependence breaking that should + // be performed before post-RA scheduling. + typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode; + virtual ~TargetSubtarget(); /// getSpecialAddressLatency - For targets where it is beneficial to @@ -39,9 +45,14 @@ public: /// should be attempted. virtual unsigned getSpecialAddressLatency() const { return 0; } - // enablePostRAScheduler - Return true to enable - // post-register-allocation scheduling. - virtual bool enablePostRAScheduler() const { return false; } + // enablePostRAScheduler - If the target can benefit from post-regalloc + // scheduling and the specified optimization level meets the requirement + // return true to enable post-register-allocation scheduling. + virtual bool enablePostRAScheduler(CodeGenOpt::Level OptLevel, + AntiDepBreakMode& mode) const { + mode = ANTIDEP_NONE; + return false; + } // adjustSchedDependency - Perform target specific adjustments to // the latency of a schedule dependency. diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index d66ed89..9189c43 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -185,10 +185,6 @@ Pass *createSingleLoopExtractorPass(); /// ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE); -/// createIndMemRemPass - This pass removes potential indirect calls of -/// malloc and free -ModulePass *createIndMemRemPass(); - /// createStripDeadPrototypesPass - This pass removes any function declarations /// (prototypes) that are not used. ModulePass *createStripDeadPrototypesPass(); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 2483768..fee4e65 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -225,12 +225,11 @@ extern const PassInfo *const LoopSimplifyID; //===----------------------------------------------------------------------===// // -// LowerAllocations - Turn malloc and free instructions into @malloc and @free -// calls. +// LowerAllocations - Turn free instructions into @free calls. // // AU.addRequiredID(LowerAllocationsID); // -Pass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false); +Pass *createLowerAllocationsPass(); extern const PassInfo *const LowerAllocationsID; //===----------------------------------------------------------------------===// diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h index 11b90d4..ad99c74 100644 --- a/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/include/llvm/Transforms/Utils/SSAUpdater.h @@ -21,7 +21,7 @@ namespace llvm { class PHINode; template<typename T> class SmallVectorImpl; - + /// SSAUpdater - This class updates SSA form for a set of values defined in /// multiple blocks. This is used when code duplication or another unstructured /// transformation wants to rewrite a set of uses of one value with uses of a @@ -33,17 +33,17 @@ class SSAUpdater { /// eliminate them, and want the WeakVH to track this. //typedef DenseMap<BasicBlock*, TrackingVH<Value> > AvailableValsTy; void *AV; - + /// PrototypeValue is an arbitrary representative value, which we derive names /// and a type for PHI nodes. Value *PrototypeValue; - + /// IncomingPredInfo - We use this as scratch space when doing our recursive /// walk. This should only be used in GetValueInBlockInternal, normally it /// should be empty. //std::vector<std::pair<BasicBlock*, TrackingVH<Value> > > IncomingPredInfo; void *IPI; - + /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that /// it creates to the vector. SmallVectorImpl<PHINode*> *InsertedPHIs; @@ -52,11 +52,11 @@ public: /// in with all PHI Nodes created by rewriting. SSAUpdater(SmallVectorImpl<PHINode*> *InsertedPHIs = 0); ~SSAUpdater(); - + /// Initialize - Reset this object to get ready for a new set of SSA /// updates. ProtoValue is the value used to name PHI nodes. void Initialize(Value *ProtoValue); - + /// AddAvailableValue - Indicate that a rewritten value is available at the /// end of the specified block with the specified value. void AddAvailableValue(BasicBlock *BB, Value *V); @@ -64,11 +64,11 @@ public: /// HasValueForBlock - Return true if the SSAUpdater already has a value for /// the specified block. bool HasValueForBlock(BasicBlock *BB) const; - + /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is /// live at the end of the specified block. Value *GetValueAtEndOfBlock(BasicBlock *BB); - + /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that /// is live in the middle of the specified block. /// @@ -89,14 +89,14 @@ public: /// merge the appropriate values, and this value isn't live out of the block. /// Value *GetValueInMiddleOfBlock(BasicBlock *BB); - + /// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, /// which use their value in the corresponding predecessor. Note that this /// will not work if the use is supposed to be rewritten to a value defined in /// the same block as the use, but above it. Any 'AddAvailableValue's added /// for the use's block will be considered to be below it. void RewriteUse(Use &U); - + private: Value *GetValueAtEndOfBlockInternal(BasicBlock *BB); void operator=(const SSAUpdater&); // DO NOT IMPLEMENT diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 6b393f6..c09fdfb 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -42,7 +42,7 @@ class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; class LLVMContext; -class MetadataContext; +class MetadataContextImpl; //===----------------------------------------------------------------------===// // Value Class @@ -83,7 +83,7 @@ private: friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name. friend class SymbolTable; // Allow SymbolTable to directly poke Name. friend class ValueHandleBase; - friend class MetadataContext; + friend class MetadataContextImpl; friend class AbstractTypeUser; ValueName *Name; |