diff options
Diffstat (limited to 'contrib/llvm/include')
188 files changed, 5281 insertions, 2772 deletions
diff --git a/contrib/llvm/include/llvm-c/Core.h b/contrib/llvm/include/llvm-c/Core.h index 117f2d6..75cee7d 100644 --- a/contrib/llvm/include/llvm-c/Core.h +++ b/contrib/llvm/include/llvm-c/Core.h @@ -204,8 +204,7 @@ typedef enum { LLVMPointerTypeKind, /**< Pointers */ LLVMOpaqueTypeKind, /**< Opaque: type with unknown structure */ LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */ - LLVMMetadataTypeKind, /**< Metadata */ - LLVMUnionTypeKind /**< Unions */ + LLVMMetadataTypeKind /**< Metadata */ } LLVMTypeKind; typedef enum { @@ -227,7 +226,9 @@ typedef enum { LLVMGhostLinkage, /**< Obsolete */ LLVMCommonLinkage, /**< Tentative definitions */ LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */ - LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */ + LLVMLinkerPrivateWeakLinkage, /**< Like LinkerPrivate, but is weak. */ + LLVMLinkerPrivateWeakDefAutoLinkage /**< Like LinkerPrivateWeak, but possibly + hidden. */ } LLVMLinkage; typedef enum { @@ -393,13 +394,6 @@ unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); -/* Operations on union types */ -LLVMTypeRef LLVMUnionTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, - unsigned ElementCount); -LLVMTypeRef LLVMUnionType(LLVMTypeRef *ElementTypes, unsigned ElementCount); -unsigned LLVMCountUnionElementTypes(LLVMTypeRef UnionTy); -void LLVMGetUnionElementTypes(LLVMTypeRef UnionTy, LLVMTypeRef *Dest); - /* Operations on array, pointer, and vector types (sequence types) */ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); @@ -523,6 +517,8 @@ LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); /* Operations on Users */ LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); +void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); +int LLVMGetNumOperands(LLVMValueRef Val); /* Operations on constants of any type */ LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */ @@ -570,7 +566,6 @@ LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, LLVMBool Packed); LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); -LLVMValueRef LLVMConstUnion(LLVMTypeRef Ty, LLVMValueRef Val); /* Constant expressions */ LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); @@ -750,6 +745,9 @@ LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, const char *Name); void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); +void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); +void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); + /* Operations on instructions */ LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); diff --git a/contrib/llvm/include/llvm-c/EnhancedDisassembly.h b/contrib/llvm/include/llvm-c/EnhancedDisassembly.h index ebb2cf8..d177381 100644 --- a/contrib/llvm/include/llvm-c/EnhancedDisassembly.h +++ b/contrib/llvm/include/llvm-c/EnhancedDisassembly.h @@ -51,41 +51,38 @@ typedef int (*EDRegisterReaderCallback)(uint64_t *value, unsigned regID, @typedef EDAssemblySyntax_t An assembly syntax for use in tokenizing instructions. */ -typedef enum { +enum { /*! @constant kEDAssemblySyntaxX86Intel Intel syntax for i386 and x86_64. */ kEDAssemblySyntaxX86Intel = 0, /*! @constant kEDAssemblySyntaxX86ATT AT&T syntax for i386 and x86_64. */ kEDAssemblySyntaxX86ATT = 1, kEDAssemblySyntaxARMUAL = 2 -} EDAssemblySyntax_t; +}; +typedef unsigned EDAssemblySyntax_t; /*! @typedef EDDisassemblerRef Encapsulates a disassembler for a single CPU architecture. */ -struct EDDisassembler; -typedef struct EDDisassembler *EDDisassemblerRef; +typedef void *EDDisassemblerRef; /*! @typedef EDInstRef Encapsulates a single disassembled instruction in one assembly syntax. */ -struct EDInst; -typedef struct EDInst *EDInstRef; +typedef void *EDInstRef; /*! @typedef EDTokenRef Encapsulates a token from the disassembly of an instruction. */ -struct EDToken; -typedef struct EDToken *EDTokenRef; +typedef void *EDTokenRef; /*! @typedef EDOperandRef Encapsulates an operand of an instruction. */ -struct EDOperand; -typedef struct EDOperand *EDOperandRef; +typedef void *EDOperandRef; /*! @functiongroup Getting a disassembler diff --git a/contrib/llvm/include/llvm-c/ExecutionEngine.h b/contrib/llvm/include/llvm-c/ExecutionEngine.h index 5a98a77..f5f4061 100644 --- a/contrib/llvm/include/llvm-c/ExecutionEngine.h +++ b/contrib/llvm/include/llvm-c/ExecutionEngine.h @@ -116,6 +116,8 @@ LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name, LLVMValueRef *OutFn); +void *LLVMRecompileAndRelinkFunction(LLVMExecutionEngineRef EE, LLVMValueRef Fn); + LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE); void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global, diff --git a/contrib/llvm/include/llvm-c/Target.h b/contrib/llvm/include/llvm-c/Target.h index b1b9f36..2cd15c3 100644 --- a/contrib/llvm/include/llvm-c/Target.h +++ b/contrib/llvm/include/llvm-c/Target.h @@ -1,26 +1,26 @@ -/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*\ -|* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This header declares the C interface to libLLVMTarget.a, which *| -|* implements target information. *| -|* *| -|* Many exotic languages can interoperate with C code but have a harder time *| -|* with C++ due to name mangling. So in addition to C, this interface enables *| -|* tools written in such languages. *| -|* *| -\*===----------------------------------------------------------------------===*/ +/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*/ +/* */ +/* The LLVM Compiler Infrastructure */ +/* */ +/* This file is distributed under the University of Illinois Open Source */ +/* License. See LICENSE.TXT for details. */ +/* */ +/*===----------------------------------------------------------------------===*/ +/* */ +/* This header declares the C interface to libLLVMTarget.a, which */ +/* implements target information. */ +/* */ +/* Many exotic languages can interoperate with C code but have a harder time */ +/* with C++ due to name mangling. So in addition to C, this interface enables */ +/* tools written in such languages. */ +/* */ +/*===----------------------------------------------------------------------===*/ #ifndef LLVM_C_TARGET_H #define LLVM_C_TARGET_H #include "llvm-c/Core.h" -#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" #ifdef __cplusplus extern "C" { @@ -64,15 +64,10 @@ static inline void LLVMInitializeAllTargets(void) { for JIT applications to ensure that the target gets linked in correctly. */ static inline LLVMBool LLVMInitializeNativeTarget(void) { /* If we have a native target, initialize it to ensure it is linked in. */ -#ifdef LLVM_NATIVE_ARCH -#define DoInit2(TARG) \ - LLVMInitialize ## TARG ## Info (); \ - LLVMInitialize ## TARG () -#define DoInit(T) DoInit2(T) - DoInit(LLVM_NATIVE_ARCH); +#ifdef LLVM_NATIVE_TARGET + LLVM_NATIVE_TARGETINFO(); + LLVM_NATIVE_TARGET(); return 0; -#undef DoInit -#undef DoInit2 #else return 1; #endif diff --git a/contrib/llvm/include/llvm-c/lto.h b/contrib/llvm/include/llvm-c/lto.h index 93f3760..e6f69af 100644 --- a/contrib/llvm/include/llvm-c/lto.h +++ b/contrib/llvm/include/llvm-c/lto.h @@ -18,6 +18,7 @@ #include <stdbool.h> #include <stddef.h> +#include "llvm/System/DataTypes.h" #define LTO_API_VERSION 3 @@ -135,11 +136,17 @@ lto_module_dispose(lto_module_t mod); extern const char* lto_module_get_target_triple(lto_module_t mod); +/** + * Sets triple string with which the object will be codegened. + */ +extern void +lto_module_set_target_triple(lto_module_t mod, const char *triple); + /** * Returns the number of symbols in the object module. */ -extern unsigned int +extern uint32_t lto_module_get_num_symbols(lto_module_t mod); @@ -147,14 +154,14 @@ lto_module_get_num_symbols(lto_module_t mod); * Returns the name of the ith symbol in the object module. */ extern const char* -lto_module_get_symbol_name(lto_module_t mod, unsigned int index); +lto_module_get_symbol_name(lto_module_t mod, uint32_t index); /** * Returns the attributes of the ith symbol in the object module. */ extern lto_symbol_attributes -lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); +lto_module_get_symbol_attribute(lto_module_t mod, uint32_t index); /** @@ -200,11 +207,10 @@ lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); /** - * Sets the location of the "gcc" to run. If not set, libLTO will search for - * "gcc" on the path. + * Sets the cpu to generate code for. */ extern void -lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path); +lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); /** @@ -214,6 +220,12 @@ lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path); extern void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); +/** + * Sets extra arguments that libLTO should pass to the assembler. + */ +extern void +lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, + int nargs); /** * Adds to a list of all global symbols that must exist in the final diff --git a/contrib/llvm/include/llvm/ADT/APInt.h b/contrib/llvm/include/llvm/ADT/APInt.h index 59e023b..8004cb4 100644 --- a/contrib/llvm/include/llvm/ADT/APInt.h +++ b/contrib/llvm/include/llvm/ADT/APInt.h @@ -464,7 +464,7 @@ public: // For small values, return quickly if (numBits <= APINT_BITS_PER_WORD) return APInt(numBits, ~0ULL << shiftAmt); - return (~APInt(numBits, 0)).shl(shiftAmt); + return getAllOnesValue(numBits).shl(shiftAmt); } /// Constructs an APInt value that has the bottom loBitsSet bits set. @@ -481,7 +481,7 @@ public: // For small values, return quickly. if (numBits < APINT_BITS_PER_WORD) return APInt(numBits, (1ULL << loBitsSet) - 1); - return (~APInt(numBits, 0)).lshr(numBits - loBitsSet); + return getAllOnesValue(numBits).lshr(numBits - loBitsSet); } /// The hash value is computed as the sum of the words and the bit width. diff --git a/contrib/llvm/include/llvm/ADT/DenseMap.h b/contrib/llvm/include/llvm/ADT/DenseMap.h index c53e255..06a1575 100644 --- a/contrib/llvm/include/llvm/ADT/DenseMap.h +++ b/contrib/llvm/include/llvm/ADT/DenseMap.h @@ -185,13 +185,12 @@ public: ++NumTombstones; return true; } - bool erase(iterator I) { + void erase(iterator I) { BucketT *TheBucket = &*I; TheBucket->second.~ValueT(); TheBucket->first = getTombstoneKey(); --NumEntries; ++NumTombstones; - return true; } void swap(DenseMap& RHS) { diff --git a/contrib/llvm/include/llvm/ADT/DenseSet.h b/contrib/llvm/include/llvm/ADT/DenseSet.h index 9388338..00bcf64 100644 --- a/contrib/llvm/include/llvm/ADT/DenseSet.h +++ b/contrib/llvm/include/llvm/ADT/DenseSet.h @@ -58,6 +58,7 @@ public: class Iterator { typename MapTy::iterator I; + friend class DenseSet; public: typedef typename MapTy::iterator::difference_type difference_type; typedef ValueT value_type; @@ -77,6 +78,7 @@ public: class ConstIterator { typename MapTy::const_iterator I; + friend class DenseSet; public: typedef typename MapTy::const_iterator::difference_type difference_type; typedef ValueT value_type; @@ -103,6 +105,10 @@ public: const_iterator begin() const { return ConstIterator(TheMap.begin()); } const_iterator end() const { return ConstIterator(TheMap.end()); } + iterator find(const ValueT &V) { return Iterator(TheMap.find(V)); } + void erase(Iterator I) { return TheMap.erase(I.I); } + void erase(ConstIterator CI) { return TheMap.erase(CI.I); } + std::pair<iterator, bool> insert(const ValueT &V) { return TheMap.insert(std::make_pair(V, 0)); } diff --git a/contrib/llvm/include/llvm/ADT/DepthFirstIterator.h b/contrib/llvm/include/llvm/ADT/DepthFirstIterator.h index 5f2df2a..b9e5cbd 100644 --- a/contrib/llvm/include/llvm/ADT/DepthFirstIterator.h +++ b/contrib/llvm/include/llvm/ADT/DepthFirstIterator.h @@ -183,6 +183,16 @@ public: inline bool nodeVisited(NodeType *Node) const { return this->Visited.count(Node) != 0; } + + /// getPathLength - Return the length of the path from the entry node to the + /// current node, counting both nodes. + unsigned getPathLength() const { return VisitStack.size(); } + + /// getPath - Return the n'th node in the path from the the entry node to the + /// current node. + NodeType *getPath(unsigned n) const { + return VisitStack[n].first.getPointer(); + } }; diff --git a/contrib/llvm/include/llvm/ADT/FoldingSet.h b/contrib/llvm/include/llvm/ADT/FoldingSet.h index fc8490a..662b5e2 100644 --- a/contrib/llvm/include/llvm/ADT/FoldingSet.h +++ b/contrib/llvm/include/llvm/ADT/FoldingSet.h @@ -54,9 +54,9 @@ namespace llvm { /// void Profile(FoldingSetNodeID &ID) const { /// ID.AddString(Name); /// ID.AddInteger(Value); -/// } -/// ... -/// }; +/// } +/// ... +/// }; /// /// To define the folding set itself use the FoldingSet template; /// @@ -190,26 +190,76 @@ protected: /// GetNodeProfile - Instantiations of the FoldingSet template implement /// this function to gather data bits for the given node. - virtual void GetNodeProfile(FoldingSetNodeID &ID, Node *N) const = 0; + virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const = 0; + /// NodeEquals - Instantiations of the FoldingSet template implement + /// this function to compare the given node with the given ID. + virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID) const=0; + /// NodeEquals - Instantiations of the FoldingSet template implement + /// this function to compute a hash value for the given node. + virtual unsigned ComputeNodeHash(Node *N, + FoldingSetNodeID &TempID) const = 0; }; //===----------------------------------------------------------------------===// -/// FoldingSetTrait - This trait class is used to define behavior of how -/// to "profile" (in the FoldingSet parlance) an object of a given type. -/// The default behavior is to invoke a 'Profile' method on an object, but -/// through template specialization the behavior can be tailored for specific -/// types. Combined with the FoldingSetNodeWrapper classs, one can add objects -/// to FoldingSets that were not originally designed to have that behavior. + +template<typename T> struct FoldingSetTrait; + +/// DefaultFoldingSetTrait - This class provides default implementations +/// for FoldingSetTrait implementations. /// -template<typename T> struct FoldingSetTrait { - static inline void Profile(const T& X, FoldingSetNodeID& ID) { X.Profile(ID);} - static inline void Profile(T& X, FoldingSetNodeID& ID) { X.Profile(ID); } - template <typename Ctx> - static inline void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { +template<typename T> struct DefaultFoldingSetTrait { + static void Profile(const T& X, FoldingSetNodeID& ID) { + X.Profile(ID); + } + static void Profile(T& X, FoldingSetNodeID& ID) { + X.Profile(ID); + } + + // Equals - Test if the profile for X would match ID, using TempID + // to compute a temporary ID if necessary. The default implementation + // just calls Profile and does a regular comparison. Implementations + // can override this to provide more efficient implementations. + static inline bool Equals(T &X, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID); + + // ComputeHash - Compute a hash value for X, using TempID to + // compute a temporary ID if necessary. The default implementation + // just calls Profile and does a regular hash computation. + // Implementations can override this to provide more efficient + // implementations. + static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID); +}; + +/// FoldingSetTrait - This trait class is used to define behavior of how +/// to "profile" (in the FoldingSet parlance) an object of a given type. +/// The default behavior is to invoke a 'Profile' method on an object, but +/// through template specialization the behavior can be tailored for specific +/// types. Combined with the FoldingSetNodeWrapper class, one can add objects +/// to FoldingSets that were not originally designed to have that behavior. +template<typename T> struct FoldingSetTrait + : public DefaultFoldingSetTrait<T> {}; + +template<typename T, typename Ctx> struct ContextualFoldingSetTrait; + +/// DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but +/// for ContextualFoldingSets. +template<typename T, typename Ctx> +struct DefaultContextualFoldingSetTrait { + static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) { X.Profile(ID, Context); } + static inline bool Equals(T &X, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID, Ctx Context); + static inline unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, + Ctx Context); }; +/// ContextualFoldingSetTrait - Like FoldingSetTrait, but for +/// ContextualFoldingSets. +template<typename T, typename Ctx> struct ContextualFoldingSetTrait + : public DefaultContextualFoldingSetTrait<T, Ctx> {}; + //===--------------------------------------------------------------------===// /// FoldingSetNodeIDRef - This class describes a reference to an interned /// FoldingSetNodeID, which can be a useful to store node id data rather @@ -217,13 +267,19 @@ template<typename T> struct FoldingSetTrait { /// is often much larger than necessary, and the possibility of heap /// allocation means it requires a non-trivial destructor call. class FoldingSetNodeIDRef { - unsigned* Data; + const unsigned* Data; size_t Size; public: FoldingSetNodeIDRef() : Data(0), Size(0) {} - FoldingSetNodeIDRef(unsigned *D, size_t S) : Data(D), Size(S) {} + FoldingSetNodeIDRef(const unsigned *D, size_t S) : Data(D), Size(S) {} + + /// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, + /// used to lookup the node in the FoldingSetImpl. + unsigned ComputeHash() const; - unsigned *getData() const { return Data; } + bool operator==(FoldingSetNodeIDRef) const; + + const unsigned *getData() const { return Data; } size_t getSize() const { return Size; } }; @@ -259,16 +315,17 @@ public: inline void Add(const T& x) { FoldingSetTrait<T>::Profile(x, *this); } /// clear - Clear the accumulated profile, allowing this FoldingSetNodeID - /// object to be used to compute a new profile. + /// object to be used to compute a new profile. inline void clear() { Bits.clear(); } /// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used - /// to lookup the node in the FoldingSetImpl. + /// to lookup the node in the FoldingSetImpl. unsigned ComputeHash() const; /// operator== - Used to compare two nodes to each other. /// bool operator==(const FoldingSetNodeID &RHS) const; + bool operator==(const FoldingSetNodeIDRef RHS) const; /// Intern - Copy this node's data to a memory region allocated from the /// given allocator and return a FoldingSetNodeIDRef describing the @@ -281,6 +338,39 @@ typedef FoldingSetImpl::Node FoldingSetNode; template<class T> class FoldingSetIterator; template<class T> class FoldingSetBucketIterator; +// Definitions of FoldingSetTrait and ContextualFoldingSetTrait functions, which +// require the definition of FoldingSetNodeID. +template<typename T> +inline bool +DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID) { + FoldingSetTrait<T>::Profile(X, TempID); + return TempID == ID; +} +template<typename T> +inline unsigned +DefaultFoldingSetTrait<T>::ComputeHash(T &X, FoldingSetNodeID &TempID) { + FoldingSetTrait<T>::Profile(X, TempID); + return TempID.ComputeHash(); +} +template<typename T, typename Ctx> +inline bool +DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X, + const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID, + Ctx Context) { + ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context); + return TempID == ID; +} +template<typename T, typename Ctx> +inline unsigned +DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(T &X, + FoldingSetNodeID &TempID, + Ctx Context) { + ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context); + return TempID.ComputeHash(); +} + //===----------------------------------------------------------------------===// /// FoldingSet - This template class is used to instantiate a specialized /// implementation of the folding set to the node class T. T must be a @@ -290,9 +380,23 @@ template<class T> class FoldingSet : public FoldingSetImpl { private: /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a /// way to convert nodes into a unique specifier. - virtual void GetNodeProfile(FoldingSetNodeID &ID, Node *N) const { + virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const { + T *TN = static_cast<T *>(N); + FoldingSetTrait<T>::Profile(*TN, ID); + } + /// NodeEquals - Instantiations may optionally provide a way to compare a + /// node with a specified ID. + virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID) const { T *TN = static_cast<T *>(N); - FoldingSetTrait<T>::Profile(*TN,ID); + return FoldingSetTrait<T>::Equals(*TN, ID, TempID); + } + /// NodeEquals - Instantiations may optionally provide a way to compute a + /// hash value directly from a node. + virtual unsigned ComputeNodeHash(Node *N, + FoldingSetNodeID &TempID) const { + T *TN = static_cast<T *>(N); + return FoldingSetTrait<T>::ComputeHash(*TN, TempID); } public: @@ -354,13 +458,21 @@ private: /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a /// way to convert nodes into a unique specifier. - virtual void GetNodeProfile(FoldingSetNodeID &ID, - FoldingSetImpl::Node *N) const { + virtual void GetNodeProfile(FoldingSetImpl::Node *N, + FoldingSetNodeID &ID) const { T *TN = static_cast<T *>(N); - - // We must use explicit template arguments in case Ctx is a - // reference type. - FoldingSetTrait<T>::template Profile<Ctx>(*TN, ID, Context); + ContextualFoldingSetTrait<T, Ctx>::Profile(*TN, ID, Context); + } + virtual bool NodeEquals(FoldingSetImpl::Node *N, + const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID) const { + T *TN = static_cast<T *>(N); + return ContextualFoldingSetTrait<T, Ctx>::Equals(*TN, ID, TempID, Context); + } + virtual unsigned ComputeNodeHash(FoldingSetImpl::Node *N, + FoldingSetNodeID &TempID) const { + T *TN = static_cast<T *>(N); + return ContextualFoldingSetTrait<T, Ctx>::ComputeHash(*TN, TempID, Context); } public: @@ -447,8 +559,8 @@ public: //===----------------------------------------------------------------------===// /// FoldingSetBucketIteratorImpl - This is the common bucket iterator support -/// shared by all folding sets, which knows how to walk a particular bucket -/// of a folding set hash table. +/// shared by all folding sets, which knows how to walk a particular bucket +/// of a folding set hash table. class FoldingSetBucketIteratorImpl { protected: @@ -549,7 +661,7 @@ class FastFoldingSetNode : public FoldingSetNode { protected: explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {} public: - void Profile(FoldingSetNodeID& ID) { ID = FastID; } + void Profile(FoldingSetNodeID& ID) const { ID = FastID; } }; //===----------------------------------------------------------------------===// @@ -559,9 +671,6 @@ template<typename T> struct FoldingSetTrait<T*> { static inline void Profile(const T* X, FoldingSetNodeID& ID) { ID.AddPointer(X); } - static inline void Profile(T* X, FoldingSetNodeID& ID) { - ID.AddPointer(X); - } }; template<typename T> struct FoldingSetTrait<const T*> { diff --git a/contrib/llvm/include/llvm/ADT/ImmutableIntervalMap.h b/contrib/llvm/include/llvm/ADT/ImmutableIntervalMap.h index 7aa3155..968ce15 100644 --- a/contrib/llvm/include/llvm/ADT/ImmutableIntervalMap.h +++ b/contrib/llvm/include/llvm/ADT/ImmutableIntervalMap.h @@ -16,14 +16,14 @@ namespace llvm { class Interval { private: - uint64_t Start; - uint64_t End; + int64_t Start; + int64_t End; public: - Interval(uint64_t S, uint64_t E) : Start(S), End(E) {} + Interval(int64_t S, int64_t E) : Start(S), End(E) {} - uint64_t getStart() const { return Start; } - uint64_t getEnd() const { return End; } + int64_t getStart() const { return Start; } + int64_t getEnd() const { return End; } }; template <typename T> diff --git a/contrib/llvm/include/llvm/ADT/NullablePtr.h b/contrib/llvm/include/llvm/ADT/NullablePtr.h new file mode 100644 index 0000000..a9c47a1 --- /dev/null +++ b/contrib/llvm/include/llvm/ADT/NullablePtr.h @@ -0,0 +1,52 @@ +//===- llvm/ADT/NullablePtr.h - A pointer that allows null ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines and implements the NullablePtr class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_NULLABLE_PTR_H +#define LLVM_ADT_NULLABLE_PTR_H + +#include <cassert> +#include <cstddef> + +namespace llvm { +/// NullablePtr pointer wrapper - NullablePtr is used for APIs where a +/// potentially-null pointer gets passed around that must be explicitly handled +/// in lots of places. By putting a wrapper around the null pointer, it makes +/// it more likely that the null pointer case will be handled correctly. +template<class T> +class NullablePtr { + T *Ptr; +public: + NullablePtr(T *P = 0) : Ptr(P) {} + + bool isNull() const { return Ptr == 0; } + bool isNonNull() const { return Ptr != 0; } + + /// get - Return the pointer if it is non-null. + const T *get() const { + assert(Ptr && "Pointer wasn't checked for null!"); + return Ptr; + } + + /// get - Return the pointer if it is non-null. + T *get() { + assert(Ptr && "Pointer wasn't checked for null!"); + return Ptr; + } + + T *getPtrOrNull() { return Ptr; } + const T *getPtrOrNull() const { return Ptr; } +}; + +} // end namespace llvm + +#endif diff --git a/contrib/llvm/include/llvm/ADT/STLExtras.h b/contrib/llvm/include/llvm/ADT/STLExtras.h index 8dbf790..0b0346b 100644 --- a/contrib/llvm/include/llvm/ADT/STLExtras.h +++ b/contrib/llvm/include/llvm/ADT/STLExtras.h @@ -225,7 +225,7 @@ inline T *array_endof(T (&x)[N]) { /// Find the length of an array. template<class T, std::size_t N> -inline size_t array_lengthof(T (&x)[N]) { +inline size_t array_lengthof(T (&)[N]) { return N; } @@ -243,7 +243,7 @@ static inline int array_pod_sort_comparator(const void *P1, const void *P2) { /// get_array_pad_sort_comparator - This is an internal helper function used to /// get type deduction of T right. template<typename T> -static int (*get_array_pad_sort_comparator(const T &X)) +static int (*get_array_pad_sort_comparator(const T &)) (const void*, const void*) { return array_pod_sort_comparator<T>; } diff --git a/contrib/llvm/include/llvm/ADT/ScopedHashTable.h b/contrib/llvm/include/llvm/ADT/ScopedHashTable.h index b5ca374a..c96ad19 100644 --- a/contrib/llvm/include/llvm/ADT/ScopedHashTable.h +++ b/contrib/llvm/include/llvm/ADT/ScopedHashTable.h @@ -139,7 +139,12 @@ public: } V lookup(const K &Key) { - return TopLevelMap[Key]->getValue(); + typename DenseMap<K, ScopedHashTableVal<K, V, KInfo>*, KInfo>::iterator + I = TopLevelMap.find(Key); + if (I != TopLevelMap.end()) + return I->second->getValue(); + + return V(); } void insert(const K &Key, const V &Val) { diff --git a/contrib/llvm/include/llvm/ADT/SmallVector.h b/contrib/llvm/include/llvm/ADT/SmallVector.h index fa61d20..1d6181a 100644 --- a/contrib/llvm/include/llvm/ADT/SmallVector.h +++ b/contrib/llvm/include/llvm/ADT/SmallVector.h @@ -206,7 +206,7 @@ template <typename T, bool isPodLike> void SmallVectorTemplateBase<T, isPodLike>::grow(size_t MinSize) { size_t CurCapacity = this->capacity(); size_t CurSize = this->size(); - size_t NewCapacity = 2*CurCapacity; + size_t NewCapacity = 2*CurCapacity + 1; // Always grow, even from zero. if (NewCapacity < MinSize) NewCapacity = MinSize; T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); @@ -707,6 +707,36 @@ public: }; +/// Specialize SmallVector at N=0. This specialization guarantees +/// that it can be instantiated at an incomplete T if none of its +/// members are required. +template <typename T> +class SmallVector<T,0> : public SmallVectorImpl<T> { +public: + SmallVector() : SmallVectorImpl<T>(0) {} + + explicit SmallVector(unsigned Size, const T &Value = T()) + : SmallVectorImpl<T>(0) { + this->reserve(Size); + while (Size--) + this->push_back(Value); + } + + template<typename ItTy> + SmallVector(ItTy S, ItTy E) : SmallVectorImpl<T>(0) { + this->append(S, E); + } + + SmallVector(const SmallVector &RHS) : SmallVectorImpl<T>(0) { + SmallVectorImpl<T>::operator=(RHS); + } + + SmallVector &operator=(const SmallVectorImpl<T> &RHS) { + return SmallVectorImpl<T>::operator=(RHS); + } + +}; + } // End llvm namespace namespace std { diff --git a/contrib/llvm/include/llvm/ADT/StringMap.h b/contrib/llvm/include/llvm/ADT/StringMap.h index 4821938..59ff6aa 100644 --- a/contrib/llvm/include/llvm/ADT/StringMap.h +++ b/contrib/llvm/include/llvm/ADT/StringMap.h @@ -254,6 +254,10 @@ public: StringMap() : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) {} explicit StringMap(unsigned InitialSize) : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))) {} + + explicit StringMap(AllocatorTy A) + : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), Allocator(A) {} + explicit StringMap(const StringMap &RHS) : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) { assert(RHS.empty() && diff --git a/contrib/llvm/include/llvm/ADT/StringRef.h b/contrib/llvm/include/llvm/ADT/StringRef.h index 33756f6..8386d3e 100644 --- a/contrib/llvm/include/llvm/ADT/StringRef.h +++ b/contrib/llvm/include/llvm/ADT/StringRef.h @@ -149,7 +149,10 @@ namespace llvm { unsigned edit_distance(StringRef Other, bool AllowReplacements = true); /// str - Get the contents as an std::string. - std::string str() const { return std::string(Data, Length); } + std::string str() const { + if (Data == 0) return std::string(); + return std::string(Data, Length); + } /// @} /// @name Operator Overloads @@ -228,12 +231,14 @@ namespace llvm { /// find_first_of - Find the first character in the string that is \arg C, /// or npos if not found. Same as find. - size_type find_first_of(char C, size_t = 0) const { return find(C); } + size_type find_first_of(char C, size_t From = 0) const { + return find(C, From); + } /// find_first_of - Find the first character in the string that is in \arg /// Chars, or npos if not found. /// - /// Note: O(size() * Chars.size()) + /// Note: O(size() + Chars.size()) size_type find_first_of(StringRef Chars, size_t From = 0) const; /// find_first_not_of - Find the first character in the string that is not @@ -243,7 +248,7 @@ namespace llvm { /// find_first_not_of - Find the first character in the string that is not /// in the string \arg Chars, or npos if not found. /// - /// Note: O(size() * Chars.size()) + /// Note: O(size() + Chars.size()) size_type find_first_not_of(StringRef Chars, size_t From = 0) const; /// @} diff --git a/contrib/llvm/include/llvm/ADT/StringSet.h b/contrib/llvm/include/llvm/ADT/StringSet.h index 0004836..9c55f6b 100644 --- a/contrib/llvm/include/llvm/ADT/StringSet.h +++ b/contrib/llvm/include/llvm/ADT/StringSet.h @@ -15,7 +15,6 @@ #define LLVM_ADT_STRINGSET_H #include "llvm/ADT/StringMap.h" -#include <cassert> namespace llvm { @@ -26,10 +25,10 @@ namespace llvm { class StringSet : public llvm::StringMap<char, AllocatorTy> { typedef llvm::StringMap<char, AllocatorTy> base; public: - bool insert(const std::string& InLang) { + bool insert(StringRef InLang) { assert(!InLang.empty()); - const char* KeyStart = &InLang[0]; - const char* KeyEnd = KeyStart + InLang.size(); + const char *KeyStart = InLang.data(); + const char *KeyEnd = KeyStart + InLang.size(); return base::insert(llvm::StringMapEntry<char>:: Create(KeyStart, KeyEnd, base::getAllocator(), '+')); } diff --git a/contrib/llvm/include/llvm/ADT/StringSwitch.h b/contrib/llvm/include/llvm/ADT/StringSwitch.h index 7dd5647..7480583 100644 --- a/contrib/llvm/include/llvm/ADT/StringSwitch.h +++ b/contrib/llvm/include/llvm/ADT/StringSwitch.h @@ -61,6 +61,26 @@ public: return *this; } + template<unsigned N> + StringSwitch& EndsWith(const char (&S)[N], const T &Value) { + if (!Result && Str.size() >= N-1 && + std::memcmp(S, Str.data() + Str.size() + 1 - N, N-1) == 0) { + Result = &Value; + } + + return *this; + } + + template<unsigned N> + StringSwitch& StartsWith(const char (&S)[N], const T &Value) { + if (!Result && Str.size() >= N-1 && + std::memcmp(S, Str.data(), N-1) == 0) { + Result = &Value; + } + + return *this; + } + template<unsigned N0, unsigned N1> StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], const T& Value) { diff --git a/contrib/llvm/include/llvm/ADT/Triple.h b/contrib/llvm/include/llvm/ADT/Triple.h index feade6a..8dca3c1 100644 --- a/contrib/llvm/include/llvm/ADT/Triple.h +++ b/contrib/llvm/include/llvm/ADT/Triple.h @@ -24,7 +24,7 @@ class Twine; /// Triple - Helper class for working with target triples. /// -/// Target triples are strings in the format of: +/// Target triples are strings in the canonical form: /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM /// or /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT @@ -35,20 +35,11 @@ class Twine; /// from the components of the target triple to well known IDs. /// /// At its core the Triple class is designed to be a wrapper for a triple -/// string; it does not normally change or normalize the triple string, instead -/// it provides additional APIs to parse normalized parts out of the triple. +/// string; the constructor does not change or normalize the triple string. +/// Clients that need to handle the non-canonical triples that users often +/// specify should use the normalize method. /// -/// One curiosity this implies is that for some odd triples the results of, -/// e.g., getOSName() can be very different from the result of getOS(). For -/// example, for 'i386-mingw32', getOS() will return MinGW32, but since -/// getOSName() is purely based on the string structure that will return the -/// empty string. -/// -/// Clients should generally avoid using getOSName() and related APIs unless -/// they are familiar with the triple format (this is particularly true when -/// rewriting a triple). -/// -/// See autoconf/config.guess for a glimpse into what they look like in +/// See autoconf/config.guess for a glimpse into what triples look like in /// practice. class Triple { public: @@ -117,6 +108,9 @@ private: mutable OSType OS; bool isInitialized() const { return Arch != InvalidArch; } + static ArchType ParseArch(StringRef ArchName); + static VendorType ParseVendor(StringRef VendorName); + static OSType ParseOS(StringRef OSName); void Parse() const; public: @@ -134,6 +128,16 @@ public: } /// @} + /// @name Normalization + /// @{ + + /// normalize - Turn an arbitrary machine specification into the canonical + /// triple form (or something sensible that the Triple class understands if + /// nothing better can reasonably be done). In particular, it handles the + /// common case in which otherwise valid components are in the wrong order. + static std::string normalize(StringRef Str); + + /// @} /// @name Typed Component Access /// @{ diff --git a/contrib/llvm/include/llvm/ADT/ValueMap.h b/contrib/llvm/include/llvm/ADT/ValueMap.h index 9e30bd4..ded17fc 100644 --- a/contrib/llvm/include/llvm/ADT/ValueMap.h +++ b/contrib/llvm/include/llvm/ADT/ValueMap.h @@ -82,13 +82,13 @@ class ValueMap { typedef typename Config::ExtraData ExtraData; MapT Map; ExtraData Data; + ValueMap(const ValueMap&); // DO NOT IMPLEMENT + ValueMap& operator=(const ValueMap&); // DO NOT IMPLEMENT 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) @@ -149,7 +149,7 @@ public: bool erase(const KeyT &Val) { return Map.erase(Wrap(Val)); } - bool erase(iterator I) { + void erase(iterator I) { return Map.erase(I.base()); } @@ -161,12 +161,6 @@ public: 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). @@ -250,12 +244,6 @@ public: } }; - -template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT> -struct isPodLike<ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> > { - static const bool value = true; -}; - template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT> struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> > { typedef ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> VH; diff --git a/contrib/llvm/include/llvm/ADT/ilist.h b/contrib/llvm/include/llvm/ADT/ilist.h index 9479d00..4e3afe1 100644 --- a/contrib/llvm/include/llvm/ADT/ilist.h +++ b/contrib/llvm/include/llvm/ADT/ilist.h @@ -614,7 +614,6 @@ public: template<class Pr3> void sort(Pr3 pred); void sort() { sort(op_less); } - void reverse(); }; diff --git a/contrib/llvm/include/llvm/ADT/iterator.cmake b/contrib/llvm/include/llvm/ADT/iterator.cmake deleted file mode 100644 index 55df8ce..0000000 --- a/contrib/llvm/include/llvm/ADT/iterator.cmake +++ /dev/null @@ -1,79 +0,0 @@ -//===-- llvm/ADT/iterator - Portable wrapper around <iterator> --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides a wrapper around the mysterious <iterator> header file. -// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other -// friends), instead of the standard iterator class. In GCC 3.1, the -// bidirectional_iterator class got moved out and the new, standards compliant, -// iterator<> class was added. Because there is nothing that we can do to get -// correct behavior on both compilers, we have this header with #ifdef's. Gross -// huh? -// -// By #includ'ing this file, you get the contents of <iterator> plus the -// following classes in the global namespace: -// -// 1. bidirectional_iterator -// 2. forward_iterator -// -// The #if directives' expressions are filled in by Autoconf. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_ITERATOR -#define LLVM_ADT_ITERATOR - -#include <iterator> - -#undef HAVE_BI_ITERATOR -#undef HAVE_STD_ITERATOR -#undef HAVE_FWD_ITERATOR - -// defined by Kevin -#define HAVE_STD_ITERATOR 1 - -#ifdef _MSC_VER -# define HAVE_BI_ITERATOR 0 -# define HAVE_STD_ITERATOR 1 -# define HAVE_FWD_ITERATOR 0 -#endif - -#if !HAVE_BI_ITERATOR -# if HAVE_STD_ITERATOR -/// If the bidirectional iterator is not defined, we attempt to define it in -/// terms of the C++ standard iterator. Otherwise, we import it with a "using" -/// statement. -/// -template<class Ty, class PtrDiffTy> -struct bidirectional_iterator - : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> { -}; -# else -# error "Need to have standard iterator to define bidirectional iterator!" -# endif -#else -using std::bidirectional_iterator; -#endif - -#if !HAVE_FWD_ITERATOR -# if HAVE_STD_ITERATOR -/// If the forward iterator is not defined, attempt to define it in terms of -/// the C++ standard iterator. Otherwise, we import it with a "using" statement. -/// -template<class Ty, class PtrDiffTy> -struct forward_iterator - : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> { -}; -# else -# error "Need to have standard iterator to define forward iterator!" -# endif -#else -using std::forward_iterator; -#endif - -#endif diff --git a/contrib/llvm/include/llvm/ADT/iterator.h.in b/contrib/llvm/include/llvm/ADT/iterator.h.in deleted file mode 100644 index dce7462..0000000 --- a/contrib/llvm/include/llvm/ADT/iterator.h.in +++ /dev/null @@ -1,76 +0,0 @@ -//==-- llvm/ADT/iterator.h - Portable wrapper around <iterator> --*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides a wrapper around the mysterious <iterator> header file. -// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other -// friends), instead of the standard iterator class. In GCC 3.1, the -// bidirectional_iterator class got moved out and the new, standards compliant, -// iterator<> class was added. Because there is nothing that we can do to get -// correct behavior on both compilers, we have this header with #ifdef's. Gross -// huh? -// -// By #includ'ing this file, you get the contents of <iterator> plus the -// following classes in the global namespace: -// -// 1. bidirectional_iterator -// 2. forward_iterator -// -// The #if directives' expressions are filled in by Autoconf. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ADT_ITERATOR_H -#define LLVM_ADT_ITERATOR_H - -#include <iterator> - -#undef HAVE_BI_ITERATOR -#undef HAVE_STD_ITERATOR -#undef HAVE_FWD_ITERATOR - -#ifdef _MSC_VER -# define HAVE_BI_ITERATOR 0 -# define HAVE_STD_ITERATOR 1 -# define HAVE_FWD_ITERATOR 0 -#endif - -#if !HAVE_BI_ITERATOR -# if HAVE_STD_ITERATOR -/// If the bidirectional iterator is not defined, we attempt to define it in -/// terms of the C++ standard iterator. Otherwise, we import it with a "using" -/// statement. -/// -template<class Ty, class PtrDiffTy> -struct bidirectional_iterator - : public std::iterator<std::bidirectional_iterator_tag, Ty, PtrDiffTy> { -}; -# else -# error "Need to have standard iterator to define bidirectional iterator!" -# endif -#else -using std::bidirectional_iterator; -#endif - -#if !HAVE_FWD_ITERATOR -# if HAVE_STD_ITERATOR -/// If the forward iterator is not defined, attempt to define it in terms of -/// the C++ standard iterator. Otherwise, we import it with a "using" statement. -/// -template<class Ty, class PtrDiffTy> -struct forward_iterator - : public std::iterator<std::forward_iterator_tag, Ty, PtrDiffTy> { -}; -# else -# error "Need to have standard iterator to define forward iterator!" -# endif -#else -using std::forward_iterator; -#endif - -#endif // LLVM_ADT_ITERATOR_H diff --git a/contrib/llvm/include/llvm/Analysis/AliasAnalysis.h b/contrib/llvm/include/llvm/Analysis/AliasAnalysis.h index e611a35..ad68d48 100644 --- a/contrib/llvm/include/llvm/Analysis/AliasAnalysis.h +++ b/contrib/llvm/include/llvm/Analysis/AliasAnalysis.h @@ -18,12 +18,9 @@ // // This API represents memory as a (Pointer, Size) pair. The Pointer component // specifies the base memory address of the region, the Size specifies how large -// of an area is being queried. If Size is 0, two pointers only alias if they -// are exactly equal. If size is greater than zero, but small, the two pointers -// alias if the areas pointed to overlap. If the size is very large (ie, ~0U), -// then the two pointers alias if they may be pointing to components of the same -// memory object. Pointers that point to two completely different objects in -// memory never alias, regardless of the value of the Size component. +// of an area is being queried, or UnknownSize if the size is not known. +// Pointers that point to two completely different objects in memory never +// alias, regardless of the value of the Size component. // //===----------------------------------------------------------------------===// @@ -46,8 +43,11 @@ class AnalysisUsage; class AliasAnalysis { protected: const TargetData *TD; + +private: AliasAnalysis *AA; // Previous Alias Analysis to chain to. +protected: /// InitializeAliasAnalysis - Subclasses must call this method to initialize /// the AliasAnalysis interface before any other methods are called. This is /// typically called by the run* methods of these subclasses. This may be @@ -64,6 +64,11 @@ public: AliasAnalysis() : TD(0), AA(0) {} virtual ~AliasAnalysis(); // We want to be subclassed + /// UnknownSize - This is a special value which can be used with the + /// size arguments in alias queries to indicate that the caller does not + /// know the sizes of the potential memory references. + static unsigned const UnknownSize = ~0u; + /// getTargetData - Return a pointer to the current TargetData object, or /// null if no TargetData object is available. /// @@ -84,6 +89,9 @@ public: /// if (AA.alias(P1, P2)) { ... } /// to check to see if two pointers might alias. /// + /// See docs/AliasAnalysis.html for more information on the specific meanings + /// of these values. + /// enum AliasResult { NoAlias = 0, MayAlias = 1, MustAlias = 2 }; /// alias - The main low level interface to the alias analysis implementation. @@ -94,6 +102,11 @@ public: virtual AliasResult alias(const Value *V1, unsigned V1Size, const Value *V2, unsigned V2Size); + /// alias - A convenience wrapper for the case where the sizes are unknown. + AliasResult alias(const Value *V1, const Value *V2) { + return alias(V1, UnknownSize, V2, UnknownSize); + } + /// isNoAlias - A trivial helper function to check to see if the specified /// pointers are no-alias. bool isNoAlias(const Value *V1, unsigned V1Size, @@ -130,17 +143,11 @@ public: // AccessesArguments - This function accesses function arguments in well // known (possibly volatile) ways, but does not access any other memory. - // - // Clients may use the Info parameter of getModRefBehavior to get specific - // information about how pointer arguments are used. AccessesArguments, // AccessesArgumentsAndGlobals - This function has accesses function // arguments and global variables well known (possibly volatile) ways, but // does not access any other memory. - // - // Clients may use the Info parameter of getModRefBehavior to get specific - // information about how pointer arguments are used. AccessesArgumentsAndGlobals, // OnlyReadsMemory - This function does not perform any non-local stores or @@ -154,31 +161,17 @@ public: UnknownModRefBehavior }; - /// PointerAccessInfo - This struct is used to return results for pointers, - /// globals, and the return value of a function. - struct PointerAccessInfo { - /// V - The value this record corresponds to. This may be an Argument for - /// the function, a GlobalVariable, or null, corresponding to the return - /// value for the function. - Value *V; - - /// ModRefInfo - Whether the pointer is loaded or stored to/from. - /// - ModRefResult ModRefInfo; - }; - /// getModRefBehavior - Return the behavior when calling the given call site. - virtual ModRefBehavior getModRefBehavior(CallSite CS, - std::vector<PointerAccessInfo> *Info = 0); + virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS); /// getModRefBehavior - Return the behavior when calling the given function. /// For use when the call site is not known. - virtual ModRefBehavior getModRefBehavior(Function *F, - std::vector<PointerAccessInfo> *Info = 0); + virtual ModRefBehavior getModRefBehavior(const Function *F); - /// getModRefBehavior - Return the modref behavior of the intrinsic with the - /// given id. - static ModRefBehavior getModRefBehavior(unsigned iid); + /// getIntrinsicModRefBehavior - Return the modref behavior of the intrinsic + /// with the given id. Most clients won't need this, because the regular + /// getModRefBehavior incorporates this information. + static ModRefBehavior getIntrinsicModRefBehavior(unsigned iid); /// doesNotAccessMemory - If the specified call is known to never read or /// write memory, return true. If the call only reads from known-constant @@ -191,14 +184,14 @@ public: /// /// This property corresponds to the GCC 'const' attribute. /// - bool doesNotAccessMemory(CallSite CS) { + bool doesNotAccessMemory(ImmutableCallSite CS) { return getModRefBehavior(CS) == DoesNotAccessMemory; } /// doesNotAccessMemory - If the specified function is known to never read or /// write memory, return true. For use when the call site is not known. /// - bool doesNotAccessMemory(Function *F) { + bool doesNotAccessMemory(const Function *F) { return getModRefBehavior(F) == DoesNotAccessMemory; } @@ -211,7 +204,7 @@ public: /// /// This property corresponds to the GCC 'pure' attribute. /// - bool onlyReadsMemory(CallSite CS) { + bool onlyReadsMemory(ImmutableCallSite CS) { ModRefBehavior MRB = getModRefBehavior(CS); return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory; } @@ -220,7 +213,7 @@ public: /// non-volatile memory (or not access memory at all), return true. For use /// when the call site is not known. /// - bool onlyReadsMemory(Function *F) { + bool onlyReadsMemory(const Function *F) { ModRefBehavior MRB = getModRefBehavior(F); return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory; } @@ -234,36 +227,36 @@ public: /// a particular call site modifies or reads the memory specified by the /// pointer. /// - virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + virtual ModRefResult getModRefInfo(ImmutableCallSite CS, + const Value *P, unsigned Size); /// getModRefInfo - Return information about whether two call sites may refer - /// to the same set of memory locations. This function returns NoModRef if - /// the two calls refer to disjoint memory locations, Ref if CS1 reads memory - /// written by CS2, Mod if CS1 writes to memory read or written by CS2, or - /// ModRef if CS1 might read or write memory accessed by CS2. - /// - virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); + /// to the same set of memory locations. See + /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo + /// for details. + virtual ModRefResult getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2); public: /// Convenience functions... - ModRefResult getModRefInfo(LoadInst *L, Value *P, unsigned Size); - ModRefResult getModRefInfo(StoreInst *S, Value *P, unsigned Size); - ModRefResult getModRefInfo(CallInst *C, Value *P, unsigned Size) { - return getModRefInfo(CallSite(C), P, Size); - } - ModRefResult getModRefInfo(InvokeInst *I, Value *P, unsigned Size) { - return getModRefInfo(CallSite(I), P, Size); + ModRefResult getModRefInfo(const LoadInst *L, const Value *P, unsigned Size); + ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size); + ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, unsigned Size); + ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) { + return getModRefInfo(ImmutableCallSite(C), P, Size); } - ModRefResult getModRefInfo(VAArgInst* I, Value* P, unsigned Size) { - return AliasAnalysis::ModRef; + ModRefResult getModRefInfo(const InvokeInst *I, + const Value *P, unsigned Size) { + return getModRefInfo(ImmutableCallSite(I), P, Size); } - ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) { + ModRefResult getModRefInfo(const Instruction *I, + const Value *P, unsigned Size) { switch (I->getOpcode()) { - case Instruction::VAArg: return getModRefInfo((VAArgInst*)I, P, Size); - case Instruction::Load: return getModRefInfo((LoadInst*)I, P, Size); - case Instruction::Store: return getModRefInfo((StoreInst*)I, P, Size); - case Instruction::Call: return getModRefInfo((CallInst*)I, P, Size); - case Instruction::Invoke: return getModRefInfo((InvokeInst*)I, P, Size); + case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, P,Size); + case Instruction::Load: return getModRefInfo((const LoadInst*)I, P, Size); + case Instruction::Store: return getModRefInfo((const StoreInst*)I, P,Size); + case Instruction::Call: return getModRefInfo((const CallInst*)I, P, Size); + case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,P,Size); default: return NoModRef; } } diff --git a/contrib/llvm/include/llvm/Analysis/AliasSetTracker.h b/contrib/llvm/include/llvm/Analysis/AliasSetTracker.h index 09f12ad..8e2f7fd 100644 --- a/contrib/llvm/include/llvm/Analysis/AliasSetTracker.h +++ b/contrib/llvm/include/llvm/Analysis/AliasSetTracker.h @@ -92,7 +92,8 @@ class AliasSet : public ilist_node<AliasSet> { AliasSet *Forward; // Forwarding pointer. AliasSet *Next, *Prev; // Doubly linked list of AliasSets. - std::vector<CallSite> CallSites; // All calls & invokes in this alias set. + // All calls & invokes in this alias set. + std::vector<AssertingVH<Instruction> > CallSites; // RefCount - Number of nodes pointing to this AliasSet plus the number of // AliasSets forwarding to it. @@ -127,6 +128,11 @@ class AliasSet : public ilist_node<AliasSet> { removeFromTracker(AST); } + CallSite getCallSite(unsigned i) const { + assert(i < CallSites.size()); + return CallSite(CallSites[i]); + } + public: /// Accessors... bool isRef() const { return AccessTy & Refs; } @@ -229,7 +235,7 @@ private: void addCallSite(CallSite CS, AliasAnalysis &AA); void removeCallSite(CallSite CS) { for (size_t i = 0, e = CallSites.size(); i != e; ++i) - if (CallSites[i].getInstruction() == CS.getInstruction()) { + if (CallSites[i] == CS.getInstruction()) { CallSites[i] = CallSites.back(); CallSites.pop_back(); } diff --git a/contrib/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h b/contrib/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h index 4828eba..d8daf51 100644 --- a/contrib/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h +++ b/contrib/llvm/include/llvm/Analysis/DOTGraphTraitsPass.h @@ -22,7 +22,7 @@ template <class Analysis, bool Simple> struct DOTGraphTraitsViewer : public FunctionPass { std::string Name; - DOTGraphTraitsViewer(std::string GraphName, const void *ID) : FunctionPass(ID) { + DOTGraphTraitsViewer(std::string GraphName, char &ID) : FunctionPass(ID) { Name = GraphName; } @@ -48,7 +48,7 @@ struct DOTGraphTraitsPrinter : public FunctionPass { std::string Name; - DOTGraphTraitsPrinter(std::string GraphName, const void *ID) + DOTGraphTraitsPrinter(std::string GraphName, char &ID) : FunctionPass(ID) { Name = GraphName; } diff --git a/contrib/llvm/include/llvm/Analysis/DebugInfo.h b/contrib/llvm/include/llvm/Analysis/DebugInfo.h index a85b6bc..2d1418d 100644 --- a/contrib/llvm/include/llvm/Analysis/DebugInfo.h +++ b/contrib/llvm/include/llvm/Analysis/DebugInfo.h @@ -36,6 +36,12 @@ namespace llvm { class LLVMContext; class raw_ostream; + class DIFile; + class DISubprogram; + class DILexicalBlock; + class DIVariable; + class DIType; + /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. /// This should not be stored in a container, because underly MDNode may /// change in certain situations. @@ -56,11 +62,17 @@ namespace llvm { } GlobalVariable *getGlobalVariableField(unsigned Elt) const; + Constant *getConstantField(unsigned Elt) const; Function *getFunctionField(unsigned Elt) const; public: explicit DIDescriptor() : DbgNode(0) {} explicit DIDescriptor(const MDNode *N) : DbgNode(N) {} + explicit DIDescriptor(const DIFile F); + explicit DIDescriptor(const DISubprogram F); + explicit DIDescriptor(const DILexicalBlock F); + explicit DIDescriptor(const DIVariable F); + explicit DIDescriptor(const DIType F); bool Verify() const { return DbgNode != 0; } @@ -134,7 +146,7 @@ namespace llvm { public: explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {} - unsigned getLanguage() const { return getUnsignedField(2); } + unsigned getLanguage() const { return getUnsignedField(2); } StringRef getFilename() const { return getStringField(3); } StringRef getDirectory() const { return getStringField(4); } StringRef getProducer() const { return getStringField(5); } @@ -260,6 +272,10 @@ namespace llvm { StringRef getFilename() const { return getCompileUnit().getFilename();} StringRef getDirectory() const { return getCompileUnit().getDirectory();} + /// replaceAllUsesWith - Replace all uses of debug info referenced by + /// this descriptor. + void replaceAllUsesWith(DIDescriptor &D); + /// print - print type. void print(raw_ostream &OS) const; @@ -274,6 +290,9 @@ namespace llvm { unsigned getEncoding() const { return getUnsignedField(9); } + /// Verify - Verify that a basic type descriptor is well formed. + bool Verify() const; + /// print - print basic type. void print(raw_ostream &OS) const; @@ -297,16 +316,14 @@ namespace llvm { /// return base type size. uint64_t getOriginalTypeSize() const; + /// Verify - Verify that a derived type descriptor is well formed. + bool Verify() const; + /// print - print derived type. void print(raw_ostream &OS) const; /// dump - print derived type to dbgs() with a newline. void dump() const; - - /// replaceAllUsesWith - Replace all uses of debug info referenced by - /// this descriptor. After this completes, the current debug info value - /// is erased. - void replaceAllUsesWith(DIDescriptor &D); }; /// DICompositeType - This descriptor holds a type that can refer to multiple @@ -437,6 +454,7 @@ namespace llvm { unsigned isDefinition() const { return getUnsignedField(10); } GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } + Constant *getConstant() const { return getConstantField(11); } /// Verify - Verify that a global variable descriptor is well formed. bool Verify() const; @@ -504,10 +522,18 @@ namespace llvm { public: explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {} DIScope getContext() const { return getFieldAs<DIScope>(1); } - StringRef getDirectory() const { return getContext().getDirectory(); } - StringRef getFilename() const { return getContext().getFilename(); } unsigned getLineNumber() const { return getUnsignedField(2); } unsigned getColumnNumber() const { return getUnsignedField(3); } + StringRef getDirectory() const { + DIFile F = getFieldAs<DIFile>(4); + StringRef dir = F.getDirectory(); + return !dir.empty() ? dir : getContext().getDirectory(); + } + StringRef getFilename() const { + DIFile F = getFieldAs<DIFile>(4); + StringRef filename = F.getFilename(); + return !filename.empty() ? filename : getContext().getFilename(); + } }; /// DINameSpace - A wrapper for a C++ style name space. @@ -634,6 +660,9 @@ namespace llvm { unsigned RunTimeLang = 0, MDNode *ContainingType = 0); + /// CreateTemporaryType - Create a temporary forward-declared type. + DIType CreateTemporaryType(); + /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType CreateArtificialType(DIType Ty); @@ -648,7 +677,8 @@ namespace llvm { unsigned Flags, DIType DerivedFrom, DIArray Elements, - unsigned RunTimeLang = 0); + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); /// CreateSubprogram - Create a new descriptor for the specified subprogram. /// See comments in DISubprogram for descriptions of these fields. @@ -678,6 +708,15 @@ namespace llvm { unsigned LineNo, DIType Ty, bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *GV); + /// CreateGlobalVariable - Create a new descriptor for the specified constant. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::Constant *C); + /// CreateVariable - Create a new descriptor for the specified variable. DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, StringRef Name, @@ -694,8 +733,8 @@ namespace llvm { /// CreateLexicalBlock - This creates a descriptor for a lexical block /// with the specified parent context. - DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0, - unsigned Col = 0); + DILexicalBlock CreateLexicalBlock(DIDescriptor Context, DIFile F, + unsigned Line = 0, unsigned Col = 0); /// CreateNameSpace - This creates new descriptor for a namespace /// with the specified parent context. diff --git a/contrib/llvm/include/llvm/Analysis/Dominators.h b/contrib/llvm/include/llvm/Analysis/Dominators.h index 1979d3f..73c6e62 100644 --- a/contrib/llvm/include/llvm/Analysis/Dominators.h +++ b/contrib/llvm/include/llvm/Analysis/Dominators.h @@ -702,7 +702,7 @@ public: static char ID; // Pass ID, replacement for typeid DominatorTreeBase<BasicBlock>* DT; - DominatorTree() : FunctionPass(&ID) { + DominatorTree() : FunctionPass(ID) { DT = new DominatorTreeBase<BasicBlock>(false); } @@ -890,7 +890,7 @@ protected: const bool IsPostDominators; public: - DominanceFrontierBase(void *ID, bool isPostDom) + DominanceFrontierBase(char &ID, bool isPostDom) : FunctionPass(ID), IsPostDominators(isPostDom) {} /// getRoots - Return the root blocks of the current CFG. This may include @@ -995,6 +995,9 @@ public: /// print - Convert to human readable form /// virtual void print(raw_ostream &OS, const Module* = 0) const; + + /// dump - Dump the dominance frontier to dbgs(). + void dump() const; }; @@ -1006,7 +1009,7 @@ class DominanceFrontier : public DominanceFrontierBase { public: static char ID; // Pass ID, replacement for typeid DominanceFrontier() : - DominanceFrontierBase(&ID, false) {} + DominanceFrontierBase(ID, false) {} BasicBlock *getRoot() const { assert(Roots.size() == 1 && "Should always have entry node!"); diff --git a/contrib/llvm/include/llvm/Analysis/FindUsedTypes.h b/contrib/llvm/include/llvm/Analysis/FindUsedTypes.h index 1337385..8a78eb6 100644 --- a/contrib/llvm/include/llvm/Analysis/FindUsedTypes.h +++ b/contrib/llvm/include/llvm/Analysis/FindUsedTypes.h @@ -26,7 +26,7 @@ class FindUsedTypes : public ModulePass { std::set<const Type *> UsedTypes; public: static char ID; // Pass identification, replacement for typeid - FindUsedTypes() : ModulePass(&ID) {} + FindUsedTypes() : ModulePass(ID) {} /// getTypes - After the pass has been run, return the set containing all of /// the types used in the module. diff --git a/contrib/llvm/include/llvm/Analysis/IntervalPartition.h b/contrib/llvm/include/llvm/Analysis/IntervalPartition.h index c1214e7..75a5cdf 100644 --- a/contrib/llvm/include/llvm/Analysis/IntervalPartition.h +++ b/contrib/llvm/include/llvm/Analysis/IntervalPartition.h @@ -48,7 +48,7 @@ class IntervalPartition : public FunctionPass { public: static char ID; // Pass identification, replacement for typeid - IntervalPartition() : FunctionPass(&ID), RootInterval(0) {} + IntervalPartition() : FunctionPass(ID), RootInterval(0) {} // run - Calculate the interval partition for this function virtual bool runOnFunction(Function &F); diff --git a/contrib/llvm/include/llvm/Analysis/LazyValueInfo.h b/contrib/llvm/include/llvm/Analysis/LazyValueInfo.h index 566788d..b2a3afb 100644 --- a/contrib/llvm/include/llvm/Analysis/LazyValueInfo.h +++ b/contrib/llvm/include/llvm/Analysis/LazyValueInfo.h @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_ANALYSIS_LIVEVALUES_H -#define LLVM_ANALYSIS_LIVEVALUES_H +#ifndef LLVM_ANALYSIS_LAZYVALUEINFO_H +#define LLVM_ANALYSIS_LAZYVALUEINFO_H #include "llvm/Pass.h" @@ -31,7 +31,7 @@ class LazyValueInfo : public FunctionPass { void operator=(const LazyValueInfo&); // DO NOT IMPLEMENT. public: static char ID; - LazyValueInfo() : FunctionPass(&ID), PImpl(0) {} + LazyValueInfo() : FunctionPass(ID), PImpl(0) {} ~LazyValueInfo() { assert(PImpl == 0 && "releaseMemory not called"); } /// Tristate - This is used to return true/false/dunno results. @@ -57,6 +57,12 @@ public: /// constant on the specified edge. Return null if not. Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB); + /// threadEdge - Inform the analysis cache that we have threaded an edge from + /// PredBB to OldSucc to be from PredBB to NewSucc instead. + void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc); + + /// eraseBlock - Inform the analysis cache that we have erased a block. + void eraseBlock(BasicBlock *BB); // Implementation boilerplate. diff --git a/contrib/llvm/include/llvm/Analysis/LibCallAliasAnalysis.h b/contrib/llvm/include/llvm/Analysis/LibCallAliasAnalysis.h index 01f108d..c9adf3f 100644 --- a/contrib/llvm/include/llvm/Analysis/LibCallAliasAnalysis.h +++ b/contrib/llvm/include/llvm/Analysis/LibCallAliasAnalysis.h @@ -28,18 +28,20 @@ namespace llvm { LibCallInfo *LCI; explicit LibCallAliasAnalysis(LibCallInfo *LC = 0) - : FunctionPass(&ID), LCI(LC) { + : FunctionPass(ID), LCI(LC) { } - explicit LibCallAliasAnalysis(const void *ID, LibCallInfo *LC) + explicit LibCallAliasAnalysis(char &ID, LibCallInfo *LC) : FunctionPass(ID), LCI(LC) { } ~LibCallAliasAnalysis(); - ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); + ModRefResult getModRefInfo(ImmutableCallSite CS, + const Value *P, unsigned Size); - ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) { + ModRefResult getModRefInfo(ImmutableCallSite CS1, + ImmutableCallSite CS2) { // TODO: Could compare two direct calls against each other if we cared to. - return AliasAnalysis::getModRefInfo(CS1,CS2); + return AliasAnalysis::getModRefInfo(CS1, CS2); } virtual void getAnalysisUsage(AnalysisUsage &AU) const; @@ -49,9 +51,20 @@ namespace llvm { return false; } + /// getAdjustedAnalysisPointer - This method is used when a pass implements + /// an analysis interface through multiple inheritance. If needed, it + /// should override this to adjust the this pointer as needed for the + /// specified pass info. + virtual void *getAdjustedAnalysisPointer(const void *PI) { + if (PI == &AliasAnalysis::ID) + return (AliasAnalysis*)this; + return this; + } + private: ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, - CallSite CS, Value *P, unsigned Size); + ImmutableCallSite CS, + const Value *P, unsigned Size); }; } // End of llvm namespace diff --git a/contrib/llvm/include/llvm/Analysis/LibCallSemantics.h b/contrib/llvm/include/llvm/Analysis/LibCallSemantics.h index 74e8401..31d7cc5 100644 --- a/contrib/llvm/include/llvm/Analysis/LibCallSemantics.h +++ b/contrib/llvm/include/llvm/Analysis/LibCallSemantics.h @@ -47,7 +47,8 @@ namespace llvm { enum LocResult { Yes, No, Unknown }; - LocResult (*isLocation)(CallSite CS, const Value *Ptr, unsigned Size); + LocResult (*isLocation)(ImmutableCallSite CS, + const Value *Ptr, unsigned Size); }; /// LibCallFunctionInfo - Each record in the array of FunctionInfo structs @@ -142,7 +143,7 @@ namespace llvm { /// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to /// the specified function if we have it. If not, return null. - const LibCallFunctionInfo *getFunctionInfo(Function *F) const; + const LibCallFunctionInfo *getFunctionInfo(const Function *F) const; //===------------------------------------------------------------------===// diff --git a/contrib/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h b/contrib/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h index a1a5637..94fd990 100644 --- a/contrib/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h +++ b/contrib/llvm/include/llvm/Analysis/LoopDependenceAnalysis.h @@ -91,7 +91,7 @@ class LoopDependenceAnalysis : public LoopPass { public: static char ID; // Class identification, replacement for typeinfo - LoopDependenceAnalysis() : LoopPass(&ID) {} + LoopDependenceAnalysis() : LoopPass(ID) {} /// isDependencePair - Check whether two values can possibly give rise to /// a data dependence: that is the case if both are instructions accessing diff --git a/contrib/llvm/include/llvm/Analysis/LoopInfo.h b/contrib/llvm/include/llvm/Analysis/LoopInfo.h index 9455fd8..462620f 100644 --- a/contrib/llvm/include/llvm/Analysis/LoopInfo.h +++ b/contrib/llvm/include/llvm/Analysis/LoopInfo.h @@ -35,6 +35,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Support/CFG.h" #include "llvm/Support/raw_ostream.h" @@ -229,13 +230,16 @@ public: return 0; } + /// Edge type. + typedef std::pair<BlockT*, BlockT*> Edge; + /// getExitEdges - Return all pairs of (_inside_block_,_outside_block_). - typedef std::pair<const BlockT*,const BlockT*> Edge; - void getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const { + template <typename EdgeT> + void getExitEdges(SmallVectorImpl<EdgeT> &ExitEdges) const { // Sort the blocks vector so that we can use binary search to do quick // lookups. SmallVector<BlockT*, 128> LoopBBs(block_begin(), block_end()); - std::sort(LoopBBs.begin(), LoopBBs.end()); + array_pod_sort(LoopBBs.begin(), LoopBBs.end()); typedef GraphTraits<BlockT*> BlockTraits; for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) @@ -244,7 +248,7 @@ public: I != E; ++I) if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) // Not in current loop? It must be an exit block. - ExitEdges.push_back(std::make_pair(*BI, *I)); + ExitEdges.push_back(EdgeT(*BI, *I)); } /// getLoopPreheader - If there is a preheader for this loop, return it. A @@ -505,6 +509,12 @@ protected: } }; +template<class BlockT, class LoopT> +raw_ostream& operator<<(raw_ostream &OS, const LoopBase<BlockT, LoopT> &Loop) { + Loop.print(OS); + return OS; +} + class Loop : public LoopBase<BasicBlock, Loop> { public: Loop() {} @@ -552,12 +562,6 @@ public: /// PHINode *getCanonicalInductionVariable() const; - /// getCanonicalInductionVariableIncrement - Return the LLVM value that holds - /// the canonical induction variable value for the "next" iteration of the - /// loop. This always succeeds if getCanonicalInductionVariable succeeds. - /// - Instruction *getCanonicalInductionVariableIncrement() const; - /// getTripCount - Return a loop-invariant LLVM value indicating the number of /// times the loop will be executed. Note that this means that the backedge /// of the loop executes N-1 times. If the trip-count cannot be determined, @@ -936,7 +940,7 @@ class LoopInfo : public FunctionPass { public: static char ID; // Pass identification, replacement for typeid - LoopInfo() : FunctionPass(&ID) {} + LoopInfo() : FunctionPass(ID) {} LoopInfoBase<BasicBlock, Loop>& getBase() { return LI; } diff --git a/contrib/llvm/include/llvm/Analysis/LoopPass.h b/contrib/llvm/include/llvm/Analysis/LoopPass.h index 6f77d01..1603d2e 100644 --- a/contrib/llvm/include/llvm/Analysis/LoopPass.h +++ b/contrib/llvm/include/llvm/Analysis/LoopPass.h @@ -19,6 +19,7 @@ #include "llvm/Pass.h" #include "llvm/PassManagers.h" #include "llvm/Function.h" +#include <deque> namespace llvm { @@ -28,8 +29,7 @@ class PMStack; class LoopPass : public Pass { public: - explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} - explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} + explicit LoopPass(char &pid) : Pass(PT_Loop, pid) {} /// getPrinterPass - Get a pass to print the function corresponding /// to a Loop. @@ -58,7 +58,7 @@ public: /// Assign pass manager to manage this pass virtual void assignPassManager(PMStack &PMS, - PassManagerType PMT = PMT_LoopPassManager); + PassManagerType PMT); /// Return what kind of Pass Manager can manage this pass. virtual PassManagerType getPotentialPassManagerType() const { @@ -104,10 +104,10 @@ public: /// Print passes managed by this manager void dumpPassStructure(unsigned Offset); - Pass *getContainedPass(unsigned N) { + LoopPass *getContainedPass(unsigned N) { assert(N < PassVector.size() && "Pass number out of range!"); - Pass *FP = static_cast<Pass *>(PassVector[N]); - return FP; + LoopPass *LP = static_cast<LoopPass *>(PassVector[N]); + return LP; } virtual PassManagerType getPassManagerType() const { diff --git a/contrib/llvm/include/llvm/Analysis/Passes.h b/contrib/llvm/include/llvm/Analysis/Passes.h index ce3f7a6..37425eb 100644 --- a/contrib/llvm/include/llvm/Analysis/Passes.h +++ b/contrib/llvm/include/llvm/Analysis/Passes.h @@ -81,11 +81,18 @@ namespace llvm { //===--------------------------------------------------------------------===// // + // createTypeBasedAliasAnalysisPass - This pass implements metadata-based + // type-based alias analysis. + // + ImmutablePass *createTypeBasedAliasAnalysisPass(); + + //===--------------------------------------------------------------------===// + // // createProfileLoaderPass - This pass loads information from a profile dump // file. // ModulePass *createProfileLoaderPass(); - extern const PassInfo *ProfileLoaderPassID; + extern char &ProfileLoaderPassID; //===--------------------------------------------------------------------===// // @@ -99,7 +106,7 @@ namespace llvm { // instead of loading it from a previous run. // FunctionPass *createProfileEstimatorPass(); - extern const PassInfo *ProfileEstimatorPassID; + extern char &ProfileEstimatorPassID; //===--------------------------------------------------------------------===// // @@ -154,6 +161,13 @@ namespace llvm { // print debug info intrinsics in human readable form FunctionPass *createDbgInfoPrinterPass(); + //===--------------------------------------------------------------------===// + // + // createRegionInfoPass - This pass finds all single entry single exit regions + // in a function and builds the region hierarchy. + // + FunctionPass *createRegionInfoPass(); + // Print module-level debug info metadata in human-readable form. ModulePass *createModuleDebugInfoPrinterPass(); } diff --git a/contrib/llvm/include/llvm/Analysis/PointerTracking.h b/contrib/llvm/include/llvm/Analysis/PointerTracking.h index 6c4f838..6b49e18 100644 --- a/contrib/llvm/include/llvm/Analysis/PointerTracking.h +++ b/contrib/llvm/include/llvm/Analysis/PointerTracking.h @@ -98,6 +98,7 @@ namespace llvm { virtual bool runOnFunction(Function &F); virtual void getAnalysisUsage(AnalysisUsage &AU) const; void print(raw_ostream &OS, const Module* = 0) const; + Value *computeAllocationCountValue(Value *P, const Type *&Ty) const; private: Function *FF; TargetData *TD; diff --git a/contrib/llvm/include/llvm/Analysis/PostDominators.h b/contrib/llvm/include/llvm/Analysis/PostDominators.h index 5552017..46ce820 100644 --- a/contrib/llvm/include/llvm/Analysis/PostDominators.h +++ b/contrib/llvm/include/llvm/Analysis/PostDominators.h @@ -25,7 +25,7 @@ struct PostDominatorTree : public FunctionPass { static char ID; // Pass identification, replacement for typeid DominatorTreeBase<BasicBlock>* DT; - PostDominatorTree() : FunctionPass(&ID) { + PostDominatorTree() : FunctionPass(ID) { DT = new DominatorTreeBase<BasicBlock>(true); } @@ -106,7 +106,7 @@ template <> struct GraphTraits<PostDominatorTree*> struct PostDominanceFrontier : public DominanceFrontierBase { static char ID; PostDominanceFrontier() - : DominanceFrontierBase(&ID, true) {} + : DominanceFrontierBase(ID, true) {} virtual bool runOnFunction(Function &) { Frontiers.clear(); diff --git a/contrib/llvm/include/llvm/Analysis/RegionInfo.h b/contrib/llvm/include/llvm/Analysis/RegionInfo.h new file mode 100644 index 0000000..7a2670f --- /dev/null +++ b/contrib/llvm/include/llvm/Analysis/RegionInfo.h @@ -0,0 +1,630 @@ +//===- RegionInfo.h - SESE region analysis ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Calculate a program structure tree built out of single entry single exit +// regions. +// The basic ideas are taken from "The Program Structure Tree - Richard Johnson, +// David Pearson, Keshav Pingali - 1994", however enriched with ideas from "The +// Refined Process Structure Tree - Jussi Vanhatalo, Hagen Voelyer, Jana +// Koehler - 2009". +// The algorithm to calculate these data structures however is completely +// different, as it takes advantage of existing information already available +// in (Post)dominace tree and dominance frontier passes. This leads to a simpler +// and in practice hopefully better performing algorithm. The runtime of the +// algorithms described in the papers above are both linear in graph size, +// O(V+E), whereas this algorithm is not, as the dominance frontier information +// itself is not, but in practice runtime seems to be in the order of magnitude +// of dominance tree calculation. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_REGION_INFO_H +#define LLVM_ANALYSIS_REGION_INFO_H + +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/Analysis/Dominators.h" +#include "llvm/Analysis/PostDominators.h" +#include "llvm/Support/Allocator.h" + +namespace llvm { + +class Region; +class RegionInfo; +class raw_ostream; +class Loop; +class LoopInfo; + +/// @brief Marker class to iterate over the elements of a Region in flat mode. +/// +/// The class is used to either iterate in Flat mode or by not using it to not +/// iterate in Flat mode. During a Flat mode iteration all Regions are entered +/// and the iteration returns every BasicBlock. If the Flat mode is not +/// selected for SubRegions just one RegionNode containing the subregion is +/// returned. +template <class GraphType> +class FlatIt {}; + +/// @brief A RegionNode represents a subregion or a BasicBlock that is part of a +/// Region. +class RegionNode { + // DO NOT IMPLEMENT + RegionNode(const RegionNode &); + // DO NOT IMPLEMENT + const RegionNode &operator=(const RegionNode &); + + /// This is the entry basic block that starts this region node. If this is a + /// BasicBlock RegionNode, then entry is just the basic block, that this + /// RegionNode represents. Otherwise it is the entry of this (Sub)RegionNode. + /// + /// In the BBtoRegionNode map of the parent of this node, BB will always map + /// to this node no matter which kind of node this one is. + /// + /// The node can hold either a Region or a BasicBlock. + /// Use one bit to save, if this RegionNode is a subregion or BasicBlock + /// RegionNode. + PointerIntPair<BasicBlock*, 1, bool> entry; + +protected: + /// @brief The parent Region of this RegionNode. + /// @see getParent() + Region* parent; + +public: + /// @brief Create a RegionNode. + /// + /// @param Parent The parent of this RegionNode. + /// @param Entry The entry BasicBlock of the RegionNode. If this + /// RegionNode represents a BasicBlock, this is the + /// BasicBlock itself. If it represents a subregion, this + /// is the entry BasicBlock of the subregion. + /// @param isSubRegion If this RegionNode represents a SubRegion. + inline RegionNode(Region* Parent, BasicBlock* Entry, bool isSubRegion = 0) + : entry(Entry, isSubRegion), parent(Parent) {} + + /// @brief Get the parent Region of this RegionNode. + /// + /// The parent Region is the Region this RegionNode belongs to. If for + /// example a BasicBlock is element of two Regions, there exist two + /// RegionNodes for this BasicBlock. Each with the getParent() function + /// pointing to the Region this RegionNode belongs to. + /// + /// @return Get the parent Region of this RegionNode. + inline Region* getParent() const { return parent; } + + /// @brief Get the entry BasicBlock of this RegionNode. + /// + /// If this RegionNode represents a BasicBlock this is just the BasicBlock + /// itself, otherwise we return the entry BasicBlock of the Subregion + /// + /// @return The entry BasicBlock of this RegionNode. + inline BasicBlock* getEntry() const { return entry.getPointer(); } + + /// @brief Get the content of this RegionNode. + /// + /// This can be either a BasicBlock or a subregion. Before calling getNodeAs() + /// check the type of the content with the isSubRegion() function call. + /// + /// @return The content of this RegionNode. + template<class T> + inline T* getNodeAs() const; + + /// @brief Is this RegionNode a subregion? + /// + /// @return True if it contains a subregion. False if it contains a + /// BasicBlock. + inline bool isSubRegion() const { + return entry.getInt(); + } +}; + +/// Print a RegionNode. +inline raw_ostream &operator<<(raw_ostream &OS, const RegionNode &Node); + +template<> +inline BasicBlock* RegionNode::getNodeAs<BasicBlock>() const { + assert(!isSubRegion() && "This is not a BasicBlock RegionNode!"); + return getEntry(); +} + +template<> +inline Region* RegionNode::getNodeAs<Region>() const { + assert(isSubRegion() && "This is not a subregion RegionNode!"); + return reinterpret_cast<Region*>(const_cast<RegionNode*>(this)); +} + +//===----------------------------------------------------------------------===// +/// @brief A single entry single exit Region. +/// +/// A Region is a connected subgraph of a control flow graph that has exactly +/// two connections to the remaining graph. It can be used to analyze or +/// optimize parts of the control flow graph. +/// +/// A <em> simple Region </em> is connected to the remaing graph by just two +/// edges. One edge entering the Region and another one leaving the Region. +/// +/// An <em> extended Region </em> (or just Region) is a subgraph that can be +/// transform into a simple Region. The transformation is done by adding +/// BasicBlocks that merge several entry or exit edges so that after the merge +/// just one entry and one exit edge exists. +/// +/// The \e Entry of a Region is the first BasicBlock that is passed after +/// entering the Region. It is an element of the Region. The entry BasicBlock +/// dominates all BasicBlocks in the Region. +/// +/// The \e Exit of a Region is the first BasicBlock that is passed after +/// leaving the Region. It is not an element of the Region. The exit BasicBlock, +/// postdominates all BasicBlocks in the Region. +/// +/// A <em> canonical Region </em> cannot be constructed by combining smaller +/// Regions. +/// +/// Region A is the \e parent of Region B, if B is completely contained in A. +/// +/// Two canonical Regions either do not intersect at all or one is +/// the parent of the other. +/// +/// The <em> Program Structure Tree</em> is a graph (V, E) where V is the set of +/// Regions in the control flow graph and E is the \e parent relation of these +/// Regions. +/// +/// Example: +/// +/// \verbatim +/// A simple control flow graph, that contains two regions. +/// +/// 1 +/// / | +/// 2 | +/// / \ 3 +/// 4 5 | +/// | | | +/// 6 7 8 +/// \ | / +/// \ |/ Region A: 1 -> 9 {1,2,3,4,5,6,7,8} +/// 9 Region B: 2 -> 9 {2,4,5,6,7} +/// \endverbatim +/// +/// You can obtain more examples by either calling +/// +/// <tt> "opt -regions -analyze anyprogram.ll" </tt> +/// or +/// <tt> "opt -view-regions-only anyprogram.ll" </tt> +/// +/// on any LLVM file you are interested in. +/// +/// The first call returns a textual representation of the program structure +/// tree, the second one creates a graphical representation using graphviz. +class Region : public RegionNode { + friend class RegionInfo; + // DO NOT IMPLEMENT + Region(const Region &); + // DO NOT IMPLEMENT + const Region &operator=(const Region &); + + // Information necessary to manage this Region. + RegionInfo* RI; + DominatorTree *DT; + + // The exit BasicBlock of this region. + // (The entry BasicBlock is part of RegionNode) + BasicBlock *exit; + + typedef std::vector<Region*> RegionSet; + + // The subregions of this region. + RegionSet children; + + typedef std::map<BasicBlock*, RegionNode*> BBNodeMapT; + + // Save the BasicBlock RegionNodes that are element of this Region. + mutable BBNodeMapT BBNodeMap; + + /// verifyBBInRegion - Check if a BB is in this Region. This check also works + /// if the region is incorrectly built. (EXPENSIVE!) + void verifyBBInRegion(BasicBlock* BB) const; + + /// verifyWalk - Walk over all the BBs of the region starting from BB and + /// verify that all reachable basic blocks are elements of the region. + /// (EXPENSIVE!) + void verifyWalk(BasicBlock* BB, std::set<BasicBlock*>* visitedBB) const; + + /// verifyRegionNest - Verify if the region and its children are valid + /// regions (EXPENSIVE!) + void verifyRegionNest() const; + +public: + /// @brief Create a new region. + /// + /// @param Entry The entry basic block of the region. + /// @param Exit The exit basic block of the region. + /// @param RI The region info object that is managing this region. + /// @param DT The dominator tree of the current function. + /// @param Parent The surrounding region or NULL if this is a top level + /// region. + Region(BasicBlock *Entry, BasicBlock *Exit, RegionInfo* RI, + DominatorTree *DT, Region *Parent = 0); + + /// Delete the Region and all its subregions. + ~Region(); + + /// @brief Get the entry BasicBlock of the Region. + /// @return The entry BasicBlock of the region. + BasicBlock *getEntry() const { return RegionNode::getEntry(); } + + /// @brief Get the exit BasicBlock of the Region. + /// @return The exit BasicBlock of the Region, NULL if this is the TopLevel + /// Region. + BasicBlock *getExit() const { return exit; } + + /// @brief Get the parent of the Region. + /// @return The parent of the Region or NULL if this is a top level + /// Region. + Region *getParent() const { return RegionNode::getParent(); } + + /// @brief Get the RegionNode representing the current Region. + /// @return The RegionNode representing the current Region. + RegionNode* getNode() const { + return const_cast<RegionNode*>(reinterpret_cast<const RegionNode*>(this)); + } + + /// @brief Get the nesting level of this Region. + /// + /// An toplevel Region has depth 0. + /// + /// @return The depth of the region. + unsigned getDepth() const; + + /// @brief Is this a simple region? + /// + /// A region is simple if it has exactly one exit and one entry edge. + /// + /// @return True if the Region is simple. + bool isSimple() const; + + /// @brief Returns the name of the Region. + /// @return The Name of the Region. + std::string getNameStr() const; + + /// @brief Return the RegionInfo object, that belongs to this Region. + RegionInfo *getRegionInfo() const { + return RI; + } + + /// @brief Print the region. + /// + /// @param OS The output stream the Region is printed to. + /// @param printTree Print also the tree of subregions. + /// @param level The indentation level used for printing. + void print(raw_ostream& OS, bool printTree = true, unsigned level = 0) const; + + /// @brief Print the region to stderr. + void dump() const; + + /// @brief Check if the region contains a BasicBlock. + /// + /// @param BB The BasicBlock that might be contained in this Region. + /// @return True if the block is contained in the region otherwise false. + bool contains(const BasicBlock *BB) const; + + /// @brief Check if the region contains another region. + /// + /// @param SubRegion The region that might be contained in this Region. + /// @return True if SubRegion is contained in the region otherwise false. + bool contains(const Region *SubRegion) const { + // Toplevel Region. + if (!getExit()) + return true; + + return contains(SubRegion->getEntry()) + && (contains(SubRegion->getExit()) || SubRegion->getExit() == getExit()); + } + + /// @brief Check if the region contains an Instruction. + /// + /// @param Inst The Instruction that might be contained in this region. + /// @return True if the Instruction is contained in the region otherwise false. + bool contains(const Instruction *Inst) const { + return contains(Inst->getParent()); + } + + /// @brief Check if the region contains a loop. + /// + /// @param L The loop that might be contained in this region. + /// @return True if the loop is contained in the region otherwise false. + /// In case a NULL pointer is passed to this function the result + /// is false, except for the region that describes the whole function. + /// In that case true is returned. + bool contains(const Loop *L) const; + + /// @brief Get the outermost loop in the region that contains a loop. + /// + /// Find for a Loop L the outermost loop OuterL that is a parent loop of L + /// and is itself contained in the region. + /// + /// @param L The loop the lookup is started. + /// @return The outermost loop in the region, NULL if such a loop does not + /// exist or if the region describes the whole function. + Loop *outermostLoopInRegion(Loop *L) const; + + /// @brief Get the outermost loop in the region that contains a basic block. + /// + /// Find for a basic block BB the outermost loop L that contains BB and is + /// itself contained in the region. + /// + /// @param LI A pointer to a LoopInfo analysis. + /// @param BB The basic block surrounded by the loop. + /// @return The outermost loop in the region, NULL if such a loop does not + /// exist or if the region describes the whole function. + Loop *outermostLoopInRegion(LoopInfo *LI, BasicBlock* BB) const; + + /// @brief Get the subregion that starts at a BasicBlock + /// + /// @param BB The BasicBlock the subregion should start. + /// @return The Subregion if available, otherwise NULL. + Region* getSubRegionNode(BasicBlock *BB) const; + + /// @brief Get the RegionNode for a BasicBlock + /// + /// @param BB The BasicBlock at which the RegionNode should start. + /// @return If available, the RegionNode that represents the subregion + /// starting at BB. If no subregion starts at BB, the RegionNode + /// representing BB. + RegionNode* getNode(BasicBlock *BB) const; + + /// @brief Get the BasicBlock RegionNode for a BasicBlock + /// + /// @param BB The BasicBlock for which the RegionNode is requested. + /// @return The RegionNode representing the BB. + RegionNode* getBBNode(BasicBlock *BB) const; + + /// @brief Add a new subregion to this Region. + /// + /// @param SubRegion The new subregion that will be added. + void addSubRegion(Region *SubRegion); + + /// @brief Remove a subregion from this Region. + /// + /// The subregion is not deleted, as it will probably be inserted into another + /// region. + /// @param SubRegion The SubRegion that will be removed. + Region *removeSubRegion(Region *SubRegion); + + /// @brief Move all direct child nodes of this Region to another Region. + /// + /// @param To The Region the child nodes will be transfered to. + void transferChildrenTo(Region *To); + + /// @brief Verify if the region is a correct region. + /// + /// Check if this is a correctly build Region. This is an expensive check, as + /// the complete CFG of the Region will be walked. + void verifyRegion() const; + + /// @brief Clear the cache for BB RegionNodes. + /// + /// After calling this function the BasicBlock RegionNodes will be stored at + /// different memory locations. RegionNodes obtained before this function is + /// called are therefore not comparable to RegionNodes abtained afterwords. + void clearNodeCache(); + + /// @name Subregion Iterators + /// + /// These iterators iterator over all subregions of this Region. + //@{ + typedef RegionSet::iterator iterator; + typedef RegionSet::const_iterator const_iterator; + + iterator begin() { return children.begin(); } + iterator end() { return children.end(); } + + const_iterator begin() const { return children.begin(); } + const_iterator end() const { return children.end(); } + //@} + + /// @name BasicBlock Iterators + /// + /// These iterators iterate over all BasicBlock RegionNodes that are + /// contained in this Region. The iterator also iterates over BasicBlocks + /// that are elements of a subregion of this Region. It is therefore called a + /// flat iterator. + //@{ + typedef df_iterator<RegionNode*, SmallPtrSet<RegionNode*, 8>, false, + GraphTraits<FlatIt<RegionNode*> > > block_iterator; + + typedef df_iterator<const RegionNode*, SmallPtrSet<const RegionNode*, 8>, + false, GraphTraits<FlatIt<const RegionNode*> > > + const_block_iterator; + + block_iterator block_begin(); + block_iterator block_end(); + + const_block_iterator block_begin() const; + const_block_iterator block_end() const; + //@} + + /// @name Element Iterators + /// + /// These iterators iterate over all BasicBlock and subregion RegionNodes that + /// are direct children of this Region. It does not iterate over any + /// RegionNodes that are also element of a subregion of this Region. + //@{ + typedef df_iterator<RegionNode*, SmallPtrSet<RegionNode*, 8>, false, + GraphTraits<RegionNode*> > element_iterator; + + typedef df_iterator<const RegionNode*, SmallPtrSet<const RegionNode*, 8>, + false, GraphTraits<const RegionNode*> > + const_element_iterator; + + element_iterator element_begin(); + element_iterator element_end(); + + const_element_iterator element_begin() const; + const_element_iterator element_end() const; + //@} +}; + +//===----------------------------------------------------------------------===// +/// @brief Analysis that detects all canonical Regions. +/// +/// The RegionInfo pass detects all canonical regions in a function. The Regions +/// are connected using the parent relation. This builds a Program Structure +/// Tree. +class RegionInfo : public FunctionPass { + typedef DenseMap<BasicBlock*,BasicBlock*> BBtoBBMap; + typedef DenseMap<BasicBlock*, Region*> BBtoRegionMap; + typedef SmallPtrSet<Region*, 4> RegionSet; + + // DO NOT IMPLEMENT + RegionInfo(const RegionInfo &); + // DO NOT IMPLEMENT + const RegionInfo &operator=(const RegionInfo &); + + DominatorTree *DT; + PostDominatorTree *PDT; + DominanceFrontier *DF; + + /// The top level region. + Region *TopLevelRegion; + + /// Map every BB to the smallest region, that contains BB. + BBtoRegionMap BBtoRegion; + + // isCommonDomFrontier - Returns true if BB is in the dominance frontier of + // entry, because it was inherited from exit. In the other case there is an + // edge going from entry to BB without passing exit. + bool isCommonDomFrontier(BasicBlock* BB, BasicBlock* entry, + BasicBlock* exit) const; + + // isRegion - Check if entry and exit surround a valid region, based on + // dominance tree and dominance frontier. + bool isRegion(BasicBlock* entry, BasicBlock* exit) const; + + // insertShortCut - Saves a shortcut pointing from entry to exit. + // This function may extend this shortcut if possible. + void insertShortCut(BasicBlock* entry, BasicBlock* exit, + BBtoBBMap* ShortCut) const; + + // getNextPostDom - Returns the next BB that postdominates N, while skipping + // all post dominators that cannot finish a canonical region. + DomTreeNode *getNextPostDom(DomTreeNode* N, BBtoBBMap *ShortCut) const; + + // isTrivialRegion - A region is trivial, if it contains only one BB. + bool isTrivialRegion(BasicBlock *entry, BasicBlock *exit) const; + + // createRegion - Creates a single entry single exit region. + Region *createRegion(BasicBlock *entry, BasicBlock *exit); + + // findRegionsWithEntry - Detect all regions starting with bb 'entry'. + void findRegionsWithEntry(BasicBlock *entry, BBtoBBMap *ShortCut); + + // scanForRegions - Detects regions in F. + void scanForRegions(Function &F, BBtoBBMap *ShortCut); + + // getTopMostParent - Get the top most parent with the same entry block. + Region *getTopMostParent(Region *region); + + // buildRegionsTree - build the region hierarchy after all region detected. + void buildRegionsTree(DomTreeNode *N, Region *region); + + // Calculate - detecte all regions in function and build the region tree. + void Calculate(Function& F); + + void releaseMemory(); + + // updateStatistics - Update statistic about created regions. + void updateStatistics(Region *R); + + // isSimple - Check if a region is a simple region with exactly one entry + // edge and exactly one exit edge. + bool isSimple(Region* R) const; + +public: + static char ID; + explicit RegionInfo(); + + ~RegionInfo(); + + /// @name FunctionPass interface + //@{ + virtual bool runOnFunction(Function &F); + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual void print(raw_ostream &OS, const Module *) const; + virtual void verifyAnalysis() const; + //@} + + /// @brief Get the smallest region that contains a BasicBlock. + /// + /// @param BB The basic block. + /// @return The smallest region, that contains BB or NULL, if there is no + /// region containing BB. + Region *getRegionFor(BasicBlock *BB) const; + + /// @brief A shortcut for getRegionFor(). + /// + /// @param BB The basic block. + /// @return The smallest region, that contains BB or NULL, if there is no + /// region containing BB. + Region *operator[](BasicBlock *BB) const; + + /// @brief Return the exit of the maximal refined region, that starts at a + /// BasicBlock. + /// + /// @param BB The BasicBlock the refined region starts. + BasicBlock *getMaxRegionExit(BasicBlock *BB) const; + + /// @brief Find the smallest region that contains two regions. + /// + /// @param A The first region. + /// @param B The second region. + /// @return The smallest region containing A and B. + Region *getCommonRegion(Region* A, Region *B) const; + + /// @brief Find the smallest region that contains two basic blocks. + /// + /// @param A The first basic block. + /// @param B The second basic block. + /// @return The smallest region that contains A and B. + Region* getCommonRegion(BasicBlock* A, BasicBlock *B) const { + return getCommonRegion(getRegionFor(A), getRegionFor(B)); + } + + /// @brief Find the smallest region that contains a set of regions. + /// + /// @param Regions A vector of regions. + /// @return The smallest region that contains all regions in Regions. + Region* getCommonRegion(SmallVectorImpl<Region*> &Regions) const; + + /// @brief Find the smallest region that contains a set of basic blocks. + /// + /// @param BBs A vector of basic blocks. + /// @return The smallest region that contains all basic blocks in BBS. + Region* getCommonRegion(SmallVectorImpl<BasicBlock*> &BBs) const; + + Region *getTopLevelRegion() const { + return TopLevelRegion; + } + + /// @brief Clear the Node Cache for all Regions. + /// + /// @see Region::clearNodeCache() + void clearNodeCache() { + if (TopLevelRegion) + TopLevelRegion->clearNodeCache(); + } +}; + +inline raw_ostream &operator<<(raw_ostream &OS, const RegionNode &Node) { + if (Node.isSubRegion()) + return OS << Node.getNodeAs<Region>()->getNameStr(); + else + return OS << Node.getNodeAs<BasicBlock>()->getNameStr(); +} +} // End llvm namespace +#endif + diff --git a/contrib/llvm/include/llvm/Analysis/RegionIterator.h b/contrib/llvm/include/llvm/Analysis/RegionIterator.h new file mode 100644 index 0000000..ced5b52 --- /dev/null +++ b/contrib/llvm/include/llvm/Analysis/RegionIterator.h @@ -0,0 +1,342 @@ +//===- RegionIterator.h - Iterators to iteratate over Regions ---*- 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 iterators to iterate over the elements of a Region. +//===----------------------------------------------------------------------===// +#ifndef LLVM_ANALYSIS_REGION_ITERATOR_H +#define LLVM_ANALYSIS_REGION_ITERATOR_H + +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/Analysis/RegionInfo.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { +//===----------------------------------------------------------------------===// +/// @brief Hierachical RegionNode successor iterator. +/// +/// This iterator iterates over all successors of a RegionNode. +/// +/// For a BasicBlock RegionNode it skips all BasicBlocks that are not part of +/// the parent Region. Furthermore for BasicBlocks that start a subregion, a +/// RegionNode representing the subregion is returned. +/// +/// For a subregion RegionNode there is just one successor. The RegionNode +/// representing the exit of the subregion. +template<class NodeType> +class RNSuccIterator : public std::iterator<std::forward_iterator_tag, + NodeType, ptrdiff_t> +{ + typedef std::iterator<std::forward_iterator_tag, NodeType, ptrdiff_t> super; + // The iterator works in two modes, bb mode or region mode. + enum ItMode{ + // In BB mode it returns all successors of this BasicBlock as its + // successors. + ItBB, + // In region mode there is only one successor, thats the regionnode mapping + // to the exit block of the regionnode + ItRgBegin, // At the beginning of the regionnode successor. + ItRgEnd // At the end of the regionnode successor. + }; + + // Use two bit to represent the mode iterator. + PointerIntPair<NodeType*, 2, enum ItMode> Node; + + // The block successor iterator. + succ_iterator BItor; + + // advanceRegionSucc - A region node has only one successor. It reaches end + // once we advance it. + void advanceRegionSucc() { + assert(Node.getInt() == ItRgBegin && "Cannot advance region successor!"); + Node.setInt(ItRgEnd); + } + + NodeType* getNode() const{ return Node.getPointer(); } + + // isRegionMode - Is the current iterator in region mode? + bool isRegionMode() const { return Node.getInt() != ItBB; } + + // Get the immediate successor. This function may return a Basic Block + // RegionNode or a subregion RegionNode. + RegionNode* getISucc(BasicBlock* BB) const { + RegionNode *succ; + succ = getNode()->getParent()->getNode(BB); + assert(succ && "BB not in Region or entered subregion!"); + return succ; + } + + // getRegionSucc - Return the successor basic block of a SubRegion RegionNode. + inline BasicBlock* getRegionSucc() const { + assert(Node.getInt() == ItRgBegin && "Cannot get the region successor!"); + return getNode()->template getNodeAs<Region>()->getExit(); + } + + // isExit - Is this the exit BB of the Region? + inline bool isExit(BasicBlock* BB) const { + return getNode()->getParent()->getExit() == BB; + } +public: + typedef RNSuccIterator<NodeType> Self; + + typedef typename super::pointer pointer; + + /// @brief Create begin iterator of a RegionNode. + inline RNSuccIterator(NodeType* node) + : Node(node, node->isSubRegion() ? ItRgBegin : ItBB), + BItor(succ_begin(node->getEntry())) { + + + // Skip the exit block + if (!isRegionMode()) + while (succ_end(node->getEntry()) != BItor && isExit(*BItor)) + ++BItor; + + if (isRegionMode() && isExit(getRegionSucc())) + advanceRegionSucc(); + } + + /// @brief Create an end iterator. + inline RNSuccIterator(NodeType* node, bool) + : Node(node, node->isSubRegion() ? ItRgEnd : ItBB), + BItor(succ_end(node->getEntry())) {} + + inline bool operator==(const Self& x) const { + assert(isRegionMode() == x.isRegionMode() && "Broken iterator!"); + if (isRegionMode()) + return Node.getInt() == x.Node.getInt(); + else + return BItor == x.BItor; + } + + inline bool operator!=(const Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + BasicBlock* BB = isRegionMode() ? getRegionSucc() : *BItor; + assert(!isExit(BB) && "Iterator out of range!"); + return getISucc(BB); + } + + inline Self& operator++() { + if(isRegionMode()) { + // The Region only has 1 successor. + advanceRegionSucc(); + } else { + // Skip the exit. + do + ++BItor; + while (BItor != succ_end(getNode()->getEntry()) + && isExit(*BItor)); + } + return *this; + } + + inline Self operator++(int) { + Self tmp = *this; + ++*this; + return tmp; + } + + inline const Self &operator=(const Self &I) { + if (this != &I) { + assert(getNode()->getParent() == I.getNode()->getParent() + && "Cannot assign iterators of two different regions!"); + Node = I.Node; + BItor = I.BItor; + } + return *this; + } +}; + + +//===----------------------------------------------------------------------===// +/// @brief Flat RegionNode iterator. +/// +/// The Flat Region iterator will iterate over all BasicBlock RegionNodes that +/// are contained in the Region and its subregions. This is close to a virtual +/// control flow graph of the Region. +template<class NodeType> +class RNSuccIterator<FlatIt<NodeType> > + : public std::iterator<std::forward_iterator_tag, NodeType, ptrdiff_t> +{ + typedef std::iterator<std::forward_iterator_tag, NodeType, ptrdiff_t> super; + NodeType* Node; + succ_iterator Itor; + +public: + typedef RNSuccIterator<FlatIt<NodeType> > Self; + typedef typename super::pointer pointer; + + /// @brief Create the iterator from a RegionNode. + /// + /// Note that the incoming node must be a bb node, otherwise it will trigger + /// an assertion when we try to get a BasicBlock. + inline RNSuccIterator(NodeType* node) : Node(node), + Itor(succ_begin(node->getEntry())) { + assert(!Node->isSubRegion() + && "Subregion node not allowed in flat iterating mode!"); + assert(Node->getParent() && "A BB node must have a parent!"); + + // Skip the exit block of the iterating region. + while (succ_end(Node->getEntry()) != Itor + && Node->getParent()->getExit() == *Itor) + ++Itor; + } + /// @brief Create an end iterator + inline RNSuccIterator(NodeType* node, bool) : Node(node), + Itor(succ_end(node->getEntry())) { + assert(!Node->isSubRegion() + && "Subregion node not allowed in flat iterating mode!"); + } + + inline bool operator==(const Self& x) const { + assert(Node->getParent() == x.Node->getParent() + && "Cannot compare iterators of different regions!"); + + return Itor == x.Itor && Node == x.Node; + } + + inline bool operator!=(const Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + BasicBlock* BB = *Itor; + + // Get the iterating region. + Region* Parent = Node->getParent(); + + // The only case that the successor reaches out of the region is it reaches + // the exit of the region. + assert(Parent->getExit() != BB && "iterator out of range!"); + + return Parent->getBBNode(BB); + } + + inline Self& operator++() { + // Skip the exit block of the iterating region. + do + ++Itor; + while (Itor != succ_end(Node->getEntry()) + && Node->getParent()->getExit() == *Itor); + + return *this; + } + + inline Self operator++(int) { + Self tmp = *this; + ++*this; + return tmp; + } + + inline const Self &operator=(const Self &I) { + if (this != &I) { + assert(Node->getParent() == I.Node->getParent() + && "Cannot assign iterators to two different regions!"); + Node = I.Node; + Itor = I.Itor; + } + return *this; + } +}; + +template<class NodeType> +inline RNSuccIterator<NodeType> succ_begin(NodeType* Node) { + return RNSuccIterator<NodeType>(Node); +} + +template<class NodeType> +inline RNSuccIterator<NodeType> succ_end(NodeType* Node) { + return RNSuccIterator<NodeType>(Node, true); +} + +//===--------------------------------------------------------------------===// +// RegionNode GraphTraits specialization so the bbs in the region can be +// iterate by generic graph iterators. +// +// NodeT can either be region node or const region node, otherwise child_begin +// and child_end fail. + +#define RegionNodeGraphTraits(NodeT) \ + template<> struct GraphTraits<NodeT*> { \ + typedef NodeT NodeType; \ + typedef RNSuccIterator<NodeType> ChildIteratorType; \ + static NodeType *getEntryNode(NodeType* N) { return N; } \ + static inline ChildIteratorType child_begin(NodeType *N) { \ + return RNSuccIterator<NodeType>(N); \ + } \ + static inline ChildIteratorType child_end(NodeType *N) { \ + return RNSuccIterator<NodeType>(N, true); \ + } \ +}; \ +template<> struct GraphTraits<FlatIt<NodeT*> > { \ + typedef NodeT NodeType; \ + typedef RNSuccIterator<FlatIt<NodeT> > ChildIteratorType; \ + static NodeType *getEntryNode(NodeType* N) { return N; } \ + static inline ChildIteratorType child_begin(NodeType *N) { \ + return RNSuccIterator<FlatIt<NodeType> >(N); \ + } \ + static inline ChildIteratorType child_end(NodeType *N) { \ + return RNSuccIterator<FlatIt<NodeType> >(N, true); \ + } \ +} + +#define RegionGraphTraits(RegionT, NodeT) \ +template<> struct GraphTraits<RegionT*> \ + : public GraphTraits<NodeT*> { \ + typedef df_iterator<NodeType*> nodes_iterator; \ + static NodeType *getEntryNode(RegionT* R) { \ + return R->getNode(R->getEntry()); \ + } \ + static nodes_iterator nodes_begin(RegionT* R) { \ + return nodes_iterator::begin(getEntryNode(R)); \ + } \ + static nodes_iterator nodes_end(RegionT* R) { \ + return nodes_iterator::end(getEntryNode(R)); \ + } \ +}; \ +template<> struct GraphTraits<FlatIt<RegionT*> > \ + : public GraphTraits<FlatIt<NodeT*> > { \ + typedef df_iterator<NodeType*, SmallPtrSet<NodeType*, 8>, false, \ + GraphTraits<FlatIt<NodeType*> > > nodes_iterator; \ + static NodeType *getEntryNode(RegionT* R) { \ + return R->getBBNode(R->getEntry()); \ + } \ + static nodes_iterator nodes_begin(RegionT* R) { \ + return nodes_iterator::begin(getEntryNode(R)); \ + } \ + static nodes_iterator nodes_end(RegionT* R) { \ + return nodes_iterator::end(getEntryNode(R)); \ + } \ +} + +RegionNodeGraphTraits(RegionNode); +RegionNodeGraphTraits(const RegionNode); + +RegionGraphTraits(Region, RegionNode); +RegionGraphTraits(const Region, const RegionNode); + +template <> struct GraphTraits<RegionInfo*> + : public GraphTraits<FlatIt<RegionNode*> > { + typedef df_iterator<NodeType*, SmallPtrSet<NodeType*, 8>, false, + GraphTraits<FlatIt<NodeType*> > > nodes_iterator; + + static NodeType *getEntryNode(RegionInfo *RI) { + return GraphTraits<FlatIt<Region*> >::getEntryNode(RI->getTopLevelRegion()); + } + static nodes_iterator nodes_begin(RegionInfo* RI) { + return nodes_iterator::begin(getEntryNode(RI)); + } + static nodes_iterator nodes_end(RegionInfo *RI) { + return nodes_iterator::end(getEntryNode(RI)); + } +}; + +} // End namespace llvm + +#endif diff --git a/contrib/llvm/include/llvm/Analysis/RegionPrinter.h b/contrib/llvm/include/llvm/Analysis/RegionPrinter.h new file mode 100644 index 0000000..758748a --- /dev/null +++ b/contrib/llvm/include/llvm/Analysis/RegionPrinter.h @@ -0,0 +1,26 @@ +//===-- RegionPrinter.h - Region 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 region printer. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_REGIONPRINTER_H +#define LLVM_ANALYSIS_REGIONPRINTER_H + +namespace llvm { + class FunctionPass; + FunctionPass *createRegionViewerPass(); + FunctionPass *createRegionOnlyViewerPass(); + FunctionPass *createRegionPrinterPass(); + FunctionPass *createRegionOnlyPrinterPass(); +} // End llvm namespace + +#endif diff --git a/contrib/llvm/include/llvm/Analysis/ScalarEvolution.h b/contrib/llvm/include/llvm/Analysis/ScalarEvolution.h index 8da3af0..1fa94e9 100644 --- a/contrib/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/contrib/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -44,12 +44,17 @@ namespace llvm { class Loop; class LoopInfo; class Operator; + class SCEVUnknown; + class SCEV; + template<> struct FoldingSetTrait<SCEV>; /// SCEV - This class represents an analyzed expression in the program. These /// are opaque objects that the client is not allowed to do much with /// directly. /// class SCEV : public FoldingSetNode { + friend struct FoldingSetTrait<SCEV>; + /// FastID - A reference to an Interned FoldingSetNodeID for this node. /// The ScalarEvolution's BumpPtrAllocator holds the data. FoldingSetNodeIDRef FastID; @@ -73,9 +78,6 @@ namespace llvm { unsigned getSCEVType() const { return SCEVType; } - /// Profile - FoldingSet support. - void Profile(FoldingSetNodeID& ID) { ID = FastID; } - /// isLoopInvariant - Return true if the value of this SCEV is unchanging in /// the specified loop. virtual bool isLoopInvariant(const Loop *L) const = 0; @@ -125,6 +127,21 @@ namespace llvm { void dump() const; }; + // Specialize FoldingSetTrait for SCEV to avoid needing to compute + // temporary FoldingSetNodeID values. + template<> struct FoldingSetTrait<SCEV> : DefaultFoldingSetTrait<SCEV> { + static void Profile(const SCEV &X, FoldingSetNodeID& ID) { + ID = X.FastID; + } + static bool Equals(const SCEV &X, const FoldingSetNodeID &ID, + FoldingSetNodeID &TempID) { + return ID == X.FastID; + } + static unsigned ComputeHash(const SCEV &X, FoldingSetNodeID &TempID) { + return X.FastID.ComputeHash(); + } + }; + inline raw_ostream &operator<<(raw_ostream &OS, const SCEV &S) { S.print(OS); return OS; @@ -175,6 +192,7 @@ namespace llvm { friend class SCEVCallbackVH; friend class SCEVExpander; + friend class SCEVUnknown; /// F - The function we are analyzing. /// @@ -196,9 +214,14 @@ namespace llvm { /// counts and things. SCEVCouldNotCompute CouldNotCompute; - /// Scalars - This is a cache of the scalars we have analyzed so far. + /// ValueExprMapType - The typedef for ValueExprMap. /// - std::map<SCEVCallbackVH, const SCEV *> Scalars; + typedef DenseMap<SCEVCallbackVH, const SCEV *, DenseMapInfo<Value *> > + ValueExprMapType; + + /// ValueExprMap - This is a cache of the values we have analyzed so far. + /// + ValueExprMapType ValueExprMap; /// BackedgeTakenInfo - Information about the backedge-taken count /// of a loop. This currently includes an exact count and a maximum count. @@ -263,7 +286,7 @@ namespace llvm { /// ForgetSymbolicValue - This looks up computed SCEV values for all /// instructions that depend on the given instruction and removes them from - /// the Scalars map if they reference SymName. This is used during PHI + /// the ValueExprMap map if they reference SymName. This is used during PHI /// resolution. void ForgetSymbolicName(Instruction *I, const SCEV *SymName); @@ -350,10 +373,11 @@ namespace llvm { std::pair<BasicBlock *, BasicBlock *> getPredecessorWithUniqueSuccessorForBB(BasicBlock *BB); - /// isImpliedCond - Test whether the condition described by Pred, LHS, - /// and RHS is true whenever the given Cond value evaluates to true. - bool isImpliedCond(Value *Cond, ICmpInst::Predicate Pred, + /// isImpliedCond - Test whether the condition described by Pred, LHS, and + /// RHS is true whenever the given FoundCondValue value evaluates to true. + bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, + Value *FoundCondValue, bool Inverse); /// isImpliedCondOperands - Test whether the condition described by Pred, @@ -659,6 +683,11 @@ namespace llvm { private: FoldingSet<SCEV> UniqueSCEVs; BumpPtrAllocator SCEVAllocator; + + /// FirstUnknown - The head of a linked list of all SCEVUnknown + /// values that have been allocated. This is used by releaseMemory + /// to locate them all and call their destructors. + SCEVUnknown *FirstUnknown; }; } diff --git a/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h b/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h index 9501555..4b02f82 100644 --- a/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -18,6 +18,7 @@ #include "llvm/Analysis/ScalarEvolutionNormalization.h" #include "llvm/Support/IRBuilder.h" #include "llvm/Support/TargetFolder.h" +#include "llvm/Support/ValueHandle.h" #include <set> namespace llvm { @@ -31,8 +32,8 @@ namespace llvm { ScalarEvolution &SE; std::map<std::pair<const SCEV *, Instruction *>, AssertingVH<Value> > InsertedExpressions; - std::set<Value*> InsertedValues; - std::set<Value*> InsertedPostIncValues; + std::set<AssertingVH<Value> > InsertedValues; + std::set<AssertingVH<Value> > InsertedPostIncValues; /// PostIncLoops - Addrecs referring to any of the given loops are expanded /// in post-inc mode. For example, expanding {1,+,1}<L> in post-inc mode @@ -70,13 +71,18 @@ namespace llvm { /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or /// different places within the same BasicBlock can do so. - void clear() { InsertedExpressions.clear(); } + void clear() { + InsertedExpressions.clear(); + InsertedValues.clear(); + InsertedPostIncValues.clear(); + } /// getOrInsertCanonicalInductionVariable - This method returns the /// canonical induction variable of the specified type for the specified /// loop (inserting one if there is none). A canonical induction variable /// starts at zero and steps by one on each iteration. - Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty); + PHINode *getOrInsertCanonicalInductionVariable(const Loop *L, + const Type *Ty); /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the diff --git a/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h index 7424203..4213a28 100644 --- a/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/contrib/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -202,33 +202,14 @@ namespace llvm { op_iterator op_begin() const { return Operands; } op_iterator op_end() const { return Operands + NumOperands; } - virtual bool isLoopInvariant(const Loop *L) const { - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (!getOperand(i)->isLoopInvariant(L)) return false; - return true; - } + virtual bool isLoopInvariant(const Loop *L) const; // hasComputableLoopEvolution - N-ary expressions have computable loop // evolutions iff they have at least one operand that varies with the loop, // but that all varying operands are computable. - virtual bool hasComputableLoopEvolution(const Loop *L) const { - bool HasVarying = false; - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (!getOperand(i)->isLoopInvariant(L)) { - if (getOperand(i)->hasComputableLoopEvolution(L)) - HasVarying = true; - else - return false; - } - return HasVarying; - } + virtual bool hasComputableLoopEvolution(const Loop *L) const; - virtual bool hasOperand(const SCEV *O) const { - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (O == getOperand(i) || getOperand(i)->hasOperand(O)) - return true; - return false; - } + virtual bool hasOperand(const SCEV *O) const; bool dominates(BasicBlock *BB, DominatorTree *DT) const; @@ -520,15 +501,28 @@ namespace llvm { /// value, and only represent it as its LLVM Value. This is the "bottom" /// value for the analysis. /// - class SCEVUnknown : public SCEV { + class SCEVUnknown : public SCEV, private CallbackVH { friend class ScalarEvolution; - Value *V; - SCEVUnknown(const FoldingSetNodeIDRef ID, Value *v) : - SCEV(ID, scUnknown), V(v) {} + // Implement CallbackVH. + virtual void deleted(); + virtual void allUsesReplacedWith(Value *New); + + /// SE - The parent ScalarEvolution value. This is used to update + /// the parent's maps when the value associated with a SCEVUnknown + /// is deleted or RAUW'd. + ScalarEvolution *SE; + + /// Next - The next pointer in the linked list of all + /// SCEVUnknown instances owned by a ScalarEvolution. + SCEVUnknown *Next; + + SCEVUnknown(const FoldingSetNodeIDRef ID, Value *V, + ScalarEvolution *se, SCEVUnknown *next) : + SCEV(ID, scUnknown), CallbackVH(V), SE(se), Next(next) {} public: - Value *getValue() const { return V; } + Value *getValue() const { return getValPtr(); } /// isSizeOf, isAlignOf, isOffsetOf - Test whether this is a special /// constant representing a type size, alignment, or field offset in diff --git a/contrib/llvm/include/llvm/Analysis/ValueTracking.h b/contrib/llvm/include/llvm/Analysis/ValueTracking.h index b9634f0..7b6026f 100644 --- a/contrib/llvm/include/llvm/Analysis/ValueTracking.h +++ b/contrib/llvm/include/llvm/Analysis/ValueTracking.h @@ -77,25 +77,6 @@ namespace llvm { /// bool CannotBeNegativeZero(const Value *V, unsigned Depth = 0); - /// DecomposeGEPExpression - If V is a symbolic pointer expression, decompose - /// it into a base pointer with a constant offset and a number of scaled - /// symbolic offsets. - /// - /// The scaled symbolic offsets (represented by pairs of a Value* and a scale - /// in the VarIndices vector) are Value*'s that are known to be scaled by the - /// specified amount, but which may have other unrepresented high bits. As - /// such, the gep cannot necessarily be reconstructed from its decomposed - /// form. - /// - /// When TargetData is around, this function is capable of analyzing - /// everything that Value::getUnderlyingObject() can look through. When not, - /// it just looks through pointer casts. - /// - const Value *DecomposeGEPExpression(const Value *V, int64_t &BaseOffs, - SmallVectorImpl<std::pair<const Value*, int64_t> > &VarIndices, - const TargetData *TD); - - /// FindInsertedValue - Given an aggregrate and an sequence of indices, see if /// the scalar value indexed is already around as a register, for example if diff --git a/contrib/llvm/include/llvm/Assembly/AsmAnnotationWriter.h b/contrib/llvm/include/llvm/Assembly/AssemblyAnnotationWriter.h index 6d75720..3a65f97 100644 --- a/contrib/llvm/include/llvm/Assembly/AsmAnnotationWriter.h +++ b/contrib/llvm/include/llvm/Assembly/AssemblyAnnotationWriter.h @@ -1,4 +1,4 @@ -//===-- AsmAnnotationWriter.h - Itf for annotation .ll files - --*- C++ -*-===// +//===-- AssemblyAnnotationWriter.h - Annotation .ll files -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -32,21 +32,26 @@ public: /// emitFunctionAnnot - This may be implemented to emit a string right before /// the start of a function. - virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {} + virtual void emitFunctionAnnot(const Function *F, + formatted_raw_ostream &OS) {} /// emitBasicBlockStartAnnot - This may be implemented to emit a string right - /// after the basic block label, but before the first instruction in the block. - virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, raw_ostream &OS){ + /// after the basic block label, but before the first instruction in the + /// block. + virtual void emitBasicBlockStartAnnot(const BasicBlock *BB, + formatted_raw_ostream &OS) { } /// emitBasicBlockEndAnnot - This may be implemented to emit a string right /// after the basic block. - virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS){ + virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, + formatted_raw_ostream &OS) { } /// emitInstructionAnnot - This may be implemented to emit a string right /// before an instruction is emitted. - virtual void emitInstructionAnnot(const Instruction *I, raw_ostream &OS) {} + virtual void emitInstructionAnnot(const Instruction *I, + formatted_raw_ostream &OS) {} /// printInfoComment - This may be implemented to emit a comment to the /// right of an instruction or global value. diff --git a/contrib/llvm/include/llvm/AutoUpgrade.h b/contrib/llvm/include/llvm/AutoUpgrade.h index 0a81c80..5ce20b6 100644 --- a/contrib/llvm/include/llvm/AutoUpgrade.h +++ b/contrib/llvm/include/llvm/AutoUpgrade.h @@ -16,6 +16,7 @@ namespace llvm { class Module; + class GlobalVariable; class Function; class CallInst; @@ -35,6 +36,10 @@ namespace llvm { /// so that it can update all calls to the old function. void UpgradeCallsToIntrinsic(Function* F); + /// This checks for global variables which should be upgraded. It returns true + /// if it requires upgrading. + bool UpgradeGlobalVariable(GlobalVariable *GV); + /// This function checks debug info intrinsics. If an intrinsic is invalid /// then this function simply removes the intrinsic. void CheckDebugInfoIntrinsics(Module *M); diff --git a/contrib/llvm/include/llvm/Bitcode/Archive.h b/contrib/llvm/include/llvm/Bitcode/Archive.h index 83a3758..934e764 100644 --- a/contrib/llvm/include/llvm/Bitcode/Archive.h +++ b/contrib/llvm/include/llvm/Bitcode/Archive.h @@ -297,7 +297,7 @@ class Archive { /// its symbol table without reading in any of the archive's members. This /// reduces both I/O and cpu time in opening the archive if it is to be used /// solely for symbol lookup (e.g. during linking). The \p Filename must - /// exist and be an archive file or an exception will be thrown. This form + /// exist and be an archive file or an error will be returned. This form /// of opening the archive is intended for read-only operations that need to /// locate members via the symbol table for link editing. Since the archve /// members are not read by this method, the archive will appear empty upon @@ -306,8 +306,7 @@ class Archive { /// if this form of opening the archive is used that only the symbol table /// lookup methods (getSymbolTable, findModuleDefiningSymbol, and /// findModulesDefiningSymbols) be used. - /// @throws std::string if an error occurs opening the file - /// @returns an Archive* that represents the archive file. + /// @returns an Archive* that represents the archive file, or null on error. /// @brief Open an existing archive and load its symbols. static Archive* OpenAndLoadSymbols( const sys::Path& Filename, ///< Name of the archive file to open @@ -319,7 +318,6 @@ class Archive { /// closes files. It does nothing with the archive file on disk. If you /// haven't used the writeToDisk method by the time the destructor is /// called, all changes to the archive will be lost. - /// @throws std::string if an error occurs /// @brief Destruct in-memory archive ~Archive(); diff --git a/contrib/llvm/include/llvm/Bitcode/BitstreamWriter.h b/contrib/llvm/include/llvm/Bitcode/BitstreamWriter.h index 31d513c..bfb3a4e 100644 --- a/contrib/llvm/include/llvm/Bitcode/BitstreamWriter.h +++ b/contrib/llvm/include/llvm/Bitcode/BitstreamWriter.h @@ -88,7 +88,7 @@ public: //===--------------------------------------------------------------------===// void Emit(uint32_t Val, unsigned NumBits) { - assert(NumBits <= 32 && "Invalid value size!"); + assert(NumBits && NumBits <= 32 && "Invalid value size!"); assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!"); CurValue |= Val << CurBit; if (CurBit + NumBits < 32) { @@ -277,10 +277,12 @@ private: switch (Op.getEncoding()) { default: assert(0 && "Unknown encoding!"); case BitCodeAbbrevOp::Fixed: - Emit((unsigned)V, (unsigned)Op.getEncodingData()); + if (Op.getEncodingData()) + Emit((unsigned)V, (unsigned)Op.getEncodingData()); break; case BitCodeAbbrevOp::VBR: - EmitVBR64(V, (unsigned)Op.getEncodingData()); + if (Op.getEncodingData()) + EmitVBR64(V, (unsigned)Op.getEncodingData()); break; case BitCodeAbbrevOp::Char6: Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6); diff --git a/contrib/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/contrib/llvm/include/llvm/Bitcode/LLVMBitCodes.h index de9b64d..4f9b783 100644 --- a/contrib/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/contrib/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -94,8 +94,7 @@ namespace bitc { TYPE_CODE_FP128 = 14, // LONG DOUBLE (112 bit mantissa) TYPE_CODE_PPC_FP128= 15, // PPC LONG DOUBLE (2 doubles) - TYPE_CODE_METADATA = 16, // METADATA - TYPE_CODE_UNION = 17 // UNION: [eltty x N] + TYPE_CODE_METADATA = 16 // METADATA }; // The type symbol table only has one code (TST_ENTRY_CODE). @@ -111,12 +110,20 @@ namespace bitc { enum MetadataCodes { METADATA_STRING = 1, // MDSTRING: [values] - METADATA_NODE = 2, // MDNODE: [n x (type num, value num)] - METADATA_FN_NODE = 3, // FN_MDNODE: [n x (type num, value num)] + // FIXME: Remove NODE in favor of NODE2 in LLVM 3.0 + METADATA_NODE = 2, // NODE with potentially invalid metadata + // FIXME: Remove FN_NODE in favor of FN_NODE2 in LLVM 3.0 + METADATA_FN_NODE = 3, // FN_NODE with potentially invalid metadata METADATA_NAME = 4, // STRING: [values] - METADATA_NAMED_NODE = 5, // NAMEDMDNODE: [n x mdnodes] + // FIXME: Remove NAMED_NODE in favor of NAMED_NODE2 in LLVM 3.0 + METADATA_NAMED_NODE = 5, // NAMED_NODE with potentially invalid metadata METADATA_KIND = 6, // [n x [id, name]] - METADATA_ATTACHMENT = 7 // [m x [value, [n x [id, mdnode]]] + // FIXME: Remove ATTACHMENT in favor of ATTACHMENT2 in LLVM 3.0 + METADATA_ATTACHMENT = 7, // ATTACHMENT with potentially invalid metadata + METADATA_NODE2 = 8, // NODE2: [n x (type num, value num)] + METADATA_FN_NODE2 = 9, // FN_NODE2: [n x (type num, value num)] + METADATA_NAMED_NODE2 = 10, // NAMED_NODE2: [n x mdnodes] + METADATA_ATTACHMENT2 = 11 // [m x [value, [n x [id, mdnode]]] }; // The constants block (CONSTANTS_BLOCK_ID) describes emission for each // constant and maintains an implicit current type value. @@ -224,7 +231,8 @@ namespace bitc { FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol] // FIXME: Remove STORE in favor of STORE2 in LLVM 3.0 FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol] - FUNC_CODE_INST_CALL = 22, // CALL: [attr, fnty, fnid, args...] + // FIXME: Remove CALL in favor of CALL2 in LLVM 3.0 + FUNC_CODE_INST_CALL = 22, // CALL with potentially invalid metadata FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty] // This store code encodes the pointer type, rather than the value type // this is so information only available in the pointer type (e.g. address @@ -242,8 +250,13 @@ namespace bitc { FUNC_CODE_INST_INBOUNDS_GEP= 30, // INBOUNDS_GEP: [n x operands] FUNC_CODE_INST_INDIRECTBR = 31, // INDIRECTBR: [opty, op0, op1, ...] - FUNC_CODE_DEBUG_LOC = 32, // DEBUG_LOC: [Line,Col,ScopeVal, IAVal] - FUNC_CODE_DEBUG_LOC_AGAIN = 33 // DEBUG_LOC_AGAIN + // FIXME: Remove DEBUG_LOC in favor of DEBUG_LOC2 in LLVM 3.0 + FUNC_CODE_DEBUG_LOC = 32, // DEBUG_LOC with potentially invalid metadata + FUNC_CODE_DEBUG_LOC_AGAIN = 33, // DEBUG_LOC_AGAIN + + FUNC_CODE_INST_CALL2 = 34, // CALL2: [attr, fnty, fnid, args...] + + FUNC_CODE_DEBUG_LOC2 = 35 // DEBUG_LOC2: [Line,Col,ScopeVal, IAVal] }; } // End bitc namespace } // End llvm namespace diff --git a/contrib/llvm/include/llvm/CallGraphSCCPass.h b/contrib/llvm/include/llvm/CallGraphSCCPass.h index e11b967..7154aa3 100644 --- a/contrib/llvm/include/llvm/CallGraphSCCPass.h +++ b/contrib/llvm/include/llvm/CallGraphSCCPass.h @@ -33,8 +33,7 @@ class CallGraphSCC; class CallGraphSCCPass : public Pass { public: - explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} - explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} + explicit CallGraphSCCPass(char &pid) : Pass(PT_CallGraphSCC, pid) {} /// createPrinterPass - Get a pass that prints the Module /// corresponding to a CallGraph. @@ -64,7 +63,7 @@ public: /// Assign pass manager to manager this pass virtual void assignPassManager(PMStack &PMS, - PassManagerType PMT =PMT_CallGraphPassManager); + PassManagerType PMT); /// Return what kind of Pass Manager can manage this pass. virtual PassManagerType getPotentialPassManagerType() const { diff --git a/contrib/llvm/include/llvm/CodeGen/AsmPrinter.h b/contrib/llvm/include/llvm/CodeGen/AsmPrinter.h index 7ca6c62..b018603 100644 --- a/contrib/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/contrib/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -54,6 +54,7 @@ namespace llvm { class Mangler; class TargetLoweringObjectFile; class TargetData; + class TargetMachine; class Twine; class Type; @@ -296,7 +297,7 @@ namespace llvm { MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const; MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const; - //===------------------------------------------------------------------===// + //===------------------------------------------------------------------===// // Emission Helper Routines. //===------------------------------------------------------------------===// public: @@ -327,6 +328,12 @@ namespace llvm { void EmitLabelOffsetDifference(const MCSymbol *Hi, uint64_t Offset, const MCSymbol *Lo, unsigned Size) const; + /// EmitLabelPlusOffset - Emit something like ".long Label+Offset" + /// where the size in bytes of the directive is specified by Size and Label + /// specifies the label. This implicitly uses .set if it is available. + void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, + unsigned Size) const; + //===------------------------------------------------------------------===// // Dwarf Emission Helper Routines //===------------------------------------------------------------------===// @@ -369,6 +376,10 @@ namespace llvm { /// operands. virtual MachineLocation getDebugValueLocation(const MachineInstr *MI) const; + /// getISAEncoding - Get the value for DW_AT_APPLE_isa. Zero if no isa + /// encoding specified. + virtual unsigned getISAEncoding() { return 0; } + //===------------------------------------------------------------------===// // Dwarf Lowering Routines //===------------------------------------------------------------------===// diff --git a/contrib/llvm/include/llvm/CodeGen/CalcSpillWeights.h b/contrib/llvm/include/llvm/CodeGen/CalcSpillWeights.h index 2fc03bd..240734f 100644 --- a/contrib/llvm/include/llvm/CodeGen/CalcSpillWeights.h +++ b/contrib/llvm/include/llvm/CodeGen/CalcSpillWeights.h @@ -12,10 +12,35 @@ #define LLVM_CODEGEN_CALCSPILLWEIGHTS_H #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/ADT/DenseMap.h" namespace llvm { class LiveInterval; + class LiveIntervals; + class MachineLoopInfo; + + /// VirtRegAuxInfo - Calculate auxiliary information for a virtual + /// register such as its spill weight and allocation hint. + class VirtRegAuxInfo { + MachineFunction &mf_; + LiveIntervals &lis_; + const MachineLoopInfo &loops_; + DenseMap<unsigned, float> hint_; + public: + VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis, + const MachineLoopInfo &loops) : + mf_(mf), lis_(lis), loops_(loops) {} + + /// CalculateRegClass - recompute the register class for reg from its uses. + /// Since the register class can affect the allocation hint, this function + /// should be called before CalculateWeightAndHint if both are called. + void CalculateRegClass(unsigned reg); + + /// CalculateWeightAndHint - (re)compute li's spill weight and allocation + /// hint. + void CalculateWeightAndHint(LiveInterval &li); + }; /// CalculateSpillWeights - Compute spill weights for all virtual register /// live intervals. @@ -23,11 +48,11 @@ namespace llvm { public: static char ID; - CalculateSpillWeights() : MachineFunctionPass(&ID) {} + CalculateSpillWeights() : MachineFunctionPass(ID) {} virtual void getAnalysisUsage(AnalysisUsage &au) const; - virtual bool runOnMachineFunction(MachineFunction &fn); + virtual bool runOnMachineFunction(MachineFunction &fn); private: /// Returns true if the given live interval is zero length. diff --git a/contrib/llvm/include/llvm/CodeGen/CallingConvLower.h b/contrib/llvm/include/llvm/CodeGen/CallingConvLower.h index 7911907..6fb8436 100644 --- a/contrib/llvm/include/llvm/CodeGen/CallingConvLower.h +++ b/contrib/llvm/include/llvm/CodeGen/CallingConvLower.h @@ -275,6 +275,12 @@ public: return Result; } + /// Version of AllocateStack with extra register to be shadowed. + unsigned AllocateStack(unsigned Size, unsigned Align, unsigned ShadowReg) { + MarkAllocated(ShadowReg); + return AllocateStack(Size, Align); + } + // HandleByVal - Allocate a stack slot large enough to pass an argument by // value. The size and alignment information of the argument is encoded in its // parameter attribute. diff --git a/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h index c49d1ed..f17fe5a 100644 --- a/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h +++ b/contrib/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h @@ -77,6 +77,9 @@ public: /// anywhere in the function. DenseMap<const AllocaInst*, int> StaticAllocaMap; + /// ByValArgFrameIndexMap - Keep track of frame indices for byval arguments. + DenseMap<const Argument*, int> ByValArgFrameIndexMap; + /// ArgDbgValues - A list of DBG_VALUE instructions created during isel for /// function arguments that are inserted after scheduling is completed. SmallVector<MachineInstr*, 8> ArgDbgValues; @@ -138,6 +141,13 @@ public: assert(R == 0 && "Already initialized this value register!"); return R = CreateRegs(V->getType()); } + + /// setByValArgumentFrameIndex - Record frame index for the byval + /// argument. + void setByValArgumentFrameIndex(const Argument *A, int FI); + + /// getByValArgumentFrameIndex - Get frame index for the byval argument. + int getByValArgumentFrameIndex(const Argument *A); }; /// AddCatchInfo - Extract the personality and type infos from an eh.selector diff --git a/contrib/llvm/include/llvm/CodeGen/ISDOpcodes.h b/contrib/llvm/include/llvm/CodeGen/ISDOpcodes.h index 69de598..2e23f4e 100644 --- a/contrib/llvm/include/llvm/CodeGen/ISDOpcodes.h +++ b/contrib/llvm/include/llvm/CodeGen/ISDOpcodes.h @@ -603,7 +603,7 @@ namespace ISD { /// which do not reference a specific memory location should be less than /// this value. Those that do must not be less than this value, and can /// be used with SelectionDAG::getMemIntrinsicNode. - static const int FIRST_TARGET_MEMORY_OPCODE = BUILTIN_OP_END+100; + static const int FIRST_TARGET_MEMORY_OPCODE = BUILTIN_OP_END+150; //===--------------------------------------------------------------------===// /// MemIndexedMode enum - This enum defines the load / store indexed @@ -633,7 +633,6 @@ namespace ISD { /// (the result of the load and the result of the base +/- offset /// computation); a post-indexed store produces one value (the /// the result of the base +/- offset computation). - /// enum MemIndexedMode { UNINDEXED = 0, PRE_INC, @@ -651,10 +650,8 @@ namespace ISD { /// integer result type. /// ZEXTLOAD loads the integer operand and zero extends it to a larger /// integer result type. - /// EXTLOAD is used for three things: floating point extending loads, - /// integer extending loads [the top bits are undefined], and vector - /// extending loads [load into low elt]. - /// + /// EXTLOAD is used for two things: floating point extending loads and + /// integer extending loads [the top bits are undefined]. enum LoadExtType { NON_EXTLOAD = 0, EXTLOAD, diff --git a/contrib/llvm/include/llvm/CodeGen/LiveInterval.h b/contrib/llvm/include/llvm/CodeGen/LiveInterval.h index 8d80efb..29e689a 100644 --- a/contrib/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/contrib/llvm/include/llvm/CodeGen/LiveInterval.h @@ -39,7 +39,7 @@ namespace llvm { /// This class holds information about a machine level values, including /// definition and use points. /// - /// Care must be taken in interpreting the def index of the value. The + /// Care must be taken in interpreting the def index of the value. The /// following rules apply: /// /// If the isDefAccurate() method returns false then def does not contain the @@ -108,7 +108,7 @@ namespace llvm { /// For a stack interval, returns the reg which this stack interval was /// defined from. - /// For a register interval the behaviour of this method is undefined. + /// For a register interval the behaviour of this method is undefined. unsigned getReg() const { return cr.reg; } /// For a stack interval, set the defining register. /// This method should not be called on register intervals as it may lead @@ -189,7 +189,7 @@ namespace llvm { } /// containsRange - Return true if the given range, [S, E), is covered by - /// this range. + /// this range. bool containsRange(SlotIndex S, SlotIndex E) const { assert((S < E) && "Backwards interval?"); return (start <= S && S < end) && (start < E && E <= end); @@ -236,7 +236,7 @@ namespace llvm { float weight; // weight of this interval Ranges ranges; // the ranges in which this register is live VNInfoList valnos; // value#'s - + struct InstrSlots { enum { LOAD = 0, @@ -281,7 +281,7 @@ namespace llvm { while (I->end <= Pos) ++I; return I; } - + void clear() { valnos.clear(); ranges.clear(); @@ -305,7 +305,7 @@ namespace llvm { bool containsOneValue() const { return valnos.size() == 1; } unsigned getNumValNums() const { return (unsigned)valnos.size(); } - + /// getValNumInfo - Returns pointer to the specified val#. /// inline VNInfo *getValNumInfo(unsigned ValNo) { @@ -336,6 +336,11 @@ namespace llvm { return VNI; } + /// RenumberValues - Renumber all values in order of appearance and remove + /// unused values. + /// Recalculate phi-kill flags in case any phi-def values were removed. + void RenumberValues(LiveIntervals &lis); + /// isOnlyLROfValNo - Return true if the specified live range is the only /// one defined by the its val#. bool isOnlyLROfValNo(const LiveRange *LR) { @@ -346,7 +351,7 @@ namespace llvm { } return true; } - + /// MergeValueNumberInto - This method is called when two value nubmers /// are found to be equivalent. This eliminates V1, replacing all /// LiveRanges with the V1 value number with the V2 value number. This can @@ -387,7 +392,7 @@ namespace llvm { /// except for the register of the interval. void Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI, VNInfo::Allocator &VNInfoAllocator); - + bool empty() const { return ranges.empty(); } /// beginIndex - Return the lowest numbered slot covered by interval. @@ -454,17 +459,19 @@ namespace llvm { iterator FindLiveRangeContaining(SlotIndex Idx); /// findDefinedVNInfo - Find the by the specified - /// index (register interval) or defined + /// index (register interval) or defined VNInfo *findDefinedVNInfoForRegInt(SlotIndex Idx) const; /// findDefinedVNInfo - Find the VNInfo that's defined by the specified /// register (stack inteval only). VNInfo *findDefinedVNInfoForStackInt(unsigned Reg) const; - + /// overlaps - Return true if the intersection of the two live intervals is /// not empty. bool overlaps(const LiveInterval& other) const { + if (other.empty()) + return false; return overlapsFrom(other, other.begin()); } @@ -514,6 +521,15 @@ namespace llvm { /// unsigned getSize() const; + /// Returns true if the live interval is zero length, i.e. no live ranges + /// span instructions. It doesn't pay to spill such an interval. + bool isZeroLength() const { + for (const_iterator i = begin(), e = end(); i != e; ++i) + if (i->end.getPrevIndex() > i->start) + return false; + return true; + } + /// isSpillable - Can this interval be spilled? bool isSpillable() const { return weight != HUGE_VALF; @@ -543,6 +559,7 @@ namespace llvm { Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); void extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd); Ranges::iterator extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStr); + void markValNoForDeletion(VNInfo *V); LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT diff --git a/contrib/llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h b/contrib/llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h index c136048..2918c3c2a 100644 --- a/contrib/llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/contrib/llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -42,7 +42,7 @@ namespace llvm { class TargetInstrInfo; class TargetRegisterClass; class VirtRegMap; - + class LiveIntervals : public MachineFunctionPass { MachineFunction* mf_; MachineRegisterInfo* mri_; @@ -68,7 +68,7 @@ namespace llvm { public: static char ID; // Pass identification, replacement for typeid - LiveIntervals() : MachineFunctionPass(&ID) {} + LiveIntervals() : MachineFunctionPass(ID) {} // Calculate the spill weight to assign to a single instruction. static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth); @@ -105,6 +105,12 @@ namespace llvm { return r2iMap_.count(reg); } + /// isAllocatable - is the physical register reg allocatable in the current + /// function? + bool isAllocatable(unsigned reg) const { + return allocatableRegs_.test(reg); + } + /// getScaledIntervalSize - get the size of an interval in "units," /// where every function is composed of one thousand units. This /// measure scales properly with empty index slots in the function. @@ -117,7 +123,7 @@ namespace llvm { unsigned getFuncInstructionCount() { return indexes_->getFunctionSize(); } - + /// getApproximateInstructionCount - computes an estimate of the number /// of instructions in a given LiveInterval. unsigned getApproximateInstructionCount(LiveInterval& I) { @@ -149,7 +155,7 @@ namespace llvm { /// dupInterval - Duplicate a live interval. The caller is responsible for /// managing the allocated memory. LiveInterval *dupInterval(LiveInterval *li); - + /// addLiveRangeToEndOfBlock - Given a register and an instruction, /// adds a live range from that instruction to the end of its MBB. LiveRange addLiveRangeToEndOfBlock(unsigned reg, @@ -181,7 +187,7 @@ namespace llvm { SlotIndex getInstructionIndex(const MachineInstr *instr) const { return indexes_->getInstructionIndex(instr); } - + /// Returns the instruction associated with the given index. MachineInstr* getInstructionFromIndex(SlotIndex index) const { return indexes_->getInstructionFromIndex(index); @@ -190,12 +196,32 @@ namespace llvm { /// Return the first index in the given basic block. SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const { return indexes_->getMBBStartIdx(mbb); - } + } /// Return the last index in the given basic block. SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const { return indexes_->getMBBEndIdx(mbb); - } + } + + bool isLiveInToMBB(const LiveInterval &li, + const MachineBasicBlock *mbb) const { + return li.liveAt(getMBBStartIdx(mbb)); + } + + LiveRange* findEnteringRange(LiveInterval &li, + const MachineBasicBlock *mbb) { + return li.getLiveRangeContaining(getMBBStartIdx(mbb)); + } + + bool isLiveOutOfMBB(const LiveInterval &li, + const MachineBasicBlock *mbb) const { + return li.liveAt(getMBBEndIdx(mbb).getPrevSlot()); + } + + LiveRange* findExitingRange(LiveInterval &li, + const MachineBasicBlock *mbb) { + return li.getLiveRangeContaining(getMBBEndIdx(mbb).getPrevSlot()); + } MachineBasicBlock* getMBBFromIndex(SlotIndex index) const { return indexes_->getMBBFromIndex(index); @@ -217,6 +243,10 @@ namespace llvm { indexes_->replaceMachineInstrInMaps(MI, NewMI); } + void InsertMBBInMaps(MachineBasicBlock *MBB) { + indexes_->insertMBBInMaps(MBB); + } + bool findLiveInMBBs(SlotIndex Start, SlotIndex End, SmallVectorImpl<MachineBasicBlock*> &MBBs) const { return indexes_->findLiveInMBBs(Start, End, MBBs); @@ -276,7 +306,7 @@ namespace llvm { /// within a single basic block. bool intervalIsInOneMBB(const LiveInterval &li) const; - private: + private: /// computeIntervals - Compute live intervals. void computeIntervals(); @@ -290,7 +320,7 @@ namespace llvm { /// isPartialRedef - Return true if the specified def at the specific index /// is partially re-defining the specified live interval. A common case of - /// this is a definition of the sub-register. + /// this is a definition of the sub-register. bool isPartialRedef(SlotIndex MIIdx, MachineOperand &MO, LiveInterval &interval); diff --git a/contrib/llvm/include/llvm/CodeGen/LiveStackAnalysis.h b/contrib/llvm/include/llvm/CodeGen/LiveStackAnalysis.h index c6af6a1..ad984db 100644 --- a/contrib/llvm/include/llvm/CodeGen/LiveStackAnalysis.h +++ b/contrib/llvm/include/llvm/CodeGen/LiveStackAnalysis.h @@ -39,7 +39,7 @@ namespace llvm { public: static char ID; // Pass identification, replacement for typeid - LiveStacks() : MachineFunctionPass(&ID) {} + LiveStacks() : MachineFunctionPass(ID) {} typedef SS2IntervalMap::iterator iterator; typedef SS2IntervalMap::const_iterator const_iterator; diff --git a/contrib/llvm/include/llvm/CodeGen/LiveVariables.h b/contrib/llvm/include/llvm/CodeGen/LiveVariables.h index fc5ea6f..c8182e0 100644 --- a/contrib/llvm/include/llvm/CodeGen/LiveVariables.h +++ b/contrib/llvm/include/llvm/CodeGen/LiveVariables.h @@ -46,7 +46,7 @@ class TargetRegisterInfo; class LiveVariables : public MachineFunctionPass { public: static char ID; // Pass identification, replacement for typeid - LiveVariables() : MachineFunctionPass(&ID) {} + LiveVariables() : MachineFunctionPass(ID) {} /// VarInfo - This represents the regions where a virtual register is live in /// the program. We represent this with three different pieces of diff --git a/contrib/llvm/include/llvm/CodeGen/MachineFrameInfo.h b/contrib/llvm/include/llvm/CodeGen/MachineFrameInfo.h index 9471316..dca65ef 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineFrameInfo.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineFrameInfo.h @@ -15,6 +15,7 @@ #define LLVM_CODEGEN_MACHINEFRAMEINFO_H #include "llvm/ADT/SmallVector.h" +//#include "llvm/ADT/IndexedMap.h" #include "llvm/System/DataTypes.h" #include <cassert> #include <vector> @@ -30,15 +31,15 @@ class TargetFrameInfo; class BitVector; /// The CalleeSavedInfo class tracks the information need to locate where a -/// callee saved register in the current frame. +/// callee saved register is in the current frame. class CalleeSavedInfo { unsigned Reg; int FrameIdx; - + public: explicit CalleeSavedInfo(unsigned R, int FI = 0) : Reg(R), FrameIdx(FI) {} - + // Accessors. unsigned getReg() const { return Reg; } int getFrameIdx() const { return FrameIdx; } @@ -81,7 +82,7 @@ class MachineFrameInfo { // 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; @@ -94,13 +95,23 @@ class MachineFrameInfo { // default, fixed objects are immutable unless marked otherwise. bool isImmutable; - // isSpillSlot - If true, the stack object is used as spill slot. It + // 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, bool IM, bool isSS) + // MayNeedSP - If true the stack object triggered the creation of the stack + // protector. We should allocate this object right after the stack + // protector. + bool MayNeedSP; + + // PreAllocated - If true, the object was mapped into the local frame + // block and doesn't need additional handling for allocation beyond that. + bool PreAllocated; + + StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, + bool isSS, bool NSP) : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), - isSpillSlot(isSS) {} + isSpillSlot(isSS), MayNeedSP(NSP), PreAllocated(false) {} }; /// Objects - The list of stack objects allocated... @@ -132,7 +143,7 @@ class MachineFrameInfo { /// to be allocated on entry to the function. /// uint64_t StackSize; - + /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to /// have the actual offset from the stack/frame pointer. The exact usage of /// this is target-dependent, but it is typically used to adjust between @@ -143,10 +154,10 @@ class MachineFrameInfo { /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the /// corresponding adjustments are performed directly. int OffsetAdjustment; - - /// MaxAlignment - The prolog/epilog code inserter may process objects + + /// MaxAlignment - The prolog/epilog code inserter may process objects /// that require greater alignment than the default alignment the target - /// provides. To handle this, MaxAlignment is set to the maximum alignment + /// provides. To handle this, MaxAlignment is set to the maximum alignment /// needed by the objects on the current frame. If this is greater than the /// native alignment maintained by the compiler, dynamic alignment code will /// be needed. @@ -171,7 +182,7 @@ class MachineFrameInfo { /// insertion. /// unsigned MaxCallFrameSize; - + /// CSInfo - The prolog/epilog code inserter fills in this vector with each /// callee saved register saved in the frame. Beyond its use by the prolog/ /// epilog code inserter, this data used for debug info and exception @@ -189,8 +200,24 @@ class MachineFrameInfo { /// const TargetFrameInfo &TFI; + /// LocalFrameObjects - References to frame indices which are mapped + /// into the local frame allocation block. <FrameIdx, LocalOffset> + SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects; + + /// LocalFrameSize - Size of the pre-allocated local frame block. + int64_t LocalFrameSize; + + /// Required alignment of the local object blob, which is the strictest + /// alignment of any object in it. + unsigned LocalFrameMaxAlign; + + /// Whether the local object blob needs to be allocated together. If not, + /// PEI should ignore the isPreAllocated flags on the stack objects and + /// just allocate them normally. + bool UseLocalStackAllocationBlock; + public: - explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { + explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; HasVarSizedObjects = false; FrameAddressTaken = false; @@ -200,6 +227,9 @@ public: StackProtectorIdx = -1; MaxCallFrameSize = 0; CSIValid = false; + LocalFrameSize = 0; + LocalFrameMaxAlign = 0; + UseLocalStackAllocationBlock = false; } /// hasStackObjects - Return true if there are any stack objects in this @@ -225,8 +255,8 @@ public: bool isFrameAddressTaken() const { return FrameAddressTaken; } void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; } - /// isReturnAddressTaken - This method may be called any time after instruction - /// selection is complete to determine if there is a call to + /// isReturnAddressTaken - This method may be called any time after + /// instruction selection is complete to determine if there is a call to /// \@llvm.returnaddress in this function. bool isReturnAddressTaken() const { return ReturnAddressTaken; } void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; } @@ -239,13 +269,64 @@ public: /// int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } - /// getNumFixedObjects() - Return the number of fixed objects. + /// getNumFixedObjects - Return the number of fixed objects. unsigned getNumFixedObjects() const { return NumFixedObjects; } - /// getNumObjects() - Return the number of objects. + /// getNumObjects - Return the number of objects. /// unsigned getNumObjects() const { return Objects.size(); } + /// mapLocalFrameObject - Map a frame index into the local object block + void mapLocalFrameObject(int ObjectIndex, int64_t Offset) { + LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset)); + Objects[ObjectIndex + NumFixedObjects].PreAllocated = true; + } + + /// getLocalFrameObjectMap - Get the local offset mapping for a for an object + std::pair<int, int64_t> getLocalFrameObjectMap(int i) { + assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() && + "Invalid local object reference!"); + return LocalFrameObjects[i]; + } + + /// getLocalFrameObjectCount - Return the number of objects allocated into + /// the local object block. + int64_t getLocalFrameObjectCount() { return LocalFrameObjects.size(); } + + /// setLocalFrameSize - Set the size of the local object blob. + void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; } + + /// getLocalFrameSize - Get the size of the local object blob. + int64_t getLocalFrameSize() const { return LocalFrameSize; } + + /// setLocalFrameMaxAlign - Required alignment of the local object blob, + /// which is the strictest alignment of any object in it. + void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; } + + /// getLocalFrameMaxAlign - Return the required alignment of the local + /// object blob. + unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; } + + /// getUseLocalStackAllocationBlock - Get whether the local allocation blob + /// should be allocated together or let PEI allocate the locals in it + /// directly. + bool getUseLocalStackAllocationBlock() {return UseLocalStackAllocationBlock;} + + /// setUseLocalStackAllocationBlock - Set whether the local allocation blob + /// should be allocated together or let PEI allocate the locals in it + /// directly. + void setUseLocalStackAllocationBlock(bool v) { + UseLocalStackAllocationBlock = v; + } + + /// isObjectPreAllocated - Return true if the object was pre-allocated into + /// the local block. + bool isObjectPreAllocated(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].PreAllocated; + } + /// getObjectSize - Return the size of the specified object. /// int64_t getObjectSize(int ObjectIdx) const { @@ -276,6 +357,14 @@ public: MaxAlignment = std::max(MaxAlignment, Align); } + /// NeedsStackProtector - Returns true if the object may need stack + /// protectors. + bool MayNeedStackProtector(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].MayNeedSP; + } + /// getObjectOffset - Return the assigned stack offset of the specified object /// from the incoming stack pointer. /// @@ -307,21 +396,21 @@ public: /// setStackSize - Set the size of the stack... /// void setStackSize(uint64_t Size) { StackSize = Size; } - + /// getOffsetAdjustment - Return the correction for frame offsets. /// int getOffsetAdjustment() const { return OffsetAdjustment; } - + /// setOffsetAdjustment - Set the correction for frame offsets. /// void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; } - /// getMaxAlignment - Return the alignment in bytes that this function must be - /// aligned to, which is greater than the default stack alignment provided by + /// getMaxAlignment - Return the alignment in bytes that this function must be + /// aligned to, which is greater than the default stack alignment provided by /// the target. /// unsigned getMaxAlignment() const { return MaxAlignment; } - + /// setMaxAlignment - Set the preferred alignment. /// void setMaxAlignment(unsigned Align) { MaxAlignment = Align; } @@ -350,8 +439,8 @@ public: /// index with a negative value. /// int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable); - - + + /// isFixedObjectIndex - Returns true if the specified index corresponds to a /// fixed stack object. bool isFixedObjectIndex(int ObjectIdx) const { @@ -382,25 +471,26 @@ public: return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL; } - /// CreateStackObject - Create a new statically sized stack object, - /// returning a nonnegative identifier to represent it. + /// CreateStackObject - Create a new statically sized stack object, returning + /// a nonnegative identifier to represent it. /// - int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS) { + int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, + bool MayNeedSP = false) { assert(Size != 0 && "Cannot allocate zero size stack objects!"); - Objects.push_back(StackObject(Size, Alignment, 0, false, isSS)); - int Index = (int)Objects.size()-NumFixedObjects-1; + Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, MayNeedSP)); + int Index = (int)Objects.size() - NumFixedObjects - 1; assert(Index >= 0 && "Bad frame index!"); MaxAlignment = std::max(MaxAlignment, Alignment); return Index; } - /// CreateSpillStackObject - Create a new statically sized stack - /// object that represents a spill slot, returning a nonnegative - /// identifier to represent it. + /// CreateSpillStackObject - Create a new statically sized stack object that + /// represents a spill slot, returning a nonnegative identifier to represent + /// it. /// int CreateSpillStackObject(uint64_t Size, unsigned Alignment) { - CreateStackObject(Size, Alignment, true); - int Index = (int)Objects.size()-NumFixedObjects-1; + CreateStackObject(Size, Alignment, true, false); + int Index = (int)Objects.size() - NumFixedObjects - 1; MaxAlignment = std::max(MaxAlignment, Alignment); return Index; } @@ -417,9 +507,10 @@ public: /// variable sized object is created, whether or not the index returned is /// actually used. /// - int CreateVariableSizedObject() { + int CreateVariableSizedObject(unsigned Alignment) { HasVarSizedObjects = true; - Objects.push_back(StackObject(0, 1, 0, false, false)); + Objects.push_back(StackObject(0, Alignment, 0, false, false, true)); + MaxAlignment = std::max(MaxAlignment, Alignment); return (int)Objects.size()-NumFixedObjects-1; } @@ -431,7 +522,7 @@ public: /// setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's /// callee saved information. - void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) { + void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) { CSInfo = CSI; } @@ -452,7 +543,7 @@ public: BitVector getPristineRegs(const MachineBasicBlock *MBB) const; /// print - Used by the MachineFunction printer to print information about - /// stack objects. Implemented in MachineFunction.cpp + /// stack objects. Implemented in MachineFunction.cpp /// void print(const MachineFunction &MF, raw_ostream &OS) const; diff --git a/contrib/llvm/include/llvm/CodeGen/MachineFunction.h b/contrib/llvm/include/llvm/CodeGen/MachineFunction.h index 409d13ee..5bb453d 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineFunction.h @@ -266,7 +266,7 @@ public: /// verify - Run the current MachineFunction through the machine code /// verifier, useful for debugger use. - void verify(Pass *p=NULL, bool allowDoubleDefs=false) const; + void verify(Pass *p=NULL) const; // Provide accessors for the MachineBasicBlock list... typedef BasicBlockListType::iterator iterator; diff --git a/contrib/llvm/include/llvm/CodeGen/MachineFunctionPass.h b/contrib/llvm/include/llvm/CodeGen/MachineFunctionPass.h index 685e868..b7bf0a3 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineFunctionPass.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineFunctionPass.h @@ -31,8 +31,7 @@ class MachineFunction; /// override runOnMachineFunction. class MachineFunctionPass : public FunctionPass { protected: - explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} - explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} + explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {} /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. diff --git a/contrib/llvm/include/llvm/CodeGen/MachineInstr.h b/contrib/llvm/include/llvm/CodeGen/MachineInstr.h index e67b2dd..f843196 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineInstr.h @@ -201,12 +201,14 @@ public: /// isLabel - Returns true if the MachineInstr represents a label. /// bool isLabel() const { - return getOpcode() == TargetOpcode::DBG_LABEL || + return getOpcode() == TargetOpcode::PROLOG_LABEL || getOpcode() == TargetOpcode::EH_LABEL || getOpcode() == TargetOpcode::GC_LABEL; } - bool isDebugLabel() const { return getOpcode() == TargetOpcode::DBG_LABEL; } + bool isPrologLabel() const { + return getOpcode() == TargetOpcode::PROLOG_LABEL; + } bool isEHLabel() const { return getOpcode() == TargetOpcode::EH_LABEL; } bool isGCLabel() const { return getOpcode() == TargetOpcode::GC_LABEL; } bool isDebugValue() const { return getOpcode() == TargetOpcode::DBG_VALUE; } diff --git a/contrib/llvm/include/llvm/CodeGen/MachineLoopInfo.h b/contrib/llvm/include/llvm/CodeGen/MachineLoopInfo.h index 3b3e31e..9760eba 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineLoopInfo.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineLoopInfo.h @@ -67,7 +67,7 @@ class MachineLoopInfo : public MachineFunctionPass { public: static char ID; // Pass identification, replacement for typeid - MachineLoopInfo() : MachineFunctionPass(&ID) {} + MachineLoopInfo() : MachineFunctionPass(ID) {} LoopInfoBase<MachineBasicBlock, MachineLoop>& getBase() { return LI; } diff --git a/contrib/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/contrib/llvm/include/llvm/CodeGen/MachineModuleInfo.h index 50e38b4..0e719c8 100644 --- a/contrib/llvm/include/llvm/CodeGen/MachineModuleInfo.h +++ b/contrib/llvm/include/llvm/CodeGen/MachineModuleInfo.h @@ -344,7 +344,7 @@ public: VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Loc))); } - VariableDbgInfoMapTy &getVariableDbgInfo(); + VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; } }; // End class MachineModuleInfo diff --git a/contrib/llvm/include/llvm/CodeGen/Passes.h b/contrib/llvm/include/llvm/CodeGen/Passes.h index 7445ec7..4762a39 100644 --- a/contrib/llvm/include/llvm/CodeGen/Passes.h +++ b/contrib/llvm/include/llvm/CodeGen/Passes.h @@ -30,55 +30,55 @@ namespace llvm { /// createUnreachableBlockEliminationPass - The LLVM code generator does not /// work well with unreachable basic blocks (what live ranges make sense for a /// block that cannot be reached?). As such, a code generator should either - /// not instruction select unreachable blocks, or it can run this pass as it's + /// not instruction select unreachable blocks, or run this pass as its /// last LLVM modifying pass to clean up blocks that are not reachable from /// the entry block. FunctionPass *createUnreachableBlockEliminationPass(); /// MachineFunctionPrinter pass - This pass prints out the machine function to - /// the given stream, as a debugging tool. + /// the given stream as a debugging tool. MachineFunctionPass * createMachineFunctionPrinterPass(raw_ostream &OS, const std::string &Banner =""); /// MachineLoopInfo pass - This pass is a loop analysis pass. - /// - extern const PassInfo *const MachineLoopInfoID; + /// + extern char &MachineLoopInfoID; /// MachineDominators pass - This pass is a machine dominators analysis pass. - /// - extern const PassInfo *const MachineDominatorsID; + /// + extern char &MachineDominatorsID; /// PHIElimination pass - This pass eliminates machine instruction PHI nodes /// by inserting copy instructions. This destroys SSA information, but is the /// desired input for some register allocators. This pass is "required" by /// these register allocator like this: AU.addRequiredID(PHIEliminationID); /// - extern const PassInfo *const PHIEliminationID; - + extern char &PHIEliminationID; + /// StrongPHIElimination pass - This pass eliminates machine instruction PHI /// nodes by inserting copy instructions. This destroys SSA information, but /// is the desired input for some register allocators. This pass is /// "required" by these register allocator like this: /// AU.addRequiredID(PHIEliminationID); /// This pass is still in development - extern const PassInfo *const StrongPHIEliminationID; + extern char &StrongPHIEliminationID; - extern const PassInfo *const PreAllocSplittingID; + extern char &PreAllocSplittingID; /// SimpleRegisterCoalescing pass. Aggressively coalesces every register /// copy it can. /// - extern const PassInfo *const SimpleRegisterCoalescingID; + extern char &SimpleRegisterCoalescingID; /// TwoAddressInstruction pass - This pass reduces two-address instructions to /// use two operands. This destroys SSA information but it is desired by /// register allocators. - extern const PassInfo *const TwoAddressInstructionPassID; + extern char &TwoAddressInstructionPassID; /// UnreachableMachineBlockElimination pass - This pass removes unreachable /// machine basic blocks. - extern const PassInfo *const UnreachableMachineBlockElimID; + extern char &UnreachableMachineBlockElimID; /// DeadMachineInstructionElim pass - This pass removes dead machine /// instructions. @@ -114,7 +114,7 @@ namespace llvm { /// and eliminates abstract frame references. /// FunctionPass *createPrologEpilogCodeInserter(); - + /// LowerSubregs Pass - This pass lowers subregs to register-register copies /// which yields suboptimal, but correct code if the register allocator /// cannot coalesce all subreg operations during allocation. @@ -145,36 +145,36 @@ namespace llvm { /// IntrinsicLowering Pass - Performs target-independent LLVM IR /// transformations for highly portable strategies. FunctionPass *createGCLoweringPass(); - + /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in /// machine code. Must be added very late during code generation, just prior /// to output, and importantly after all CFG transformations (such as branch /// folding). FunctionPass *createGCMachineCodeAnalysisPass(); - + /// Deleter Pass - Releases GC metadata. - /// + /// FunctionPass *createGCInfoDeleter(); - + /// Creates a pass to print GC metadata. - /// + /// FunctionPass *createGCInfoPrinter(raw_ostream &OS); - + /// createMachineCSEPass - This pass performs global CSE on machine /// instructions. FunctionPass *createMachineCSEPass(); /// createMachineLICMPass - This pass performs LICM on machine instructions. - /// + /// FunctionPass *createMachineLICMPass(bool PreRegAlloc = true); /// createMachineSinkingPass - This pass performs sinking on machine /// instructions. FunctionPass *createMachineSinkingPass(); - /// createOptimizeExtsPass - This pass performs sign / zero extension - /// optimization by increasing uses of extended values. - FunctionPass *createOptimizeExtsPass(); + /// createPeepholeOptimizerPass - This pass performs peephole optimizations - + /// like extension and comparison eliminations. + FunctionPass *createPeepholeOptimizerPass(); /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs /// to take advantage of opportunities created during DAG legalization. @@ -188,19 +188,23 @@ namespace llvm { /// createMachineVerifierPass - This pass verifies cenerated machine code /// instructions for correctness. - /// - /// @param allowDoubleDefs ignore double definitions of - /// registers. Useful before LiveVariables has run. - FunctionPass *createMachineVerifierPass(bool allowDoubleDefs); + FunctionPass *createMachineVerifierPass(); /// createDwarfEHPass - This pass mulches exception handling code into a form /// adapted to code generation. Required if using dwarf exception handling. - FunctionPass *createDwarfEHPass(const TargetMachine *tm, bool fast); + FunctionPass *createDwarfEHPass(const TargetMachine *tm); /// createSjLjEHPass - This pass adapts exception handling code to use /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. FunctionPass *createSjLjEHPass(const TargetLowering *tli); + /// createLocalStackSlotAllocationPass - This pass assigns local frame + /// indices to stack slots relative to one another and allocates + /// base registers to access them when it is estimated by the target to + /// be out of range of normal frame pointer or stack pointer index + /// addressing. + FunctionPass *createLocalStackSlotAllocationPass(); + } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h b/contrib/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h index 30477b9..1d743c1 100644 --- a/contrib/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h +++ b/contrib/llvm/include/llvm/CodeGen/ProcessImplicitDefs.h @@ -31,7 +31,7 @@ namespace llvm { public: static char ID; - ProcessImplicitDefs() : MachineFunctionPass(&ID) {} + ProcessImplicitDefs() : MachineFunctionPass(ID) {} virtual void getAnalysisUsage(AnalysisUsage &au) const; diff --git a/contrib/llvm/include/llvm/CodeGen/SchedulerRegistry.h b/contrib/llvm/include/llvm/CodeGen/SchedulerRegistry.h index 14c33e2..96573dd 100644 --- a/contrib/llvm/include/llvm/CodeGen/SchedulerRegistry.h +++ b/contrib/llvm/include/llvm/CodeGen/SchedulerRegistry.h @@ -78,12 +78,19 @@ ScheduleDAGSDNodes *createTDRRListDAGScheduler(SelectionDAGISel *IS, ScheduleDAGSDNodes *createSourceListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level OptLevel); -/// createHybridListDAGScheduler - This creates a bottom up hybrid register -/// usage reduction list scheduler that make use of latency information to -/// avoid stalls for long latency instructions. +/// createHybridListDAGScheduler - This creates a bottom up register pressure +/// aware list scheduler that make use of latency information to avoid stalls +/// for long latency instructions in low register pressure mode. In high +/// register pressure mode it schedules to reduce register pressure. ScheduleDAGSDNodes *createHybridListDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level); +/// createILPListDAGScheduler - This creates a bottom up register pressure +/// aware list scheduler that tries to increase instruction level parallelism +/// in low register pressure mode. In high register pressure mode it schedules +/// to reduce register pressure. +ScheduleDAGSDNodes *createILPListDAGScheduler(SelectionDAGISel *IS, + CodeGenOpt::Level); /// createTDListDAGScheduler - This creates a top-down list scheduler with /// a hazard recognizer. ScheduleDAGSDNodes *createTDListDAGScheduler(SelectionDAGISel *IS, diff --git a/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h b/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h index de49d18..7723fa0 100644 --- a/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -977,10 +977,6 @@ public: /// been verified as a debug information descriptor. bool isVerifiedDebugInfoDesc(SDValue Op) const; - /// getShuffleScalarElt - Returns the scalar element that will make up the ith - /// element of the result of the vector shuffle. - SDValue getShuffleScalarElt(const ShuffleVectorSDNode *N, unsigned Idx); - /// UnrollVectorOp - Utility function used by legalize and lowering to /// "unroll" a vector operation by splitting out the scalars and operating /// on each element individually. If the ResNE is 0, fully unroll the vector diff --git a/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h b/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h index f1f047b..88044c7 100644 --- a/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/contrib/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -128,7 +128,8 @@ namespace llvm { friend class SlotIndexes; friend struct DenseMapInfo<SlotIndex>; - private: + enum Slot { LOAD, USE, DEF, STORE, NUM }; + static const unsigned PHI_BIT = 1 << 2; PointerIntPair<IndexListEntry*, 3, unsigned> lie; @@ -146,6 +147,11 @@ namespace llvm { return entry().getIndex() | getSlot(); } + /// Returns the slot for this SlotIndex. + Slot getSlot() const { + return static_cast<Slot>(lie.getInt() & ~PHI_BIT); + } + static inline unsigned getHashValue(const SlotIndex &v) { IndexListEntry *ptrVal = &v.entry(); return (unsigned((intptr_t)ptrVal) >> 4) ^ @@ -153,11 +159,6 @@ namespace llvm { } public: - - // FIXME: Ugh. This is public because LiveIntervalAnalysis is still using it - // for some spill weight stuff. Fix that, then make this private. - enum Slot { LOAD, USE, DEF, STORE, NUM }; - static inline SlotIndex getEmptyKey() { return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0); } @@ -235,16 +236,31 @@ namespace llvm { return other.getIndex() - getIndex(); } - /// Returns the slot for this SlotIndex. - Slot getSlot() const { - return static_cast<Slot>(lie.getInt() & ~PHI_BIT); - } - /// Returns the state of the PHI bit. bool isPHI() const { return lie.getInt() & PHI_BIT; } + /// isLoad - Return true if this is a LOAD slot. + bool isLoad() const { + return getSlot() == LOAD; + } + + /// isDef - Return true if this is a DEF slot. + bool isDef() const { + return getSlot() == DEF; + } + + /// isUse - Return true if this is a USE slot. + bool isUse() const { + return getSlot() == USE; + } + + /// isStore - Return true if this is a STORE slot. + bool isStore() const { + return getSlot() == STORE; + } + /// Returns the base index for associated with this index. The base index /// is the one associated with the LOAD slot for the instruction pointed to /// by this index. @@ -475,7 +491,7 @@ namespace llvm { public: static char ID; - SlotIndexes() : MachineFunctionPass(&ID), indexListHead(0) {} + SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) {} virtual void getAnalysisUsage(AnalysisUsage &au) const; virtual void releaseMemory(); @@ -494,6 +510,11 @@ namespace llvm { return SlotIndex(front(), 0); } + /// Returns the base index of the last slot in this analysis. + SlotIndex getLastIndex() { + return SlotIndex(back(), 0); + } + /// Returns the invalid index marker for this analysis. SlotIndex getInvalidIndex() { return getZeroIndex(); diff --git a/contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index 3aaab88..d8f0373 100644 --- a/contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/contrib/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -105,7 +105,6 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { const MCSection *UStringSection; const MCSection *TextCoalSection; const MCSection *ConstTextCoalSection; - const MCSection *ConstDataCoalSection; const MCSection *ConstDataSection; const MCSection *DataCoalSection; const MCSection *DataCommonSection; diff --git a/contrib/llvm/include/llvm/CodeGen/ValueTypes.h b/contrib/llvm/include/llvm/CodeGen/ValueTypes.h index 6e2a102..51f324c 100644 --- a/contrib/llvm/include/llvm/CodeGen/ValueTypes.h +++ b/contrib/llvm/include/llvm/CodeGen/ValueTypes.h @@ -159,14 +159,12 @@ namespace llvm { /// getPow2VectorType - Widens the length of the given vector EVT up to /// the nearest power of 2 and returns that type. MVT getPow2VectorType() const { - if (!isPow2VectorType()) { - unsigned NElts = getVectorNumElements(); - unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts); - return MVT::getVectorVT(getVectorElementType(), Pow2NElts); - } - else { + if (isPow2VectorType()) return *this; - } + + unsigned NElts = getVectorNumElements(); + unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts); + return MVT::getVectorVT(getVectorElementType(), Pow2NElts); } /// getScalarType - If this is a vector type, return the element type, @@ -350,17 +348,6 @@ namespace llvm { } return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); } - - static MVT getIntVectorWithNumElements(unsigned NumElts) { - switch (NumElts) { - default: return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); - case 1: return MVT::v1i64; - case 2: return MVT::v2i32; - case 4: return MVT::v4i16; - case 8: return MVT::v8i8; - case 16: return MVT::v16i8; - } - } }; struct EVT { // EVT = Extended Value Type @@ -374,22 +361,16 @@ namespace llvm { EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(0) { } EVT(MVT S) : V(S), LLVMTy(0) {} - bool operator==(const EVT VT) const { - if (V.SimpleTy == VT.V.SimpleTy) { - if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) - return LLVMTy == VT.LLVMTy; + bool operator==(EVT VT) const { + return !(*this != VT); + } + bool operator!=(EVT VT) const { + if (V.SimpleTy != VT.V.SimpleTy) return true; - } + if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) + return LLVMTy != VT.LLVMTy; return false; } - bool operator!=(const EVT VT) const { - if (V.SimpleTy == VT.V.SimpleTy) { - if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) - return LLVMTy != VT.LLVMTy; - return false; - } - return true; - } /// getFloatingPointVT - Returns the EVT that represents a floating point /// type with the given number of bits. There are two floating point types @@ -402,30 +383,32 @@ namespace llvm { /// number of bits. static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth) { MVT M = MVT::getIntegerVT(BitWidth); - if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) - return getExtendedIntegerVT(Context, BitWidth); - else + if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE) return M; + return getExtendedIntegerVT(Context, BitWidth); } /// getVectorVT - Returns the EVT that represents a vector NumElements in /// length, where each element is of type VT. static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements) { MVT M = MVT::getVectorVT(VT.V, NumElements); - if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) - return getExtendedVectorVT(Context, VT, NumElements); - else + if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE) return M; + return getExtendedVectorVT(Context, VT, NumElements); } /// getIntVectorWithNumElements - Return any integer vector type that has /// the specified number of elements. static EVT getIntVectorWithNumElements(LLVMContext &C, unsigned NumElts) { - MVT M = MVT::getIntVectorWithNumElements(NumElts); - if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) - return getVectorVT(C, MVT::i8, NumElts); - else - return M; + switch (NumElts) { + default: return getVectorVT(C, MVT::i8, NumElts); + case 1: return MVT::v1i64; + case 2: return MVT::v2i32; + case 4: return MVT::v4i16; + case 8: return MVT::v8i8; + case 16: return MVT::v16i8; + } + return MVT::INVALID_SIMPLE_VALUE_TYPE; } /// isSimple - Test if the given EVT is simple (as opposed to being @@ -457,26 +440,27 @@ namespace llvm { /// is64BitVector - Return true if this is a 64-bit vector type. bool is64BitVector() const { - return isSimple() ? - (V==MVT::v8i8 || V==MVT::v4i16 || V==MVT::v2i32 || - V==MVT::v1i64 || V==MVT::v2f32) : - isExtended64BitVector(); + if (!isSimple()) + return isExtended64BitVector(); + + return (V == MVT::v8i8 || V==MVT::v4i16 || V==MVT::v2i32 || + V == MVT::v1i64 || V==MVT::v2f32); } /// is128BitVector - Return true if this is a 128-bit vector type. bool is128BitVector() const { - return isSimple() ? - (V==MVT::v16i8 || V==MVT::v8i16 || V==MVT::v4i32 || - V==MVT::v2i64 || V==MVT::v4f32 || V==MVT::v2f64) : - isExtended128BitVector(); + if (!isSimple()) + return isExtended128BitVector(); + return (V==MVT::v16i8 || V==MVT::v8i16 || V==MVT::v4i32 || + V==MVT::v2i64 || V==MVT::v4f32 || V==MVT::v2f64); } /// is256BitVector - Return true if this is a 256-bit vector type. inline bool is256BitVector() const { - return isSimple() - ? (V==MVT::v8f32 || V==MVT::v4f64 || V==MVT::v32i8 || - V==MVT::v16i16 || V==MVT::v8i32 || V==MVT::v4i64) - : isExtended256BitVector(); + if (!isSimple()) + return isExtended256BitVector(); + return (V == MVT::v8f32 || V == MVT::v4f64 || V == MVT::v32i8 || + V == MVT::v16i16 || V == MVT::v8i32 || V == MVT::v4i64); } /// is512BitVector - Return true if this is a 512-bit vector type. @@ -550,8 +534,7 @@ namespace llvm { assert(isVector() && "Invalid vector type!"); if (isSimple()) return V.getVectorElementType(); - else - return getExtendedVectorElementType(); + return getExtendedVectorElementType(); } /// getVectorNumElements - Given a vector type, return the number of @@ -560,16 +543,14 @@ namespace llvm { assert(isVector() && "Invalid vector type!"); if (isSimple()) return V.getVectorNumElements(); - else - return getExtendedVectorNumElements(); + return getExtendedVectorNumElements(); } /// getSizeInBits - Return the size of the specified value type in bits. unsigned getSizeInBits() const { if (isSimple()) return V.getSizeInBits(); - else - return getExtendedSizeInBits(); + return getExtendedSizeInBits(); } /// getStoreSize - Return the number of bytes overwritten by a store @@ -592,8 +573,7 @@ namespace llvm { unsigned BitWidth = getSizeInBits(); if (BitWidth <= 8) return EVT(MVT::i8); - else - return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth)); + return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth)); } /// getHalfSizedIntegerVT - Finds the smallest simple value type that is @@ -604,12 +584,10 @@ namespace llvm { assert(isInteger() && !isVector() && "Invalid integer type!"); unsigned EVTSize = getSizeInBits(); for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE; - IntVT <= MVT::LAST_INTEGER_VALUETYPE; - ++IntVT) { + IntVT <= MVT::LAST_INTEGER_VALUETYPE; ++IntVT) { EVT HalfVT = EVT((MVT::SimpleValueType)IntVT); - if(HalfVT.getSizeInBits() * 2 >= EVTSize) { + if (HalfVT.getSizeInBits() * 2 >= EVTSize) return HalfVT; - } } return getIntegerVT(Context, (EVTSize + 1) / 2); } diff --git a/contrib/llvm/include/llvm/CompilerDriver/Action.h b/contrib/llvm/include/llvm/CompilerDriver/Action.h index 7014139..f2b7965 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/Action.h +++ b/contrib/llvm/include/llvm/CompilerDriver/Action.h @@ -34,12 +34,16 @@ namespace llvmc { std::string OutFile_; public: - Action (const std::string& C, const StrVector& A, - bool S, const std::string& O) - : Command_(C), Args_(A), StopCompilation_(S), OutFile_(O) - {} - - /// Execute - Executes the represented action. + void Construct (const std::string& C, const StrVector& A, + bool S, const std::string& O) { + Command_ = C; + Args_ = A; + StopCompilation_ = S; + OutFile_ = O; + } + bool IsConstructed () { return (Command_.size() != 0);} + + /// Execute - Executes the command. Returns -1 on error. int Execute () const; bool StopCompilation () const { return StopCompilation_; } const std::string& OutFile() { return OutFile_; } diff --git a/contrib/llvm/include/llvm/CompilerDriver/AutoGenerated.h b/contrib/llvm/include/llvm/CompilerDriver/AutoGenerated.h new file mode 100644 index 0000000..7b926c6 --- /dev/null +++ b/contrib/llvm/include/llvm/CompilerDriver/AutoGenerated.h @@ -0,0 +1,40 @@ +//===--- AutoGenerated.h - The LLVM Compiler Driver -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open +// Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Interface to the autogenerated driver code. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H +#define LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H + +namespace llvmc { + class LanguageMap; + class CompilationGraph; + + namespace autogenerated { + + int PreprocessOptions(); + int PopulateLanguageMap(LanguageMap& langMap); + int PopulateCompilationGraph(CompilationGraph& graph); + + inline int RunInitialization (LanguageMap& M, CompilationGraph& G) { + if (int ret = PreprocessOptions()) + return ret; + if (int ret = PopulateLanguageMap(M)) + return ret; + if (int ret = PopulateCompilationGraph(G)) + return ret; + + return 0; + } + } +} + +#endif // LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/BuiltinOptions.h b/contrib/llvm/include/llvm/CompilerDriver/BuiltinOptions.h index 0c1bbe2..7b9c15c 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/BuiltinOptions.h +++ b/contrib/llvm/include/llvm/CompilerDriver/BuiltinOptions.h @@ -18,6 +18,8 @@ #include <string> +namespace llvmc { + namespace SaveTempsEnum { enum Values { Cwd, Obj, Unset }; } extern llvm::cl::list<std::string> InputFilenames; @@ -32,4 +34,6 @@ extern llvm::cl::opt<bool> ViewGraph; extern llvm::cl::opt<bool> WriteGraph; extern llvm::cl::opt<SaveTempsEnum::Values> SaveTemps; +} // End namespace llvmc. + #endif // LLVM_INCLUDE_COMPILER_DRIVER_BUILTIN_OPTIONS_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/Common.td b/contrib/llvm/include/llvm/CompilerDriver/Common.td index 31a627d..84e8783 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/Common.td +++ b/contrib/llvm/include/llvm/CompilerDriver/Common.td @@ -32,6 +32,7 @@ def actions; def alias_option; def switch_option; +def switch_list_option; def parameter_option; def parameter_list_option; def prefix_option; @@ -39,7 +40,6 @@ def prefix_list_option; // Possible option properties. -def extern; def help; def hidden; def init; @@ -93,17 +93,8 @@ def error; def set_option; def unset_option; -// Increase/decrease the edge weight. +// Increase the edge weight. def inc_weight; -def dec_weight; - -// Empty DAG marker. -def empty_dag_marker; - -// Used to specify plugin priority. -class PluginPriority<int p> { - int priority = p; -} // Option list - a single place to specify options. class OptionList<list<dag> l> { @@ -117,31 +108,17 @@ class OptionPreprocessor<dag d> { // Map from suffixes to language names -class LangToSuffixes<string str, list<string> lst> { - string lang = str; - list<string> suffixes = lst; -} +def lang_to_suffixes; -class LanguageMap<list<LangToSuffixes> lst> { - list<LangToSuffixes> map = lst; +class LanguageMap<list<dag> l> { + list<dag> map = l; } // Compilation graph -class EdgeBase<string t1, string t2, dag d> { - string a = t1; - string b = t2; - dag weight = d; -} - -class Edge<string t1, string t2> : EdgeBase<t1, t2, (empty_dag_marker)>; - -// Edge and SimpleEdge are synonyms. -class SimpleEdge<string t1, string t2> : EdgeBase<t1, t2, (empty_dag_marker)>; - -// Optionally enabled edge. -class OptionalEdge<string t1, string t2, dag props> : EdgeBase<t1, t2, props>; +def edge; +def optional_edge; -class CompilationGraph<list<EdgeBase> lst> { - list<EdgeBase> edges = lst; +class CompilationGraph<list<dag> l> { + list<dag> edges = l; } diff --git a/contrib/llvm/include/llvm/CompilerDriver/CompilationGraph.h b/contrib/llvm/include/llvm/CompilerDriver/CompilationGraph.h index ba6ff47..619c904 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/CompilationGraph.h +++ b/contrib/llvm/include/llvm/CompilerDriver/CompilationGraph.h @@ -36,7 +36,7 @@ namespace llvmc { public: /// GetLanguage - Find the language name corresponding to a given file. - const std::string& GetLanguage(const llvm::sys::Path&) const; + const std::string* GetLanguage(const llvm::sys::Path&) const; }; /// Edge - Represents an edge of the compilation graph. @@ -46,7 +46,7 @@ namespace llvmc { virtual ~Edge() {} const std::string& ToolName() const { return ToolName_; } - virtual unsigned Weight(const InputLanguagesSet& InLangs) const = 0; + virtual int Weight(const InputLanguagesSet& InLangs) const = 0; private: std::string ToolName_; }; @@ -55,7 +55,7 @@ namespace llvmc { class SimpleEdge : public Edge { public: SimpleEdge(const std::string& T) : Edge(T) {} - unsigned Weight(const InputLanguagesSet&) const { return 1; } + int Weight(const InputLanguagesSet&) const { return 1; } }; /// Node - A node (vertex) of the compilation graph. @@ -132,32 +132,32 @@ namespace llvmc { void insertNode(Tool* T); /// insertEdge - Insert a new edge into the graph. Takes ownership - /// of the Edge object. - void insertEdge(const std::string& A, Edge* E); + /// of the Edge object. Returns non-zero value on error. + int insertEdge(const std::string& A, Edge* E); - /// Build - Build target(s) from the input file set. Command-line - /// options are passed implicitly as global variables. + /// Build - Build target(s) from the input file set. Command-line options + /// are passed implicitly as global variables. Returns non-zero value on + /// error (usually the failed program's exit code). int Build(llvm::sys::Path const& TempDir, const LanguageMap& LangMap); - /// Check - Check the compilation graph for common errors like - /// cycles, input/output language mismatch and multiple default - /// edges. Prints error messages and in case it finds any errors. + /// Check - Check the compilation graph for common errors like cycles, + /// input/output language mismatch and multiple default edges. Prints error + /// messages and in case it finds any errors. int Check(); - /// getNode - Return a reference to the node correponding to the - /// given tool name. Throws std::runtime_error. - Node& getNode(const std::string& ToolName); - const Node& getNode(const std::string& ToolName) const; + /// getNode - Return a reference to the node corresponding to the given tool + /// name. Returns 0 on error. + Node* getNode(const std::string& ToolName); + const Node* getNode(const std::string& ToolName) const; - /// viewGraph - This function is meant for use from the debugger. - /// You can just say 'call G->viewGraph()' and a ghostview window - /// should pop up from the program, displaying the compilation - /// graph. This depends on there being a 'dot' and 'gv' program - /// in your path. + /// viewGraph - This function is meant for use from the debugger. You can + /// just say 'call G->viewGraph()' and a ghostview window should pop up from + /// the program, displaying the compilation graph. This depends on there + /// being a 'dot' and 'gv' program in your path. void viewGraph(); /// writeGraph - Write Graphviz .dot source file to the current direcotry. - void writeGraph(const std::string& OutputFilename); + int writeGraph(const std::string& OutputFilename); // GraphTraits support. friend NodesIterator GraphBegin(CompilationGraph*); @@ -167,16 +167,15 @@ namespace llvmc { // Helper functions. /// getToolsVector - Return a reference to the list of tool names - /// corresponding to the given language name. Throws - /// std::runtime_error. - const tools_vector_type& getToolsVector(const std::string& LangName) const; + /// corresponding to the given language name. Returns 0 on error. + const tools_vector_type* getToolsVector(const std::string& LangName) const; - /// PassThroughGraph - Pass the input file through the toolchain - /// starting at StartNode. - void PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode, - const InputLanguagesSet& InLangs, - const llvm::sys::Path& TempDir, - const LanguageMap& LangMap) const; + /// PassThroughGraph - Pass the input file through the toolchain starting at + /// StartNode. + int PassThroughGraph (const llvm::sys::Path& In, const Node* StartNode, + const InputLanguagesSet& InLangs, + const llvm::sys::Path& TempDir, + const LanguageMap& LangMap) const; /// FindToolChain - Find head of the toolchain corresponding to /// the given file. @@ -185,26 +184,32 @@ namespace llvmc { InputLanguagesSet& InLangs, const LanguageMap& LangMap) const; - /// BuildInitial - Traverse the initial parts of the toolchains. - void BuildInitial(InputLanguagesSet& InLangs, - const llvm::sys::Path& TempDir, - const LanguageMap& LangMap); + /// BuildInitial - Traverse the initial parts of the toolchains. Returns + /// non-zero value on error. + int BuildInitial(InputLanguagesSet& InLangs, + const llvm::sys::Path& TempDir, + const LanguageMap& LangMap); - /// TopologicalSort - Sort the nodes in topological order. - void TopologicalSort(std::vector<const Node*>& Out); - /// TopologicalSortFilterJoinNodes - Call TopologicalSort and - /// filter the resulting list to include only Join nodes. - void TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out); + /// TopologicalSort - Sort the nodes in topological order. Returns non-zero + /// value on error. + int TopologicalSort(std::vector<const Node*>& Out); + /// TopologicalSortFilterJoinNodes - Call TopologicalSort and filter the + /// resulting list to include only Join nodes. Returns non-zero value on + /// error. + int TopologicalSortFilterJoinNodes(std::vector<const Node*>& Out); // Functions used to implement Check(). - /// CheckLanguageNames - Check that output/input language names - /// match for all nodes. + /// CheckLanguageNames - Check that output/input language names match for + /// all nodes. Returns non-zero value on error (number of errors + /// encountered). int CheckLanguageNames() const; - /// CheckMultipleDefaultEdges - check that there are no multiple - /// default default edges. + /// CheckMultipleDefaultEdges - check that there are no multiple default + /// default edges. Returns non-zero value on error (number of errors + /// encountered). int CheckMultipleDefaultEdges() const; - /// CheckCycles - Check that there are no cycles in the graph. + /// CheckCycles - Check that there are no cycles in the graph. Returns + /// non-zero value on error (number of errors encountered). int CheckCycles(); }; @@ -270,7 +275,7 @@ namespace llvmc { } inline pointer operator*() const { - return &OwningGraph->getNode((*EdgeIter)->ToolName()); + return OwningGraph->getNode((*EdgeIter)->ToolName()); } inline pointer operator->() const { return this->operator*(); @@ -301,7 +306,7 @@ namespace llvm { typedef llvmc::NodeChildIterator ChildIteratorType; static NodeType* getEntryNode(GraphType* G) { - return &G->getNode("root"); + return G->getNode("root"); } static ChildIteratorType child_begin(NodeType* N) { diff --git a/contrib/llvm/include/llvm/CompilerDriver/Error.h b/contrib/llvm/include/llvm/CompilerDriver/Error.h index fa678cf..013094e 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/Error.h +++ b/contrib/llvm/include/llvm/CompilerDriver/Error.h @@ -7,28 +7,22 @@ // //===----------------------------------------------------------------------===// // -// Exception classes for llvmc. +// Error handling. // //===----------------------------------------------------------------------===// #ifndef LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H #define LLVM_INCLUDE_COMPILER_DRIVER_ERROR_H -#include <stdexcept> +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/raw_ostream.h" namespace llvmc { - /// error_code - This gets thrown during the compilation process if a tool - /// invocation returns a non-zero exit code. - class error_code: public std::runtime_error { - int Code_; - public: - error_code (int c) - : std::runtime_error("Tool returned error code"), Code_(c) - {} - - int code() const { return Code_; } - }; + inline void PrintError(llvm::StringRef Err) { + extern const char* ProgramName; + llvm::errs() << ProgramName << ": " << Err << '\n'; + } } diff --git a/contrib/llvm/include/llvm/CompilerDriver/ForceLinkage.h b/contrib/llvm/include/llvm/CompilerDriver/ForceLinkage.h deleted file mode 100644 index 830c04e..0000000 --- a/contrib/llvm/include/llvm/CompilerDriver/ForceLinkage.h +++ /dev/null @@ -1,122 +0,0 @@ -//===--- ForceLinkage.h - The LLVM Compiler Driver --------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// A bit of preprocessor magic to force references to static libraries. Needed -// because plugin initialization is done via static variables. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H -#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H - -#include "llvm/CompilerDriver/ForceLinkageMacros.h" - -namespace llvmc { - -// Declare all ForceLinkage$(PluginName) functions. - -#ifdef LLVMC_BUILTIN_PLUGIN_1 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_1); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_2 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_2); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_3 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_3); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_4 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_4); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_5 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_5); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_6 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_6); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_7 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_7); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_8 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_8); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_9 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_9); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_10 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_10); -#endif - -namespace force_linkage { - - struct LinkageForcer { - - LinkageForcer() { - -// Call all ForceLinkage$(PluginName) functions. -#ifdef LLVMC_BUILTIN_PLUGIN_1 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_1); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_2 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_2); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_3 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_3); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_4 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_4); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_5 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_5); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_6 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_6); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_7 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_7); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_8 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_8); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_9 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_9); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_10 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_10); -#endif - - } - }; -} // End namespace force_linkage. - -// The only externally used bit. -void ForceLinkage() { - force_linkage::LinkageForcer dummy; -} - -} // End namespace llvmc. - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/ForceLinkageMacros.h b/contrib/llvm/include/llvm/CompilerDriver/ForceLinkageMacros.h deleted file mode 100644 index 8862b00..0000000 --- a/contrib/llvm/include/llvm/CompilerDriver/ForceLinkageMacros.h +++ /dev/null @@ -1,29 +0,0 @@ -//===--- ForceLinkageMacros.h - The LLVM Compiler Driver --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Preprocessor magic that forces references to static libraries - common -// macros used by both driver and plugins. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H -#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H - -#define LLVMC_FORCE_LINKAGE_PREFIX(PluginName) ForceLinkage ## PluginName - -#define LLVMC_FORCE_LINKAGE_FUN(PluginName) \ - LLVMC_FORCE_LINKAGE_PREFIX(PluginName) - -#define LLVMC_FORCE_LINKAGE_DECL(PluginName) \ - void LLVMC_FORCE_LINKAGE_FUN(PluginName) () - -#define LLVMC_FORCE_LINKAGE_CALL(PluginName) \ - LLVMC_FORCE_LINKAGE_FUN(PluginName) () - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/Main.h b/contrib/llvm/include/llvm/CompilerDriver/Main.h new file mode 100644 index 0000000..d136a5d --- /dev/null +++ b/contrib/llvm/include/llvm/CompilerDriver/Main.h @@ -0,0 +1,21 @@ +//===--- Main.h - The LLVM Compiler Driver ----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open +// Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Entry point for the driver executable. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H +#define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H + +namespace llvmc { + int Main(int argc, char** argv); +} + +#endif // LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/Main.inc b/contrib/llvm/include/llvm/CompilerDriver/Main.inc index 71bb8cb..4164043 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/Main.inc +++ b/contrib/llvm/include/llvm/CompilerDriver/Main.inc @@ -7,26 +7,16 @@ // //===----------------------------------------------------------------------===// // -// This tool provides a single point of access to the LLVM -// compilation tools. It has many options. To discover the options -// supported please refer to the tools' manual page or run the tool -// with the -help option. -// -// This file provides the default entry point for the driver executable. +// Default main() for the driver executable. // //===----------------------------------------------------------------------===// #ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC #define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC -#include "llvm/CompilerDriver/ForceLinkage.h" - -namespace llvmc { - int Main(int argc, char** argv); -} +#include "llvm/CompilerDriver/Main.h" int main(int argc, char** argv) { - llvmc::ForceLinkage(); return llvmc::Main(argc, argv); } diff --git a/contrib/llvm/include/llvm/CompilerDriver/Plugin.h b/contrib/llvm/include/llvm/CompilerDriver/Plugin.h deleted file mode 100644 index e9a2048..0000000 --- a/contrib/llvm/include/llvm/CompilerDriver/Plugin.h +++ /dev/null @@ -1,81 +0,0 @@ -//===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Plugin support for llvmc. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H -#define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H - -#include "llvm/Support/Registry.h" - -namespace llvmc { - - class LanguageMap; - class CompilationGraph; - - /// BasePlugin - An abstract base class for all LLVMC plugins. - struct BasePlugin { - - /// Priority - Plugin priority, useful for handling dependencies - /// between plugins. Plugins with lower priorities are loaded - /// 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; - - /// PopulateCompilationGraph - The auto-generated function that - /// populates the compilation graph with nodes and edges. - virtual void PopulateCompilationGraph(CompilationGraph&) const = 0; - - /// Needed to avoid a compiler warning. - virtual ~BasePlugin() {} - }; - - typedef llvm::Registry<BasePlugin> PluginRegistry; - - template <class P> - struct RegisterPlugin - : public PluginRegistry::Add<P> { - typedef PluginRegistry::Add<P> Base; - - RegisterPlugin(const char* Name = "Nameless", - const char* Desc = "Auto-generated plugin") - : Base(Name, Desc) {} - }; - - - /// PluginLoader - Helper class used by the main program for - /// lifetime management. - struct PluginLoader { - PluginLoader(); - ~PluginLoader(); - - /// 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 - PluginLoader(const PluginLoader& other); - const PluginLoader& operator=(const PluginLoader& other); - }; - -} - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H diff --git a/contrib/llvm/include/llvm/CompilerDriver/Tool.h b/contrib/llvm/include/llvm/CompilerDriver/Tool.h index 85d1690..45ef50d 100644 --- a/contrib/llvm/include/llvm/CompilerDriver/Tool.h +++ b/contrib/llvm/include/llvm/CompilerDriver/Tool.h @@ -38,17 +38,23 @@ namespace llvmc { virtual ~Tool() {} - virtual Action GenerateAction (const PathVector& inFiles, - bool HasChildren, - const llvm::sys::Path& TempDir, - const InputLanguagesSet& InLangs, - const LanguageMap& LangMap) const = 0; - - virtual Action GenerateAction (const llvm::sys::Path& inFile, - bool HasChildren, - const llvm::sys::Path& TempDir, - const InputLanguagesSet& InLangs, - const LanguageMap& LangMap) const = 0; + /// GenerateAction - Generate an Action given particular command-line + /// options. Returns non-zero value on error. + virtual int GenerateAction (Action& Out, + const PathVector& inFiles, + const bool HasChildren, + const llvm::sys::Path& TempDir, + const InputLanguagesSet& InLangs, + const LanguageMap& LangMap) const = 0; + + /// GenerateAction - Generate an Action given particular command-line + /// options. Returns non-zero value on error. + virtual int GenerateAction (Action& Out, + const llvm::sys::Path& inFile, + const bool HasChildren, + const llvm::sys::Path& TempDir, + const InputLanguagesSet& InLangs, + const LanguageMap& LangMap) const = 0; virtual const char* Name() const = 0; virtual const char** InputLanguages() const = 0; @@ -74,11 +80,13 @@ namespace llvmc { void ClearJoinList() { JoinList_.clear(); } bool JoinListEmpty() const { return JoinList_.empty(); } - Action GenerateAction(bool HasChildren, - const llvm::sys::Path& TempDir, - const InputLanguagesSet& InLangs, - const LanguageMap& LangMap) const { - return GenerateAction(JoinList_, HasChildren, TempDir, InLangs, LangMap); + int GenerateAction(Action& Out, + const bool HasChildren, + const llvm::sys::Path& TempDir, + const InputLanguagesSet& InLangs, + const LanguageMap& LangMap) const { + return GenerateAction(Out, JoinList_, HasChildren, TempDir, InLangs, + LangMap); } // We shouldn't shadow base class's version of GenerateAction. using Tool::GenerateAction; diff --git a/contrib/llvm/include/llvm/Config/config.h.cmake b/contrib/llvm/include/llvm/Config/config.h.cmake index e7594ba..e8feabf 100644 --- a/contrib/llvm/include/llvm/Config/config.h.cmake +++ b/contrib/llvm/include/llvm/Config/config.h.cmake @@ -3,6 +3,9 @@ ** Created by Kevin from config.h.in ** ***************************************/ +#ifndef CONFIG_H +#define CONFIG_H + /* Define if dlopen(0) will open the symbols of the program */ #undef CAN_DLOPEN_SELF @@ -525,7 +528,7 @@ #cmakedefine LLVM_PATH_TWOPI "${LLVM_PATH_TWOPI}" /* Installation prefix directory */ -#undef LLVM_PREFIX +#cmakedefine LLVM_PREFIX "${LLVM_PREFIX}" /* Define if the OS needs help to load dependent libraries for dlopen(). */ #cmakedefine LTDL_DLOPEN_DEPLIBS ${LTDL_DLOPEN_DEPLIBS} @@ -623,5 +626,16 @@ /* Define to a function implementing strdup */ #cmakedefine strdup ${strdup} -/* Native LLVM architecture */ -#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}Target +/* LLVM architecture name for the native architecture, if available */ +#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} + +/* LLVM name for the native Target init function, if available */ +#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target + +/* LLVM name for the native TargetInfo init function, if available */ +#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo + +/* LLVM name for the native AsmPrinter init function, if available */ +#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter + +#endif diff --git a/contrib/llvm/include/llvm/Config/config.h.in b/contrib/llvm/include/llvm/Config/config.h.in index d12f82a..d62da1a 100644 --- a/contrib/llvm/include/llvm/Config/config.h.in +++ b/contrib/llvm/include/llvm/Config/config.h.in @@ -1,5 +1,8 @@ /* include/llvm/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */ +#ifndef CONFIG_H +#define CONFIG_H + /* 32 bit multilib directory. */ #undef CXX_INCLUDE_32BIT_DIR @@ -458,6 +461,9 @@ /* Define to 1 if you have the `__dso_handle' function. */ #undef HAVE___DSO_HANDLE +/* Linker version detected at compile time. */ +#undef HOST_LINK_VERSION + /* Installation directory for binary executables */ #undef LLVM_BINDIR @@ -494,6 +500,15 @@ /* LLVM architecture name for the native architecture, if available */ #undef LLVM_NATIVE_ARCH +/* LLVM name for the native AsmPrinter init function, if available */ +#undef LLVM_NATIVE_ASMPRINTER + +/* LLVM name for the native Target init function, if available */ +#undef LLVM_NATIVE_TARGET + +/* LLVM name for the native TargetInfo init function, if available */ +#undef LLVM_NATIVE_TARGETINFO + /* Define if this is Unixish platform */ #undef LLVM_ON_UNIX @@ -598,3 +613,5 @@ /* Define to `unsigned int' if <sys/types.h> does not define. */ #undef size_t + +#endif diff --git a/contrib/llvm/include/llvm/Config/llvm-config.h.cmake b/contrib/llvm/include/llvm/Config/llvm-config.h.cmake new file mode 100644 index 0000000..8469bcc --- /dev/null +++ b/contrib/llvm/include/llvm/Config/llvm-config.h.cmake @@ -0,0 +1,97 @@ +/*===-- llvm/config/llvm-config.h - llvm configure variable -------*- 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 llvm variables from configure so that + they can be in exported headers and won't override package specific + directives. This is a C file so we can include it in the llvm-c headers. */ + +/* To avoid multiple inclusions of these variables when we include the exported + headers and config.h, conditionally include these. */ +/* TODO: This is a bit of a hack. */ +#ifndef CONFIG_H + +/* Installation directory for binary executables */ +#cmakedefine LLVM_BINDIR "${LLVM_BINDIR}" + +/* Time at which LLVM was configured */ +#cmakedefine LLVM_CONFIGTIME "${LLVM_CONFIGTIME}" + +/* Installation directory for data files */ +#cmakedefine LLVM_DATADIR "${LLVM_DATADIR}" + +/* Installation directory for documentation */ +#cmakedefine LLVM_DOCSDIR "${LLVM_DOCSDIR}" + +/* Installation directory for config files */ +#cmakedefine LLVM_ETCDIR "${LLVM_ETCDIR}" + +/* Host triple we were built on */ +#cmakedefine LLVM_HOSTTRIPLE "${LLVM_HOSTTRIPLE}" + +/* Installation directory for include files */ +#cmakedefine LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}" + +/* Installation directory for .info files */ +#cmakedefine LLVM_INFODIR "${LLVM_INFODIR}" + +/* Installation directory for libraries */ +#cmakedefine LLVM_LIBDIR "${LLVM_LIBDIR}" + +/* Installation directory for man pages */ +#cmakedefine LLVM_MANDIR "${LLVM_MANDIR}" + +/* Build multithreading support into LLVM */ +#cmakedefine LLVM_MULTITHREADED + +/* LLVM architecture name for the native architecture, if available */ +#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} + +/* LLVM name for the native Target init function, if available */ +#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target + +/* LLVM name for the native TargetInfo init function, if available */ +#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo + +/* LLVM name for the native AsmPrinter init function, if available */ +#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter + +/* Define if this is Unixish platform */ +#cmakedefine LLVM_ON_UNIX + +/* Define if this is Win32ish platform */ +#cmakedefine LLVM_ON_WIN32 + +/* Define to path to circo program if found or 'echo circo' otherwise */ +#cmakedefine LLVM_PATH_CIRCO "${LLVM_PATH_CIRCO}" + +/* Define to path to dot program if found or 'echo dot' otherwise */ +#cmakedefine LLVM_PATH_DOT "${LLVM_PATH_DOT}" + +/* Define to path to dotty program if found or 'echo dotty' otherwise */ +#cmakedefine LLVM_PATH_DOTTY "${LLVM_PATH_DOTTY}" + +/* Define to path to fdp program if found or 'echo fdp' otherwise */ +#cmakedefine LLVM_PATH_FDP "${LLVM_PATH_FDP}" + +/* Define to path to Graphviz program if found or 'echo Graphviz' otherwise */ +#cmakedefine LLVM_PATH_GRAPHVIZ "${LLVM_PATH_GRAPHVIZ}" + +/* Define to path to gv program if found or 'echo gv' otherwise */ +#cmakedefine LLVM_PATH_GV "${LLVM_PATH_GV}" + +/* Define to path to neato program if found or 'echo neato' otherwise */ +#cmakedefine LLVM_PATH_NEATO "${LLVM_PATH_NEATO}" + +/* Define to path to twopi program if found or 'echo twopi' otherwise */ +#cmakedefine LLVM_PATH_TWOPI "${LLVM_PATH_TWOPI}" + +/* Installation prefix directory */ +#cmakedefine LLVM_PREFIX "${LLVM_PREFIX}" + +#endif diff --git a/contrib/llvm/include/llvm/Config/llvm-config.h.in b/contrib/llvm/include/llvm/Config/llvm-config.h.in new file mode 100644 index 0000000..e7a04ee --- /dev/null +++ b/contrib/llvm/include/llvm/Config/llvm-config.h.in @@ -0,0 +1,97 @@ +/*===-- llvm/config/llvm-config.h - llvm configure variable -------*- 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 llvm variables from configure so that + they can be in exported headers and won't override package specific + directives. This is a C file so we can include it in the llvm-c headers. */ + +/* To avoid multiple inclusions of these variables when we include the exported + headers and config.h, conditionally include these. */ +/* TODO: This is a bit of a hack. */ +#ifndef CONFIG_H + +/* Installation directory for binary executables */ +#undef LLVM_BINDIR + +/* Time at which LLVM was configured */ +#undef LLVM_CONFIGTIME + +/* Installation directory for data files */ +#undef LLVM_DATADIR + +/* Installation directory for documentation */ +#undef LLVM_DOCSDIR + +/* Installation directory for config files */ +#undef LLVM_ETCDIR + +/* Host triple we were built on */ +#undef LLVM_HOSTTRIPLE + +/* Installation directory for include files */ +#undef LLVM_INCLUDEDIR + +/* Installation directory for .info files */ +#undef LLVM_INFODIR + +/* Installation directory for libraries */ +#undef LLVM_LIBDIR + +/* Installation directory for man pages */ +#undef LLVM_MANDIR + +/* Build multithreading support into LLVM */ +#undef LLVM_MULTITHREADED + +/* LLVM architecture name for the native architecture, if available */ +#undef LLVM_NATIVE_ARCH + +/* LLVM name for the native Target init function, if available */ +#undef LLVM_NATIVE_TARGET + +/* LLVM name for the native TargetInfo init function, if available */ +#undef LLVM_NATIVE_TARGETINFO + +/* LLVM name for the native AsmPrinter init function, if available */ +#undef LLVM_NATIVE_ASMPRINTER + +/* Define if this is Unixish platform */ +#undef LLVM_ON_UNIX + +/* 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 */ +#undef LLVM_PREFIX + +#endif diff --git a/contrib/llvm/include/llvm/Constants.h b/contrib/llvm/include/llvm/Constants.h index 9ca845e..a7deae0 100644 --- a/contrib/llvm/include/llvm/Constants.h +++ b/contrib/llvm/include/llvm/Constants.h @@ -33,7 +33,6 @@ namespace llvm { class ArrayType; class IntegerType; class StructType; -class UnionType; class PointerType; class VectorType; @@ -459,49 +458,6 @@ struct OperandTraits<ConstantStruct> : public VariadicOperandTraits<> { DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant) -//===----------------------------------------------------------------------===// -// ConstantUnion - Constant Union Declarations -// -class ConstantUnion : public Constant { - friend struct ConstantCreator<ConstantUnion, UnionType, Constant*>; - ConstantUnion(const ConstantUnion &); // DO NOT IMPLEMENT -protected: - ConstantUnion(const UnionType *T, Constant* Val); -public: - // ConstantUnion accessors - static Constant *get(const UnionType *T, Constant* V); - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); - - /// getType() specialization - Reduce amount of casting... - /// - inline const UnionType *getType() const { - return reinterpret_cast<const UnionType*>(Value::getType()); - } - - /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. This always returns false because zero structs are always - /// created as ConstantAggregateZero objects. - virtual bool isNullValue() const { - return false; - } - - virtual void destroyConstant(); - virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); - - /// Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const ConstantUnion *) { return true; } - static bool classof(const Value *V) { - return V->getValueID() == ConstantUnionVal; - } -}; - -template <> -struct OperandTraits<ConstantUnion> : public FixedNumOperandTraits<1> { -}; - -DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantUnion, Constant) //===----------------------------------------------------------------------===// /// ConstantVector - Constant Vector Declarations diff --git a/contrib/llvm/include/llvm/DerivedTypes.h b/contrib/llvm/include/llvm/DerivedTypes.h index 912bb6d..9b6b19f 100644 --- a/contrib/llvm/include/llvm/DerivedTypes.h +++ b/contrib/llvm/include/llvm/DerivedTypes.h @@ -27,7 +27,6 @@ template<class ValType, class TypeClass> class TypeMap; class FunctionValType; class ArrayValType; class StructValType; -class UnionValType; class PointerValType; class VectorValType; class IntegerValType; @@ -52,10 +51,6 @@ protected: /// void dropAllTypeUses(); - /// unlockedRefineAbstractTypeTo - Internal version of refineAbstractTypeTo - /// that performs no locking. Only used for internal recursion. - void unlockedRefineAbstractTypeTo(const Type *NewType); - public: //===--------------------------------------------------------------------===// @@ -230,8 +225,7 @@ public: return T->getTypeID() == ArrayTyID || T->getTypeID() == StructTyID || T->getTypeID() == PointerTyID || - T->getTypeID() == VectorTyID || - T->getTypeID() == UnionTyID; + T->getTypeID() == VectorTyID; } }; @@ -302,64 +296,6 @@ public: bool isPacked() const { return (0 != getSubclassData()) ? true : false; } }; - -/// UnionType - Class to represent union types. A union type is similar to -/// a structure, except that all member fields begin at offset 0. -/// -class UnionType : public CompositeType { - friend class TypeMap<UnionValType, UnionType>; - UnionType(const UnionType &); // Do not implement - const UnionType &operator=(const UnionType &); // Do not implement - UnionType(LLVMContext &C, const Type* const* Types, unsigned NumTypes); -public: - /// UnionType::get - This static method is the primary way to create a - /// UnionType. - static UnionType *get(const Type* const* Types, unsigned NumTypes); - - /// UnionType::get - This static method is a convenience method for - /// creating union types by specifying the elements as arguments. - static UnionType *get(const Type *type, ...) END_WITH_NULL; - - /// isValidElementType - Return true if the specified type is valid as a - /// element type. - static bool isValidElementType(const Type *ElemTy); - - /// Given an element type, return the member index of that type, or -1 - /// if there is no such member type. - int getElementTypeIndex(const Type *ElemTy) const; - - // Iterator access to the elements - typedef Type::subtype_iterator element_iterator; - element_iterator element_begin() const { return ContainedTys; } - element_iterator element_end() const { return &ContainedTys[NumContainedTys];} - - // Random access to the elements - unsigned getNumElements() const { return NumContainedTys; } - const Type *getElementType(unsigned N) const { - assert(N < NumContainedTys && "Element number out of range!"); - return ContainedTys[N]; - } - - /// getTypeAtIndex - Given an index value into the type, return the type of - /// the element. For a union type, this must be a constant value... - /// - virtual const Type *getTypeAtIndex(const Value *V) const; - virtual const Type *getTypeAtIndex(unsigned Idx) const; - virtual bool indexValid(const Value *V) const; - virtual bool indexValid(unsigned Idx) const; - - // Implement the AbstractTypeUser interface. - virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); - virtual void typeBecameConcrete(const DerivedType *AbsTy); - - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const UnionType *) { return true; } - static inline bool classof(const Type *T) { - return T->getTypeID() == UnionTyID; - } -}; - - /// SequentialType - This is the superclass of the array, pointer and vector /// type classes. All of these represent "arrays" in memory. The array type /// represents a specifically sized array, pointer types are unsized/unknown diff --git a/contrib/llvm/include/llvm/ExecutionEngine/JITMemoryManager.h b/contrib/llvm/include/llvm/ExecutionEngine/JITMemoryManager.h index fd51920..e015930 100644 --- a/contrib/llvm/include/llvm/ExecutionEngine/JITMemoryManager.h +++ b/contrib/llvm/include/llvm/ExecutionEngine/JITMemoryManager.h @@ -29,10 +29,9 @@ namespace llvm { class JITMemoryManager { protected: bool HasGOT; - bool SizeRequired; public: - JITMemoryManager() : HasGOT(false), SizeRequired(false) {} + JITMemoryManager() : HasGOT(false) {} virtual ~JITMemoryManager(); /// CreateDefaultMemManager - This is used to create the default @@ -71,12 +70,6 @@ public: /// return a pointer to its base. virtual uint8_t *getGOTBase() const = 0; - /// NeedsExactSize - If the memory manager requires to know the size of the - /// objects to be emitted - bool NeedsExactSize() const { - return SizeRequired; - } - //===--------------------------------------------------------------------===// // Main Allocation Functions //===--------------------------------------------------------------------===// diff --git a/contrib/llvm/include/llvm/GlobalValue.h b/contrib/llvm/include/llvm/GlobalValue.h index d175080..62e84f8 100644 --- a/contrib/llvm/include/llvm/GlobalValue.h +++ b/contrib/llvm/include/llvm/GlobalValue.h @@ -41,6 +41,8 @@ public: PrivateLinkage, ///< Like Internal, but omit from symbol table. LinkerPrivateLinkage, ///< Like Private, but linker removes. LinkerPrivateWeakLinkage, ///< Like LinkerPrivate, but weak. + LinkerPrivateWeakDefAutoLinkage, ///< Like LinkerPrivateWeak, but possibly + /// hidden. DLLImportLinkage, ///< Function to be imported from DLL DLLExportLinkage, ///< Function to be accessible from DLL. ExternalWeakLinkage,///< ExternalWeak linkage description. @@ -74,11 +76,10 @@ public: removeDeadConstantUsers(); // remove any dead constants using this. } - unsigned getAlignment() const { return Alignment; } - void setAlignment(unsigned Align) { - assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); - Alignment = Align; + unsigned getAlignment() const { + return (1u << Alignment) >> 1; } + void setAlignment(unsigned Align); VisibilityTypes getVisibility() const { return VisibilityTypes(Visibility); } bool hasDefaultVisibility() const { return Visibility == DefaultVisibility; } @@ -138,9 +139,13 @@ public: static bool isLinkerPrivateWeakLinkage(LinkageTypes Linkage) { return Linkage == LinkerPrivateWeakLinkage; } + static bool isLinkerPrivateWeakDefAutoLinkage(LinkageTypes Linkage) { + return Linkage == LinkerPrivateWeakDefAutoLinkage; + } static bool isLocalLinkage(LinkageTypes Linkage) { return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage) || - isLinkerPrivateLinkage(Linkage) || isLinkerPrivateWeakLinkage(Linkage); + isLinkerPrivateLinkage(Linkage) || isLinkerPrivateWeakLinkage(Linkage) || + isLinkerPrivateWeakDefAutoLinkage(Linkage); } static bool isDLLImportLinkage(LinkageTypes Linkage) { return Linkage == DLLImportLinkage; @@ -159,24 +164,26 @@ public: /// by something non-equivalent at link time. For example, if a function has /// weak linkage then the code defining it may be replaced by different code. static bool mayBeOverridden(LinkageTypes Linkage) { - return (Linkage == WeakAnyLinkage || - Linkage == LinkOnceAnyLinkage || - Linkage == CommonLinkage || - Linkage == ExternalWeakLinkage || - Linkage == LinkerPrivateWeakLinkage); + return Linkage == WeakAnyLinkage || + Linkage == LinkOnceAnyLinkage || + Linkage == CommonLinkage || + Linkage == ExternalWeakLinkage || + Linkage == LinkerPrivateWeakLinkage || + Linkage == LinkerPrivateWeakDefAutoLinkage; } /// isWeakForLinker - Whether the definition of this global may be replaced at /// link time. static bool isWeakForLinker(LinkageTypes Linkage) { - return (Linkage == AvailableExternallyLinkage || - Linkage == WeakAnyLinkage || - Linkage == WeakODRLinkage || - Linkage == LinkOnceAnyLinkage || - Linkage == LinkOnceODRLinkage || - Linkage == CommonLinkage || - Linkage == ExternalWeakLinkage || - Linkage == LinkerPrivateWeakLinkage); + return Linkage == AvailableExternallyLinkage || + Linkage == WeakAnyLinkage || + Linkage == WeakODRLinkage || + Linkage == LinkOnceAnyLinkage || + Linkage == LinkOnceODRLinkage || + Linkage == CommonLinkage || + Linkage == ExternalWeakLinkage || + Linkage == LinkerPrivateWeakLinkage || + Linkage == LinkerPrivateWeakDefAutoLinkage; } bool hasExternalLinkage() const { return isExternalLinkage(Linkage); } @@ -196,6 +203,9 @@ public: bool hasLinkerPrivateWeakLinkage() const { return isLinkerPrivateWeakLinkage(Linkage); } + bool hasLinkerPrivateWeakDefAutoLinkage() const { + return isLinkerPrivateWeakDefAutoLinkage(Linkage); + } bool hasLocalLinkage() const { return isLocalLinkage(Linkage); } bool hasDLLImportLinkage() const { return isDLLImportLinkage(Linkage); } bool hasDLLExportLinkage() const { return isDLLExportLinkage(Linkage); } diff --git a/contrib/llvm/include/llvm/Instruction.h b/contrib/llvm/include/llvm/Instruction.h index 0b772b0..88f5ce1 100644 --- a/contrib/llvm/include/llvm/Instruction.h +++ b/contrib/llvm/include/llvm/Instruction.h @@ -170,16 +170,6 @@ public: void setMetadata(unsigned KindID, MDNode *Node); void setMetadata(const char *Kind, MDNode *Node); - /// setDbgMetadata - This is just an optimized helper function that is - /// equivalent to setMetadata("dbg", Node); - void setDbgMetadata(MDNode *Node); - - /// getDbgMetadata - This is just an optimized helper function that is - /// equivalent to calling getMetadata("dbg"). - MDNode *getDbgMetadata() const { - return DbgLoc.getAsMDNode(getContext()); - } - /// setDebugLoc - Set the debug location information for this instruction. void setDebugLoc(const DebugLoc &Loc) { DbgLoc = Loc; } @@ -199,7 +189,7 @@ private: void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const; void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned, MDNode*> > &) const; - void removeAllMetadata(); + void clearMetadataHashEntries(); public: //===--------------------------------------------------------------------===// // Predicates and helper methods. diff --git a/contrib/llvm/include/llvm/Instructions.h b/contrib/llvm/include/llvm/Instructions.h index af93a29..bd1e889 100644 --- a/contrib/llvm/include/llvm/Instructions.h +++ b/contrib/llvm/include/llvm/Instructions.h @@ -941,33 +941,17 @@ public: unsigned(isTC)); } - /// @deprecated these "define hacks" will go away soon - /// @brief coerce out-of-tree code to abandon the low-level interfaces - /// @detail see below comments and update your code to high-level interfaces - /// - getOperand(0) ---> getCalledValue(), or possibly getCalledFunction - /// - setOperand(0, V) ---> setCalledFunction(V) - /// - /// in LLVM v2.8-only code - /// - getOperand(N+1) ---> getArgOperand(N) - /// - setOperand(N+1, V) ---> setArgOperand(N, V) - /// - getNumOperands() ---> getNumArgOperands()+1 // note the "+1"! - /// - /// in backward compatible code please consult llvm/Support/CallSite.h, - /// you should create a callsite using the CallInst pointer and call its - /// methods - /// -# define public private -# define protected private /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -# undef public -# undef protected -public: - enum { ArgOffset = 0 }; ///< temporary, do not use for new code! + /// getNumArgOperands - Return the number of call arguments. + /// unsigned getNumArgOperands() const { return getNumOperands() - 1; } - Value *getArgOperand(unsigned i) const { return getOperand(i + ArgOffset); } - void setArgOperand(unsigned i, Value *v) { setOperand(i + ArgOffset, v); } + + /// getArgOperand/setArgOperand - Return/set the i-th call argument. + /// + Value *getArgOperand(unsigned i) const { return getOperand(i); } + void setArgOperand(unsigned i, Value *v) { setOperand(i, v); } /// getCallingConv/setCallingConv - Get or set the calling convention of this /// function call. @@ -1056,17 +1040,22 @@ public: /// indirect function invocation. /// Function *getCalledFunction() const { - return dyn_cast<Function>(Op<ArgOffset -1>()); + return dyn_cast<Function>(Op<-1>()); } /// getCalledValue - Get a pointer to the function that is invoked by this /// instruction. - const Value *getCalledValue() const { return Op<ArgOffset -1>(); } - Value *getCalledValue() { return Op<ArgOffset -1>(); } + const Value *getCalledValue() const { return Op<-1>(); } + Value *getCalledValue() { return Op<-1>(); } /// setCalledFunction - Set the function called. void setCalledFunction(Value* Fn) { - Op<ArgOffset -1>() = Fn; + Op<-1>() = Fn; + } + + /// isInlineAsm - Check if this call is an inline asm statement. + bool isInlineAsm() const { + return isa<InlineAsm>(Op<-1>()); } // Methods for support type inquiry through isa, cast, and dyn_cast: @@ -2461,7 +2450,12 @@ public: /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getNumArgOperands - Return the number of invoke arguments. + /// unsigned getNumArgOperands() const { return getNumOperands() - 3; } + + /// getArgOperand/setArgOperand - Return/set the i-th invoke argument. + /// Value *getArgOperand(unsigned i) const { return getOperand(i); } void setArgOperand(unsigned i, Value *v) { setOperand(i, v); } @@ -2735,7 +2729,7 @@ public: TruncInst( Value *S, ///< The value to be truncated const Type *Ty, ///< The (smaller) type to truncate to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2743,7 +2737,7 @@ public: TruncInst( Value *S, ///< The value to be truncated const Type *Ty, ///< The (smaller) type to truncate to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2772,7 +2766,7 @@ public: ZExtInst( Value *S, ///< The value to be zero extended const Type *Ty, ///< The type to zero extend to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2780,7 +2774,7 @@ public: ZExtInst( Value *S, ///< The value to be zero extended const Type *Ty, ///< The type to zero extend to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2809,7 +2803,7 @@ public: SExtInst( Value *S, ///< The value to be sign extended const Type *Ty, ///< The type to sign extend to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2817,7 +2811,7 @@ public: SExtInst( Value *S, ///< The value to be sign extended const Type *Ty, ///< The type to sign extend to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2846,7 +2840,7 @@ public: FPTruncInst( Value *S, ///< The value to be truncated const Type *Ty, ///< The type to truncate to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2854,7 +2848,7 @@ public: FPTruncInst( Value *S, ///< The value to be truncated const Type *Ty, ///< The type to truncate to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2883,7 +2877,7 @@ public: FPExtInst( Value *S, ///< The value to be extended const Type *Ty, ///< The type to extend to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2891,7 +2885,7 @@ public: FPExtInst( Value *S, ///< The value to be extended const Type *Ty, ///< The type to extend to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2920,7 +2914,7 @@ public: UIToFPInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2928,7 +2922,7 @@ public: UIToFPInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2957,7 +2951,7 @@ public: SIToFPInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -2965,7 +2959,7 @@ public: SIToFPInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -2994,7 +2988,7 @@ public: FPToUIInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -3002,7 +2996,7 @@ public: FPToUIInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< Where to insert the new instruction ); @@ -3031,7 +3025,7 @@ public: FPToSIInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -3039,7 +3033,7 @@ public: FPToSIInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3064,7 +3058,7 @@ public: IntToPtrInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -3072,7 +3066,7 @@ public: IntToPtrInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3104,7 +3098,7 @@ public: PtrToIntInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -3112,7 +3106,7 @@ public: PtrToIntInst( Value *S, ///< The value to be converted const Type *Ty, ///< The type to convert to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); @@ -3141,7 +3135,7 @@ public: BitCastInst( Value *S, ///< The value to be casted const Type *Ty, ///< The type to casted to - const Twine &NameStr = "", ///< A name for the new instruction + const Twine &NameStr = "", ///< A name for the new instruction Instruction *InsertBefore = 0 ///< Where to insert the new instruction ); @@ -3149,7 +3143,7 @@ public: BitCastInst( Value *S, ///< The value to be casted const Type *Ty, ///< The type to casted to - const Twine &NameStr, ///< A name for the new instruction + const Twine &NameStr, ///< A name for the new instruction BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); diff --git a/contrib/llvm/include/llvm/IntrinsicInst.h b/contrib/llvm/include/llvm/IntrinsicInst.h index 48f2da9..a17fa9c 100644 --- a/contrib/llvm/include/llvm/IntrinsicInst.h +++ b/contrib/llvm/include/llvm/IntrinsicInst.h @@ -103,7 +103,7 @@ namespace llvm { Value *getValue(); uint64_t getOffset() const { return cast<ConstantInt>( - const_cast<Value*>(getArgOperand(1)))->getZExtValue(); + const_cast<Value*>(getArgOperand(1)))->getZExtValue(); } MDNode *getVariable() const { return cast<MDNode>(getArgOperand(2)); } @@ -269,6 +269,20 @@ namespace llvm { } }; + /// EHExceptionInst - This represents the llvm.eh.exception instruction. + /// + class EHExceptionInst : public IntrinsicInst { + public: + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const EHExceptionInst *) { return true; } + static inline bool classof(const IntrinsicInst *I) { + return I->getIntrinsicID() == Intrinsic::eh_exception; + } + static inline bool classof(const Value *V) { + return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V)); + } + }; + /// EHSelectorInst - This represents the llvm.eh.selector instruction. /// class EHSelectorInst : public IntrinsicInst { diff --git a/contrib/llvm/include/llvm/Intrinsics.td b/contrib/llvm/include/llvm/Intrinsics.td index 444f514..fb4f750 100644 --- a/contrib/llvm/include/llvm/Intrinsics.td +++ b/contrib/llvm/include/llvm/Intrinsics.td @@ -19,10 +19,11 @@ include "llvm/CodeGen/ValueTypes.td" class IntrinsicProperty; -// Intr*Mem - Memory properties. An intrinsic is allowed to have exactly one of +// Intr*Mem - Memory properties. An intrinsic is allowed to have at most one of // these properties set. They are listed from the most aggressive (best to use // if correct) to the least aggressive. If no property is set, the worst case -// is assumed (IntrWriteMem). +// is assumed (it may read and write any memory it can get access to and it may +// have other side effects). // IntrNoMem - The intrinsic does not access memory or have any other side // effects. It may be CSE'd deleted if dead, etc. @@ -37,15 +38,11 @@ def IntrReadArgMem : IntrinsicProperty; // deleted if dead. def IntrReadMem : IntrinsicProperty; -// IntrWriteArgMem - This intrinsic reads and writes only from memory that one -// of its arguments points to, but may access an unspecified amount. The reads -// and writes may be volatile, but except for this it has no other side effects. -def IntrWriteArgMem : IntrinsicProperty; - -// IntrWriteMem - This intrinsic may read or modify unspecified memory or has -// other side effects. It cannot be modified by the optimizer. This is the -// default if the intrinsic has no other Intr*Mem property. -def IntrWriteMem : IntrinsicProperty; +// IntrReadWriteArgMem - This intrinsic reads and writes only from memory that +// one of its arguments points to, but may access an unspecified amount. The +// reads and writes may be volatile, but except for this it has no other side +// effects. +def IntrReadWriteArgMem : IntrinsicProperty; // Commutative - This intrinsic is commutative: X op Y == Y op X. def Commutative : IntrinsicProperty; @@ -117,7 +114,7 @@ def llvm_v4i8_ty : LLVMType<v4i8>; // 4 x i8 def llvm_v8i8_ty : LLVMType<v8i8>; // 8 x i8 def llvm_v16i8_ty : LLVMType<v16i8>; // 16 x i8 def llvm_v32i8_ty : LLVMType<v32i8>; // 32 x i8 -def llvm_v2i16_ty : LLVMType<v2i16>; // 4 x i16 +def llvm_v2i16_ty : LLVMType<v2i16>; // 2 x i16 def llvm_v4i16_ty : LLVMType<v4i16>; // 4 x i16 def llvm_v8i16_ty : LLVMType<v8i16>; // 8 x i16 def llvm_v16i16_ty : LLVMType<v16i16>; // 16 x i16 @@ -190,7 +187,7 @@ def int_gcread : Intrinsic<[llvm_ptr_ty], [IntrReadArgMem]>; def int_gcwrite : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptrptr_ty], - [IntrWriteArgMem, NoCapture<1>, NoCapture<2>]>; + [IntrReadWriteArgMem, NoCapture<1>, NoCapture<2>]>; //===--------------------- Code Generator Intrinsics ----------------------===// // @@ -204,21 +201,19 @@ def int_stacksave : Intrinsic<[llvm_ptr_ty]>, def int_stackrestore : Intrinsic<[], [llvm_ptr_ty]>, GCCBuiltin<"__builtin_stack_restore">; -// IntrWriteArgMem is more pessimistic than strictly necessary for prefetch, +// IntrReadWriteArgMem is more pessimistic than strictly necessary for prefetch, // however it does conveniently prevent the prefetch from being reordered // with respect to nearby accesses to the same memory. def int_prefetch : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteArgMem, NoCapture<0>]>; + [IntrReadWriteArgMem, NoCapture<0>]>; def int_pcmarker : Intrinsic<[], [llvm_i32_ty]>; def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>; // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack // guard to the correct place on the stack frame. -def int_stackprotector : Intrinsic<[], - [llvm_ptr_ty, llvm_ptrptr_ty], - [IntrWriteMem]>; +def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>; //===------------------- Standard C Library Intrinsics --------------------===// // @@ -226,15 +221,15 @@ def int_stackprotector : Intrinsic<[], def int_memcpy : Intrinsic<[], [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty], - [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; + [IntrReadWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memmove : Intrinsic<[], [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty], - [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; + [IntrReadWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memset : Intrinsic<[], [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, llvm_i32_ty, llvm_i1_ty], - [IntrWriteArgMem, NoCapture<0>]>; + [IntrReadWriteArgMem, NoCapture<0>]>; // These functions do not actually read memory, but they are sensitive to the // rounding mode. This needs to be modelled separately; in the meantime @@ -331,7 +326,7 @@ def int_annotation : Intrinsic<[llvm_anyint_ty], // def int_init_trampoline : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], - [IntrWriteArgMem]>, + [IntrReadWriteArgMem]>, GCCBuiltin<"__builtin_init_trampoline">; //===------------------------ Overflow Intrinsics -------------------------===// @@ -369,79 +364,79 @@ def int_memory_barrier : Intrinsic<[], def int_atomic_cmp_swap : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_val_compare_and_swap">; def int_atomic_load_add : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_add">; def int_atomic_swap : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_lock_test_and_set">; def int_atomic_load_sub : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_sub">; def int_atomic_load_and : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_and">; def int_atomic_load_or : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_or">; def int_atomic_load_xor : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_xor">; def int_atomic_load_nand : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_nand">; def int_atomic_load_min : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_min">; def int_atomic_load_max : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_max">; def int_atomic_load_umin : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_umin">; def int_atomic_load_umax : Intrinsic<[llvm_anyint_ty], [LLVMAnyPointerType<LLVMMatchType<0>>, LLVMMatchType<0>], - [IntrWriteArgMem, NoCapture<0>]>, + [IntrReadWriteArgMem, NoCapture<0>]>, GCCBuiltin<"__sync_fetch_and_umax">; //===------------------------- Memory Use Markers -------------------------===// // def int_lifetime_start : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty], - [IntrWriteArgMem, NoCapture<1>]>; + [IntrReadWriteArgMem, NoCapture<1>]>; def int_lifetime_end : Intrinsic<[], [llvm_i64_ty, llvm_ptr_ty], - [IntrWriteArgMem, NoCapture<1>]>; + [IntrReadWriteArgMem, NoCapture<1>]>; def int_invariant_start : Intrinsic<[llvm_descriptor_ty], [llvm_i64_ty, llvm_ptr_ty], [IntrReadArgMem, NoCapture<1>]>; def int_invariant_end : Intrinsic<[], [llvm_descriptor_ty, llvm_i64_ty, llvm_ptr_ty], - [IntrWriteArgMem, NoCapture<2>]>; + [IntrReadWriteArgMem, NoCapture<2>]>; //===-------------------------- Other Intrinsics --------------------------===// // diff --git a/contrib/llvm/include/llvm/IntrinsicsARM.td b/contrib/llvm/include/llvm/IntrinsicsARM.td index 40333ca..6c04771 100644 --- a/contrib/llvm/include/llvm/IntrinsicsARM.td +++ b/contrib/llvm/include/llvm/IntrinsicsARM.td @@ -21,6 +21,35 @@ let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". } //===----------------------------------------------------------------------===// +// Saturating Arithmentic + +let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". + def int_arm_qadd : GCCBuiltin<"__builtin_arm_qadd">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem, Commutative]>; + def int_arm_qsub : GCCBuiltin<"__builtin_arm_qsub">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; + def int_arm_ssat : GCCBuiltin<"__builtin_arm_ssat">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; + def int_arm_usat : GCCBuiltin<"__builtin_arm_usat">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; +} + +//===----------------------------------------------------------------------===// +// VFP + +let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". + def int_arm_get_fpscr : GCCBuiltin<"__builtin_arm_get_fpscr">, + Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>; + def int_arm_set_fpscr : GCCBuiltin<"__builtin_arm_set_fpscr">, + Intrinsic<[], [llvm_i32_ty], []>; + def int_arm_vcvtr : Intrinsic<[llvm_float_ty], [llvm_anyfloat_ty], + [IntrNoMem]>; + def int_arm_vcvtru : Intrinsic<[llvm_float_ty], [llvm_anyfloat_ty], + [IntrNoMem]>; +} + +//===----------------------------------------------------------------------===// // Advanced SIMD (NEON) let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". @@ -31,9 +60,6 @@ let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". class Neon_1Arg_Narrow_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMExtendedElementVectorType<0>], [IntrNoMem]>; - class Neon_1Arg_Long_Intrinsic - : Intrinsic<[llvm_anyvector_ty], - [LLVMTruncatedElementVectorType<0>], [IntrNoMem]>; class Neon_2Arg_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>; @@ -47,10 +73,6 @@ let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". [LLVMTruncatedElementVectorType<0>, LLVMTruncatedElementVectorType<0>], [IntrNoMem]>; - class Neon_2Arg_Wide_Intrinsic - : Intrinsic<[llvm_anyvector_ty], - [LLVMMatchType<0>, LLVMTruncatedElementVectorType<0>], - [IntrNoMem]>; class Neon_3Arg_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], @@ -102,25 +124,13 @@ let Properties = [IntrNoMem, Commutative] in { def int_arm_neon_vqaddu : Neon_2Arg_Intrinsic; def int_arm_neon_vaddhn : Neon_2Arg_Narrow_Intrinsic; def int_arm_neon_vraddhn : Neon_2Arg_Narrow_Intrinsic; - def int_arm_neon_vaddls : Neon_2Arg_Long_Intrinsic; - def int_arm_neon_vaddlu : Neon_2Arg_Long_Intrinsic; - def int_arm_neon_vaddws : Neon_2Arg_Wide_Intrinsic; - def int_arm_neon_vaddwu : Neon_2Arg_Wide_Intrinsic; // Vector Multiply. def int_arm_neon_vmulp : Neon_2Arg_Intrinsic; def int_arm_neon_vqdmulh : Neon_2Arg_Intrinsic; def int_arm_neon_vqrdmulh : Neon_2Arg_Intrinsic; - def int_arm_neon_vmulls : Neon_2Arg_Long_Intrinsic; - def int_arm_neon_vmullu : Neon_2Arg_Long_Intrinsic; def int_arm_neon_vmullp : Neon_2Arg_Long_Intrinsic; def int_arm_neon_vqdmull : Neon_2Arg_Long_Intrinsic; - - // Vector Multiply and Accumulate/Subtract. - def int_arm_neon_vmlals : Neon_3Arg_Long_Intrinsic; - def int_arm_neon_vmlalu : Neon_3Arg_Long_Intrinsic; - def int_arm_neon_vmlsls : Neon_3Arg_Long_Intrinsic; - def int_arm_neon_vmlslu : Neon_3Arg_Long_Intrinsic; def int_arm_neon_vqdmlal : Neon_3Arg_Long_Intrinsic; def int_arm_neon_vqdmlsl : Neon_3Arg_Long_Intrinsic; @@ -146,10 +156,6 @@ def int_arm_neon_vqsubs : Neon_2Arg_Intrinsic; def int_arm_neon_vqsubu : Neon_2Arg_Intrinsic; def int_arm_neon_vsubhn : Neon_2Arg_Narrow_Intrinsic; def int_arm_neon_vrsubhn : Neon_2Arg_Narrow_Intrinsic; -def int_arm_neon_vsubls : Neon_2Arg_Long_Intrinsic; -def int_arm_neon_vsublu : Neon_2Arg_Long_Intrinsic; -def int_arm_neon_vsubws : Neon_2Arg_Wide_Intrinsic; -def int_arm_neon_vsubwu : Neon_2Arg_Wide_Intrinsic; // Vector Absolute Compare. let TargetPrefix = "arm" in { @@ -170,14 +176,6 @@ let TargetPrefix = "arm" in { // Vector Absolute Differences. def int_arm_neon_vabds : Neon_2Arg_Intrinsic; def int_arm_neon_vabdu : Neon_2Arg_Intrinsic; -def int_arm_neon_vabdls : Neon_2Arg_Long_Intrinsic; -def int_arm_neon_vabdlu : Neon_2Arg_Long_Intrinsic; - -// Vector Absolute Difference and Accumulate. -def int_arm_neon_vabas : Neon_3Arg_Intrinsic; -def int_arm_neon_vabau : Neon_3Arg_Intrinsic; -def int_arm_neon_vabals : Neon_3Arg_Long_Intrinsic; -def int_arm_neon_vabalu : Neon_3Arg_Long_Intrinsic; // Vector Pairwise Add. def int_arm_neon_vpadd : Neon_2Arg_Intrinsic; @@ -288,13 +286,10 @@ def int_arm_neon_vcvtfp2fxu : Neon_CvtFPToFx_Intrinsic; def int_arm_neon_vcvtfxs2fp : Neon_CvtFxToFP_Intrinsic; def int_arm_neon_vcvtfxu2fp : Neon_CvtFxToFP_Intrinsic; -// Narrowing and Lengthening Vector Moves. -def int_arm_neon_vmovn : Neon_1Arg_Narrow_Intrinsic; +// Narrowing Saturating Vector Moves. def int_arm_neon_vqmovns : Neon_1Arg_Narrow_Intrinsic; def int_arm_neon_vqmovnu : Neon_1Arg_Narrow_Intrinsic; def int_arm_neon_vqmovnsu : Neon_1Arg_Narrow_Intrinsic; -def int_arm_neon_vmovls : Neon_1Arg_Long_Intrinsic; -def int_arm_neon_vmovlu : Neon_1Arg_Long_Intrinsic; // Vector Table Lookup. // The first 1-4 arguments are the table. @@ -315,62 +310,76 @@ def int_arm_neon_vtbx4 : Neon_Tbl6Arg_Intrinsic; let TargetPrefix = "arm" in { // De-interleaving vector loads from N-element structures. + // Source operands are the address and alignment. def int_arm_neon_vld1 : Intrinsic<[llvm_anyvector_ty], - [llvm_ptr_ty], [IntrReadArgMem]>; + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; def int_arm_neon_vld2 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>], - [llvm_ptr_ty], [IntrReadArgMem]>; + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; def int_arm_neon_vld3 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>], - [llvm_ptr_ty], [IntrReadArgMem]>; + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; def int_arm_neon_vld4 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], - [llvm_ptr_ty], [IntrReadArgMem]>; + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; // Vector load N-element structure to one lane. + // Source operands are: the address, the N input vectors (since only one + // lane is assigned), the lane number, and the alignment. def int_arm_neon_vld2lane : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>], [llvm_ptr_ty, LLVMMatchType<0>, - LLVMMatchType<0>, llvm_i32_ty], - [IntrReadArgMem]>; + LLVMMatchType<0>, llvm_i32_ty, + llvm_i32_ty], [IntrReadArgMem]>; def int_arm_neon_vld3lane : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>], [llvm_ptr_ty, LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>, - llvm_i32_ty], [IntrReadArgMem]>; + llvm_i32_ty, llvm_i32_ty], + [IntrReadArgMem]>; def int_arm_neon_vld4lane : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [llvm_ptr_ty, LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>, - LLVMMatchType<0>, llvm_i32_ty], - [IntrReadArgMem]>; + LLVMMatchType<0>, llvm_i32_ty, + llvm_i32_ty], [IntrReadArgMem]>; // Interleaving vector stores from N-element structures. + // Source operands are: the address, the N vectors, and the alignment. def int_arm_neon_vst1 : Intrinsic<[], - [llvm_ptr_ty, llvm_anyvector_ty], - [IntrWriteArgMem]>; + [llvm_ptr_ty, llvm_anyvector_ty, + llvm_i32_ty], [IntrReadWriteArgMem]>; def int_arm_neon_vst2 : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, - LLVMMatchType<0>], [IntrWriteArgMem]>; + LLVMMatchType<0>, llvm_i32_ty], + [IntrReadWriteArgMem]>; def int_arm_neon_vst3 : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, - LLVMMatchType<0>, LLVMMatchType<0>], - [IntrWriteArgMem]>; + LLVMMatchType<0>, LLVMMatchType<0>, + llvm_i32_ty], [IntrReadWriteArgMem]>; def int_arm_neon_vst4 : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, - LLVMMatchType<0>], [IntrWriteArgMem]>; + LLVMMatchType<0>, llvm_i32_ty], + [IntrReadWriteArgMem]>; // Vector store N-element structure from one lane. + // Source operands are: the address, the N vectors, the lane number, and + // the alignment. def int_arm_neon_vst2lane : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, - LLVMMatchType<0>, llvm_i32_ty], - [IntrWriteArgMem]>; + LLVMMatchType<0>, llvm_i32_ty, + llvm_i32_ty], [IntrReadWriteArgMem]>; def int_arm_neon_vst3lane : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, - llvm_i32_ty], [IntrWriteArgMem]>; + llvm_i32_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; def int_arm_neon_vst4lane : Intrinsic<[], [llvm_ptr_ty, llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>, - LLVMMatchType<0>, llvm_i32_ty], - [IntrWriteArgMem]>; + LLVMMatchType<0>, llvm_i32_ty, + llvm_i32_ty], [IntrReadWriteArgMem]>; } diff --git a/contrib/llvm/include/llvm/IntrinsicsPowerPC.td b/contrib/llvm/include/llvm/IntrinsicsPowerPC.td index 4e959f3..da85bfb 100644 --- a/contrib/llvm/include/llvm/IntrinsicsPowerPC.td +++ b/contrib/llvm/include/llvm/IntrinsicsPowerPC.td @@ -18,17 +18,17 @@ // Non-altivec intrinsics. let TargetPrefix = "ppc" in { // All intrinsics start with "llvm.ppc.". // dcba/dcbf/dcbi/dcbst/dcbt/dcbz/dcbzl(PPC970) instructions. - def int_ppc_dcba : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbf : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbi : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbst : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbt : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbtst: Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbz : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; - def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; + def int_ppc_dcba : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbf : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbi : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbst : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbt : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbtst: Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbz : Intrinsic<[], [llvm_ptr_ty], []>; + def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>; // sync instruction - def int_ppc_sync : Intrinsic<[], [], [IntrWriteMem]>; + def int_ppc_sync : Intrinsic<[], [], []>; } @@ -86,31 +86,31 @@ class PowerPC_Vec_WWW_Intrinsic<string GCCIntSuffix> let TargetPrefix = "ppc" in { // All intrinsics start with "llvm.ppc.". // Data Stream Control. def int_ppc_altivec_dss : GCCBuiltin<"__builtin_altivec_dss">, - Intrinsic<[], [llvm_i32_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_i32_ty], []>; def int_ppc_altivec_dssall : GCCBuiltin<"__builtin_altivec_dssall">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; def int_ppc_altivec_dst : GCCBuiltin<"__builtin_altivec_dst">, Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteMem]>; + []>; def int_ppc_altivec_dstt : GCCBuiltin<"__builtin_altivec_dstt">, Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteMem]>; + []>; def int_ppc_altivec_dstst : GCCBuiltin<"__builtin_altivec_dstst">, Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteMem]>; + []>; def int_ppc_altivec_dststt : GCCBuiltin<"__builtin_altivec_dststt">, Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteMem]>; + []>; // VSCR access. def int_ppc_altivec_mfvscr : GCCBuiltin<"__builtin_altivec_mfvscr">, Intrinsic<[llvm_v8i16_ty], [], [IntrReadMem]>; def int_ppc_altivec_mtvscr : GCCBuiltin<"__builtin_altivec_mtvscr">, - Intrinsic<[], [llvm_v4i32_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_v4i32_ty], []>; // Loads. These don't map directly to GCC builtins because they represent the @@ -129,20 +129,15 @@ let TargetPrefix = "ppc" in { // All intrinsics start with "llvm.ppc.". // Stores. These don't map directly to GCC builtins because they represent the // source address with a single pointer. def int_ppc_altivec_stvx : - Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], []>; def int_ppc_altivec_stvxl : - Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], []>; def int_ppc_altivec_stvebx : - Intrinsic<[], [llvm_v16i8_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v16i8_ty, llvm_ptr_ty], []>; def int_ppc_altivec_stvehx : - Intrinsic<[], [llvm_v8i16_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v8i16_ty, llvm_ptr_ty], []>; def int_ppc_altivec_stvewx : - Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty], []>; // Comparisons setting a vector. def int_ppc_altivec_vcmpbfp : GCCBuiltin<"__builtin_altivec_vcmpbfp">, diff --git a/contrib/llvm/include/llvm/IntrinsicsX86.td b/contrib/llvm/include/llvm/IntrinsicsX86.td index cea4856..06ea3ae 100644 --- a/contrib/llvm/include/llvm/IntrinsicsX86.td +++ b/contrib/llvm/include/llvm/IntrinsicsX86.td @@ -11,6 +11,11 @@ // //===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// Interrupt traps +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_int : Intrinsic<[], [llvm_i8_ty]>; +} //===----------------------------------------------------------------------===// // SSE1 @@ -143,24 +148,24 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse_storeu_ps : GCCBuiltin<"__builtin_ia32_storeups">, Intrinsic<[], [llvm_ptr_ty, - llvm_v4f32_ty], [IntrWriteMem]>; + llvm_v4f32_ty], []>; } // Cacheability support ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse_movnt_ps : GCCBuiltin<"__builtin_ia32_movntps">, Intrinsic<[], [llvm_ptr_ty, - llvm_v4f32_ty], [IntrWriteMem]>; + llvm_v4f32_ty], []>; def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; } // Control register. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse_stmxcsr : - Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_ptr_ty], []>; def int_x86_sse_ldmxcsr : - Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_ptr_ty], []>; } // Misc. @@ -459,26 +464,26 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_storeu_pd : GCCBuiltin<"__builtin_ia32_storeupd">, Intrinsic<[], [llvm_ptr_ty, - llvm_v2f64_ty], [IntrWriteMem]>; + llvm_v2f64_ty], []>; def int_x86_sse2_storeu_dq : GCCBuiltin<"__builtin_ia32_storedqu">, Intrinsic<[], [llvm_ptr_ty, - llvm_v16i8_ty], [IntrWriteMem]>; + llvm_v16i8_ty], []>; def int_x86_sse2_storel_dq : GCCBuiltin<"__builtin_ia32_storelv4si">, Intrinsic<[], [llvm_ptr_ty, - llvm_v4i32_ty], [IntrWriteMem]>; + llvm_v4i32_ty], []>; } // Cacheability support ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_movnt_dq : GCCBuiltin<"__builtin_ia32_movntdq">, Intrinsic<[], [llvm_ptr_ty, - llvm_v2i64_ty], [IntrWriteMem]>; + llvm_v2i64_ty], []>; def int_x86_sse2_movnt_pd : GCCBuiltin<"__builtin_ia32_movntpd">, Intrinsic<[], [llvm_ptr_ty, - llvm_v2f64_ty], [IntrWriteMem]>; + llvm_v2f64_ty], []>; def int_x86_sse2_movnt_i : GCCBuiltin<"__builtin_ia32_movnti">, Intrinsic<[], [llvm_ptr_ty, - llvm_i32_ty], [IntrWriteMem]>; + llvm_i32_ty], []>; } // Misc. @@ -498,13 +503,13 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; def int_x86_sse2_maskmov_dqu : GCCBuiltin<"__builtin_ia32_maskmovdqu">, Intrinsic<[], [llvm_v16i8_ty, - llvm_v16i8_ty, llvm_ptr_ty], [IntrWriteMem]>; + llvm_v16i8_ty, llvm_ptr_ty], []>; def int_x86_sse2_clflush : GCCBuiltin<"__builtin_ia32_clflush">, - Intrinsic<[], [llvm_ptr_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_ptr_ty], []>; def int_x86_sse2_lfence : GCCBuiltin<"__builtin_ia32_lfence">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; def int_x86_sse2_mfence : GCCBuiltin<"__builtin_ia32_mfence">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; } //===----------------------------------------------------------------------===// @@ -546,10 +551,10 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse3_monitor : GCCBuiltin<"__builtin_ia32_monitor">, Intrinsic<[], [llvm_ptr_ty, - llvm_i32_ty, llvm_i32_ty], [IntrWriteMem]>; + llvm_i32_ty, llvm_i32_ty], []>; def int_x86_sse3_mwait : GCCBuiltin<"__builtin_ia32_mwait">, Intrinsic<[], [llvm_i32_ty, - llvm_i32_ty], [IntrWriteMem]>; + llvm_i32_ty], []>; } //===----------------------------------------------------------------------===// @@ -625,6 +630,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_ssse3_pshuf_b_128 : GCCBuiltin<"__builtin_ia32_pshufb128">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + def int_x86_ssse3_pshuf_w : GCCBuiltin<"__builtin_ia32_pshufw">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_i32_ty], + [IntrNoMem]>; } // Sign ops @@ -978,19 +986,360 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". } //===----------------------------------------------------------------------===// +// AVX + +// Arithmetic ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_addsub_pd_256 : GCCBuiltin<"__builtin_ia32_addsubpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_addsub_ps_256 : GCCBuiltin<"__builtin_ia32_addsubps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_max_pd_256 : GCCBuiltin<"__builtin_ia32_maxpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_min_pd_256 : GCCBuiltin<"__builtin_ia32_minpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_min_ps_256 : GCCBuiltin<"__builtin_ia32_minps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + + def int_x86_avx_sqrt_pd_256 : GCCBuiltin<"__builtin_ia32_sqrtpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; + + def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; + + def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; + + def int_x86_avx_round_pd_256 : GCCBuiltin<"__builtin_ia32_roundpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx_round_ps_256 : GCCBuiltin<"__builtin_ia32_roundps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_i32_ty], [IntrNoMem]>; +} + +// Horizontal ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_hadd_pd_256 : GCCBuiltin<"__builtin_ia32_haddpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_hsub_ps_256 : GCCBuiltin<"__builtin_ia32_hsubps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_hsub_pd_256 : GCCBuiltin<"__builtin_ia32_hsubpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_hadd_ps_256 : GCCBuiltin<"__builtin_ia32_haddps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; +} + +// Vector permutation +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_vpermilvar_pd : GCCBuiltin<"__builtin_ia32_vpermilvarpd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_v2i64_ty], [IntrNoMem]>; + def int_x86_avx_vpermilvar_ps : GCCBuiltin<"__builtin_ia32_vpermilvarps">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_v4i32_ty], [IntrNoMem]>; + + def int_x86_avx_vpermilvar_pd_256 : + GCCBuiltin<"__builtin_ia32_vpermilvarpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4i64_ty], [IntrNoMem]>; + def int_x86_avx_vpermilvar_ps_256 : + GCCBuiltin<"__builtin_ia32_vpermilvarps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty], [IntrNoMem]>; + + def int_x86_avx_vperm2f128_pd_256 : + GCCBuiltin<"__builtin_ia32_vperm2f128_pd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vperm2f128_ps_256 : + GCCBuiltin<"__builtin_ia32_vperm2f128_ps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vperm2f128_si_256 : + GCCBuiltin<"__builtin_ia32_vperm2f128_si256">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, + llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>; + + def int_x86_avx_vpermil_pd : GCCBuiltin<"__builtin_ia32_vpermilpd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vpermil_ps : GCCBuiltin<"__builtin_ia32_vpermilps">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_i8_ty], [IntrNoMem]>; + + def int_x86_avx_vpermil_pd_256 : GCCBuiltin<"__builtin_ia32_vpermilpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vpermil_ps_256 : GCCBuiltin<"__builtin_ia32_vpermilps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_i8_ty], [IntrNoMem]>; +} + +// Vector blend +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_blend_pd_256 : GCCBuiltin<"__builtin_ia32_blendpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty, llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx_blend_ps_256 : GCCBuiltin<"__builtin_ia32_blendps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>; +} + +// Vector dot product +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; +} + +// Vector compare +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; +} + +// Vector extract and insert +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_vextractf128_pd_256 : + GCCBuiltin<"__builtin_ia32_vextractf128_pd256">, + Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vextractf128_ps_256 : + GCCBuiltin<"__builtin_ia32_vextractf128_ps256">, + Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vextractf128_si_256 : + GCCBuiltin<"__builtin_ia32_vextractf128_si256">, + Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>; + + def int_x86_avx_vinsertf128_pd_256 : + GCCBuiltin<"__builtin_ia32_vinsertf128_pd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, + llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vinsertf128_ps_256 : + GCCBuiltin<"__builtin_ia32_vinsertf128_ps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, + llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>; + def int_x86_avx_vinsertf128_si_256 : + GCCBuiltin<"__builtin_ia32_vinsertf128_si256">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, + llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>; +} + +// Vector convert +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>; + def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; +} + +// Vector bit test +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty, + llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty, + llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty, + llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, + llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, + llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, + llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">, + Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">, + Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">, + Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty, + llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">, + Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">, + Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">, + Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty, + llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">, + Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty, + llvm_v4i64_ty], [IntrNoMem]>; + def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">, + Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty, + llvm_v4i64_ty], [IntrNoMem]>; + def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">, + Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty, + llvm_v4i64_ty], [IntrNoMem]>; +} + +// Vector extract sign mask +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">, + Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">, + Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; +} + +// Vector zero +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">, + Intrinsic<[], [], []>; + def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">, + Intrinsic<[], [], []>; +} + +// Vector load with broadcast +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_vbroadcastss : + GCCBuiltin<"__builtin_ia32_vbroadcastss">, + Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_vbroadcast_sd_256 : + GCCBuiltin<"__builtin_ia32_vbroadcastsd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_vbroadcastss_256 : + GCCBuiltin<"__builtin_ia32_vbroadcastss256">, + Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_vbroadcastf128_pd_256 : + GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_vbroadcastf128_ps_256 : + GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>; +} + +// SIMD load ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_loadu_pd_256 : GCCBuiltin<"__builtin_ia32_loadupd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_loadu_ps_256 : GCCBuiltin<"__builtin_ia32_loadups256">, + Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_loadu_dq_256 : GCCBuiltin<"__builtin_ia32_loaddqu256">, + Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>; + def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">, + Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>; +} + +// SIMD store ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], []>; + def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], []>; + def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], []>; +} + +// Cacheability support ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_movnt_dq_256 : GCCBuiltin<"__builtin_ia32_movntdq256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty], []>; + def int_x86_avx_movnt_pd_256 : GCCBuiltin<"__builtin_ia32_movntpd256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], []>; + def int_x86_avx_movnt_ps_256 : GCCBuiltin<"__builtin_ia32_movntps256">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], []>; +} + +// Conditional load ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">, + Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2f64_ty], [IntrReadMem]>; + def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">, + Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4f32_ty], [IntrReadMem]>; + def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">, + Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadMem]>; + def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">, + Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadMem]>; +} + +// Conditional store ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v4f32_ty, llvm_v4f32_ty], []>; + def int_x86_avx_maskstore_pd_256 : + GCCBuiltin<"__builtin_ia32_maskstorepd256">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v4f64_ty, llvm_v4f64_ty], []>; + def int_x86_avx_maskstore_ps_256 : + GCCBuiltin<"__builtin_ia32_maskstoreps256">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v8f32_ty, llvm_v8f32_ty], []>; +} + +//===----------------------------------------------------------------------===// // MMX // Empty MMX state op. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_mmx_emms : GCCBuiltin<"__builtin_ia32_emms">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; def int_x86_mmx_femms : GCCBuiltin<"__builtin_ia32_femms">, - Intrinsic<[], [], [IntrWriteMem]>; + Intrinsic<[], [], []>; } // Integer arithmetic ops. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". // Addition + def int_x86_mmx_padd_b : GCCBuiltin<"__builtin_ia32_paddb">, + Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], + [IntrNoMem]>; + def int_x86_mmx_padd_w : GCCBuiltin<"__builtin_ia32_paddw">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], + [IntrNoMem]>; + def int_x86_mmx_padd_d : GCCBuiltin<"__builtin_ia32_paddd">, + Intrinsic<[llvm_v2i32_ty], [llvm_v2i32_ty, llvm_v2i32_ty], + [IntrNoMem]>; + def int_x86_mmx_padd_q : GCCBuiltin<"__builtin_ia32_paddq">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + def int_x86_mmx_padds_b : GCCBuiltin<"__builtin_ia32_paddsb">, Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], [IntrNoMem, Commutative]>; @@ -1006,6 +1355,19 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". llvm_v4i16_ty], [IntrNoMem, Commutative]>; // Subtraction + def int_x86_mmx_psub_b : GCCBuiltin<"__builtin_ia32_psubb">, + Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], + [IntrNoMem]>; + def int_x86_mmx_psub_w : GCCBuiltin<"__builtin_ia32_psubw">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], + [IntrNoMem]>; + def int_x86_mmx_psub_d : GCCBuiltin<"__builtin_ia32_psubd">, + Intrinsic<[llvm_v2i32_ty], [llvm_v2i32_ty, llvm_v2i32_ty], + [IntrNoMem]>; + def int_x86_mmx_psub_q : GCCBuiltin<"__builtin_ia32_psubq">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + def int_x86_mmx_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb">, Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], [IntrNoMem]>; @@ -1024,6 +1386,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_mmx_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw">, Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], [IntrNoMem, Commutative]>; + def int_x86_mmx_pmull_w : GCCBuiltin<"__builtin_ia32_pmullw">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, + llvm_v4i16_ty], [IntrNoMem, Commutative]>; def int_x86_mmx_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw">, Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], [IntrNoMem, Commutative]>; @@ -1034,6 +1399,20 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v2i32_ty], [llvm_v4i16_ty, llvm_v4i16_ty], [IntrNoMem, Commutative]>; + // Bitwise operations + def int_x86_mmx_pand : GCCBuiltin<"__builtin_ia32_pand">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + def int_x86_mmx_pandn : GCCBuiltin<"__builtin_ia32_pandn">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + def int_x86_mmx_por : GCCBuiltin<"__builtin_ia32_por">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + def int_x86_mmx_pxor : GCCBuiltin<"__builtin_ia32_pxor">, + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], + [IntrNoMem]>; + // Averages def int_x86_mmx_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb">, Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, @@ -1135,6 +1514,28 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". llvm_v4i16_ty], [IntrNoMem]>; } +// Unpacking ops. +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_mmx_punpckhbw : GCCBuiltin<"__builtin_ia32_punpckhbw">, + Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], + [IntrNoMem]>; + def int_x86_mmx_punpckhwd : GCCBuiltin<"__builtin_ia32_punpckhwd">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], + [IntrNoMem]>; + def int_x86_mmx_punpckhdq : GCCBuiltin<"__builtin_ia32_punpckhdq">, + Intrinsic<[llvm_v2i32_ty], [llvm_v2i32_ty, llvm_v2i32_ty], + [IntrNoMem]>; + def int_x86_mmx_punpcklbw : GCCBuiltin<"__builtin_ia32_punpcklbw">, + Intrinsic<[llvm_v8i8_ty], [llvm_v8i8_ty, llvm_v8i8_ty], + [IntrNoMem]>; + def int_x86_mmx_punpcklwd : GCCBuiltin<"__builtin_ia32_punpcklwd">, + Intrinsic<[llvm_v4i16_ty], [llvm_v4i16_ty, llvm_v4i16_ty], + [IntrNoMem]>; + def int_x86_mmx_punpckldq : GCCBuiltin<"__builtin_ia32_punpckldq">, + Intrinsic<[llvm_v2i32_ty], [llvm_v2i32_ty, llvm_v2i32_ty], + [IntrNoMem]>; +} + // Integer comparison ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_mmx_pcmpeq_b : GCCBuiltin<"__builtin_ia32_pcmpeqb">, @@ -1161,14 +1562,47 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". // Misc. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_mmx_maskmovq : GCCBuiltin<"__builtin_ia32_maskmovq">, - Intrinsic<[], - [llvm_v8i8_ty, llvm_v8i8_ty, llvm_ptr_ty], - [IntrWriteMem]>; + Intrinsic<[], [llvm_v8i8_ty, llvm_v8i8_ty, llvm_ptr_ty], []>; def int_x86_mmx_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb">, Intrinsic<[llvm_i32_ty], [llvm_v8i8_ty], [IntrNoMem]>; def int_x86_mmx_movnt_dq : GCCBuiltin<"__builtin_ia32_movntq">, - Intrinsic<[], [llvm_ptr_ty, - llvm_v1i64_ty], [IntrWriteMem]>; + Intrinsic<[], [llvm_ptr_ty, llvm_v1i64_ty], []>; + +// def int_x86_mmx_palignr_b : GCCBuiltin<"__builtin_ia32_palignr">, +// Intrinsic<[llvm_v1i64_ty], [llvm_1i64_ty, +// llvm_v1i64_ty, llvm_i8_ty], [IntrNoMem]>; + + def int_x86_mmx_pextr_w : + Intrinsic<[llvm_i32_ty], [llvm_v1i64_ty, llvm_i32_ty], + [IntrNoMem]>; + + def int_x86_mmx_pinsr_w : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, + llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; + + def int_x86_mmx_cvtsi32_si64 : + Intrinsic<[llvm_v1i64_ty], [llvm_i32_ty], [IntrNoMem]>; + def int_x86_mmx_cvtsi64_si32 : + Intrinsic<[llvm_i32_ty], [llvm_v1i64_ty], [IntrNoMem]>; + + def int_x86_mmx_vec_init_b : GCCBuiltin<"__builtin_ia32_vec_init_v8qi">, + Intrinsic<[llvm_v8i8_ty], + [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty, llvm_i8_ty, + llvm_i8_ty, llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], + [IntrNoMem]>; + def int_x86_mmx_vec_init_w : GCCBuiltin<"__builtin_ia32_vec_init_v4hi">, + Intrinsic<[llvm_v4i16_ty], + [llvm_i16_ty, llvm_i16_ty, llvm_i16_ty, llvm_i16_ty], + [IntrNoMem]>; + def int_x86_mmx_vec_init_d : GCCBuiltin<"__builtin_ia32_vec_init_v2si">, + Intrinsic<[llvm_v2i32_ty], + [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; + + def int_x86_mmx_vec_ext_d : GCCBuiltin<"__builtin_ia32_vec_ext_v2si">, + Intrinsic<[llvm_v2i32_ty], + [llvm_v2i32_ty, llvm_i32_ty], + [IntrNoMem]>; } diff --git a/contrib/llvm/include/llvm/LLVMContext.h b/contrib/llvm/include/llvm/LLVMContext.h index afae08b..7cb6579 100644 --- a/contrib/llvm/include/llvm/LLVMContext.h +++ b/contrib/llvm/include/llvm/LLVMContext.h @@ -40,7 +40,7 @@ public: // Pinned metadata names, which always have the same value. This is a // compile-time performance optimization, not a correctness optimization. enum { - MD_dbg = 1 // "dbg" -> 1. + MD_dbg = 0 // "dbg" }; /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. @@ -48,8 +48,7 @@ public: unsigned getMDKindID(StringRef Name) const; /// getMDKindNames - Populate client supplied SmallVector with the name for - /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, - /// so it is filled in as an empty string. + /// custom metadata IDs registered in this LLVMContext. void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; /// setInlineAsmDiagnosticHandler - This method sets a handler that is invoked diff --git a/contrib/llvm/include/llvm/LinkAllPasses.h b/contrib/llvm/include/llvm/LinkAllPasses.h index 876703b..35dab62 100644 --- a/contrib/llvm/include/llvm/LinkAllPasses.h +++ b/contrib/llvm/include/llvm/LinkAllPasses.h @@ -22,6 +22,7 @@ #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/PointerTracking.h" #include "llvm/Analysis/PostDominators.h" +#include "llvm/Analysis/RegionPrinter.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/Lint.h" #include "llvm/Assembly/PrintModulePass.h" @@ -52,6 +53,7 @@ namespace { (void) llvm::createBasicAliasAnalysisPass(); (void) llvm::createLibCallAliasAnalysisPass(0); (void) llvm::createScalarEvolutionAliasAnalysisPass(); + (void) llvm::createTypeBasedAliasAnalysisPass(); (void) llvm::createBlockPlacementPass(); (void) llvm::createBreakCriticalEdgesPass(); (void) llvm::createCFGSimplificationPass(); @@ -106,6 +108,11 @@ namespace { (void) llvm::createPostDomOnlyViewerPass(); (void) llvm::createPostDomViewerPass(); (void) llvm::createReassociatePass(); + (void) llvm::createRegionInfoPass(); + (void) llvm::createRegionOnlyPrinterPass(); + (void) llvm::createRegionOnlyViewerPass(); + (void) llvm::createRegionPrinterPass(); + (void) llvm::createRegionViewerPass(); (void) llvm::createSCCPPass(); (void) llvm::createScalarReplAggregatesPass(); (void) llvm::createSimplifyLibCallsPass(); @@ -135,12 +142,11 @@ namespace { (void) llvm::createDbgInfoPrinterPass(); (void) llvm::createModuleDebugInfoPrinterPass(); (void) llvm::createPartialInliningPass(); - (void) llvm::createSSIPass(); - (void) llvm::createSSIEverythingPass(); (void) llvm::createGEPSplitterPass(); - (void) llvm::createABCDPass(); (void) llvm::createLintPass(); (void) llvm::createSinkingPass(); + (void) llvm::createLowerAtomicPass(); + (void) llvm::createCorrelatedValuePropagationPass(); (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); diff --git a/contrib/llvm/include/llvm/LinkAllVMCore.h b/contrib/llvm/include/llvm/LinkAllVMCore.h index 6cf2c4b..6959cb6 100644 --- a/contrib/llvm/include/llvm/LinkAllVMCore.h +++ b/contrib/llvm/include/llvm/LinkAllVMCore.h @@ -33,7 +33,6 @@ #include "llvm/System/TimeValue.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/SlowOperationInformer.h" #include <cstdlib> namespace { diff --git a/contrib/llvm/include/llvm/Linker.h b/contrib/llvm/include/llvm/Linker.h index cc7bf88..b402a60 100644 --- a/contrib/llvm/include/llvm/Linker.h +++ b/contrib/llvm/include/llvm/Linker.h @@ -158,7 +158,6 @@ class Linker { /// @returns true if an error occurred, false otherwise /// @see LinkItemKind /// @see getLastError - /// @throws nothing bool LinkInItems ( const ItemList& Items, ///< Set of libraries/files to link in ItemList& NativeItems ///< Output list of native files/libs diff --git a/contrib/llvm/include/llvm/MC/ELFObjectWriter.h b/contrib/llvm/include/llvm/MC/ELFObjectWriter.h new file mode 100644 index 0000000..3b9951f --- /dev/null +++ b/contrib/llvm/include/llvm/MC/ELFObjectWriter.h @@ -0,0 +1,46 @@ +//===-- llvm/MC/ELFObjectWriter.h - ELF File Writer ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_ELFOBJECTWRITER_H +#define LLVM_MC_ELFOBJECTWRITER_H + +#include "llvm/MC/MCObjectWriter.h" +#include "llvm/Support/raw_ostream.h" +#include <cassert> + +namespace llvm { +class MCAsmFixup; +class MCAssembler; +class MCFragment; +class MCValue; +class raw_ostream; + +class ELFObjectWriter : public MCObjectWriter { + void *Impl; + +public: + ELFObjectWriter(raw_ostream &OS, bool Is64Bit, bool IsLittleEndian = true, + bool HasRelocationAddend = true); + + virtual ~ELFObjectWriter(); + + virtual void ExecutePostLayoutBinding(MCAssembler &Asm); + + virtual void RecordRelocation(const MCAssembler &Asm, + const MCAsmLayout &Layout, + const MCFragment *Fragment, + const MCFixup &Fixup, MCValue Target, + uint64_t &FixedValue); + + virtual void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout); +}; + +} // End llvm namespace + +#endif diff --git a/contrib/llvm/include/llvm/MC/MCAsmInfo.h b/contrib/llvm/include/llvm/MC/MCAsmInfo.h index 8516de0..43952e0 100644 --- a/contrib/llvm/include/llvm/MC/MCAsmInfo.h +++ b/contrib/llvm/include/llvm/MC/MCAsmInfo.h @@ -255,6 +255,14 @@ namespace llvm { /// DwarfSectionOffsetDirective - Special section offset directive. const char* DwarfSectionOffsetDirective; // Defaults to NULL + /// DwarfUsesAbsoluteLabelForStmtList - True if DW_AT_stmt_list needs + /// absolute label instead of offset. + bool DwarfUsesAbsoluteLabelForStmtList; // Defaults to true; + + // DwarfUsesLabelOffsetDifference - True if Dwarf2 output can + // use EmitLabelOffsetDifference. + bool DwarfUsesLabelOffsetForRanges; + //===--- CBE Asm Translation Table -----------------------------------===// const char *const *AsmTransCBE; // Defaults to empty @@ -417,6 +425,12 @@ namespace llvm { const char *getDwarfSectionOffsetDirective() const { return DwarfSectionOffsetDirective; } + bool doesDwarfUsesAbsoluteLabelForStmtList() const { + return DwarfUsesAbsoluteLabelForStmtList; + } + bool doesDwarfUsesLabelOffsetForRanges() const { + return DwarfUsesLabelOffsetForRanges; + } const char *const *getAsmCBE() const { return AsmTransCBE; } diff --git a/contrib/llvm/include/llvm/MC/MCAssembler.h b/contrib/llvm/include/llvm/MC/MCAssembler.h index 07ca070..d193b98 100644 --- a/contrib/llvm/include/llvm/MC/MCAssembler.h +++ b/contrib/llvm/include/llvm/MC/MCAssembler.h @@ -24,6 +24,7 @@ namespace llvm { class raw_ostream; class MCAsmLayout; class MCAssembler; +class MCBinaryExpr; class MCContext; class MCCodeEmitter; class MCExpr; @@ -87,6 +88,7 @@ protected: public: // Only for sentinel. MCFragment(); + virtual ~MCFragment(); FragmentType getKind() const { return Kind; } @@ -162,7 +164,7 @@ class MCInstFragment : public MCFragment { /// Inst - The instruction this is a fragment for. MCInst Inst; - /// InstSize - The size of the currently encoded instruction. + /// Code - Binary data for the currently encoded instruction. SmallString<8> Code; /// Fixups - The list of fixups in this fragment. @@ -452,6 +454,10 @@ public: // common symbol can never get a definition. uint64_t CommonSize; + /// SymbolSize - An expression describing how to calculate the size of + /// a symbol. If a symbol has no size this field will be NULL. + const MCExpr *SymbolSize; + /// CommonAlign - The alignment of the symbol, if it is 'common'. // // FIXME: Pack this in with other fields? @@ -509,6 +515,15 @@ public: return CommonSize; } + void setSize(const MCExpr *SS) { + SymbolSize = SS; + } + + const MCExpr *getSize() const { + return SymbolSize; + } + + /// getCommonAlignment - Return the alignment of a 'common' symbol. unsigned getCommonAlignment() const { assert(isCommon() && "Not a 'common' symbol!"); @@ -649,6 +664,8 @@ public: void WriteSectionData(const MCSectionData *Section, const MCAsmLayout &Layout, MCObjectWriter *OW) const; + void AddSectionToTheEnd(MCSectionData &SD, MCAsmLayout &Layout); + public: /// Construct a new assembler instance. /// @@ -669,7 +686,9 @@ public: MCCodeEmitter &getEmitter() const { return Emitter; } /// Finish - Do final processing and write the object to the output stream. - void Finish(); + /// \arg Writer is used for custom object writer (as the MCJIT does), + /// if not specified it is automatically created from backend. + void Finish(MCObjectWriter *Writer = 0); // FIXME: This does not belong here. bool getSubsectionsViaSymbols() const { diff --git a/contrib/llvm/include/llvm/MC/MCContext.h b/contrib/llvm/include/llvm/MC/MCContext.h index a57b5bf..d22868c 100644 --- a/contrib/llvm/include/llvm/MC/MCContext.h +++ b/contrib/llvm/include/llvm/MC/MCContext.h @@ -11,10 +11,12 @@ #define LLVM_MC_MCCONTEXT_H #include "llvm/MC/SectionKind.h" +#include "llvm/MC/MCDwarf.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/raw_ostream.h" +#include <vector> // FIXME: Shouldn't be needed. namespace llvm { class MCAsmInfo; @@ -22,6 +24,9 @@ namespace llvm { class MCSection; class MCSymbol; class MCLabel; + class MCDwarfFile; + class MCDwarfLoc; + class MCLineSection; class StringRef; class Twine; class MCSectionMachO; @@ -35,9 +40,6 @@ namespace llvm { /// The MCAsmInfo for this target. const MCAsmInfo &MAI; - - /// Sections - Bindings of names to allocated sections. - StringMap<MCSection*> Sections; /// Symbols - Bindings of names to symbols. StringMap<MCSymbol*> Symbols; @@ -66,6 +68,18 @@ namespace llvm { /// .secure_log_reset appearing between them. bool SecureLogUsed; + /// The dwarf file and directory tables from the dwarf .file directive. + std::vector<MCDwarfFile *> MCDwarfFiles; + std::vector<StringRef> MCDwarfDirs; + + /// The current dwarf line information from the last dwarf .loc directive. + MCDwarfLoc CurrentDwarfLoc; + bool DwarfLocSeen; + + /// The dwarf line information from the .loc directives for the sections + /// with assembled machine instructions have after seeing .loc directives. + DenseMap<const MCSection *, MCLineSection *> MCLineSections; + /// Allocator - Allocator object used for creating machine code objects. /// /// We use a bump pointer allocator to avoid the need to track all allocated @@ -126,7 +140,8 @@ namespace llvm { const MCSection *getELFSection(StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind, - bool IsExplicit = false); + bool IsExplicit = false, + unsigned EntrySize = 0); const MCSection *getCOFFSection(StringRef Section, unsigned Characteristics, int Selection, SectionKind Kind); @@ -139,6 +154,43 @@ namespace llvm { /// @} + /// @name Dwarf Managment + /// @{ + + /// GetDwarfFile - creates an entry in the dwarf file and directory tables. + unsigned GetDwarfFile(StringRef FileName, unsigned FileNumber); + + bool ValidateDwarfFileNumber(unsigned FileNumber); + + const std::vector<MCDwarfFile *> &getMCDwarfFiles() { + return MCDwarfFiles; + } + const std::vector<StringRef> &getMCDwarfDirs() { + return MCDwarfDirs; + } + DenseMap<const MCSection *, MCLineSection *> &getMCLineSections() { + return MCLineSections; + } + + /// setCurrentDwarfLoc - saves the information from the currently parsed + /// dwarf .loc directive and sets DwarfLocSeen. When the next instruction /// is assembled an entry in the line number table with this information and + /// the address of the instruction will be created. + void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, + unsigned Flags, unsigned Isa) { + CurrentDwarfLoc.setFileNum(FileNum); + CurrentDwarfLoc.setLine(Line); + CurrentDwarfLoc.setColumn(Column); + CurrentDwarfLoc.setFlags(Flags); + CurrentDwarfLoc.setIsa(Isa); + DwarfLocSeen = true; + } + void clearDwarfLocSeen() { DwarfLocSeen = false; } + + bool getDwarfLocSeen() { return DwarfLocSeen; } + const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; } + + /// @} + char *getSecureLogFile() { return SecureLogFile; } raw_ostream *getSecureLog() { return SecureLog; } bool getSecureLogUsed() { return SecureLogUsed; } diff --git a/contrib/llvm/include/llvm/MC/MCDwarf.h b/contrib/llvm/include/llvm/MC/MCDwarf.h new file mode 100644 index 0000000..dac875c --- /dev/null +++ b/contrib/llvm/include/llvm/MC/MCDwarf.h @@ -0,0 +1,156 @@ +//===- MCDwarf.h - Machine Code Dwarf support -------------------*- 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 the declaration of the MCDwarfFile to support the dwarf +// .file directive. +// TODO: add the support needed for the .loc directive. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_MCDWARF_H +#define LLVM_MC_MCDWARF_H + +#include "llvm/ADT/StringRef.h" +#include <vector> + +namespace llvm { + class MCContext; + class MCSection; + class MCSymbol; + class raw_ostream; + + /// MCDwarfFile - Instances of this class represent the name of the dwarf + /// .file directive and its associated dwarf file number in the MC file, + /// and MCDwarfFile's are created and unique'd by the MCContext class where + /// the file number for each is its index into the vector of DwarfFiles (note + /// index 0 is not used and not a valid dwarf file number). + class MCDwarfFile { + // Name - the base name of the file without its directory path. + // The StringRef references memory allocated in the MCContext. + StringRef Name; + + // DirIndex - the index into the list of directory names for this file name. + unsigned DirIndex; + + private: // MCContext creates and uniques these. + friend class MCContext; + MCDwarfFile(StringRef name, unsigned dirIndex) + : Name(name), DirIndex(dirIndex) {} + + MCDwarfFile(const MCDwarfFile&); // DO NOT IMPLEMENT + void operator=(const MCDwarfFile&); // DO NOT IMPLEMENT + public: + /// getName - Get the base name of this MCDwarfFile. + StringRef getName() const { return Name; } + + /// getDirIndex - Get the dirIndex of this MCDwarfFile. + unsigned getDirIndex() const { return DirIndex; } + + + /// print - Print the value to the stream \arg OS. + void print(raw_ostream &OS) const; + + /// dump - Print the value to stderr. + void dump() const; + }; + + inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){ + DwarfFile.print(OS); + return OS; + } + + /// MCDwarfLoc - Instances of this class represent the information from a + /// dwarf .loc directive. + class MCDwarfLoc { + // FileNum - the file number. + unsigned FileNum; + // Line - the line number. + unsigned Line; + // Column - the column position. + unsigned Column; + // Flags (see #define's below) + unsigned Flags; + // Isa + unsigned Isa; + +#define DWARF2_FLAG_IS_STMT (1 << 0) +#define DWARF2_FLAG_BASIC_BLOCK (1 << 1) +#define DWARF2_FLAG_PROLOGUE_END (1 << 2) +#define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3) + + private: // MCContext manages these + friend class MCContext; + friend class MCLineEntry; + MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags, + unsigned isa) + : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa) {} + + // Allow the default copy constructor and assignment operator to be used + // for an MCDwarfLoc object. + + public: + /// setFileNum - Set the FileNum of this MCDwarfLoc. + void setFileNum(unsigned fileNum) { FileNum = fileNum; } + + /// setLine - Set the Line of this MCDwarfLoc. + void setLine(unsigned line) { Line = line; } + + /// setColumn - Set the Column of this MCDwarfLoc. + void setColumn(unsigned column) { Column = column; } + + /// setFlags - Set the Flags of this MCDwarfLoc. + void setFlags(unsigned flags) { Flags = flags; } + + /// setIsa - Set the Isa of this MCDwarfLoc. + void setIsa(unsigned isa) { Isa = isa; } + }; + + /// MCLineEntry - Instances of this class represent the line information for + /// the dwarf line table entries. Which is created after a machine + /// instruction is assembled and uses an address from a temporary label + /// created at the current address in the current section and the info from + /// the last .loc directive seen as stored in the context. + class MCLineEntry : public MCDwarfLoc { + MCSymbol *Label; + + private: + // Allow the default copy constructor and assignment operator to be used + // for an MCLineEntry object. + + public: + // Constructor to create an MCLineEntry given a symbol and the dwarf loc. + MCLineEntry(MCSymbol *label, const MCDwarfLoc loc) : MCDwarfLoc(loc), + Label(label) {} + }; + + /// MCLineSection - Instances of this class represent the line information + /// for a section where machine instructions have been assembled after seeing + /// .loc directives. This is the information used to build the dwarf line + /// table for a section. + class MCLineSection { + std::vector<MCLineEntry> MCLineEntries; + + private: + MCLineSection(const MCLineSection&); // DO NOT IMPLEMENT + void operator=(const MCLineSection&); // DO NOT IMPLEMENT + + public: + // Constructor to create an MCLineSection with an empty MCLineEntries + // vector. + MCLineSection() {} + + // addLineEntry - adds an entry to this MCLineSection's line entries + void addLineEntry(const MCLineEntry &LineEntry) { + MCLineEntries.push_back(LineEntry); + } + }; + +} // end namespace llvm + +#endif diff --git a/contrib/llvm/include/llvm/MC/MCELFSymbolFlags.h b/contrib/llvm/include/llvm/MC/MCELFSymbolFlags.h new file mode 100644 index 0000000..eb7978b --- /dev/null +++ b/contrib/llvm/include/llvm/MC/MCELFSymbolFlags.h @@ -0,0 +1,54 @@ +//===- MCELFSymbolFlags.h - ELF Symbol Flags ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the SymbolFlags used for the ELF target. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_MCELFSYMBOLFLAGS_H +#define LLVM_MC_MCELFSYMBOLFLAGS_H + +#include "llvm/Support/ELF.h" + +// Because all the symbol flags need to be stored in the MCSymbolData +// 'flags' variable we need to provide shift constants per flag type. + +namespace llvm { + enum { + ELF_STT_Shift = 0, // Shift value for STT_* flags. + ELF_STB_Shift = 4, // Shift value for STB_* flags. + ELF_STV_Shift = 8 // Shift value ofr STV_* flags. + }; + + enum SymbolFlags { + ELF_STB_Local = (ELF::STB_LOCAL << ELF_STB_Shift), + ELF_STB_Global = (ELF::STB_GLOBAL << ELF_STB_Shift), + ELF_STB_Weak = (ELF::STB_WEAK << ELF_STB_Shift), + ELF_STB_Loproc = (ELF::STB_LOPROC << ELF_STB_Shift), + ELF_STB_Hiproc = (ELF::STB_HIPROC << ELF_STB_Shift), + + ELF_STT_Notype = (ELF::STT_NOTYPE << ELF_STT_Shift), + ELF_STT_Object = (ELF::STT_OBJECT << ELF_STT_Shift), + ELF_STT_Func = (ELF::STT_FUNC << ELF_STT_Shift), + ELF_STT_Section = (ELF::STT_SECTION << ELF_STT_Shift), + ELF_STT_File = (ELF::STT_FILE << ELF_STT_Shift), + ELF_STT_Common = (ELF::STT_COMMON << ELF_STT_Shift), + ELF_STT_Tls = (ELF::STT_TLS << ELF_STT_Shift), + ELF_STT_Loproc = (ELF::STT_LOPROC << ELF_STT_Shift), + ELF_STT_Hiproc = (ELF::STT_HIPROC << ELF_STT_Shift), + + ELF_STV_Default = (ELF::STV_DEFAULT << ELF_STV_Shift), + ELF_STV_Internal = (ELF::STV_INTERNAL << ELF_STV_Shift), + ELF_STV_Hidden = (ELF::STV_HIDDEN << ELF_STV_Shift), + ELF_STV_Protected = (ELF::STV_PROTECTED << ELF_STV_Shift) + }; + +} // end namespace llvm + +#endif diff --git a/contrib/llvm/include/llvm/MC/MCObjectStreamer.h b/contrib/llvm/include/llvm/MC/MCObjectStreamer.h index 7b9ff00..ea6d9c1 100644 --- a/contrib/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/contrib/llvm/include/llvm/MC/MCObjectStreamer.h @@ -16,6 +16,9 @@ namespace llvm { class MCAssembler; class MCCodeEmitter; class MCSectionData; +class MCExpr; +class MCFragment; +class MCDataFragment; class TargetAsmBackend; class raw_ostream; @@ -39,6 +42,14 @@ protected: return CurSectionData; } + MCFragment *getCurrentFragment() const; + + /// Get a data fragment to write into, creating a new one if the current + /// fragment is not a data fragment. + MCDataFragment *getOrCreateDataFragment() const; + + const MCExpr *AddValueSymbols(const MCExpr *Value); + public: MCAssembler &getAssembler() { return *Assembler; } diff --git a/contrib/llvm/include/llvm/MC/MCObjectWriter.h b/contrib/llvm/include/llvm/MC/MCObjectWriter.h index 22eea7e..f1c1cb8 100644 --- a/contrib/llvm/include/llvm/MC/MCObjectWriter.h +++ b/contrib/llvm/include/llvm/MC/MCObjectWriter.h @@ -162,7 +162,7 @@ public: /// @} }; -MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS); +MCObjectWriter *createWinCOFFObjectWriter(raw_ostream &OS, bool is64Bit); } // End llvm namespace diff --git a/contrib/llvm/include/llvm/MC/MCParser/AsmParser.h b/contrib/llvm/include/llvm/MC/MCParser/AsmParser.h deleted file mode 100644 index 0e8570a..0000000 --- a/contrib/llvm/include/llvm/MC/MCParser/AsmParser.h +++ /dev/null @@ -1,152 +0,0 @@ -//===- AsmParser.h - Parser for Assembly Files ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class declares the parser for assembly files. -// -//===----------------------------------------------------------------------===// - -#ifndef ASMPARSER_H -#define ASMPARSER_H - -#include "llvm/MC/MCParser/AsmLexer.h" -#include "llvm/MC/MCParser/AsmCond.h" -#include "llvm/MC/MCParser/MCAsmParser.h" -#include "llvm/MC/MCSectionMachO.h" -#include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/ADT/StringMap.h" -#include <vector> - -namespace llvm { -class AsmCond; -class AsmToken; -class MCAsmParserExtension; -class MCContext; -class MCExpr; -class MCInst; -class MCStreamer; -class MCAsmInfo; -class SourceMgr; -class TargetAsmParser; -class Twine; - -class AsmParser : public MCAsmParser { - AsmParser(const AsmParser &); // DO NOT IMPLEMENT - void operator=(const AsmParser &); // DO NOT IMPLEMENT -private: - AsmLexer Lexer; - MCContext &Ctx; - MCStreamer &Out; - SourceMgr &SrcMgr; - MCAsmParserExtension *GenericParser; - MCAsmParserExtension *PlatformParser; - TargetAsmParser *TargetParser; - - /// This is the current buffer index we're lexing from as managed by the - /// SourceMgr object. - int CurBuffer; - - AsmCond TheCondState; - std::vector<AsmCond> TheCondStack; - - /// DirectiveMap - This is a table handlers for directives. Each handler is - /// invoked after the directive identifier is read and is responsible for - /// parsing and validating the rest of the directive. The handler is passed - /// in the directive name and the location of the directive keyword. - StringMap<std::pair<MCAsmParserExtension*, DirectiveHandler> > DirectiveMap; -public: - AsmParser(const Target &T, SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, - const MCAsmInfo &MAI); - ~AsmParser(); - - bool Run(bool NoInitialTextSection, bool NoFinalize = false); - - void AddDirectiveHandler(MCAsmParserExtension *Object, - StringRef Directive, - DirectiveHandler Handler) { - DirectiveMap[Directive] = std::make_pair(Object, Handler); - } - -public: - TargetAsmParser &getTargetParser() const { return *TargetParser; } - void setTargetParser(TargetAsmParser &P); - - /// @name MCAsmParser Interface - /// { - - virtual SourceMgr &getSourceManager() { return SrcMgr; } - virtual MCAsmLexer &getLexer() { return Lexer; } - virtual MCContext &getContext() { return Ctx; } - virtual MCStreamer &getStreamer() { return Out; } - - virtual void Warning(SMLoc L, const Twine &Meg); - virtual bool Error(SMLoc L, const Twine &Msg); - - const AsmToken &Lex(); - - bool ParseExpression(const MCExpr *&Res); - virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc); - virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc); - virtual bool ParseAbsoluteExpression(int64_t &Res); - - /// } - -private: - bool ParseStatement(); - - void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type) const; - - /// EnterIncludeFile - Enter the specified file. This returns true on failure. - bool EnterIncludeFile(const std::string &Filename); - - void EatToEndOfStatement(); - - bool ParseAssignment(StringRef Name); - - bool ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc); - bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res, SMLoc &EndLoc); - bool ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc); - - /// ParseIdentifier - Parse an identifier or string (as a quoted identifier) - /// and set \arg Res to the identifier contents. - bool ParseIdentifier(StringRef &Res); - - // Directive Parsing. - bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz" - bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ... - bool ParseDirectiveFill(); // ".fill" - bool ParseDirectiveSpace(); // ".space" - bool ParseDirectiveSet(); // ".set" - bool ParseDirectiveOrg(); // ".org" - // ".align{,32}", ".p2align{,w,l}" - bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize); - - /// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which - /// accepts a single symbol (which should be a label or an external). - bool ParseDirectiveSymbolAttribute(MCSymbolAttr Attr); - bool ParseDirectiveELFType(); // ELF specific ".type" - - bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm" - - bool ParseDirectiveAbort(); // ".abort" - bool ParseDirectiveInclude(); // ".include" - - bool ParseDirectiveIf(SMLoc DirectiveLoc); // ".if" - bool ParseDirectiveElseIf(SMLoc DirectiveLoc); // ".elseif" - bool ParseDirectiveElse(SMLoc DirectiveLoc); // ".else" - bool ParseDirectiveEndIf(SMLoc DirectiveLoc); // .endif - - /// ParseEscapedString - Parse the current token as a string which may include - /// escaped characters and return the string contents. - bool ParseEscapedString(std::string &Data); -}; - -} // end namespace llvm - -#endif diff --git a/contrib/llvm/include/llvm/MC/MCParser/MCAsmParser.h b/contrib/llvm/include/llvm/MC/MCParser/MCAsmParser.h index d0ccd0f..b37d46c 100644 --- a/contrib/llvm/include/llvm/MC/MCParser/MCAsmParser.h +++ b/contrib/llvm/include/llvm/MC/MCParser/MCAsmParser.h @@ -14,6 +14,7 @@ namespace llvm { class AsmToken; +class MCAsmInfo; class MCAsmLexer; class MCAsmParserExtension; class MCContext; @@ -22,17 +23,24 @@ class MCStreamer; class SMLoc; class SourceMgr; class StringRef; +class Target; +class TargetAsmParser; class Twine; /// MCAsmParser - Generic assembler parser interface, for use by target specific /// assembly parsers. class MCAsmParser { public: - typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc); + typedef bool (*DirectiveHandler)(MCAsmParserExtension*, StringRef, SMLoc); private: MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT void operator=(const MCAsmParser &); // DO NOT IMPLEMENT + + TargetAsmParser *TargetParser; + + unsigned ShowParsedOperands : 1; + protected: // Can only create subclasses. MCAsmParser(); @@ -52,6 +60,15 @@ public: /// getStreamer - Return the output streamer for the assembler. virtual MCStreamer &getStreamer() = 0; + TargetAsmParser &getTargetParser() const { return *TargetParser; } + void setTargetParser(TargetAsmParser &P); + + bool getShowParsedOperands() const { return ShowParsedOperands; } + void setShowParsedOperands(bool Value) { ShowParsedOperands = Value; } + + /// Run - Run the parser on the input source buffer. + virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0; + /// Warning - Emit a warning at the location \arg L, with the message \arg /// Msg. virtual void Warning(SMLoc L, const Twine &Msg) = 0; @@ -71,12 +88,17 @@ public: const AsmToken &getTok(); /// \brief Report an error at the current lexer location. - bool TokError(const char *Msg); + bool TokError(const Twine &Msg); /// ParseIdentifier - Parse an identifier or string (as a quoted identifier) /// and set \arg Res to the identifier contents. virtual bool ParseIdentifier(StringRef &Res) = 0; + /// \brief Parse up to the end of statement and return the contents from the + /// current token until the end of the statement; the current token on exit + /// will be either the EndOfStatement or EOF. + virtual StringRef ParseStringToEndOfStatement() = 0; + /// ParseExpression - Parse an arbitrary expression. /// /// @param Res - The value of the expression. The result is undefined @@ -102,6 +124,10 @@ public: virtual bool ParseAbsoluteExpression(int64_t &Res) = 0; }; +/// \brief Create an MCAsmParser instance. +MCAsmParser *createMCAsmParser(const Target &, SourceMgr &, MCContext &, + MCStreamer &, const MCAsmInfo &); + } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h b/contrib/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h index ad9ccf7..95184cd 100644 --- a/contrib/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h +++ b/contrib/llvm/include/llvm/MC/MCParser/MCAsmParserExtension.h @@ -11,9 +11,11 @@ #define LLVM_MC_MCASMPARSEREXTENSION_H #include "llvm/MC/MCParser/MCAsmParser.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/SMLoc.h" namespace llvm { +class Twine; /// \brief Generic interface for extending the MCAsmParser, /// which is implemented by target and object file assembly parser @@ -27,6 +29,15 @@ class MCAsmParserExtension { protected: MCAsmParserExtension(); + // Helper template for implementing static dispatch functions. + template<typename T, bool (T::*Handler)(StringRef, SMLoc)> + static bool HandleDirective(MCAsmParserExtension *Target, + StringRef Directive, + SMLoc DirectiveLoc) { + T *Obj = static_cast<T*>(Target); + return (Obj->*Handler)(Directive, DirectiveLoc); + } + public: virtual ~MCAsmParserExtension(); @@ -49,15 +60,14 @@ public: bool Error(SMLoc L, const Twine &Msg) { return getParser().Error(L, Msg); } + bool TokError(const Twine &Msg) { + return getParser().TokError(Msg); + } const AsmToken &Lex() { return getParser().Lex(); } const AsmToken &getTok() { return getParser().getTok(); } - bool TokError(const char *Msg) { - return getParser().TokError(Msg); - } - /// @} }; diff --git a/contrib/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h b/contrib/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h index 7c2f5be..99fa5ad 100644 --- a/contrib/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h +++ b/contrib/llvm/include/llvm/MC/MCParser/MCParsedAsmOperand.h @@ -12,6 +12,7 @@ namespace llvm { class SMLoc; +class raw_ostream; /// MCParsedAsmOperand - This abstract class represents a source-level assembly /// instruction operand. It should be subclassed by target-specific code. This @@ -23,9 +24,12 @@ public: virtual ~MCParsedAsmOperand() {} /// getStartLoc - Get the location of the first token of this operand. - virtual SMLoc getStartLoc() const; + virtual SMLoc getStartLoc() const = 0; /// getEndLoc - Get the location of the last token of this operand. - virtual SMLoc getEndLoc() const; + virtual SMLoc getEndLoc() const = 0; + + /// dump - Print a debug representation of the operand to the given stream. + virtual void dump(raw_ostream &OS) const = 0; }; } // end namespace llvm. diff --git a/contrib/llvm/include/llvm/MC/MCSectionELF.h b/contrib/llvm/include/llvm/MC/MCSectionELF.h index 5fe8171..5de0bf5 100644 --- a/contrib/llvm/include/llvm/MC/MCSectionELF.h +++ b/contrib/llvm/include/llvm/MC/MCSectionELF.h @@ -35,13 +35,18 @@ class MCSectionELF : public MCSection { /// IsExplicit - Indicates that this section comes from globals with an /// explicit section specified. bool IsExplicit; + + /// EntrySize - The size of each entry in this section. This size only + /// makes sense for sections that contain fixed-sized entries. If a + /// section does not contain fixed-sized entries 'EntrySize' will be 0. + unsigned EntrySize; private: friend class MCContext; MCSectionELF(StringRef Section, unsigned type, unsigned flags, - SectionKind K, bool isExplicit) + SectionKind K, bool isExplicit, unsigned entrySize) : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags), - IsExplicit(isExplicit) {} + IsExplicit(isExplicit), EntrySize(entrySize) {} ~MCSectionELF(); public: @@ -169,6 +174,7 @@ public: StringRef getSectionName() const { return SectionName; } unsigned getType() const { return Type; } unsigned getFlags() const { return Flags; } + unsigned getEntrySize() const { return EntrySize; } void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; diff --git a/contrib/llvm/include/llvm/MC/MCStreamer.h b/contrib/llvm/include/llvm/MC/MCStreamer.h index aca7dd3..1ce1b0e 100644 --- a/contrib/llvm/include/llvm/MC/MCStreamer.h +++ b/contrib/llvm/include/llvm/MC/MCStreamer.h @@ -54,6 +54,10 @@ namespace llvm { /// kept up to date by SwitchSection. const MCSection *CurSection; + /// PrevSection - This is the previous section code is being emitted to, it is + /// kept up to date by SwitchSection. + const MCSection *PrevSection; + public: virtual ~MCStreamer(); @@ -96,6 +100,10 @@ namespace llvm { /// emitting code to. const MCSection *getCurrentSection() const { return CurSection; } + /// getPreviousSection - Return the previous section that the streamer is + /// emitting code to. + const MCSection *getPreviousSection() const { return PrevSection; } + /// SwitchSection - Set the current section where code is being emitted to /// @p Section. This is required to update CurSection. /// @@ -217,12 +225,13 @@ namespace llvm { /// @param Size - The size of the integer (in bytes) to emit. This must /// match a native machine width. virtual void EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) = 0; + unsigned AddrSpace = 0) = 0; /// EmitIntValue - Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. - virtual void EmitIntValue(uint64_t Value, unsigned Size,unsigned AddrSpace); - + virtual void EmitIntValue(uint64_t Value, unsigned Size, + unsigned AddrSpace = 0); + /// EmitSymbolValue - Special case of EmitValue that avoids the client /// having to pass in a MCExpr for MCSymbols. virtual void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, @@ -331,7 +340,7 @@ namespace llvm { /// InstPrint. /// /// \param CE - If given, a code emitter to use to show the instruction - /// encoding inline with the assembly. + /// encoding inline with the assembly. This method takes ownership of \arg CE. /// /// \param ShowInst - Whether to show the MCInst representation inline with /// the assembly. @@ -343,15 +352,26 @@ namespace llvm { /// createMachOStreamer - Create a machine code streamer which will generate /// Mach-O format object files. + /// + /// Takes ownership of \arg TAB and \arg CE. MCStreamer *createMachOStreamer(MCContext &Ctx, TargetAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll = false); /// createWinCOFFStreamer - Create a machine code streamer which will /// generate Microsoft COFF format object files. + /// + /// Takes ownership of \arg TAB and \arg CE. MCStreamer *createWinCOFFStreamer(MCContext &Ctx, TargetAsmBackend &TAB, - MCCodeEmitter &CE, raw_ostream &OS); + MCCodeEmitter &CE, raw_ostream &OS, + bool RelaxAll = false); + + /// createELFStreamer - Create a machine code streamer which will generate + /// ELF format object files. + MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE, + bool RelaxAll = false); /// createLoggingStreamer - Create a machine code streamer which just logs the /// API calls and then dispatches to another streamer. diff --git a/contrib/llvm/include/llvm/Metadata.h b/contrib/llvm/include/llvm/Metadata.h index 64ab6b7..f5a80a3 100644 --- a/contrib/llvm/include/llvm/Metadata.h +++ b/contrib/llvm/include/llvm/Metadata.h @@ -38,7 +38,6 @@ class MDString : public Value { MDString(const MDString &); // DO NOT IMPLEMENT StringRef Str; -protected: explicit MDString(LLVMContext &C, StringRef S); public: @@ -111,9 +110,8 @@ class MDNode : public Value, public FoldingSetNode { void replaceOperand(MDNodeOperand *Op, Value *NewVal); ~MDNode(); -protected: - explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, - bool isFunctionLocal); + MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, + bool isFunctionLocal); static MDNode *getMDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, FunctionLocalness FL, bool Insert = true); @@ -128,6 +126,16 @@ public: static MDNode *getIfExists(LLVMContext &Context, Value *const *Vals, unsigned NumVals); + + /// getTemporary - Return a temporary MDNode, for use in constructing + /// cyclic MDNode structures. A temporary MDNode is not uniqued, + /// may be RAUW'd, and must be manually deleted with deleteTemporary. + static MDNode *getTemporary(LLVMContext &Context, Value *const *Vals, + unsigned NumVals); + + /// deleteTemporary - Deallocate a node created by getTemporary. The + /// node must not have any users. + static void deleteTemporary(MDNode *N); /// getOperand - Return specified operand. Value *getOperand(unsigned i) const; @@ -149,9 +157,6 @@ public: // critical code because it recursively visits all the MDNode's operands. const Function *getFunction() const; - // destroy - Delete this node. Only when there are no uses. - void destroy(); - /// Profile - calculate a unique identifier for this MDNode to collapse /// duplicates void Profile(FoldingSetNodeID &ID) const; @@ -162,6 +167,9 @@ public: return V->getValueID() == MDNodeVal; } private: + // destroy - Delete this node. Only when there are no uses. + void destroy(); + bool isNotUniqued() const { return (getSubclassDataFromValue() & NotUniquedBit) != 0; } @@ -175,31 +183,25 @@ private: }; //===----------------------------------------------------------------------===// -/// NamedMDNode - a tuple of MDNodes. -/// NamedMDNode is always named. All NamedMDNode operand has a type of metadata. -class NamedMDNode : public Value, public ilist_node<NamedMDNode> { +/// NamedMDNode - a tuple of MDNodes. Despite its name, a NamedMDNode isn't +/// itself an MDNode. NamedMDNodes belong to modules, have names, and contain +/// lists of MDNodes. +class NamedMDNode : public ilist_node<NamedMDNode> { friend class SymbolTableListTraits<NamedMDNode, Module>; friend struct ilist_traits<NamedMDNode>; friend class LLVMContextImpl; + friend class Module; NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT std::string Name; Module *Parent; - void *Operands; // SmallVector<WeakVH<MDNode>, 4> + void *Operands; // SmallVector<TrackingVH<MDNode>, 4> void setParent(Module *M) { Parent = M; } -protected: - explicit NamedMDNode(LLVMContext &C, const Twine &N, MDNode*const *Vals, - unsigned NumVals, Module *M = 0); -public: - static NamedMDNode *Create(LLVMContext &C, const Twine &N, - MDNode *const *MDs, - unsigned NumMDs, Module *M = 0) { - return new NamedMDNode(C, N, MDs, NumMDs, M); - } - static NamedMDNode *Create(const NamedMDNode *NMD, Module *M = 0); + explicit NamedMDNode(const Twine &N); +public: /// eraseFromParent - Drop all references and remove the node from parent /// module. void eraseFromParent(); @@ -223,17 +225,11 @@ public: /// addOperand - Add metadata operand. void addOperand(MDNode *M); - /// setName - Set the name of this named metadata. - void setName(const Twine &NewName); - /// getName - Return a constant reference to this named metadata's name. StringRef getName() const; - /// 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) { - return V->getValueID() == NamedMDNodeVal; - } + /// print - Implement operator<< on NamedMDNode. + void print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW = 0) const; }; } // end llvm namespace diff --git a/contrib/llvm/include/llvm/Module.h b/contrib/llvm/include/llvm/Module.h index 5fc0418..b7880ca 100644 --- a/contrib/llvm/include/llvm/Module.h +++ b/contrib/llvm/include/llvm/Module.h @@ -28,7 +28,6 @@ namespace llvm { class FunctionType; class GVMaterializer; class LLVMContext; -class MDSymbolTable; template<> struct ilist_traits<Function> : public SymbolTableListTraits<Function, Module> { @@ -61,7 +60,7 @@ template<> struct ilist_traits<GlobalAlias> }; template<> struct ilist_traits<NamedMDNode> - : public SymbolTableListTraits<NamedMDNode, Module> { + : public ilist_default_traits<NamedMDNode> { // createSentinel is used to get hold of a node that marks the end of // the list... NamedMDNode *createSentinel() const { @@ -72,8 +71,8 @@ template<> struct ilist_traits<NamedMDNode> NamedMDNode *provideInitialHead() const { return createSentinel(); } NamedMDNode *ensureHead(NamedMDNode*) const { return createSentinel(); } static void noteHead(NamedMDNode*, NamedMDNode*) {} - void addNodeToList(NamedMDNode *N); - void removeNodeFromList(NamedMDNode *N); + void addNodeToList(NamedMDNode *) {} + void removeNodeFromList(NamedMDNode *) {} private: mutable ilist_node<NamedMDNode> Sentinel; }; @@ -100,7 +99,7 @@ public: /// The type for the list of aliases. typedef iplist<GlobalAlias> AliasListType; /// The type for the list of named metadata. - typedef iplist<NamedMDNode> NamedMDListType; + typedef ilist<NamedMDNode> NamedMDListType; /// The type for the list of dependent libraries. typedef std::vector<std::string> LibraryListType; @@ -151,7 +150,7 @@ private: std::string ModuleID; ///< Human readable identifier for the module std::string TargetTriple; ///< Platform target triple Module compiled on std::string DataLayout; ///< Target data description - MDSymbolTable *NamedMDSymTab; ///< NamedMDNode names. + void *NamedMDSymTab; ///< NamedMDNode names. friend class Constant; @@ -237,8 +236,7 @@ public: unsigned getMDKindID(StringRef Name) const; /// getMDKindNames - Populate client supplied SmallVector with the name for - /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, - /// so it is filled in as an empty string. + /// custom metadata IDs registered in this LLVMContext. void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; /// @} @@ -332,6 +330,10 @@ public: /// NamedMDNode with the specified name is not found. NamedMDNode *getOrInsertNamedMetadata(StringRef Name); + /// eraseNamedMetadata - Remove the given NamedMDNode from this module + /// and delete it. + void eraseNamedMetadata(NamedMDNode *NMD); + /// @} /// @name Type Accessors /// @{ @@ -418,13 +420,6 @@ public: static iplist<GlobalAlias> Module::*getSublistAccess(GlobalAlias*) { return &Module::AliasList; } - /// Get the Module's list of named metadata (constant). - const NamedMDListType &getNamedMDList() const { return NamedMDList; } - /// Get the Module's list of named metadata. - NamedMDListType &getNamedMDList() { return NamedMDList; } - static iplist<NamedMDNode> Module::*getSublistAccess(NamedMDNode *) { - return &Module::NamedMDList; - } /// Get the symbol table of global variable and function identifiers const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; } /// Get the Module's symbol table of global variable and function identifiers. @@ -433,10 +428,6 @@ public: const TypeSymbolTable &getTypeSymbolTable() const { return *TypeSymTab; } /// Get the Module's symbol table of types TypeSymbolTable &getTypeSymbolTable() { return *TypeSymTab; } - /// Get the symbol table of named metadata - const MDSymbolTable &getMDSymbolTable() const { return *NamedMDSymTab; } - /// Get the Module's symbol table of named metadata - MDSymbolTable &getMDSymbolTable() { return *NamedMDSymTab; } /// @} /// @name Global Variable Iteration diff --git a/contrib/llvm/include/llvm/Pass.h b/contrib/llvm/include/llvm/Pass.h index 5a58931..f4c6eed 100644 --- a/contrib/llvm/include/llvm/Pass.h +++ b/contrib/llvm/include/llvm/Pass.h @@ -29,11 +29,7 @@ #ifndef LLVM_PASS_H #define LLVM_PASS_H -#include "llvm/System/DataTypes.h" - #include <string> -#include <utility> -#include <vector> namespace llvm { @@ -50,7 +46,7 @@ class raw_ostream; class StringRef; // AnalysisID - Use the PassInfo to identify a pass... -typedef const PassInfo* AnalysisID; +typedef const void* AnalysisID; /// Different types of internal pass managers. External pass managers /// (PassManager and FunctionPassManager) are not represented here. @@ -82,14 +78,13 @@ enum PassKind { /// class Pass { AnalysisResolver *Resolver; // Used to resolve analysis - intptr_t PassID; + const void *PassID; PassKind Kind; void operator=(const Pass&); // DO NOT IMPLEMENT Pass(const Pass &); // DO NOT IMPLEMENT public: - explicit Pass(PassKind K, intptr_t pid); - explicit Pass(PassKind K, const void *pid); + explicit Pass(PassKind K, char &pid); virtual ~Pass(); @@ -101,10 +96,10 @@ public: /// virtual const char *getPassName() const; - /// getPassInfo - Return the PassInfo data structure that corresponds to this - /// pass... If the pass has not been registered, this will return null. - /// - const PassInfo *getPassInfo() const; + /// getPassID - Return the PassID number that corresponds to this pass. + virtual AnalysisID getPassID() const { + return PassID; + } /// print - Print out the internal state of the pass. This is called by /// Analyze to print out the contents of an analysis. Otherwise it is not @@ -124,7 +119,7 @@ public: /// Each pass is responsible for assigning a pass manager to itself. /// PMS is the stack of available pass manager. virtual void assignPassManager(PMStack &, - PassManagerType = PMT_Unknown) {} + PassManagerType) {} /// Check if available pass managers are suitable for this pass or not. virtual void preparePassManager(PMStack &); @@ -159,7 +154,7 @@ public: /// an analysis interface through multiple inheritance. If needed, it should /// override this to adjust the this pointer as needed for the specified pass /// info. - virtual void *getAdjustedAnalysisPointer(const PassInfo *); + virtual void *getAdjustedAnalysisPointer(AnalysisID ID); virtual ImmutablePass *getAsImmutablePass(); virtual PMDataManager *getAsPMDataManager(); @@ -170,14 +165,9 @@ public: // dumpPassStructure - Implement the -debug-passes=PassStructure option virtual void dumpPassStructure(unsigned Offset = 0); - template<typename AnalysisClass> - static const PassInfo *getClassPassInfo() { - return lookupPassInfo(intptr_t(&AnalysisClass::ID)); - } - // lookupPassInfo - Return the pass info object for the specified pass class, // or null if it is not known. - static const PassInfo *lookupPassInfo(intptr_t TI); + static const PassInfo *lookupPassInfo(const void *TI); // lookupPassInfo - Return the pass info object for the pass with the given // argument string, or null if it is not known. @@ -200,7 +190,7 @@ public: /// don't have the class name available (use getAnalysisIfAvailable if you /// do), but it can tell you if you need to preserve the pass at least. /// - bool mustPreserveAnalysisID(const PassInfo *AnalysisID) const; + bool mustPreserveAnalysisID(char &AID) const; /// getAnalysis<AnalysisType>() - This function is used by subclasses to get /// to the analysis information that they claim to use by overriding the @@ -213,10 +203,10 @@ public: AnalysisType &getAnalysis(Function &F); // Defined in PassAnalysisSupport.h template<typename AnalysisType> - AnalysisType &getAnalysisID(const PassInfo *PI) const; + AnalysisType &getAnalysisID(AnalysisID PI) const; template<typename AnalysisType> - AnalysisType &getAnalysisID(const PassInfo *PI, Function &F); + AnalysisType &getAnalysisID(AnalysisID PI, Function &F); }; @@ -235,13 +225,12 @@ public: virtual bool runOnModule(Module &M) = 0; virtual void assignPassManager(PMStack &PMS, - PassManagerType T = PMT_ModulePassManager); + PassManagerType T); /// Return what kind of Pass Manager can manage this pass. virtual PassManagerType getPotentialPassManagerType() const; - explicit ModulePass(intptr_t pid) : Pass(PT_Module, pid) {} - explicit ModulePass(const void *pid) : Pass(PT_Module, pid) {} + explicit ModulePass(char &pid) : Pass(PT_Module, pid) {} // Force out-of-line virtual method. virtual ~ModulePass(); }; @@ -268,8 +257,7 @@ public: /// bool runOnModule(Module &) { return false; } - explicit ImmutablePass(intptr_t pid) : ModulePass(pid) {} - explicit ImmutablePass(const void *pid) + explicit ImmutablePass(char &pid) : ModulePass(pid) {} // Force out-of-line virtual method. @@ -287,8 +275,7 @@ public: /// class FunctionPass : public Pass { public: - explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} - explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} + explicit FunctionPass(char &pid) : Pass(PT_Function, pid) {} /// createPrinterPass - Get a function printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; @@ -308,19 +295,8 @@ public: /// virtual bool doFinalization(Module &); - /// runOnModule - On a module, we run this pass by initializing, - /// ronOnFunction'ing once for every function in the module, then by - /// finalizing. - /// - virtual bool runOnModule(Module &M); - - /// run - On a function, we simply initialize, run the function, then - /// finalize. - /// - bool run(Function &F); - virtual void assignPassManager(PMStack &PMS, - PassManagerType T = PMT_FunctionPassManager); + PassManagerType T); /// Return what kind of Pass Manager can manage this pass. virtual PassManagerType getPotentialPassManagerType() const; @@ -340,8 +316,7 @@ public: /// class BasicBlockPass : public Pass { public: - explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} - explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} + explicit BasicBlockPass(char &pid) : Pass(PT_BasicBlock, pid) {} /// createPrinterPass - Get a function printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; @@ -371,14 +346,8 @@ public: /// virtual bool doFinalization(Module &); - - // To run this pass on a function, we simply call runOnBasicBlock once for - // each function. - // - bool runOnFunction(Function &F); - virtual void assignPassManager(PMStack &PMS, - PassManagerType T = PMT_BasicBlockPassManager); + PassManagerType T); /// Return what kind of Pass Manager can manage this pass. virtual PassManagerType getPotentialPassManagerType() const; diff --git a/contrib/llvm/include/llvm/PassAnalysisSupport.h b/contrib/llvm/include/llvm/PassAnalysisSupport.h index 977d4f4..a3342d5 100644 --- a/contrib/llvm/include/llvm/PassAnalysisSupport.h +++ b/contrib/llvm/include/llvm/PassAnalysisSupport.h @@ -19,7 +19,6 @@ #ifndef LLVM_PASS_ANALYSIS_SUPPORT_H #define LLVM_PASS_ANALYSIS_SUPPORT_H -#include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include <vector> @@ -49,34 +48,37 @@ public: // addRequired - Add the specified ID to the required set of the usage info // for a pass. // - AnalysisUsage &addRequiredID(AnalysisID ID); + AnalysisUsage &addRequiredID(const void *ID); + AnalysisUsage &addRequiredID(char &ID); template<class PassClass> AnalysisUsage &addRequired() { - return addRequiredID(Pass::getClassPassInfo<PassClass>()); + return addRequiredID(PassClass::ID); } - AnalysisUsage &addRequiredTransitiveID(AnalysisID ID); + AnalysisUsage &addRequiredTransitiveID(char &ID); template<class PassClass> AnalysisUsage &addRequiredTransitive() { - AnalysisID ID = Pass::getClassPassInfo<PassClass>(); - return addRequiredTransitiveID(ID); + return addRequiredTransitiveID(PassClass::ID); } // addPreserved - Add the specified ID to the set of analyses preserved by // this pass // - AnalysisUsage &addPreservedID(AnalysisID ID) { + AnalysisUsage &addPreservedID(const void *ID) { Preserved.push_back(ID); return *this; } + AnalysisUsage &addPreservedID(char &ID) { + Preserved.push_back(&ID); + return *this; + } // addPreserved - Add the specified Pass class to the set of analyses // preserved by this pass. // template<class PassClass> AnalysisUsage &addPreserved() { - assert(Pass::getClassPassInfo<PassClass>() && "Pass class not registered!"); - Preserved.push_back(Pass::getClassPassInfo<PassClass>()); + Preserved.push_back(&PassClass::ID); return *this; } @@ -85,12 +87,7 @@ public: // This can be useful when a pass is trivially preserved, but may not be // linked in. Be careful about spelling! // - AnalysisUsage &addPreserved(StringRef Arg) { - const PassInfo *PI = Pass::lookupPassInfo(Arg); - // If the pass exists, preserve it. Otherwise silently do nothing. - if (PI) Preserved.push_back(PI); - return *this; - } + AnalysisUsage &addPreserved(StringRef Arg); // setPreservesAll - Set by analyses that do not transform their input at all void setPreservesAll() { PreservesAll = true; } @@ -130,7 +127,7 @@ public: inline PMDataManager &getPMDataManager() { return PM; } // Find pass that is implementing PI. - Pass *findImplPass(const PassInfo *PI) { + Pass *findImplPass(AnalysisID PI) { Pass *ResultPass = 0; for (unsigned i = 0; i < AnalysisImpls.size() ; ++i) { if (AnalysisImpls[i].first == PI) { @@ -142,10 +139,10 @@ public: } // Find pass that is implementing PI. Initialize pass for Function F. - Pass *findImplPass(Pass *P, const PassInfo *PI, Function &F); + Pass *findImplPass(Pass *P, AnalysisID PI, Function &F); - void addAnalysisImplsPair(const PassInfo *PI, Pass *P) { - std::pair<const PassInfo*, Pass*> pir = std::make_pair(PI,P); + void addAnalysisImplsPair(AnalysisID PI, Pass *P) { + std::pair<AnalysisID, Pass*> pir = std::make_pair(PI,P); AnalysisImpls.push_back(pir); } @@ -158,11 +155,11 @@ public: // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist Pass *getAnalysisIfAvailable(AnalysisID ID, bool Direction) const; +private: // AnalysisImpls - This keeps track of which passes implements the interfaces // that are required by the current pass (to implement getAnalysis()). - std::vector<std::pair<const PassInfo*, Pass*> > AnalysisImpls; + std::vector<std::pair<AnalysisID, Pass*> > AnalysisImpls; -private: // PassManager that is used to resolve analysis info PMDataManager &PM; }; @@ -179,8 +176,7 @@ template<typename AnalysisType> AnalysisType *Pass::getAnalysisIfAvailable() const { assert(Resolver && "Pass not resident in a PassManager object!"); - const PassInfo *PI = getClassPassInfo<AnalysisType>(); - if (PI == 0) return 0; + const void *PI = &AnalysisType::ID; Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI, true); if (ResultPass == 0) return 0; @@ -199,11 +195,11 @@ AnalysisType *Pass::getAnalysisIfAvailable() const { template<typename AnalysisType> AnalysisType &Pass::getAnalysis() const { assert(Resolver && "Pass has not been inserted into a PassManager object!"); - return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>()); + return getAnalysisID<AnalysisType>(&AnalysisType::ID); } template<typename AnalysisType> -AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const { +AnalysisType &Pass::getAnalysisID(AnalysisID PI) const { assert(PI && "getAnalysis for unregistered pass!"); assert(Resolver&&"Pass has not been inserted into a PassManager object!"); // PI *must* appear in AnalysisImpls. Because the number of passes used @@ -229,11 +225,11 @@ template<typename AnalysisType> AnalysisType &Pass::getAnalysis(Function &F) { assert(Resolver &&"Pass has not been inserted into a PassManager object!"); - return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>(), F); + return getAnalysisID<AnalysisType>(&AnalysisType::ID, F); } template<typename AnalysisType> -AnalysisType &Pass::getAnalysisID(const PassInfo *PI, Function &F) { +AnalysisType &Pass::getAnalysisID(AnalysisID PI, Function &F) { assert(PI && "getAnalysis for unregistered pass!"); assert(Resolver && "Pass has not been inserted into a PassManager object!"); // PI *must* appear in AnalysisImpls. Because the number of passes used diff --git a/contrib/llvm/include/llvm/PassManager.h b/contrib/llvm/include/llvm/PassManager.h index 8de0f83..c8b5dca 100644 --- a/contrib/llvm/include/llvm/PassManager.h +++ b/contrib/llvm/include/llvm/PassManager.h @@ -22,7 +22,6 @@ namespace llvm { class Pass; -class ModulePass; class Module; class PassManagerImpl; diff --git a/contrib/llvm/include/llvm/PassManagers.h b/contrib/llvm/include/llvm/PassManagers.h index 81b7e7a..17f4a05 100644 --- a/contrib/llvm/include/llvm/PassManagers.h +++ b/contrib/llvm/include/llvm/PassManagers.h @@ -14,11 +14,11 @@ #ifndef LLVM_PASSMANAGERS_H #define LLVM_PASSMANAGERS_H -#include "llvm/PassManager.h" +#include "llvm/Pass.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/DenseMap.h" -#include <deque> +#include <vector> #include <map> //===----------------------------------------------------------------------===// @@ -96,14 +96,8 @@ namespace llvm { class StringRef; class Value; class Timer; + class PMDataManager; -/// FunctionPassManager and PassManager, two top level managers, serve -/// as the public interface of pass manager infrastructure. -enum TopLevelManagerType { - TLM_Function, // FunctionPassManager - TLM_Pass // PassManager -}; - // enums for debugging strings enum PassDebuggingString { EXECUTION_MSG, // "Executing Pass '" @@ -138,30 +132,28 @@ public: //===----------------------------------------------------------------------===// // PMStack // -/// PMStack +/// PMStack - This class implements a stack data structure of PMDataManager +/// pointers. +/// /// Top level pass managers (see PassManager.cpp) maintain active Pass Managers /// using PMStack. Each Pass implements assignPassManager() to connect itself /// with appropriate manager. assignPassManager() walks PMStack to find /// suitable manager. -/// -/// PMStack is just a wrapper around standard deque that overrides pop() and -/// push() methods. class PMStack { public: - typedef std::deque<PMDataManager *>::reverse_iterator iterator; - iterator begin() { return S.rbegin(); } - iterator end() { return S.rend(); } - - void handleLastUserOverflow(); + typedef std::vector<PMDataManager *>::const_reverse_iterator iterator; + iterator begin() const { return S.rbegin(); } + iterator end() const { return S.rend(); } void pop(); - inline PMDataManager *top() { return S.back(); } + PMDataManager *top() const { return S.back(); } void push(PMDataManager *PM); - inline bool empty() { return S.empty(); } + bool empty() const { return S.empty(); } + + void dump() const; - void dump(); private: - std::deque<PMDataManager *> S; + std::vector<PMDataManager *> S; }; @@ -171,21 +163,26 @@ private: /// PMTopLevelManager manages LastUser info and collects common APIs used by /// top level pass managers. class PMTopLevelManager { -public: +protected: + explicit PMTopLevelManager(PMDataManager *PMDM); virtual unsigned getNumContainedManagers() const { return (unsigned)PassManagers.size(); } - /// Schedule pass P for execution. Make sure that passes required by - /// P are run before P is run. Update analysis info maintained by - /// the manager. Remove dead passes. This is a recursive function. - void schedulePass(Pass *P); + void initializeAllAnalysisInfo(); +private: /// This is implemented by top level pass manager and used by /// schedulePass() to add analysis info passes that are not available. virtual void addTopLevelPass(Pass *P) = 0; +public: + /// Schedule pass P for execution. Make sure that passes required by + /// P are run before P is run. Update analysis info maintained by + /// the manager. Remove dead passes. This is a recursive function. + void schedulePass(Pass *P); + /// Set pass P as the last user of the given analysis passes. void setLastUser(SmallVector<Pass *, 12> &AnalysisPasses, Pass *P); @@ -200,7 +197,6 @@ public: /// Find analysis usage information for the pass P. AnalysisUsage *findAnalysisUsage(Pass *P); - explicit PMTopLevelManager(enum TopLevelManagerType t); virtual ~PMTopLevelManager(); /// Add immutable pass and initialize it. @@ -227,8 +223,6 @@ public: void dumpPasses() const; void dumpArguments() const; - void initializeAllAnalysisInfo(); - // Active Pass Managers PMStack activeStack; @@ -302,7 +296,7 @@ public: /// through getAnalysis interface. virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass); - virtual Pass *getOnTheFlyPass(Pass *P, const PassInfo *PI, Function &F); + virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F); /// Initialize available analysis information. void initializeAnalysisInfo() { @@ -414,7 +408,7 @@ class FPPassManager : public ModulePass, public PMDataManager { public: static char ID; explicit FPPassManager(int Depth) - : ModulePass(&ID), PMDataManager(Depth) { } + : ModulePass(ID), PMDataManager(Depth) { } /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. diff --git a/contrib/llvm/include/llvm/PassRegistry.h b/contrib/llvm/include/llvm/PassRegistry.h new file mode 100644 index 0000000..5907139 --- /dev/null +++ b/contrib/llvm/include/llvm/PassRegistry.h @@ -0,0 +1,71 @@ +//===- llvm/PassRegistry.h - Pass Information Registry ----------*- 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 PassRegistry, a class that is used in the initialization +// and registration of passes. At initialization, passes are registered with +// the PassRegistry, which is later provided to the PassManager for dependency +// resolution and similar tasks. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_PASSREGISTRY_H +#define LLVM_PASSREGISTRY_H + +#include "llvm/ADT/StringMap.h" +#include "llvm/System/DataTypes.h" +#include "llvm/System/Mutex.h" +#include <map> +#include <set> +#include <vector> + +namespace llvm { + +class PassInfo; +struct PassRegistrationListener; + +class PassRegistry { + /// Guards the contents of this class. + mutable sys::SmartMutex<true> Lock; + + /// PassInfoMap - Keep track of the PassInfo object for each registered pass. + typedef std::map<const void*, const PassInfo*> MapType; + MapType PassInfoMap; + + typedef StringMap<const PassInfo*> StringMapType; + StringMapType PassInfoStringMap; + + /// AnalysisGroupInfo - Keep track of information for each analysis group. + struct AnalysisGroupInfo { + std::set<const PassInfo *> Implementations; + }; + std::map<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap; + + std::vector<PassRegistrationListener*> Listeners; + +public: + static PassRegistry *getPassRegistry(); + + const PassInfo *getPassInfo(const void *TI) const; + const PassInfo *getPassInfo(StringRef Arg) const; + + void registerPass(const PassInfo &PI); + void unregisterPass(const PassInfo &PI); + + /// Analysis Group Mechanisms. + void registerAnalysisGroup(const void *InterfaceID, const void *PassID, + PassInfo& Registeree, bool isDefault); + + void enumerateWith(PassRegistrationListener *L); + void addRegistrationListener(PassRegistrationListener* L); + void removeRegistrationListener(PassRegistrationListener *L); +}; + +} + +#endif diff --git a/contrib/llvm/include/llvm/PassSupport.h b/contrib/llvm/include/llvm/PassSupport.h index b018351..0f559d6 100644 --- a/contrib/llvm/include/llvm/PassSupport.h +++ b/contrib/llvm/include/llvm/PassSupport.h @@ -22,11 +22,10 @@ #define LLVM_PASS_SUPPORT_H #include "Pass.h" +#include "llvm/PassRegistry.h" namespace llvm { -class TargetMachine; - //===--------------------------------------------------------------------------- /// PassInfo class - An instance of this class exists for every pass known by /// the system, and can be obtained from a live Pass by calling its @@ -40,7 +39,7 @@ public: private: const char *const PassName; // Nice name for Pass const char *const PassArgument; // Command Line argument to run this pass - const intptr_t PassID; + const void *PassID; const bool IsCFGOnlyPass; // Pass only looks at the CFG. const bool IsAnalysis; // True if an analysis pass. const bool IsAnalysisGroup; // True if an analysis group. @@ -51,18 +50,17 @@ private: public: /// PassInfo ctor - Do not call this directly, this should only be invoked /// through RegisterPass. - PassInfo(const char *name, const char *arg, intptr_t pi, - NormalCtor_t normal = 0, - bool isCFGOnly = false, bool is_analysis = false) + PassInfo(const char *name, const char *arg, const void *pi, + NormalCtor_t normal, bool isCFGOnly, bool is_analysis) : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly), IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) { - registerPass(); + PassRegistry::getPassRegistry()->registerPass(*this); } /// PassInfo ctor - Do not call this directly, this should only be invoked /// through RegisterPass. This version is for use by analysis groups; it /// does not auto-register the pass. - PassInfo(const char *name, intptr_t pi) + PassInfo(const char *name, const void *pi) : PassName(name), PassArgument(""), PassID(pi), IsCFGOnlyPass(false), IsAnalysis(false), IsAnalysisGroup(true), NormalCtor(0) { @@ -80,11 +78,11 @@ public: /// getTypeInfo - Return the id object for the pass... /// TODO : Rename - intptr_t getTypeInfo() const { return PassID; } + const void *getTypeInfo() const { return PassID; } /// Return true if this PassID implements the specified ID pointer. - bool isPassID(void *IDPtr) const { - return PassID == (intptr_t)IDPtr; + bool isPassID(const void *IDPtr) const { + return PassID == IDPtr; } /// isAnalysisGroup - Return true if this is an analysis group, not a normal @@ -126,15 +124,13 @@ public: return ItfImpl; } -protected: - void registerPass(); - void unregisterPass(); - private: void operator=(const PassInfo &); // do not implement PassInfo(const PassInfo &); // do not implement }; +#define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \ + static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis) template<typename PassName> Pass *callDefaultCtor() { return new PassName(); } @@ -162,9 +158,10 @@ struct RegisterPass : public PassInfo { // Register Pass using default constructor... RegisterPass(const char *PassArg, const char *Name, bool CFGOnly = false, bool is_analysis = false) - : PassInfo(Name, PassArg, intptr_t(&passName::ID), + : PassInfo(Name, PassArg, &passName::ID, PassInfo::NormalCtor_t(callDefaultCtor<passName>), CFGOnly, is_analysis) { + } }; @@ -191,8 +188,8 @@ struct RegisterPass : public PassInfo { class RegisterAGBase : public PassInfo { protected: RegisterAGBase(const char *Name, - intptr_t InterfaceID, - intptr_t PassID = 0, + const void *InterfaceID, + const void *PassID = 0, bool isDefault = false); }; @@ -200,16 +197,18 @@ template<typename Interface, bool Default = false> struct RegisterAnalysisGroup : public RegisterAGBase { explicit RegisterAnalysisGroup(PassInfo &RPB) : RegisterAGBase(RPB.getPassName(), - intptr_t(&Interface::ID), RPB.getTypeInfo(), + &Interface::ID, RPB.getTypeInfo(), Default) { } explicit RegisterAnalysisGroup(const char *Name) - : RegisterAGBase(Name, intptr_t(&Interface::ID)) { + : RegisterAGBase(Name, &Interface::ID) { } }; - +#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \ + static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis); \ + static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info) //===--------------------------------------------------------------------------- /// PassRegistrationListener class - This class is meant to be derived from by diff --git a/contrib/llvm/include/llvm/Support/COFF.h b/contrib/llvm/include/llvm/Support/COFF.h index 69137bf..78254ae 100644 --- a/contrib/llvm/include/llvm/Support/COFF.h +++ b/contrib/llvm/include/llvm/Support/COFF.h @@ -48,6 +48,11 @@ namespace COFF { uint16_t Characteristics; }; + enum MachineTypes { + IMAGE_FILE_MACHINE_I386 = 0x14C, + IMAGE_FILE_MACHINE_AMD64 = 0x8664 + }; + struct symbol { char Name[NameSize]; uint32_t Value; @@ -67,6 +72,12 @@ namespace COFF { SF_WeakReference = 0x01000000 }; + enum SymbolSectionNumber { + IMAGE_SYM_DEBUG = -2, + IMAGE_SYM_ABSOLUTE = -1, + IMAGE_SYM_UNDEFINED = 0 + }; + /// Storage class tells where and what the symbol represents enum SymbolStorageClass { IMAGE_SYM_CLASS_END_OF_FUNCTION = -1, ///< Physical end of function @@ -128,7 +139,7 @@ namespace COFF { IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type. /// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT)) - SCT_COMPLEX_TYPE_SHIFT = 4 + SCT_COMPLEX_TYPE_SHIFT = 8 }; struct section { @@ -199,10 +210,28 @@ namespace COFF { IMAGE_REL_I386_SECREL = 0x000B, IMAGE_REL_I386_TOKEN = 0x000C, IMAGE_REL_I386_SECREL7 = 0x000D, - IMAGE_REL_I386_REL32 = 0x0014 + IMAGE_REL_I386_REL32 = 0x0014, + + IMAGE_REL_AMD64_ABSOLUTE = 0x0000, + IMAGE_REL_AMD64_ADDR64 = 0x0001, + IMAGE_REL_AMD64_ADDR32 = 0x0002, + IMAGE_REL_AMD64_ADDR32NB = 0x0003, + IMAGE_REL_AMD64_REL32 = 0x0004, + IMAGE_REL_AMD64_REL32_1 = 0x0005, + IMAGE_REL_AMD64_REL32_2 = 0x0006, + IMAGE_REL_AMD64_REL32_3 = 0x0007, + IMAGE_REL_AMD64_REL32_4 = 0x0008, + IMAGE_REL_AMD64_REL32_5 = 0x0009, + IMAGE_REL_AMD64_SECTION = 0x000A, + IMAGE_REL_AMD64_SECREL = 0x000B, + IMAGE_REL_AMD64_SECREL7 = 0x000C, + IMAGE_REL_AMD64_TOKEN = 0x000D, + IMAGE_REL_AMD64_SREL32 = 0x000E, + IMAGE_REL_AMD64_PAIR = 0x000F, + IMAGE_REL_AMD64_SSPAN32 = 0x0010 }; - enum { + enum COMDATType { IMAGE_COMDAT_SELECT_NODUPLICATES = 1, IMAGE_COMDAT_SELECT_ANY, IMAGE_COMDAT_SELECT_SAME_SIZE, @@ -211,6 +240,58 @@ namespace COFF { IMAGE_COMDAT_SELECT_LARGEST }; + // Auxiliary Symbol Formats + struct AuxiliaryFunctionDefinition { + uint32_t TagIndex; + uint32_t TotalSize; + uint32_t PointerToLinenumber; + uint32_t PointerToNextFunction; + uint8_t unused[2]; + }; + + struct AuxiliarybfAndefSymbol { + uint8_t unused1[4]; + uint16_t Linenumber; + uint8_t unused2[6]; + uint32_t PointerToNextFunction; + uint8_t unused3[2]; + }; + + struct AuxiliaryWeakExternal { + uint32_t TagIndex; + uint32_t Characteristics; + uint8_t unused[10]; + }; + + /// These are not documented in the spec, but are located in WinNT.h. + enum WeakExternalCharacteristics { + IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1, + IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2, + IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3 + }; + + struct AuxiliaryFile { + uint8_t FileName[18]; + }; + + struct AuxiliarySectionDefinition { + uint32_t Length; + uint16_t NumberOfRelocations; + uint16_t NumberOfLinenumbers; + uint32_t CheckSum; + uint16_t Number; + uint8_t Selection; + uint8_t unused[3]; + }; + + union Auxiliary { + AuxiliaryFunctionDefinition FunctionDefinition; + AuxiliarybfAndefSymbol bfAndefSymbol; + AuxiliaryWeakExternal WeakExternal; + AuxiliaryFile File; + AuxiliarySectionDefinition SectionDefinition; + }; + } // End namespace llvm. } // End namespace COFF. diff --git a/contrib/llvm/include/llvm/Support/CallSite.h b/contrib/llvm/include/llvm/Support/CallSite.h index 38ee08b..9b6a409 100644 --- a/contrib/llvm/include/llvm/Support/CallSite.h +++ b/contrib/llvm/include/llvm/Support/CallSite.h @@ -49,13 +49,13 @@ protected: PointerIntPair<InstrTy*, 1, bool> I; public: CallSiteBase() : I(0, false) {} - CallSiteBase(CallTy *CI) : I(reinterpret_cast<InstrTy*>(CI), true) {} - CallSiteBase(InvokeTy *II) : I(reinterpret_cast<InstrTy*>(II), false) {} + CallSiteBase(CallTy *CI) : I(CI, true) { assert(CI); } + CallSiteBase(InvokeTy *II) : I(II, false) { assert(II); } CallSiteBase(ValTy *II) { *this = get(II); } CallSiteBase(InstrTy *II) { assert(II && "Null instruction given?"); *this = get(II); - assert(I.getPointer()); + assert(I.getPointer() && "Not a call?"); } /// CallSiteBase::get - This static method is sort of like a constructor. It @@ -66,9 +66,9 @@ public: static CallSiteBase get(ValTy *V) { if (InstrTy *II = dyn_cast<InstrTy>(V)) { if (II->getOpcode() == Instruction::Call) - return CallSiteBase(reinterpret_cast<CallTy*>(II)); + return CallSiteBase(static_cast<CallTy*>(II)); else if (II->getOpcode() == Instruction::Invoke) - return CallSiteBase(reinterpret_cast<InvokeTy*>(II)); + return CallSiteBase(static_cast<InvokeTy*>(II)); } return CallSiteBase(); } @@ -116,13 +116,13 @@ public: ValTy *getArgument(unsigned ArgNo) const { assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!"); - return *(arg_begin()+ArgNo); + return *(arg_begin() + ArgNo); } void setArgument(unsigned ArgNo, Value* newVal) { assert(getInstruction() && "Not a call or invoke instruction!"); assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!"); - getInstruction()->setOperand(getArgumentOffset() + ArgNo, newVal); + getInstruction()->setOperand(ArgNo, newVal); } /// Given a value use iterator, returns the argument that corresponds to it. @@ -143,7 +143,7 @@ public: IterTy arg_begin() const { assert(getInstruction() && "Not a call or invoke instruction!"); // Skip non-arguments - return (*this)->op_begin() + getArgumentOffset(); + return (*this)->op_begin(); } IterTy arg_end() const { return (*this)->op_end() - getArgumentEndOffset(); } @@ -253,44 +253,21 @@ public: } private: - /// Returns the operand number of the first argument - unsigned getArgumentOffset() const { - if (isCall()) - return CallInst::ArgOffset; // Skip Function (ATM) - else - return 0; // Args are at the front - } - unsigned getArgumentEndOffset() const { if (isCall()) - return CallInst::ArgOffset ? 0 : 1; // Unchanged (ATM) + return 1; // Skip Callee else - return 3; // Skip BB, BB, Function + return 3; // Skip BB, BB, Callee } IterTy getCallee() const { - // FIXME: this is slow, since we do not have the fast versions - // of the op_*() functions here. See CallSite::getCallee. - // - if (isCall()) - return CallInst::ArgOffset - ? getInstruction()->op_begin() // Unchanged - : getInstruction()->op_end() - 1; // Skip Function - else - return getInstruction()->op_end() - 3; // Skip BB, BB, Function + if (isCall()) // Skip Callee + return cast<CallInst>(getInstruction())->op_end() - 1; + else // Skip BB, BB, Callee + return cast<InvokeInst>(getInstruction())->op_end() - 3; } }; -/// ImmutableCallSite - establish a view to a call site for examination -class ImmutableCallSite : public CallSiteBase<> { - typedef CallSiteBase<> Base; -public: - ImmutableCallSite(const Value* V) : Base(V) {} - ImmutableCallSite(const CallInst *CI) : Base(CI) {} - ImmutableCallSite(const InvokeInst *II) : Base(II) {} - ImmutableCallSite(const Instruction *II) : Base(II) {} -}; - class CallSite : public CallSiteBase<Function, Value, User, Instruction, CallInst, InvokeInst, User::op_iterator> { typedef CallSiteBase<Function, Value, User, Instruction, @@ -298,6 +275,7 @@ class CallSite : public CallSiteBase<Function, Value, User, Instruction, public: CallSite() {} CallSite(Base B) : Base(B) {} + CallSite(Value* V) : Base(V) {} CallSite(CallInst *CI) : Base(CI) {} CallSite(InvokeInst *II) : Base(II) {} CallSite(Instruction *II) : Base(II) {} @@ -322,6 +300,17 @@ private: User::op_iterator getCallee() const; }; +/// ImmutableCallSite - establish a view to a call site for examination +class ImmutableCallSite : public CallSiteBase<> { + typedef CallSiteBase<> Base; +public: + ImmutableCallSite(const Value* V) : Base(V) {} + ImmutableCallSite(const CallInst *CI) : Base(CI) {} + ImmutableCallSite(const InvokeInst *II) : Base(II) {} + ImmutableCallSite(const Instruction *II) : Base(II) {} + ImmutableCallSite(CallSite CS) : Base(CS.getInstruction()) {} +}; + } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/Support/Casting.h b/contrib/llvm/include/llvm/Support/Casting.h index dccbfad..c589171 100644 --- a/contrib/llvm/include/llvm/Support/Casting.h +++ b/contrib/llvm/include/llvm/Support/Casting.h @@ -236,73 +236,6 @@ inline typename cast_retty<X, Y>::ret_type dyn_cast_or_null(const Y &Val) { return (Val && isa<X>(Val)) ? cast<X, Y>(Val) : 0; } - -#ifdef DEBUG_CAST_OPERATORS -#include "llvm/Support/raw_ostream.h" - -struct bar { - bar() {} -private: - bar(const bar &); -}; -struct foo { - void ext() const; - /* static bool classof(const bar *X) { - cerr << "Classof: " << X << "\n"; - return true; - }*/ -}; - -template <> struct isa_impl<foo,bar> { - static inline bool doit(const bar &Val) { - dbgs() << "Classof: " << &Val << "\n"; - return true; - } -}; - - -bar *fub(); -void test(bar &B1, const bar *B2) { - // test various configurations of const - const bar &B3 = B1; - const bar *const B4 = B2; - - // test isa - if (!isa<foo>(B1)) return; - if (!isa<foo>(B2)) return; - if (!isa<foo>(B3)) return; - if (!isa<foo>(B4)) return; - - // test cast - foo &F1 = cast<foo>(B1); - const foo *F3 = cast<foo>(B2); - const foo *F4 = cast<foo>(B2); - const foo &F8 = cast<foo>(B3); - const foo *F9 = cast<foo>(B4); - foo *F10 = cast<foo>(fub()); - - // test cast_or_null - const foo *F11 = cast_or_null<foo>(B2); - const foo *F12 = cast_or_null<foo>(B2); - const foo *F13 = cast_or_null<foo>(B4); - const foo *F14 = cast_or_null<foo>(fub()); // Shouldn't print. - - // These lines are errors... - //foo *F20 = cast<foo>(B2); // Yields const foo* - //foo &F21 = cast<foo>(B3); // Yields const foo& - //foo *F22 = cast<foo>(B4); // Yields const foo* - //foo &F23 = cast_or_null<foo>(B1); - //const foo &F24 = cast_or_null<foo>(B3); -} - -bar *fub() { return 0; } -void main() { - bar B; - test(B, &B); -} - -#endif - } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/Support/CommandLine.h b/contrib/llvm/include/llvm/Support/CommandLine.h index 61c3256..9ae3d6a 100644 --- a/contrib/llvm/include/llvm/Support/CommandLine.h +++ b/contrib/llvm/include/llvm/Support/CommandLine.h @@ -31,7 +31,7 @@ #include <vector> namespace llvm { - + /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified /// usage concise. @@ -443,16 +443,23 @@ protected: template <class DataType> class parser : public generic_parser_base { protected: - SmallVector<std::pair<const char *, - std::pair<DataType, const char *> >, 8> Values; + class OptionInfo { + public: + OptionInfo(const char *name, DataType v, const char *helpStr) : + Name(name), V(v), HelpStr(helpStr) {} + const char *Name; + DataType V; + const char *HelpStr; + }; + SmallVector<OptionInfo, 8> Values; public: typedef DataType parser_data_type; // Implement virtual functions needed by generic_parser_base unsigned getNumOptions() const { return unsigned(Values.size()); } - const char *getOption(unsigned N) const { return Values[N].first; } + const char *getOption(unsigned N) const { return Values[N].Name; } const char *getDescription(unsigned N) const { - return Values[N].second.second; + return Values[N].HelpStr; } // parse - Return true on error. @@ -465,8 +472,8 @@ public: for (unsigned i = 0, e = static_cast<unsigned>(Values.size()); i != e; ++i) - if (Values[i].first == ArgVal) { - V = Values[i].second.first; + if (Values[i].Name == ArgVal) { + V = Values[i].V; return false; } @@ -478,8 +485,8 @@ public: template <class DT> void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) { assert(findOption(Name) == Values.size() && "Option already exists!"); - Values.push_back(std::make_pair(Name, - std::make_pair(static_cast<DataType>(V),HelpStr))); + OptionInfo X(Name, static_cast<DataType>(V), HelpStr); + Values.push_back(X); MarkOptionsChanged(); } @@ -781,7 +788,7 @@ public: DataType &getValue() { check(); return *Location; } const DataType &getValue() const { check(); return *Location; } - + operator DataType() const { return this->getValue(); } }; diff --git a/contrib/llvm/include/llvm/Support/Compiler.h b/contrib/llvm/include/llvm/Support/Compiler.h index b2ce76d..14b36f8 100644 --- a/contrib/llvm/include/llvm/Support/Compiler.h +++ b/contrib/llvm/include/llvm/Support/Compiler.h @@ -24,7 +24,10 @@ /// into a shared library, then the class will be accessible from outside the /// the library. Can also be used to mark variables and functions, making them /// accessible from outside any shared library they are linked into. -#if (__GNUC__ >= 4) && !defined(__MINGW32__) && !defined(__CYGWIN__) +#if defined(__MINGW32__) || defined(__CYGWIN__) +#define LLVM_LIBRARY_VISIBILITY +#define LLVM_GLOBAL_VISIBILITY __declspec(dllexport) +#elif (__GNUC__ >= 4) #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) #define LLVM_GLOBAL_VISIBILITY __attribute__ ((visibility("default"))) #else diff --git a/contrib/llvm/include/llvm/Support/ConstantRange.h b/contrib/llvm/include/llvm/Support/ConstantRange.h index 6342c6f..29086b2 100644 --- a/contrib/llvm/include/llvm/Support/ConstantRange.h +++ b/contrib/llvm/include/llvm/Support/ConstantRange.h @@ -41,8 +41,6 @@ namespace llvm { /// class ConstantRange { APInt Lower, Upper; - static ConstantRange intersect1Wrapped(const ConstantRange &LHS, - const ConstantRange &RHS); public: /// Initialize a full (the default) or empty set for the specified bit width. @@ -196,39 +194,45 @@ public: ConstantRange sextOrTrunc(uint32_t BitWidth) const; /// add - Return a new range representing the possible values resulting - /// from an addition of a value in this range and a value in Other. + /// from an addition of a value in this range and a value in \p Other. ConstantRange add(const ConstantRange &Other) const; + /// sub - Return a new range representing the possible values resulting + /// from a subtraction of a value in this range and a value in \p Other. + ConstantRange sub(const ConstantRange &Other) const; + /// multiply - Return a new range representing the possible values resulting - /// from a multiplication of a value in this range and a value in Other. + /// from a multiplication of a value in this range and a value in \p Other. /// TODO: This isn't fully implemented yet. ConstantRange multiply(const ConstantRange &Other) const; /// smax - Return a new range representing the possible values resulting - /// from a signed maximum of a value in this range and a value in Other. + /// from a signed maximum of a value in this range and a value in \p Other. ConstantRange smax(const ConstantRange &Other) const; /// umax - Return a new range representing the possible values resulting - /// from an unsigned maximum of a value in this range and a value in Other. + /// from an unsigned maximum of a value in this range and a value in \p Other. ConstantRange umax(const ConstantRange &Other) const; /// udiv - Return a new range representing the possible values resulting - /// from an unsigned division of a value in this range and a value in Other. - /// TODO: This isn't fully implemented yet. + /// from an unsigned division of a value in this range and a value in + /// \p Other. ConstantRange udiv(const ConstantRange &Other) const; /// shl - Return a new range representing the possible values resulting - /// from a left shift of a value in this range by the Amount value. - ConstantRange shl(const ConstantRange &Amount) const; - - /// ashr - Return a new range representing the possible values resulting from - /// an arithmetic right shift of a value in this range by the Amount value. - ConstantRange ashr(const ConstantRange &Amount) const; + /// from a left shift of a value in this range by a value in \p Other. + /// TODO: This isn't fully implemented yet. + ConstantRange shl(const ConstantRange &Other) const; - /// shr - Return a new range representing the possible values resulting - /// from a logical right shift of a value in this range by the Amount value. - ConstantRange lshr(const ConstantRange &Amount) const; + /// lshr - Return a new range representing the possible values resulting + /// from a logical right shift of a value in this range and a value in + /// \p Other. + ConstantRange lshr(const ConstantRange &Other) const; + /// inverse - Return a new range that is the logical not of the current set. + /// + ConstantRange inverse() const; + /// print - Print out the bounds to a stream... /// void print(raw_ostream &OS) const; diff --git a/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h b/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h new file mode 100644 index 0000000..d66609f --- /dev/null +++ b/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h @@ -0,0 +1,84 @@ +//===--- CrashRecoveryContext.h - Crash Recovery ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H +#define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H + +#include <string> + +namespace llvm { +class StringRef; + +/// \brief Crash recovery helper object. +/// +/// This class implements support for running operations in a safe context so +/// that crashes (memory errors, stack overflow, assertion violations) can be +/// detected and control restored to the crashing thread. Crash detection is +/// purely "best effort", the exact set of failures which can be recovered from +/// is platform dependent. +/// +/// Clients make use of this code by first calling +/// CrashRecoveryContext::Enable(), and then executing unsafe operations via a +/// CrashRecoveryContext object. For example: +/// +/// void actual_work(void *); +/// +/// void foo() { +/// CrashRecoveryContext CRC; +/// +/// if (!CRC.RunSafely(actual_work, 0)) { +/// ... a crash was detected, report error to user ... +/// } +/// +/// ... no crash was detected ... +/// } +/// +/// Crash recovery contexts may not be nested. +class CrashRecoveryContext { + void *Impl; + +public: + CrashRecoveryContext() : Impl(0) {} + ~CrashRecoveryContext(); + + /// \brief Enable crash recovery. + static void Enable(); + + /// \brief Disable crash recovery. + static void Disable(); + + /// \brief Return the active context, if the code is currently executing in a + /// thread which is in a protected context. + static CrashRecoveryContext *GetCurrent(); + + /// \brief Execute the provide callback function (with the given arguments) in + /// a protected context. + /// + /// \return True if the function completed successfully, and false if the + /// function crashed (or HandleCrash was called explicitly). Clients should + /// make as little assumptions as possible about the program state when + /// RunSafely has returned false. Clients can use getBacktrace() to retrieve + /// the backtrace of the crash on failures. + bool RunSafely(void (*Fn)(void*), void *UserData); + + /// \brief Explicitly trigger a crash recovery in the current process, and + /// return failure from RunSafely(). This function does not return. + void HandleCrash(); + + /// \brief Return a string containing the backtrace where the crash was + /// detected; or empty if the backtrace wasn't recovered. + /// + /// This function is only valid when a crash has been detected (i.e., + /// RunSafely() has returned false. + const std::string &getBacktrace() const; +}; + +} + +#endif diff --git a/contrib/llvm/include/llvm/Support/DataFlow.h b/contrib/llvm/include/llvm/Support/DataFlow.h index 8f79ead..355c402 100644 --- a/contrib/llvm/include/llvm/Support/DataFlow.h +++ b/contrib/llvm/include/llvm/Support/DataFlow.h @@ -25,7 +25,7 @@ namespace llvm { template <> struct GraphTraits<const Value*> { typedef const Value NodeType; - typedef Value::use_const_iterator ChildIteratorType; + typedef Value::const_use_iterator ChildIteratorType; static NodeType *getEntryNode(const Value *G) { return G; diff --git a/contrib/llvm/include/llvm/Support/DataTypes.h.cmake b/contrib/llvm/include/llvm/Support/DataTypes.h.cmake deleted file mode 100644 index ad210ed..0000000 --- a/contrib/llvm/include/llvm/Support/DataTypes.h.cmake +++ /dev/null @@ -1,152 +0,0 @@ -/*===-- 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 - -#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} -#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} -#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} -#cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T} -#cmakedefine HAVE_U_INT64_T ${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> -#ifdef __cplusplus -#include <cmath> -#else -#include <math.h> -#endif -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/contrib/llvm/include/llvm/Support/DataTypes.h.in b/contrib/llvm/include/llvm/Support/DataTypes.h.in deleted file mode 100644 index 405f476..0000000 --- a/contrib/llvm/include/llvm/Support/DataTypes.h.in +++ /dev/null @@ -1,147 +0,0 @@ -/*===-- 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 - -#undef HAVE_SYS_TYPES_H -#undef HAVE_INTTYPES_H -#undef HAVE_STDINT_H -#undef HAVE_UINT64_T -#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/contrib/llvm/include/llvm/Support/ELF.h b/contrib/llvm/include/llvm/Support/ELF.h index 6f939e7..83478b7 100644 --- a/contrib/llvm/include/llvm/Support/ELF.h +++ b/contrib/llvm/include/llvm/Support/ELF.h @@ -216,6 +216,27 @@ enum { R_X86_64_TLSDESC = 36 }; +// i386 relocations. +// TODO: this is just a subset +enum { + R_386_NONE = 0, + R_386_32 = 1, + R_386_PC32 = 2, + R_386_GOT32 = 3, + R_386_PLT32 = 4, + R_386_COPY = 5, + R_386_GLOB_DAT = 6, + R_386_JUMP_SLOT = 7, + R_386_RELATIVE = 8, + R_386_GOTOFF = 9, + R_386_GOTPC = 10, + R_386_32PLT = 11, + R_386_16 = 20, + R_386_PC16 = 21, + R_386_8 = 22, + R_386_PC8 = 23 +}; + // Section header. struct Elf32_Shdr { Elf32_Word sh_name; // Section name (index into string table) @@ -257,22 +278,29 @@ enum { // Section types. enum { - SHT_NULL = 0, // No associated section (inactive entry). - SHT_PROGBITS = 1, // Program-defined contents. - SHT_SYMTAB = 2, // Symbol table. - SHT_STRTAB = 3, // String table. - SHT_RELA = 4, // Relocation entries; explicit addends. - SHT_HASH = 5, // Symbol hash table. - SHT_DYNAMIC = 6, // Information for dynamic linking. - SHT_NOTE = 7, // Information about the file. - SHT_NOBITS = 8, // Data occupies no space in the file. - SHT_REL = 9, // Relocation entries; no explicit addends. - SHT_SHLIB = 10, // Reserved. - SHT_DYNSYM = 11, // Symbol table. - SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type. - SHT_HIPROC = 0x7fffffff, // Highest processor architecture-specific type. - SHT_LOUSER = 0x80000000, // Lowest type reserved for applications. - SHT_HIUSER = 0xffffffff // Highest type reserved for applications. + SHT_NULL = 0, // No associated section (inactive entry). + SHT_PROGBITS = 1, // Program-defined contents. + SHT_SYMTAB = 2, // Symbol table. + SHT_STRTAB = 3, // String table. + SHT_RELA = 4, // Relocation entries; explicit addends. + SHT_HASH = 5, // Symbol hash table. + SHT_DYNAMIC = 6, // Information for dynamic linking. + SHT_NOTE = 7, // Information about the file. + SHT_NOBITS = 8, // Data occupies no space in the file. + SHT_REL = 9, // Relocation entries; no explicit addends. + SHT_SHLIB = 10, // Reserved. + SHT_DYNSYM = 11, // Symbol table. + SHT_INIT_ARRAY = 14, // Pointers to initialisation functions. + SHT_FINI_ARRAY = 15, // Pointers to termination functions. + SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions. + SHT_GROUP = 17, // Section group. + SHT_SYMTAB_SHNDX = 18, // Indicies for SHN_XINDEX entries. + SHT_LOOS = 0x60000000, // Lowest operating system-specific type. + SHT_HIOS = 0x6fffffff, // Highest operating system-specific type. + SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type. + SHT_HIPROC = 0x7fffffff, // Highest processor architecture-specific type. + SHT_LOUSER = 0x80000000, // Lowest type reserved for applications. + SHT_HIUSER = 0xffffffff // Highest type reserved for applications. }; // Section flags. @@ -323,6 +351,12 @@ struct Elf64_Sym { } }; +// The size (in bytes) of symbol table entries. +enum { + SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size + SYMENTRY_SIZE64 = 24 // 64-bit symbol entry size. +}; + // Symbol bindings. enum { STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def @@ -339,10 +373,19 @@ enum { STT_FUNC = 2, // Symbol is executable code (function, etc.) STT_SECTION = 3, // Symbol refers to a section STT_FILE = 4, // Local, absolute symbol that refers to a file + STT_COMMON = 5, // An uninitialised common block + STT_TLS = 6, // Thread local data object STT_LOPROC = 13, // Lowest processor-specific symbol type STT_HIPROC = 15 // Highest processor-specific symbol type }; +enum { + STV_DEFAULT = 0, // Visibility is specified by binding type + STV_INTERNAL = 1, // Defined by processor supplements + STV_HIDDEN = 2, // Not visible to other components + STV_PROTECTED = 3 // Visible in other components but not preemptable +}; + // Relocation entry, without explicit addend. struct Elf32_Rel { Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr) @@ -356,7 +399,7 @@ struct Elf32_Rel { void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } void setSymbolAndType(Elf32_Word s, unsigned char t) { r_info = (s << 8) + t; - }; + } }; // Relocation entry with explicit addend. @@ -373,7 +416,7 @@ struct Elf32_Rela { void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } void setSymbolAndType(Elf32_Word s, unsigned char t) { r_info = (s << 8) + t; - }; + } }; // Relocation entry, without explicit addend. @@ -391,7 +434,7 @@ struct Elf64_Rel { void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } void setSymbolAndType(Elf64_Xword s, unsigned char t) { r_info = (s << 32) + (t&0xffffffffL); - }; + } }; // Relocation entry with explicit addend. @@ -410,7 +453,7 @@ struct Elf64_Rela { void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } void setSymbolAndType(Elf64_Xword s, unsigned char t) { r_info = (s << 32) + (t&0xffffffffL); - }; + } }; // Program header for ELF32. diff --git a/contrib/llvm/include/llvm/Support/ErrorHandling.h b/contrib/llvm/include/llvm/Support/ErrorHandling.h index ffcb482..9854657 100644 --- a/contrib/llvm/include/llvm/Support/ErrorHandling.h +++ b/contrib/llvm/include/llvm/Support/ErrorHandling.h @@ -52,6 +52,18 @@ namespace llvm { /// llvm_stop_multithreaded(). void remove_fatal_error_handler(); + /// ScopedFatalErrorHandler - This is a simple helper class which just + /// calls install_fatal_error_handler in its constructor and + /// remove_fatal_error_handler in its destructor. + struct ScopedFatalErrorHandler { + explicit ScopedFatalErrorHandler(fatal_error_handler_t handler, + void *user_data = 0) { + install_fatal_error_handler(handler, user_data); + } + + ~ScopedFatalErrorHandler() { remove_fatal_error_handler(); } + }; + /// Reports a serious error, calling any installed error handler. These /// functions are intended to be used for error conditions which are outside /// the control of the compiler (I/O errors, invalid user input, etc.) diff --git a/contrib/llvm/include/llvm/Support/GraphWriter.h b/contrib/llvm/include/llvm/Support/GraphWriter.h index 559f004..287c5ba 100644 --- a/contrib/llvm/include/llvm/Support/GraphWriter.h +++ b/contrib/llvm/include/llvm/Support/GraphWriter.h @@ -89,7 +89,7 @@ class GraphWriter { public: GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g) { - DTraits = DOTTraits(SN); + DTraits = DOTTraits(SN); } void writeHeader(const std::string &Name) { @@ -271,6 +271,12 @@ public: O << "[" << Attrs << "]"; O << ";\n"; } + + /// getOStream - Get the raw output stream into the graph file. Useful to + /// write fancy things using addCustomGraphFeatures(). + raw_ostream &getOStream() { + return O; + } }; template<typename GraphType> @@ -316,7 +322,7 @@ sys::Path WriteGraph(const GraphType &G, const std::string &Name, raw_fd_ostream O(Filename.c_str(), ErrorInfo); if (ErrorInfo.empty()) { - WriteGraph(O, G, ShortNames, Name, Title); + llvm::WriteGraph(O, G, ShortNames, Name, Title); errs() << " done. \n"; } else { errs() << "error opening file '" << Filename.str() << "' for writing!\n"; @@ -333,7 +339,7 @@ template<typename GraphType> void ViewGraph(const GraphType &G, const std::string &Name, bool ShortNames = false, const std::string &Title = "", GraphProgram::Name Program = GraphProgram::DOT) { - sys::Path Filename = WriteGraph(G, Name, ShortNames, Title); + sys::Path Filename = llvm::WriteGraph(G, Name, ShortNames, Title); if (Filename.isEmpty()) return; diff --git a/contrib/llvm/include/llvm/Support/IRBuilder.h b/contrib/llvm/include/llvm/Support/IRBuilder.h index 4b1b1c0..c827cce 100644 --- a/contrib/llvm/include/llvm/Support/IRBuilder.h +++ b/contrib/llvm/include/llvm/Support/IRBuilder.h @@ -165,41 +165,21 @@ public: } /// getInt8 - Get a constant 8-bit value. - ConstantInt *getInt8(int8_t C) { - return ConstantInt::getSigned(getInt8Ty(), C); - } - - /// getInt8 - Get a constant 8-bit value. ConstantInt *getInt8(uint8_t C) { return ConstantInt::get(getInt8Ty(), C); } /// getInt16 - Get a constant 16-bit value. - ConstantInt *getInt16(int16_t C) { - return ConstantInt::getSigned(getInt16Ty(), C); - } - - /// getInt16 - Get a constant 16-bit value. ConstantInt *getInt16(uint16_t C) { return ConstantInt::get(getInt16Ty(), C); } /// getInt32 - Get a constant 32-bit value. - ConstantInt *getInt32(int32_t C) { - return ConstantInt::getSigned(getInt32Ty(), C); - } - - /// getInt32 - Get a constant 32-bit value. ConstantInt *getInt32(uint32_t C) { return ConstantInt::get(getInt32Ty(), C); } /// getInt64 - Get a constant 64-bit value. - ConstantInt *getInt64(int64_t C) { - return ConstantInt::getSigned(getInt64Ty(), C); - } - - /// getInt64 - Get a constant 64-bit value. ConstantInt *getInt64(uint64_t C) { return ConstantInt::get(getInt64Ty(), C); } diff --git a/contrib/llvm/include/llvm/Support/IRReader.h b/contrib/llvm/include/llvm/Support/IRReader.h index fe47c05..a44da52 100644 --- a/contrib/llvm/include/llvm/Support/IRReader.h +++ b/contrib/llvm/include/llvm/Support/IRReader.h @@ -60,8 +60,7 @@ namespace llvm { MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg); if (F == 0) { Err = SMDiagnostic(Filename, - "Could not open input file " - "'" + Filename + "': " + ErrMsg); + "Could not open input file: " + ErrMsg); return 0; } @@ -79,10 +78,10 @@ namespace llvm { (const unsigned char *)Buffer->getBufferEnd())) { std::string ErrMsg; Module *M = ParseBitcodeFile(Buffer, Context, &ErrMsg); - // ParseBitcodeFile does not take ownership of the Buffer. - delete Buffer; if (M == 0) Err = SMDiagnostic(Buffer->getBufferIdentifier(), ErrMsg); + // ParseBitcodeFile does not take ownership of the Buffer. + delete Buffer; return M; } @@ -99,8 +98,7 @@ namespace llvm { MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg); if (F == 0) { Err = SMDiagnostic(Filename, - "Could not open input file " - "'" + Filename + "': " + ErrMsg); + "Could not open input file: " + ErrMsg); return 0; } diff --git a/contrib/llvm/include/llvm/Support/MachO.h b/contrib/llvm/include/llvm/Support/MachO.h index e6fccfc..4c13177 100644 --- a/contrib/llvm/include/llvm/Support/MachO.h +++ b/contrib/llvm/include/llvm/Support/MachO.h @@ -14,11 +14,649 @@ #ifndef LLVM_SUPPORT_MACHO_H #define LLVM_SUPPORT_MACHO_H +#include "llvm/System/DataTypes.h" + // NOTE: The enums in this file are intentially named to be different than those // in the headers in /usr/include/mach (on darwin systems) to avoid conflicts // with those macros. namespace llvm { namespace MachO { + // Enums from <mach-o/loader.h> + enum { + // Constants for the "magic" field in llvm::MachO::mach_header and + // llvm::MachO::mach_header_64 + HeaderMagic32 = 0xFEEDFACEu, // MH_MAGIC + HeaderMagic32Swapped = 0xCEFAEDFEu, // MH_CIGAM + HeaderMagic64 = 0xFEEDFACFu, // MH_MAGIC_64 + HeaderMagic64Swapped = 0xCFFAEDFEu, // MH_CIGAM_64 + UniversalMagic = 0xCAFEBABEu, // FAT_MAGIC + UniversalMagicSwapped = 0xBEBAFECAu, // FAT_CIGAM + + // Constants for the "filetype" field in llvm::MachO::mach_header and + // llvm::MachO::mach_header_64 + HeaderFileTypeObject = 0x1u, // MH_OBJECT + HeaderFileTypeExecutable = 0x2u, // MH_EXECUTE + HeaderFileTypeFixedVMShlib = 0x3u, // MH_FVMLIB + HeaderFileTypeCore = 0x4u, // MH_CORE + HeaderFileTypePreloadedExecutable = 0x5u, // MH_PRELOAD + HeaderFileTypeDynamicShlib = 0x6u, // MH_DYLIB + HeaderFileTypeDynamicLinkEditor = 0x7u, // MH_DYLINKER + HeaderFileTypeBundle = 0x8u, // MH_BUNDLE + HeaderFileTypeDynamicShlibStub = 0x9u, // MH_DYLIB_STUB + HeaderFileTypeDSYM = 0xAu, // MH_DSYM + HeaderFileTypeKextBundle = 0xBu, // MH_KEXT_BUNDLE + + // Constant bits for the "flags" field in llvm::MachO::mach_header and + // llvm::MachO::mach_header_64 + HeaderFlagBitNoUndefinedSymbols = 0x00000001u, // MH_NOUNDEFS + HeaderFlagBitIsIncrementalLinkObject= 0x00000002u, // MH_INCRLINK + HeaderFlagBitIsDynamicLinkObject = 0x00000004u, // MH_DYLDLINK + HeaderFlagBitBindAtLoad = 0x00000008u, // MH_BINDATLOAD + HeaderFlagBitPrebound = 0x00000010u, // MH_PREBOUND + HeaderFlagBitSplitSegments = 0x00000020u, // MH_SPLIT_SEGS + HeaderFlagBitLazyInit = 0x00000040u, // MH_LAZY_INIT + HeaderFlagBitTwoLevelNamespace = 0x00000080u, // MH_TWOLEVEL + HeaderFlagBitForceFlatNamespace = 0x00000100u, // MH_FORCE_FLAT + HeaderFlagBitNoMultipleDefintions = 0x00000200u, // MH_NOMULTIDEFS + HeaderFlagBitNoFixPrebinding = 0x00000400u, // MH_NOFIXPREBINDING + HeaderFlagBitPrebindable = 0x00000800u, // MH_PREBINDABLE + HeaderFlagBitAllModulesBound = 0x00001000u, // MH_ALLMODSBOUND + HeaderFlagBitSubsectionsViaSymbols = 0x00002000u, // MH_SUBSECTIONS_VIA_SYMBOLS + HeaderFlagBitCanonical = 0x00004000u, // MH_CANONICAL + HeaderFlagBitWeakDefines = 0x00008000u, // MH_WEAK_DEFINES + HeaderFlagBitBindsToWeak = 0x00010000u, // MH_BINDS_TO_WEAK + HeaderFlagBitAllowStackExecution = 0x00020000u, // MH_ALLOW_STACK_EXECUTION + HeaderFlagBitRootSafe = 0x00040000u, // MH_ROOT_SAFE + HeaderFlagBitSetUIDSafe = 0x00080000u, // MH_SETUID_SAFE + HeaderFlagBitNoReexportedDylibs = 0x00100000u, // MH_NO_REEXPORTED_DYLIBS + HeaderFlagBitPIE = 0x00200000u, // MH_PIE + HeaderFlagBitDeadStrippableDylib = 0x00400000u, // MH_DEAD_STRIPPABLE_DYLIB + + // Constants for the "cmd" field in llvm::MachO::load_command + LoadCommandDynamicLinkerRequired = 0x80000000u, // LC_REQ_DYLD + LoadCommandSegment32 = 0x00000001u, // LC_SEGMENT + LoadCommandSymtab = 0x00000002u, // LC_SYMTAB + LoadCommandSymSeg = 0x00000003u, // LC_SYMSEG + LoadCommandThread = 0x00000004u, // LC_THREAD + LoadCommandUnixThread = 0x00000005u, // LC_UNIXTHREAD + LoadCommandFixedVMShlibLoad = 0x00000006u, // LC_LOADFVMLIB + LoadCommandFixedVMShlibIdent = 0x00000007u, // LC_IDFVMLIB + LoadCommandIdent = 0x00000008u, // LC_IDENT + LoadCommandFixedVMFileInclusion = 0x00000009u, // LC_FVMFILE + LoadCommandPrePage = 0x0000000Au, // LC_PREPAGE + LoadCommandDynamicSymtabInfo = 0x0000000Bu, // LC_DYSYMTAB + LoadCommandDylibLoad = 0x0000000Cu, // LC_LOAD_DYLIB + LoadCommandDylibIdent = 0x0000000Du, // LC_ID_DYLIB + LoadCommandDynamicLinkerLoad = 0x0000000Eu, // LC_LOAD_DYLINKER + LoadCommandDynamicLinkerIdent = 0x0000000Fu, // LC_ID_DYLINKER + LoadCommandDylibPrebound = 0x00000010u, // LC_PREBOUND_DYLIB + LoadCommandRoutines32 = 0x00000011u, // LC_ROUTINES + LoadCommandSubFramework = 0x00000012u, // LC_SUB_FRAMEWORK + LoadCommandSubUmbrella = 0x00000013u, // LC_SUB_UMBRELLA + LoadCommandSubClient = 0x00000014u, // LC_SUB_CLIENT + LoadCommandSubLibrary = 0x00000015u, // LC_SUB_LIBRARY + LoadCommandTwoLevelHints = 0x00000016u, // LC_TWOLEVEL_HINTS + LoadCommandPreBindChecksum = 0x00000017u, // LC_PREBIND_CKSUM + LoadCommandDylibLoadWeak = 0x80000018u, // LC_LOAD_WEAK_DYLIB + LoadCommandSegment64 = 0x00000019u, // LC_SEGMENT_64 + LoadCommandRoutines64 = 0x0000001Au, // LC_ROUTINES_64 + LoadCommandUUID = 0x0000001Bu, // LC_UUID + LoadCommandRunpath = 0x8000001Cu, // LC_RPATH + LoadCommandCodeSignature = 0x0000001Du, // LC_CODE_SIGNATURE + LoadCommandSegmentSplitInfo = 0x0000001Eu, // LC_SEGMENT_SPLIT_INFO + LoadCommandDylibReexport = 0x8000001Fu, // LC_REEXPORT_DYLIB + LoadCommandDylibLazyLoad = 0x00000020u, // LC_LAZY_LOAD_DYLIB + LoadCommandEncryptionInfo = 0x00000021u, // LC_ENCRYPTION_INFO + LoadCommandDynamicLinkerInfo = 0x00000022u, // LC_DYLD_INFO + LoadCommandDynamicLinkerInfoOnly = 0x80000022u, // LC_DYLD_INFO_ONLY + LoadCommandDylibLoadUpward = 0x80000023u, // LC_LOAD_UPWARD_DYLIB + + // Constant bits for the "flags" field in llvm::MachO::segment_command + SegmentCommandFlagBitHighVM = 0x1u, // SG_HIGHVM + SegmentCommandFlagBitFixedVMLibrary = 0x2u, // SG_FVMLIB + SegmentCommandFlagBitNoRelocations = 0x4u, // SG_NORELOC + SegmentCommandFlagBitProtectedVersion1 = 0x8u, // SG_PROTECTED_VERSION_1 + + + // Constant masks for the "flags" field in llvm::MachO::section and + // llvm::MachO::section_64 + SectionFlagMaskSectionType = 0x000000ffu, // SECTION_TYPE + SectionFlagMaskAllAttributes = 0xffffff00u, // SECTION_ATTRIBUTES + SectionFlagMaskUserAttributes = 0xff000000u, // SECTION_ATTRIBUTES_USR + SectionFlagMaskSystemAttributes = 0x00ffff00u, // SECTION_ATTRIBUTES_SYS + + // Constant masks for the "flags[7:0]" field in llvm::MachO::section and + // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE) + SectionTypeRegular = 0x00u, // S_REGULAR + SectionTypeZeroFill = 0x01u, // S_ZEROFILL + SectionTypeCStringLiterals = 0x02u, // S_CSTRING_LITERALS + SectionType4ByteLiterals = 0x03u, // S_4BYTE_LITERALS + SectionType8ByteLiterals = 0x04u, // S_8BYTE_LITERALS + SectionTypeLiteralPointers = 0x05u, // S_LITERAL_POINTERS + SectionTypeNonLazySymbolPointers = 0x06u, // S_NON_LAZY_SYMBOL_POINTERS + SectionTypeLazySymbolPointers = 0x07u, // S_LAZY_SYMBOL_POINTERS + SectionTypeSymbolStubs = 0x08u, // S_SYMBOL_STUBS + SectionTypeModuleInitFunctionPointers = 0x09u, // S_MOD_INIT_FUNC_POINTERS + SectionTypeModuleTermFunctionPointers = 0x0au, // S_MOD_TERM_FUNC_POINTERS + SectionTypeCoalesced = 0x0bu, // S_COALESCED + SectionTypeZeroFillLarge = 0x0cu, // S_GB_ZEROFILL + SectionTypeInterposing = 0x0du, // S_INTERPOSING + SectionType16ByteLiterals = 0x0eu, // S_16BYTE_LITERALS + SectionTypeDTraceObjectFormat = 0x0fu, // S_DTRACE_DOF + SectionTypeLazyDylibSymbolPointers = 0x10u, // S_LAZY_DYLIB_SYMBOL_POINTERS + + // Constant masks for the "flags[31:24]" field in llvm::MachO::section and + // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR) + SectionAttrUserPureInstructions = 0x80000000u, // S_ATTR_PURE_INSTRUCTIONS + SectionAttrUserNoTableOfContents = 0x40000000u, // S_ATTR_NO_TOC + SectionAttrUserCanStripStaticSymbols = 0x20000000u, // S_ATTR_STRIP_STATIC_SYMS + SectionAttrUserNoDeadStrip = 0x10000000u, // S_ATTR_NO_DEAD_STRIP + SectionAttrUserLiveSupport = 0x08000000u, // S_ATTR_LIVE_SUPPORT + SectionAttrUserSelfModifyingCode = 0x04000000u, // S_ATTR_SELF_MODIFYING_CODE + SectionAttrUserDebug = 0x02000000u, // S_ATTR_DEBUG + + // Constant masks for the "flags[23:8]" field in llvm::MachO::section and + // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS) + SectionAttrSytemSomeInstructions = 0x00000400u, // S_ATTR_SOME_INSTRUCTIONS + SectionAttrSytemHasExternalRelocations= 0x00000200u, // S_ATTR_EXT_RELOC + SectionAttrSytemHasLocalRelocations = 0x00000100u, // S_ATTR_LOC_RELOC + + IndirectSymbolLocal = 0x80000000u, // INDIRECT_SYMBOL_LOCAL + IndirectSymbolAbsolute = 0x40000000u, // INDIRECT_SYMBOL_ABS + + RebaseTypePointer = 1u, // REBASE_TYPE_POINTER + RebaseTypeTextAbsolute32 = 2u, // REBASE_TYPE_TEXT_ABSOLUTE32 + RebaseTypeTextPCRelative32 = 3u, // REBASE_TYPE_TEXT_PCREL32 + + RebaseOpcodeMask = 0xF0u, // REBASE_OPCODE_MASK + RebaseImmediateMask = 0x0Fu, // REBASE_IMMEDIATE_MASK + RebaseOpcodeDone = 0x00u, // REBASE_OPCODE_DONE + RebaseOpcodeSetTypeImmediate = 0x10u, // REBASE_OPCODE_SET_TYPE_IMM + RebaseOpcodeSetSegmentAndOffsetULEB = 0x20u, // REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB + RebaseOpcodeAddAddressULEB = 0x30u, // REBASE_OPCODE_ADD_ADDR_ULEB + RebaseOpcodeAddAddressImmediateScaled = 0x40u, // REBASE_OPCODE_ADD_ADDR_IMM_SCALED + RebaseOpcodeDoRebaseImmediateTimes = 0x50u, // REBASE_OPCODE_DO_REBASE_IMM_TIMES + RebaseOpcodeDoRebaseULEBTimes = 0x60u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES + RebaseOpcodeDoRebaseAddAddressULEB = 0x70u, // REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB + RebaseOpcodeDoRebaseULEBTimesSkippingULEB = 0x80u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB + + + BindTypePointer = 1u, // BIND_TYPE_POINTER + BindTypeTextAbsolute32 = 2u, // BIND_TYPE_TEXT_ABSOLUTE32 + BindTypeTextPCRelative32 = 3u, // BIND_TYPE_TEXT_PCREL32 + + BindSpecialDylibSelf = 0u, // BIND_SPECIAL_DYLIB_SELF + BindSpecialDylibMainExecutable = -1u, // BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE + BindSpecialDylibFlatLookup = -2u, // BIND_SPECIAL_DYLIB_FLAT_LOOKUP + + BindSymbolFlagsWeakImport = 0x1u, // BIND_SYMBOL_FLAGS_WEAK_IMPORT + BindSymbolFlagsNonWeakDefinition = 0x8u, // BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION + + BindOpcodeMask = 0xF0u, // BIND_OPCODE_MASK + BindImmediateMask = 0x0Fu, // BIND_IMMEDIATE_MASK + BindOpcodeDone = 0x00u, // BIND_OPCODE_DONE + BindOpcodeSetDylibOrdinalImmediate = 0x10u, // BIND_OPCODE_SET_DYLIB_ORDINAL_IMM + BindOpcodeSetDylibOrdinalULEB = 0x20u, // BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB + BindOpcodeSetDylibSpecialImmediate = 0x30u, // BIND_OPCODE_SET_DYLIB_SPECIAL_IMM + BindOpcodeSetSymbolTrailingFlagsImmediate = 0x40u, // BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM + BindOpcodeSetTypeImmediate = 0x50u, // BIND_OPCODE_SET_TYPE_IMM + BindOpcodeSetAppendSLEB = 0x60u, // BIND_OPCODE_SET_ADDEND_SLEB + BindOpcodeSetSegmentAndOffsetULEB = 0x70u, // BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB + BindOpcodeAddAddressULEB = 0x80u, // BIND_OPCODE_ADD_ADDR_ULEB + BindOpcodeDoBind = 0x90u, // BIND_OPCODE_DO_BIND + BindOpcodeDoBindAddAddressULEB = 0xA0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB + BindOpcodeDoBindAddAddressImmediateScaled = 0xB0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED + BindOpcodeDoBindULEBTimesSkippingULEB = 0xC0u, // BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB + + ExportSymbolFlagsKindMask = 0x03u, // EXPORT_SYMBOL_FLAGS_KIND_MASK + ExportSymbolFlagsKindRegular = 0x00u, // EXPORT_SYMBOL_FLAGS_KIND_REGULAR + ExportSymbolFlagsKindThreadLocal = 0x01u, // EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL + ExportSymbolFlagsWeakDefinition = 0x04u, // EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION + ExportSymbolFlagsIndirectDefinition = 0x08u, // EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION + ExportSymbolFlagsHasSpecializations = 0x10u, // EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS + + + // Constant masks for the "n_type" field in llvm::MachO::nlist and + // llvm::MachO::nlist_64 + NlistMaskStab = 0xe0, // N_STAB + NlistMaskPrivateExternal = 0x10, // N_PEXT + NlistMaskType = 0x0e, // N_TYPE + NlistMaskExternal = 0x01, // N_EXT + + // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and + // llvm::MachO::nlist_64 + NListTypeUndefined = 0x0u, // N_UNDF + NListTypeAbsolute = 0x2u, // N_ABS + NListTypeSection = 0xeu, // N_SECT + NListTypePreboundUndefined = 0xcu, // N_PBUD + NListTypeIndirect = 0xau, // N_INDR + + // Constant masks for the "n_sect" field in llvm::MachO::nlist and + // llvm::MachO::nlist_64 + NListSectionNoSection = 0u, // NO_SECT + NListSectionMaxSection = 0xffu, // MAX_SECT + + // Constant values for the "n_type" field in llvm::MachO::nlist and + // llvm::MachO::nlist_64 when "(n_type & NlistMaskStab) != 0" + StabGlobalSymbol = 0x20u, // N_GSYM + StabFunctionName = 0x22u, // N_FNAME + StabFunction = 0x24u, // N_FUN + StabStaticSymbol = 0x26u, // N_STSYM + StabLocalCommon = 0x28u, // N_LCSYM + StabBeginSymbol = 0x2Eu, // N_BNSYM + StabSourceFileOptions = 0x3Cu, // N_OPT + StabRegisterSymbol = 0x40u, // N_RSYM + StabSourceLine = 0x44u, // N_SLINE + StabEndSymbol = 0x4Eu, // N_ENSYM + StabStructureType = 0x60u, // N_SSYM + StabSourceFileName = 0x64u, // N_SO + StabObjectFileName = 0x66u, // N_OSO + StabLocalSymbol = 0x80u, // N_LSYM + StabBeginIncludeFileName = 0x82u, // N_BINCL + StabIncludeFileName = 0x84u, // N_SOL + StabCompilerParameters = 0x86u, // N_PARAMS + StabCompilerVersion = 0x88u, // N_VERSION + StabCompilerOptLevel = 0x8Au, // N_OLEVEL + StabParameter = 0xA0u, // N_PSYM + StabEndIncludeFile = 0xA2u, // N_EINCL + StabAlternateEntry = 0xA4u, // N_ENTRY + StabLeftBracket = 0xC0u, // N_LBRAC + StabDeletedIncludeFile = 0xC2u, // N_EXCL + StabRightBracket = 0xE0u, // N_RBRAC + StabBeginCommon = 0xE2u, // N_BCOMM + StabEndCommon = 0xE4u, // N_ECOMM + StabEndCommonLocal = 0xE8u, // N_ECOML + StabLength = 0xFEu // N_LENG + + }; + + // Structs from <mach-o/loader.h> + + struct mach_header { + uint32_t magic; + uint32_t cputype; + uint32_t cpusubtype; + uint32_t filetype; + uint32_t ncmds; + uint32_t sizeofcmds; + uint32_t flags; + }; + + struct mach_header_64 { + uint32_t magic; + uint32_t cputype; + uint32_t cpusubtype; + uint32_t filetype; + uint32_t ncmds; + uint32_t sizeofcmds; + uint32_t flags; + uint32_t reserved; + }; + + struct load_command { + uint32_t cmd; + uint32_t cmdsize; + }; + + struct segment_command { + uint32_t cmd; + uint32_t cmdsize; + char segname[16]; + uint32_t vmaddr; + uint32_t vmsize; + uint32_t fileoff; + uint32_t filesize; + uint32_t maxprot; + uint32_t initprot; + uint32_t nsects; + uint32_t flags; + }; + + struct segment_command_64 { + uint32_t cmd; + uint32_t cmdsize; + char segname[16]; + uint64_t vmaddr; + uint64_t vmsize; + uint64_t fileoff; + uint64_t filesize; + uint32_t maxprot; + uint32_t initprot; + uint32_t nsects; + uint32_t flags; + }; + + struct section { + char sectname[16]; + char segname[16]; + uint32_t addr; + uint32_t size; + uint32_t offset; + uint32_t align; + uint32_t reloff; + uint32_t nreloc; + uint32_t flags; + uint32_t reserved1; + uint32_t reserved2; + }; + + struct section_64 { + char sectname[16]; + char segname[16]; + uint64_t addr; + uint64_t size; + uint32_t offset; + uint32_t align; + uint32_t reloff; + uint32_t nreloc; + uint32_t flags; + uint32_t reserved1; + uint32_t reserved2; + uint32_t reserved3; + }; + + struct fvmlib { + uint32_t name; + uint32_t minor_version; + uint32_t header_addr; + }; + + struct fvmlib_command { + uint32_t cmd; + uint32_t cmdsize; + struct fvmlib fvmlib; + }; + + struct dylib { + uint32_t name; + uint32_t timestamp; + uint32_t current_version; + uint32_t compatibility_version; + }; + + struct dylib_command { + uint32_t cmd; + uint32_t cmdsize; + struct dylib dylib; + }; + + struct sub_framework_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t umbrella; + }; + + struct sub_client_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t client; + }; + + struct sub_umbrella_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t sub_umbrella; + }; + + struct sub_library_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t sub_library; + }; + + struct prebound_dylib_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t name; + uint32_t nmodules; + uint32_t linked_modules; + }; + + struct dylinker_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t name; + }; + + struct thread_command { + uint32_t cmd; + uint32_t cmdsize; + }; + + struct routines_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t init_address; + uint32_t init_module; + uint32_t reserved1; + uint32_t reserved2; + uint32_t reserved3; + uint32_t reserved4; + uint32_t reserved5; + uint32_t reserved6; + }; + + struct routines_command_64 { + uint32_t cmd; + uint32_t cmdsize; + uint64_t init_address; + uint64_t init_module; + uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; + uint64_t reserved6; + }; + + struct symtab_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t symoff; + uint32_t nsyms; + uint32_t stroff; + uint32_t strsize; + }; + + struct dysymtab_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t ilocalsym; + uint32_t nlocalsym; + uint32_t iextdefsym; + uint32_t nextdefsym; + uint32_t iundefsym; + uint32_t nundefsym; + uint32_t tocoff; + uint32_t ntoc; + uint32_t modtaboff; + uint32_t nmodtab; + uint32_t extrefsymoff; + uint32_t nextrefsyms; + uint32_t indirectsymoff; + uint32_t nindirectsyms; + uint32_t extreloff; + uint32_t nextrel; + uint32_t locreloff; + uint32_t nlocrel; + }; + + struct dylib_table_of_contents { + uint32_t symbol_index; + uint32_t module_index; + }; + + struct dylib_module { + uint32_t module_name; + uint32_t iextdefsym; + uint32_t nextdefsym; + uint32_t irefsym; + uint32_t nrefsym; + uint32_t ilocalsym; + uint32_t nlocalsym; + uint32_t iextrel; + uint32_t nextrel; + uint32_t iinit_iterm; + uint32_t ninit_nterm; + uint32_t objc_module_info_addr; + uint32_t objc_module_info_size; + }; + + struct dylib_module_64 { + uint32_t module_name; + uint32_t iextdefsym; + uint32_t nextdefsym; + uint32_t irefsym; + uint32_t nrefsym; + uint32_t ilocalsym; + uint32_t nlocalsym; + uint32_t iextrel; + uint32_t nextrel; + uint32_t iinit_iterm; + uint32_t ninit_nterm; + uint32_t objc_module_info_size; + uint64_t objc_module_info_addr; + }; + + struct dylib_reference { + uint32_t isym:24, + flags:8; + }; + + + struct twolevel_hints_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t offset; + uint32_t nhints; + }; + + struct twolevel_hint { + uint32_t isub_image:8, + itoc:24; + }; + + struct prebind_cksum_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t cksum; + }; + + struct uuid_command { + uint32_t cmd; + uint32_t cmdsize; + uint8_t uuid[16]; + }; + + struct rpath_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t path; + }; + + struct linkedit_data_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t dataoff; + uint32_t datasize; + }; + + struct encryption_info_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t cryptoff; + uint32_t cryptsize; + uint32_t cryptid; + }; + + struct dyld_info_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t rebase_off; + uint32_t rebase_size; + uint32_t bind_off; + uint32_t bind_size; + uint32_t weak_bind_off; + uint32_t weak_bind_size; + uint32_t lazy_bind_off; + uint32_t lazy_bind_size; + uint32_t export_off; + uint32_t export_size; + }; + + struct symseg_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t offset; + uint32_t size; + }; + + struct ident_command { + uint32_t cmd; + uint32_t cmdsize; + }; + + struct fvmfile_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t name; + uint32_t header_addr; + }; + + + // Structs from <mach-o/fat.h> + struct fat_header { + uint32_t magic; + uint32_t nfat_arch; + }; + + struct fat_arch { + uint32_t cputype; + uint32_t cpusubtype; + uint32_t offset; + uint32_t size; + uint32_t align; + }; + + // Structs from <mach-o/fat.h> + struct nlist { + uint32_t n_strx; + uint8_t n_type; + uint8_t n_sect; + int16_t n_desc; + uint32_t n_value; + }; + + struct nlist_64 { + uint32_t n_strx; + uint8_t n_type; + uint8_t n_sect; + uint16_t n_desc; + uint64_t n_value; + }; + + // Get/Set functions from <mach-o/nlist.h> + + static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) + { + return (((n_desc) >> 8u) & 0xffu); + } + + static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) + { + n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)); + } + + static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) + { + return (n_desc >> 8u) & 0x0fu; + } + + static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) + { + n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u)); + } + // Enums from <mach/machine.h> enum { // Capability bits used in the definition of cpu_type. diff --git a/contrib/llvm/include/llvm/Support/MathExtras.h b/contrib/llvm/include/llvm/Support/MathExtras.h index 80d11ae..982813f 100644 --- a/contrib/llvm/include/llvm/Support/MathExtras.h +++ b/contrib/llvm/include/llvm/Support/MathExtras.h @@ -126,7 +126,8 @@ inline uint16_t ByteSwap_16(uint16_t Value) { /// ByteSwap_32 - This function returns a byte-swapped representation of the /// 32-bit argument, Value. inline uint32_t ByteSwap_32(uint32_t Value) { -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) +#if defined(__llvm__) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) return __builtin_bswap32(Value); #elif defined(_MSC_VER) && !defined(_DEBUG) return _byteswap_ulong(Value); @@ -142,7 +143,8 @@ inline uint32_t ByteSwap_32(uint32_t Value) { /// ByteSwap_64 - This function returns a byte-swapped representation of the /// 64-bit argument, Value. inline uint64_t ByteSwap_64(uint64_t Value) { -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) +#if defined(__llvm__) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) return __builtin_bswap64(Value); #elif defined(_MSC_VER) && !defined(_DEBUG) return _byteswap_uint64(Value); diff --git a/contrib/llvm/include/llvm/Support/PassNameParser.h b/contrib/llvm/include/llvm/Support/PassNameParser.h index cdca978..a24a6f0 100644 --- a/contrib/llvm/include/llvm/Support/PassNameParser.h +++ b/contrib/llvm/include/llvm/Support/PassNameParser.h @@ -23,11 +23,11 @@ #ifndef LLVM_SUPPORT_PASS_NAME_PARSER_H #define LLVM_SUPPORT_PASS_NAME_PARSER_H +#include "llvm/Pass.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Pass.h" -#include <algorithm> #include <cstring> namespace llvm { @@ -42,8 +42,7 @@ class PassNameParser : public PassRegistrationListener, public: PassNameParser() : Opt(0) {} virtual ~PassNameParser(); - - + void initialize(cl::Option &O) { Opt = &O; cl::parser<const PassInfo*>::initialize(O); @@ -77,20 +76,21 @@ public: } virtual void passEnumerate(const PassInfo *P) { passRegistered(P); } - // ValLessThan - Provide a sorting comparator for Values elements... - typedef std::pair<const char*, - std::pair<const PassInfo*, const char*> > ValType; - static bool ValLessThan(const ValType &VT1, const ValType &VT2) { - return std::string(VT1.first) < std::string(VT2.first); - } - // printOptionInfo - Print out information about this option. Override the // default implementation to sort the table before we print... virtual void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const { PassNameParser *PNP = const_cast<PassNameParser*>(this); - std::sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan); + array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan); cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth); } + +private: + // ValLessThan - Provide a sorting comparator for Values elements... + static int ValLessThan(const void *VT1, const void *VT2) { + typedef PassNameParser::OptionInfo ValType; + return std::strcmp(static_cast<const ValType *>(VT1)->Name, + static_cast<const ValType *>(VT2)->Name); + } }; ///===----------------------------------------------------------------------===// diff --git a/contrib/llvm/include/llvm/Support/PatternMatch.h b/contrib/llvm/include/llvm/Support/PatternMatch.h index f02bc34..bee6768 100644 --- a/contrib/llvm/include/llvm/Support/PatternMatch.h +++ b/contrib/llvm/include/llvm/Support/PatternMatch.h @@ -453,6 +453,13 @@ struct CastClass_match { } }; +/// m_BitCast +template<typename OpTy> +inline CastClass_match<OpTy, Instruction::BitCast> +m_BitCast(const OpTy &Op) { + return CastClass_match<OpTy, Instruction::BitCast>(Op); +} + /// m_PtrToInt template<typename OpTy> inline CastClass_match<OpTy, Instruction::PtrToInt> diff --git a/contrib/llvm/include/llvm/Support/PrettyStackTrace.h b/contrib/llvm/include/llvm/Support/PrettyStackTrace.h index 0db84e1..6dbce39 100644 --- a/contrib/llvm/include/llvm/Support/PrettyStackTrace.h +++ b/contrib/llvm/include/llvm/Support/PrettyStackTrace.h @@ -24,10 +24,10 @@ namespace llvm { /// handlers which conflict with the ones installed by this module. /// Defaults to false. extern bool DisablePrettyStackTrace; - + /// PrettyStackTraceEntry - This class is used to represent a frame of the /// "pretty" stack trace that is dumped when a program crashes. You can define - /// subclasses of this and declare them on the program stack: when they are + /// subclasses of this and declare them on the program stack: when they are /// constructed and destructed, they will add their symbolic frames to a /// virtual stack trace. This gets dumped out if the program crashes. class PrettyStackTraceEntry { @@ -37,14 +37,14 @@ namespace llvm { public: PrettyStackTraceEntry(); virtual ~PrettyStackTraceEntry(); - + /// print - Emit information about this stack frame to OS. virtual void print(raw_ostream &OS) const = 0; - + /// getNextEntry - Return the next entry in the list of frames. const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; } }; - + /// PrettyStackTraceString - This object prints a specified string (which /// should not contain newlines) to the stream as the stack trace when a crash /// occurs. @@ -54,7 +54,7 @@ namespace llvm { PrettyStackTraceString(const char *str) : Str(str) {} virtual void print(raw_ostream &OS) const; }; - + /// PrettyStackTraceProgram - This object prints a specified program arguments /// to the stream as the stack trace when a crash occurs. class PrettyStackTraceProgram : public PrettyStackTraceEntry { @@ -65,7 +65,7 @@ namespace llvm { : ArgC(argc), ArgV(argv) {} virtual void print(raw_ostream &OS) const; }; - + } // end namespace llvm #endif diff --git a/contrib/llvm/include/llvm/Support/Regex.h b/contrib/llvm/include/llvm/Support/Regex.h index ea65ccf..b46a668 100644 --- a/contrib/llvm/include/llvm/Support/Regex.h +++ b/contrib/llvm/include/llvm/Support/Regex.h @@ -11,6 +11,9 @@ // //===----------------------------------------------------------------------===// +#ifndef LLVM_SUPPORT_REGEX_H +#define LLVM_SUPPORT_REGEX_H + #include <string> struct llvm_regex; @@ -18,7 +21,7 @@ struct llvm_regex; namespace llvm { class StringRef; template<typename T> class SmallVectorImpl; - + class Regex { public: enum { @@ -26,9 +29,9 @@ namespace llvm { /// Compile for matching that ignores upper/lower case distinctions. IgnoreCase=1, /// Compile for newline-sensitive matching. With this flag '[^' bracket - /// expressions and '.' never match newline. A ^ anchor matches the - /// null string after any newline in the string in addition to its normal - /// function, and the $ anchor matches the null string before any + /// expressions and '.' never match newline. A ^ anchor matches the + /// null string after any newline in the string in addition to its normal + /// function, and the $ anchor matches the null string before any /// newline in the string in addition to its normal function. Newline=2 }; @@ -47,7 +50,7 @@ namespace llvm { /// matches it contains. The number filled in by match will include this /// many entries plus one for the whole regex (as element 0). unsigned getNumMatches() const; - + /// matches - Match the regex against a given \arg String. /// /// \param Matches - If given, on a succesful match this will be filled in @@ -74,3 +77,5 @@ namespace llvm { int error; }; } + +#endif // LLVM_SUPPORT_REGEX_H diff --git a/contrib/llvm/include/llvm/Support/Registry.h b/contrib/llvm/include/llvm/Support/Registry.h index 4db8882..d0375be 100644 --- a/contrib/llvm/include/llvm/Support/Registry.h +++ b/contrib/llvm/include/llvm/Support/Registry.h @@ -203,6 +203,8 @@ namespace llvm { }; + // Since these are defined in a header file, plugins must be sure to export + // these symbols. template <typename T, typename U> typename Registry<T,U>::node *Registry<T,U>::Head; diff --git a/contrib/llvm/include/llvm/Support/SlowOperationInformer.h b/contrib/llvm/include/llvm/Support/SlowOperationInformer.h deleted file mode 100644 index 607d993..0000000 --- a/contrib/llvm/include/llvm/Support/SlowOperationInformer.h +++ /dev/null @@ -1,65 +0,0 @@ -//===- llvm/Support/SlowOperationInformer.h - Keep user informed *- 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 a simple object which can be used to let the user know what -// is going on when a slow operation is happening, and gives them the ability to -// cancel it. Potentially slow operations can stack allocate one of these -// objects, and periodically call the "progress" method to update the progress -// bar. If the operation takes more than 1 second to complete, the progress bar -// is automatically shown and updated. As such, the slow operation should not -// print stuff to the screen, and should not be confused if an extra line -// appears on the screen (ie, the cursor should be at the start of the line). -// -// If the user presses CTRL-C during the operation, the next invocation of the -// progress method return true indicating that the operation was cancelled. -// -// Because SlowOperationInformers fiddle around with signals, they cannot be -// nested, and interact poorly with threads. The SIGALRM handler is set back to -// SIGDFL, but the SIGINT signal handler is restored when the -// SlowOperationInformer is destroyed. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_SLOW_OPERATION_INFORMER_H -#define LLVM_SUPPORT_SLOW_OPERATION_INFORMER_H - -#include <string> -#include <cassert> -#include "llvm/System/DataTypes.h" - -namespace llvm { - class SlowOperationInformer { - std::string OperationName; - unsigned LastPrintAmount; - - SlowOperationInformer(const SlowOperationInformer&); // DO NOT IMPLEMENT - void operator=(const SlowOperationInformer&); // DO NOT IMPLEMENT - public: - explicit SlowOperationInformer(const std::string &Name); - ~SlowOperationInformer(); - - /// progress - Clients should periodically call this method when they can - /// handle cancellation. The Amount variable should indicate how far - /// along the operation is, given in 1/10ths of a percent (in other words, - /// Amount should range from 0 to 1000). If the user cancels the operation, - /// this returns true, false otherwise. - bool progress(unsigned Amount); - - /// progress - Same as the method above, but this performs the division for - /// you, and helps you avoid overflow if you are dealing with largish - /// numbers. - bool progress(unsigned Current, unsigned Maximum) { - assert(Maximum != 0 && - "Shouldn't be doing work if there is nothing to do!"); - return progress(Current*uint64_t(1000UL)/Maximum); - } - }; -} // end namespace llvm - -#endif /* SLOW_OPERATION_INFORMER_H */ diff --git a/contrib/llvm/include/llvm/Support/SourceMgr.h b/contrib/llvm/include/llvm/Support/SourceMgr.h index 9cd35d1..270ab2b 100644 --- a/contrib/llvm/include/llvm/Support/SourceMgr.h +++ b/contrib/llvm/include/llvm/Support/SourceMgr.h @@ -161,8 +161,8 @@ public: // Diagnostic with no location (e.g. file not found, command line arg error). SMDiagnostic(const std::string &filename, const std::string &Msg, bool showline = true) - : SM(0), Loc(), Filename(filename), LineNo(-1), ColumnNo(-1), - Message(Msg), LineContents(""), ShowLine(showline) {} + : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1), + Message(Msg), ShowLine(showline) {} // Diagnostic with a location. SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN, diff --git a/contrib/llvm/include/llvm/Support/StandardPasses.h b/contrib/llvm/include/llvm/Support/StandardPasses.h index b97ad29..bb3bddd 100644 --- a/contrib/llvm/include/llvm/Support/StandardPasses.h +++ b/contrib/llvm/include/llvm/Support/StandardPasses.h @@ -20,6 +20,7 @@ #define LLVM_SUPPORT_STANDARDPASSES_H #include "llvm/PassManager.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Scalar.h" @@ -116,7 +117,6 @@ namespace llvm { PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args // Start of function pass. - PM->add(createScalarReplAggregatesPass()); // Break up aggregate allocas if (SimplifyLibCalls) PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations @@ -146,6 +146,7 @@ namespace llvm { // opened up by them. PM->add(createInstructionCombiningPass()); PM->add(createJumpThreadingPass()); // Thread jumps + PM->add(createCorrelatedValuePropagationPass()); PM->add(createDeadStoreEliminationPass()); // Delete dead stores PM->add(createAggressiveDCEPass()); // Delete dead instructions PM->add(createCFGSimplificationPass()); // Merge & remove BBs diff --git a/contrib/llvm/include/llvm/Support/SystemUtils.h b/contrib/llvm/include/llvm/Support/SystemUtils.h index b3d83fc..3c182c1 100644 --- a/contrib/llvm/include/llvm/Support/SystemUtils.h +++ b/contrib/llvm/include/llvm/Support/SystemUtils.h @@ -21,10 +21,9 @@ namespace llvm { class raw_ostream; namespace sys { class Path; } -/// Determine if the raw_ostream provided is connected to the outs() and -/// displayed or not (to a console window). If so, generate a warning message -/// advising against display of bitcode and return true. Otherwise just return -/// false +/// Determine if the raw_ostream provided is connected to a terminal. If so, +/// generate a warning message to errs() advising against display of bitcode +/// and return true. Otherwise just return false. /// @brief Check for output written to a console bool CheckBitcodeOutputToConsole( raw_ostream &stream_to_check, ///< The stream to be checked diff --git a/contrib/llvm/include/llvm/Support/TypeBuilder.h b/contrib/llvm/include/llvm/Support/TypeBuilder.h index 270ac52..81c2747 100644 --- a/contrib/llvm/include/llvm/Support/TypeBuilder.h +++ b/contrib/llvm/include/llvm/Support/TypeBuilder.h @@ -73,7 +73,7 @@ namespace llvm { /// /// TypeBuilder cannot handle recursive types or types you only know at runtime. /// If you try to give it a recursive type, it will deadlock, infinitely -/// recurse, or throw a recursive_init exception. +/// recurse, or do something similarly undesirable. template<typename T, bool cross_compilable> class TypeBuilder {}; // Types for use with cross-compilable TypeBuilders. These correspond diff --git a/contrib/llvm/include/llvm/Support/raw_ostream.h b/contrib/llvm/include/llvm/Support/raw_ostream.h index bb9a523..39bdbd8 100644 --- a/contrib/llvm/include/llvm/Support/raw_ostream.h +++ b/contrib/llvm/include/llvm/Support/raw_ostream.h @@ -58,10 +58,6 @@ private: ExternalBuffer } BufferMode; - /// Error This flag is true if an error of any kind has been detected. - /// - bool Error; - public: // color order matches ANSI escape sequence, don't change enum Colors { @@ -77,7 +73,7 @@ public: }; explicit raw_ostream(bool unbuffered=false) - : BufferMode(unbuffered ? Unbuffered : InternalBuffer), Error(false) { + : BufferMode(unbuffered ? Unbuffered : InternalBuffer) { // Start out ready to flush. OutBufStart = OutBufEnd = OutBufCur = 0; } @@ -87,21 +83,6 @@ public: /// tell - Return the current offset with the file. uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); } - /// has_error - Return the value of the flag in this raw_ostream indicating - /// whether an output error has been encountered. - /// This doesn't implicitly flush any pending output. - bool has_error() const { - return Error; - } - - /// clear_error - Set the flag read by has_error() to false. If the error - /// flag is set at the time when this raw_ostream's destructor is called, - /// report_fatal_error is called to report the error. Use clear_error() - /// after handling the error to avoid this behavior. - void clear_error() { - Error = false; - } - //===--------------------------------------------------------------------===// // Configuration Interface //===--------------------------------------------------------------------===// @@ -234,7 +215,7 @@ public: /// @param bold bold/brighter text, default false /// @param bg if true change the background, default: change foreground /// @returns itself so it can be used within << invocations - virtual raw_ostream &changeColor(enum Colors, bool = false, bool = false) { + virtual raw_ostream &changeColor(enum Colors, bool = false, bool = false) { return *this; } /// Resets the colors to terminal defaults. Call this when you are done @@ -285,10 +266,6 @@ protected: /// underlying output mechanism. virtual size_t preferred_buffer_size() const; - /// error_detected - Set the flag indicating that an output error has - /// been encountered. - void error_detected() { Error = true; } - /// getBufferStart - Return the beginning of the current stream buffer, or 0 /// if the stream is unbuffered. const char *getBufferStart() const { return OutBufStart; } @@ -319,6 +296,11 @@ private: class raw_fd_ostream : public raw_ostream { int FD; bool ShouldClose; + + /// Error This flag is true if an error of any kind has been detected. + /// + bool Error; + uint64_t pos; /// write_impl - See raw_ostream::write_impl. @@ -331,6 +313,10 @@ class raw_fd_ostream : public raw_ostream { /// preferred_buffer_size - Determine an efficient buffer size. virtual size_t preferred_buffer_size() const; + /// error_detected - Set the flag indicating that an output error has + /// been encountered. + void error_detected() { Error = true; } + public: enum { @@ -353,8 +339,11 @@ public: /// be immediately destroyed; the string will be empty if no error occurred. /// This allows optional flags to control how the file will be opened. /// - /// \param Filename - The file to open. If this is "-" then the - /// stream will use stdout instead. + /// As a special case, if Filename is "-", then the stream will use + /// STDOUT_FILENO instead of opening a file. Note that it will still consider + /// itself to own the file descriptor. In particular, it will close the + /// file descriptor when it is done (this is necessary to detect + /// output errors). raw_fd_ostream(const char *Filename, std::string &ErrorInfo, unsigned Flags = 0); @@ -362,15 +351,17 @@ public: /// ShouldClose is true, this closes the file when the stream is destroyed. raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false) : raw_ostream(unbuffered), FD(fd), - ShouldClose(shouldClose) {} + ShouldClose(shouldClose), + Error(false) {} ~raw_fd_ostream(); /// close - Manually flush the stream and close the file. + /// Note that this does not call fsync. void close(); /// seek - Flushes the stream and repositions the underlying file descriptor - /// positition to the offset specified from the beginning of the file. + /// positition to the offset specified from the beginning of the file. uint64_t seek(uint64_t off); virtual raw_ostream &changeColor(enum Colors colors, bool bold=false, @@ -378,24 +369,27 @@ public: virtual raw_ostream &resetColor(); virtual bool is_displayed() const; -}; -/// raw_stdout_ostream - This is a stream that always prints to stdout. -/// -class raw_stdout_ostream : public raw_fd_ostream { - // An out of line virtual method to provide a home for the class vtable. - virtual void handle(); -public: - raw_stdout_ostream(); -}; + /// has_error - Return the value of the flag in this raw_fd_ostream indicating + /// whether an output error has been encountered. + /// This doesn't implicitly flush any pending output. Also, it doesn't + /// guarantee to detect all errors unless the the stream has been closed. + bool has_error() const { + return Error; + } -/// raw_stderr_ostream - This is a stream that always prints to stderr. -/// -class raw_stderr_ostream : public raw_fd_ostream { - // An out of line virtual method to provide a home for the class vtable. - virtual void handle(); -public: - raw_stderr_ostream(); + /// clear_error - Set the flag read by has_error() to false. If the error + /// flag is set at the time when this raw_ostream's destructor is called, + /// report_fatal_error is called to report the error. Use clear_error() + /// after handling the error to avoid this behavior. + /// + /// "Errors should never pass silently. + /// Unless explicitly silenced." + /// - from The Zen of Python, by Tim Peters + /// + void clear_error() { + Error = false; + } }; /// outs() - This returns a reference to a raw_ostream for standard output. @@ -461,7 +455,7 @@ public: /// outside of the raw_svector_ostream's control. It is only safe to do this /// if the raw_svector_ostream has previously been flushed. void resync(); - + /// str - Flushes the stream contents to the target vector and return a /// StringRef for the vector contents. StringRef str(); @@ -481,6 +475,45 @@ public: ~raw_null_ostream(); }; +/// tool_output_file - This class contains a raw_fd_ostream and adds a +/// few extra features commonly needed for compiler-like tool output files: +/// - The file is automatically deleted if the process is killed. +/// - The file is automatically deleted when the tool_output_file +/// object is destroyed unless the client calls keep(). +class tool_output_file { + /// Installer - This class is declared before the raw_fd_ostream so that + /// it is constructed before the raw_fd_ostream is constructed and + /// destructed after the raw_fd_ostream is destructed. It installs + /// cleanups in its constructor and uninstalls them in its destructor. + class CleanupInstaller { + /// Filename - The name of the file. + std::string Filename; + public: + /// Keep - The flag which indicates whether we should not delete the file. + bool Keep; + + explicit CleanupInstaller(const char *filename); + ~CleanupInstaller(); + } Installer; + + /// OS - The contained stream. This is intentionally declared after + /// Installer. + raw_fd_ostream OS; + +public: + /// tool_output_file - This constructor's arguments are passed to + /// to raw_fd_ostream's constructor. + tool_output_file(const char *filename, std::string &ErrorInfo, + unsigned Flags = 0); + + /// os - Return the contained raw_fd_ostream. + raw_fd_ostream &os() { return OS; } + + /// keep - Indicate that the tool's job wrt this output file has been + /// successful and the file should not be deleted. + void keep() { Installer.Keep = true; } +}; + } // end llvm namespace #endif diff --git a/contrib/llvm/include/llvm/System/Memory.h b/contrib/llvm/include/llvm/System/Memory.h index 01bcab1..2dd36e8 100644 --- a/contrib/llvm/include/llvm/System/Memory.h +++ b/contrib/llvm/include/llvm/System/Memory.h @@ -63,7 +63,6 @@ namespace sys { /// /// On success, this returns false, otherwise it returns true and fills /// in *ErrMsg. - /// @throws std::string if an error occurred. /// @brief Release Read/Write/Execute memory. static bool ReleaseRWX(MemoryBlock &block, std::string *ErrMsg = 0); diff --git a/contrib/llvm/include/llvm/System/Path.h b/contrib/llvm/include/llvm/System/Path.h index 0461769..23b18d4 100644 --- a/contrib/llvm/include/llvm/System/Path.h +++ b/contrib/llvm/include/llvm/System/Path.h @@ -164,6 +164,7 @@ namespace sys { /// GetMainExecutable - Return the path to the main executable, given the /// value of argv[0] from program startup and the address of main itself. + /// In extremis, this function may fail and return an empty path. static Path GetMainExecutable(const char *argv0, void *MainAddr); /// This is one of the very few ways in which a path can be constructed @@ -336,9 +337,9 @@ namespace sys { /// native Dynamic Library (shared library, shared object) by looking at /// the file's magic number. The Path object must reference a file, not a /// directory. - /// @return strue if the file starts with the magid number for a native + /// @returns true if the file starts with the magic number for a native /// shared library. - /// @brief Determine if the path reference a dynamic library. + /// @brief Determine if the path references a dynamic library. bool isDynamicLibrary() const; /// This function determines if the path name references an existing file diff --git a/contrib/llvm/include/llvm/System/Process.h b/contrib/llvm/include/llvm/System/Process.h index 010499a..41bcd69 100644 --- a/contrib/llvm/include/llvm/System/Process.h +++ b/contrib/llvm/include/llvm/System/Process.h @@ -30,7 +30,6 @@ namespace sys { /// This static function will return the operating system's virtual memory /// page size. /// @returns The number of bytes in a virtual memory page. - /// @throws nothing /// @brief Get the virtual memory page size static unsigned GetPageSize(); @@ -38,7 +37,6 @@ namespace sys { /// by the process. This only counts the memory allocated via the malloc, /// calloc and realloc functions and includes any "free" holes in the /// allocated space. - /// @throws nothing /// @brief Return process memory usage. static size_t GetMallocUsage(); diff --git a/contrib/llvm/include/llvm/System/Program.h b/contrib/llvm/include/llvm/System/Program.h index 69ce478..7017305 100644 --- a/contrib/llvm/include/llvm/System/Program.h +++ b/contrib/llvm/include/llvm/System/Program.h @@ -116,7 +116,6 @@ namespace sys { /// locations to search (e.g. the PATH on Unix). /// @returns A Path object initialized to the path of the program or a /// Path object that is empty (invalid) if the program could not be found. - /// @throws nothing /// @brief Construct a Program by finding it by name. static Path FindProgramByName(const std::string& name); @@ -129,7 +128,6 @@ namespace sys { /// A convenience function equivalent to Program prg; prg.Execute(..); /// prg.Wait(..); - /// @throws nothing /// @see Execute, Wait static int ExecuteAndWait(const Path& path, const char** args, @@ -140,7 +138,6 @@ namespace sys { std::string* ErrMsg = 0); /// A convenience function equivalent to Program prg; prg.Execute(..); - /// @throws nothing /// @see Execute static void ExecuteNoWait(const Path& path, const char** args, diff --git a/contrib/llvm/include/llvm/System/Signals.h b/contrib/llvm/include/llvm/System/Signals.h index 504420c..7f1c87c 100644 --- a/contrib/llvm/include/llvm/System/Signals.h +++ b/contrib/llvm/include/llvm/System/Signals.h @@ -29,6 +29,10 @@ namespace sys { /// @brief Remove a file if a fatal signal occurs. bool RemoveFileOnSignal(const Path &Filename, std::string* ErrMsg = 0); + /// This function removes a file from the list of files to be removed on + /// signal delivery. + void DontRemoveFileOnSignal(const Path &Filename); + /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the /// process, print a stack trace and then exit. /// @brief Print a stack trace if a fatal signal occurs. diff --git a/contrib/llvm/include/llvm/System/ThreadLocal.h b/contrib/llvm/include/llvm/System/ThreadLocal.h index 39b1e64..e6edd79 100644 --- a/contrib/llvm/include/llvm/System/ThreadLocal.h +++ b/contrib/llvm/include/llvm/System/ThreadLocal.h @@ -19,6 +19,8 @@ namespace llvm { namespace sys { + // ThreadLocalImpl - Common base class of all ThreadLocal instantiations. + // YOU SHOULD NEVER USE THIS DIRECTLY. class ThreadLocalImpl { void* data; public: @@ -26,14 +28,25 @@ namespace llvm { virtual ~ThreadLocalImpl(); void setInstance(const void* d); const void* getInstance(); + void removeInstance(); }; + /// ThreadLocal - A class used to abstract thread-local storage. It holds, + /// for each thread, a pointer a single object of type T. template<class T> class ThreadLocal : public ThreadLocalImpl { public: ThreadLocal() : ThreadLocalImpl() { } + + /// get - Fetches a pointer to the object associated with the current + /// thread. If no object has yet been associated, it returns NULL; T* get() { return static_cast<T*>(getInstance()); } + + // set - Associates a pointer to an object with the current thread. void set(T* d) { setInstance(d); } + + // erase - Removes the pointer associated with the current thread. + void erase() { removeInstance(); } }; } } diff --git a/contrib/llvm/include/llvm/Target/Target.td b/contrib/llvm/include/llvm/Target/Target.td index 9a89dc9..b141a77 100644 --- a/contrib/llvm/include/llvm/Target/Target.td +++ b/contrib/llvm/include/llvm/Target/Target.td @@ -198,6 +198,7 @@ class Instruction { bit isReturn = 0; // Is this instruction a return instruction? bit isBranch = 0; // Is this instruction a branch instruction? bit isIndirectBranch = 0; // Is this instruction an indirect branch? + bit isCompare = 0; // Is this instruction a comparison instruction? bit isBarrier = 0; // Can control flow fall through this instruction? bit isCall = 0; // Is this instruction a call instruction? bit canFoldAsLoad = 0; // Can this be folded as a simple memory operand? @@ -409,7 +410,7 @@ def INLINEASM : Instruction { let InOperandList = (ins variable_ops); let AsmString = ""; } -def DBG_LABEL : Instruction { +def PROLOG_LABEL : Instruction { let OutOperandList = (outs); let InOperandList = (ins i32imm:$id); let AsmString = ""; @@ -510,10 +511,6 @@ class AsmParser { // perform target specific instruction post-processing. string AsmParserInstCleanup = ""; - // MatchInstructionName - The name of the instruction matching function to - // generate. - string MatchInstructionName = "MatchInstruction"; - // Variant - AsmParsers can be of multiple different variants. Variants are // used to support targets that need to parser multiple formats for the // assembly language. diff --git a/contrib/llvm/include/llvm/Target/TargetAsmParser.h b/contrib/llvm/include/llvm/Target/TargetAsmParser.h index f431c38..5830d1f 100644 --- a/contrib/llvm/include/llvm/Target/TargetAsmParser.h +++ b/contrib/llvm/include/llvm/Target/TargetAsmParser.h @@ -28,14 +28,20 @@ class TargetAsmParser : public MCAsmParserExtension { protected: // Can only create subclasses. TargetAsmParser(const Target &); - /// TheTarget - The Target that this machine was created for. + /// The Target that this machine was created for. const Target &TheTarget; + /// The current set of available features. + unsigned AvailableFeatures; + public: virtual ~TargetAsmParser(); const Target &getTarget() const { return TheTarget; } + unsigned getAvailableFeatures() const { return AvailableFeatures; } + void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; } + /// ParseInstruction - Parse one assembly instruction. /// /// The parser is positioned following the instruction name. The target @@ -67,8 +73,12 @@ public: /// MatchInstruction - Recognize a series of operands of a parsed instruction /// as an actual MCInst. This returns false and fills in Inst on success and /// returns true on failure to match. + /// + /// On failure, the target parser is responsible for emitting a diagnostic + /// explaining the match failure. virtual bool - MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> &Operands, + MatchInstruction(SMLoc IDLoc, + const SmallVectorImpl<MCParsedAsmOperand*> &Operands, MCInst &Inst) = 0; }; diff --git a/contrib/llvm/include/llvm/Target/TargetCallingConv.td b/contrib/llvm/include/llvm/Target/TargetCallingConv.td index ceaeb0b..6da3ba1 100644 --- a/contrib/llvm/include/llvm/Target/TargetCallingConv.td +++ b/contrib/llvm/include/llvm/Target/TargetCallingConv.td @@ -42,7 +42,7 @@ class CCIf<string predicate, CCAction A> : CCPredicateAction<A> { class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> { } -/// CCIfCC - Match of the current calling convention is 'CC'. +/// CCIfCC - Match if the current calling convention is 'CC'. class CCIfCC<string CC, CCAction A> : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {} @@ -89,6 +89,13 @@ class CCAssignToStack<int size, int align> : CCAction { int Align = align; } +/// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a register +/// to be shadowed. +class CCAssignToStackWithShadow<int size, int align, Register reg> : + CCAssignToStack<size, align> { + Register ShadowReg = reg; +} + /// CCPassByVal - This action always matches: it assigns the value to a stack /// slot to implement ByVal aggregate parameter passing. Size and alignment /// specify the minimum size and alignment for the stack slot. diff --git a/contrib/llvm/include/llvm/Target/TargetData.h b/contrib/llvm/include/llvm/Target/TargetData.h index cc88dae..b89cbe0 100644 --- a/contrib/llvm/include/llvm/Target/TargetData.h +++ b/contrib/llvm/include/llvm/Target/TargetData.h @@ -50,13 +50,13 @@ enum AlignTypeEnum { /// padding and make the structure slightly more cache friendly. struct TargetAlignElem { AlignTypeEnum AlignType : 8; //< Alignment type (AlignTypeEnum) - unsigned char ABIAlign; //< ABI alignment for this type/bitw - unsigned char PrefAlign; //< Pref. alignment for this type/bitw + unsigned ABIAlign; //< ABI alignment for this type/bitw + unsigned PrefAlign; //< Pref. alignment for this type/bitw uint32_t TypeBitWidth; //< Type bit width /// Initializer - static TargetAlignElem get(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width); + static TargetAlignElem get(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width); /// Equality predicate bool operator==(const TargetAlignElem &rhs) const; }; @@ -64,9 +64,9 @@ struct TargetAlignElem { class TargetData : public ImmutablePass { private: bool LittleEndian; ///< Defaults to false - unsigned char PointerMemSize; ///< Pointer size in bytes - unsigned char PointerABIAlign; ///< Pointer ABI alignment - unsigned char PointerPrefAlign; ///< Pointer preferred alignment + unsigned PointerMemSize; ///< Pointer size in bytes + unsigned PointerABIAlign; ///< Pointer ABI alignment + unsigned PointerPrefAlign; ///< Pointer preferred alignment SmallVector<unsigned char, 8> LegalIntWidths; ///< Legal Integers. @@ -86,12 +86,12 @@ private: mutable void *LayoutMap; //! Set/initialize target alignments - void setAlignment(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width); + void setAlignment(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width); unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width, bool ABIAlign, const Type *Ty) const; //! Internal helper method that returns requested alignment for type. - unsigned char getAlignment(const Type *Ty, bool abi_or_pref) const; + unsigned getAlignment(const Type *Ty, bool abi_or_pref) const; /// Valid alignment predicate. /// @@ -110,7 +110,7 @@ public: /// Constructs a TargetData from a specification string. See init(). explicit TargetData(StringRef TargetDescription) - : ImmutablePass(&ID) { + : ImmutablePass(ID) { init(TargetDescription); } @@ -118,7 +118,7 @@ public: explicit TargetData(const Module *M); TargetData(const TargetData &TD) : - ImmutablePass(&ID), + ImmutablePass(ID), LittleEndian(TD.isLittleEndian()), PointerMemSize(TD.PointerMemSize), PointerABIAlign(TD.PointerABIAlign), @@ -161,13 +161,13 @@ public: } /// Target pointer alignment - unsigned char getPointerABIAlignment() const { return PointerABIAlign; } + unsigned getPointerABIAlignment() const { return PointerABIAlign; } /// Return target's alignment for stack-based pointers - unsigned char getPointerPrefAlignment() const { return PointerPrefAlign; } + unsigned getPointerPrefAlignment() const { return PointerPrefAlign; } /// Target pointer size - unsigned char getPointerSize() const { return PointerMemSize; } + unsigned getPointerSize() const { return PointerMemSize; } /// Target pointer size, in bits - unsigned char getPointerSizeInBits() const { return 8*PointerMemSize; } + unsigned getPointerSizeInBits() const { return 8*PointerMemSize; } /// Size examples: /// @@ -223,26 +223,26 @@ public: /// getABITypeAlignment - Return the minimum ABI-required alignment for the /// specified type. - unsigned char getABITypeAlignment(const Type *Ty) const; + unsigned getABITypeAlignment(const Type *Ty) const; /// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for /// an integer type of the specified bitwidth. - unsigned char getABIIntegerTypeAlignment(unsigned BitWidth) const; + unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const; /// getCallFrameTypeAlignment - Return the minimum ABI-required alignment /// for the specified type when it is part of a call frame. - unsigned char getCallFrameTypeAlignment(const Type *Ty) const; + unsigned getCallFrameTypeAlignment(const Type *Ty) const; /// getPrefTypeAlignment - Return the preferred stack/global alignment for /// the specified type. This is always at least as good as the ABI alignment. - unsigned char getPrefTypeAlignment(const Type *Ty) const; + unsigned getPrefTypeAlignment(const Type *Ty) const; /// getPreferredTypeAlignmentShift - Return the preferred alignment for the /// specified type, returned as log2 of the value (a shift amount). /// - unsigned char getPreferredTypeAlignmentShift(const Type *Ty) const; + unsigned getPreferredTypeAlignmentShift(const Type *Ty) const; /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. diff --git a/contrib/llvm/include/llvm/Target/TargetInstrDesc.h b/contrib/llvm/include/llvm/Target/TargetInstrDesc.h index 8f0a6cb..a127aed 100644 --- a/contrib/llvm/include/llvm/Target/TargetInstrDesc.h +++ b/contrib/llvm/include/llvm/Target/TargetInstrDesc.h @@ -105,6 +105,7 @@ namespace TID { IndirectBranch, Predicable, NotDuplicable, + Compare, DelaySlot, FoldableAsLoad, MayLoad, @@ -151,6 +152,12 @@ public: return -1; } + /// getRegClass - Returns the register class constraint for OpNum, or NULL. + const TargetRegisterClass *getRegClass(unsigned OpNum, + const TargetRegisterInfo *TRI) const { + return OpNum < NumOperands ? OpInfo[OpNum].getRegClass(TRI) : 0; + } + /// getOpcode - Return the opcode number for this descriptor. unsigned getOpcode() const { return Opcode; @@ -315,7 +322,7 @@ public: bool isIndirectBranch() const { return Flags & (1 << TID::IndirectBranch); } - + /// isConditionalBranch - Return true if this is a branch which may fall /// through to the next instruction or may transfer control flow to some other /// block. The TargetInstrInfo::AnalyzeBranch method can be used to get more @@ -340,6 +347,11 @@ public: return Flags & (1 << TID::Predicable); } + /// isCompare - Return true if this instruction is a comparison. + bool isCompare() const { + return Flags & (1 << TID::Compare); + } + /// isNotDuplicable - Return true if this instruction cannot be safely /// duplicated. For example, if the instruction has a unique labels attached /// to it, duplicating it would cause multiple definition errors. diff --git a/contrib/llvm/include/llvm/Target/TargetInstrInfo.h b/contrib/llvm/include/llvm/Target/TargetInstrInfo.h index e42be26..520c41b 100644 --- a/contrib/llvm/include/llvm/Target/TargetInstrInfo.h +++ b/contrib/llvm/include/llvm/Target/TargetInstrInfo.h @@ -92,15 +92,6 @@ private: AliasAnalysis *AA) const; public: - /// isMoveInstr - Return true if the instruction is a register to register - /// move and return the source and dest operands and their sub-register - /// indices by reference. - virtual bool isMoveInstr(const MachineInstr& MI, - unsigned& SrcReg, unsigned& DstReg, - unsigned& SrcSubIdx, unsigned& DstSubIdx) const { - return false; - } - /// isCoalescableExtInstr - Return true if the instruction is a "coalescable" /// extension instruction. That is, it's like a copy where it's legal for the /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns @@ -113,22 +104,6 @@ public: return false; } - /// isIdentityCopy - Return true if the instruction is a copy (or - /// extract_subreg, insert_subreg, subreg_to_reg) where the source and - /// destination registers are the same. - bool isIdentityCopy(const MachineInstr &MI) const { - unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; - if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) && - SrcReg == DstReg) - return true; - - if ((MI.getOpcode() == TargetOpcode::INSERT_SUBREG || - MI.getOpcode() == TargetOpcode::SUBREG_TO_REG) && - MI.getOperand(0).getReg() == MI.getOperand(2).getReg()) - return true; - return false; - } - /// isLoadFromStackSlot - If the specified machine instruction is a direct /// load from a stack slot, return the virtual or physical register number of /// the destination along with the FrameIndex of the loaded stack slot. If @@ -591,18 +566,6 @@ public: const MachineBasicBlock *MBB, const MachineFunction &MF) const = 0; - /// GetInstSize - Returns the size of the specified Instruction. - /// - virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const { - assert(0 && "Target didn't implement TargetInstrInfo::GetInstSize!"); - return 0; - } - - /// GetFunctionSizeInBytes - Returns the size of the specified - /// MachineFunction. - /// - virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0; - /// Measure the specified inline asm to determine an approximation of its /// length. virtual unsigned getInlineAsmLength(const char *Str, @@ -613,6 +576,21 @@ public: /// register allocation. virtual ScheduleHazardRecognizer* CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const = 0; + + /// AnalyzeCompare - For a comparison instruction, return the source register + /// in SrcReg and the value it compares against in CmpValue. Return true if + /// the comparison instruction can be analyzed. + virtual bool AnalyzeCompare(const MachineInstr *MI, + unsigned &SrcReg, int &CmpValue) const { + return false; + } + + /// ConvertToSetZeroFlag - Convert the instruction to set the zero flag so + /// that we can remove a "comparison with zero". + virtual bool ConvertToSetZeroFlag(MachineInstr *Instr, + MachineInstr *CmpInstr) const { + return false; + } }; /// TargetInstrInfoImpl - This is the default implementation of @@ -646,7 +624,6 @@ public: virtual bool isSchedulingBoundary(const MachineInstr *MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const; - virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const; virtual ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const; diff --git a/contrib/llvm/include/llvm/Target/TargetLowering.h b/contrib/llvm/include/llvm/Target/TargetLowering.h index 2b6e4fa..29de994 100644 --- a/contrib/llvm/include/llvm/Target/TargetLowering.h +++ b/contrib/llvm/include/llvm/Target/TargetLowering.h @@ -168,6 +168,32 @@ public: return RC; } + /// getRepRegClassFor - Return the 'representative' register class for the + /// specified value type. The 'representative' register class is the largest + /// legal super-reg register class for the register class of the value type. + /// For example, on i386 the rep register class for i8, i16, and i32 are GR32; + /// while the rep register class is GR64 on x86_64. + virtual const TargetRegisterClass *getRepRegClassFor(EVT VT) const { + assert(VT.isSimple() && "getRepRegClassFor called on illegal type!"); + const TargetRegisterClass *RC = RepRegClassForVT[VT.getSimpleVT().SimpleTy]; + return RC; + } + + /// getRepRegClassCostFor - Return the cost of the 'representative' register + /// class for the specified value type. + virtual uint8_t getRepRegClassCostFor(EVT VT) const { + assert(VT.isSimple() && "getRepRegClassCostFor called on illegal type!"); + return RepRegClassCostForVT[VT.getSimpleVT().SimpleTy]; + } + + /// getRegPressureLimit - Return the register pressure "high water mark" for + /// the specific register class. The scheduler is in high register pressure + /// mode (for the specific register class) if it goes over the limit. + virtual unsigned getRegPressureLimit(const TargetRegisterClass *RC, + MachineFunction &MF) const { + return 0; + } + /// isTypeLegal - Return true if the target has native support for the /// specified value type. This means that it has a register that directly /// holds it without promotions or expansions. @@ -188,24 +214,53 @@ public: /// ValueTypeActions - For each value type, keep a LegalizeAction enum /// that indicates how instruction selection should deal with the type. uint8_t ValueTypeActions[MVT::LAST_VALUETYPE]; + + LegalizeAction getExtendedTypeAction(EVT VT) const { + // Handle non-vector integers. + if (!VT.isVector()) { + assert(VT.isInteger() && "Unsupported extended type!"); + unsigned BitSize = VT.getSizeInBits(); + // First promote to a power-of-two size, then expand if necessary. + if (BitSize < 8 || !isPowerOf2_32(BitSize)) + return Promote; + return Expand; + } + + // If this is a type smaller than a legal vector type, promote to that + // type, e.g. <2 x float> -> <4 x float>. + if (VT.getVectorElementType().isSimple() && + VT.getVectorNumElements() != 1) { + MVT EltType = VT.getVectorElementType().getSimpleVT(); + unsigned NumElts = VT.getVectorNumElements(); + while (1) { + // Round up to the nearest power of 2. + NumElts = (unsigned)NextPowerOf2(NumElts); + + MVT LargerVector = MVT::getVectorVT(EltType, NumElts); + if (LargerVector == MVT()) break; + + // If this the larger type is legal, promote to it. + if (getTypeAction(LargerVector) == Legal) return Promote; + } + } + + return VT.isPow2VectorType() ? Expand : Promote; + } public: ValueTypeActionImpl() { std::fill(ValueTypeActions, array_endof(ValueTypeActions), 0); } - LegalizeAction getTypeAction(LLVMContext &Context, EVT VT) const { - if (VT.isExtended()) { - if (VT.isVector()) { - return VT.isPow2VectorType() ? Expand : Promote; - } - if (VT.isInteger()) - // First promote to a power-of-two size, then expand if necessary. - return VT == VT.getRoundIntegerType(Context) ? Expand : Promote; - assert(0 && "Unsupported extended type!"); - return Legal; - } - unsigned I = VT.getSimpleVT().SimpleTy; - return (LegalizeAction)ValueTypeActions[I]; + + LegalizeAction getTypeAction(EVT VT) const { + if (!VT.isExtended()) + return getTypeAction(VT.getSimpleVT()); + return getExtendedTypeAction(VT); } + + LegalizeAction getTypeAction(MVT VT) const { + return (LegalizeAction)ValueTypeActions[VT.SimpleTy]; + } + void setTypeAction(EVT VT, LegalizeAction Action) { unsigned I = VT.getSimpleVT().SimpleTy; ValueTypeActions[I] = Action; @@ -220,10 +275,13 @@ public: /// it is already legal (return 'Legal') or we need to promote it to a larger /// type (return 'Promote'), or we need to expand it into multiple registers /// of smaller integer type (return 'Expand'). 'Custom' is not an option. - LegalizeAction getTypeAction(LLVMContext &Context, EVT VT) const { - return ValueTypeActions.getTypeAction(Context, VT); + LegalizeAction getTypeAction(EVT VT) const { + return ValueTypeActions.getTypeAction(VT); } - + LegalizeAction getTypeAction(MVT VT) const { + return ValueTypeActions.getTypeAction(VT); + } + /// getTypeToTransformTo - For types supported by the target, this is an /// identity function. For types that must be promoted to larger types, this /// returns the larger type to promote to. For integer types that are larger @@ -235,7 +293,7 @@ public: assert((unsigned)VT.getSimpleVT().SimpleTy < array_lengthof(TransformToType)); EVT NVT = TransformToType[VT.getSimpleVT().SimpleTy]; - assert(getTypeAction(Context, NVT) != Promote && + assert(getTypeAction(NVT) != Promote && "Promote may not follow Expand or Promote"); return NVT; } @@ -250,17 +308,16 @@ public: EltVT : EVT::getVectorVT(Context, EltVT, NumElts / 2); } // Promote to a power of two size, avoiding multi-step promotion. - return getTypeAction(Context, NVT) == Promote ? + return getTypeAction(NVT) == Promote ? getTypeToTransformTo(Context, NVT) : NVT; } else if (VT.isInteger()) { EVT NVT = VT.getRoundIntegerType(Context); - if (NVT == VT) - // Size is a power of two - expand to half the size. + if (NVT == VT) // Size is a power of two - expand to half the size. return EVT::getIntegerVT(Context, VT.getSizeInBits() / 2); - else - // Promote to a power of two size, avoiding multi-step promotion. - return getTypeAction(Context, NVT) == Promote ? - getTypeToTransformTo(Context, NVT) : NVT; + + // Promote to a power of two size, avoiding multi-step promotion. + return getTypeAction(NVT) == Promote ? + getTypeToTransformTo(Context, NVT) : NVT; } assert(0 && "Unsupported extended type!"); return MVT(MVT::Other); // Not reached @@ -273,7 +330,7 @@ public: EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const { assert(!VT.isVector()); while (true) { - switch (getTypeAction(Context, VT)) { + switch (getTypeAction(VT)) { case Legal: return VT; case Expand: @@ -766,6 +823,12 @@ public: return false; } + /// getMaximalGlobalOffset - Returns the maximal possible offset which can be + /// used for loads / stores from the global. + virtual unsigned getMaximalGlobalOffset() const { + return 0; + } + //===--------------------------------------------------------------------===// // TargetLowering Optimization Methods // @@ -981,6 +1044,11 @@ protected: Synthesizable[VT.getSimpleVT().SimpleTy] = isSynthesizable; } + /// findRepresentativeClass - Return the largest legal super-reg register class + /// of the register class for the specified type and its associated "cost". + virtual std::pair<const TargetRegisterClass*, uint8_t> + findRepresentativeClass(EVT VT) const; + /// computeRegisterProperties - Once all of the register classes are added, /// this allows us to compute derived properties we expose. void computeRegisterProperties(); @@ -1562,6 +1630,19 @@ private: unsigned char NumRegistersForVT[MVT::LAST_VALUETYPE]; EVT RegisterTypeForVT[MVT::LAST_VALUETYPE]; + /// RepRegClassForVT - This indicates the "representative" register class to + /// use for each ValueType the target supports natively. This information is + /// used by the scheduler to track register pressure. By default, the + /// representative register class is the largest legal super-reg register + /// class of the register class of the specified type. e.g. On x86, i8, i16, + /// and i32's representative class would be GR32. + const TargetRegisterClass *RepRegClassForVT[MVT::LAST_VALUETYPE]; + + /// RepRegClassCostForVT - This indicates the "cost" of the "representative" + /// register class for each ValueType. The cost is used by the scheduler to + /// approximate register pressure. + uint8_t RepRegClassCostForVT[MVT::LAST_VALUETYPE]; + /// Synthesizable indicates whether it is OK for the compiler to create new /// operations using this type. All Legal types are Synthesizable except /// MMX types on X86. Non-Legal types are not Synthesizable. @@ -1672,6 +1753,15 @@ protected: /// This field specifies whether the target can benefit from code placement /// optimization. bool benefitFromCodePlacementOpt; + +private: + /// isLegalRC - Return true if the value types that can be represented by the + /// specified register class are all legal. + bool isLegalRC(const TargetRegisterClass *RC) const; + + /// hasLegalSuperRegRegClasses - Return true if the specified register class + /// has one or more super-reg register classes that are legal. + bool hasLegalSuperRegRegClasses(const TargetRegisterClass *RC) const; }; /// GetReturnInfo - Given an LLVM IR type and return type attributes, diff --git a/contrib/llvm/include/llvm/Target/TargetMachine.h b/contrib/llvm/include/llvm/Target/TargetMachine.h index 227499b..42e99e0 100644 --- a/contrib/llvm/include/llvm/Target/TargetMachine.h +++ b/contrib/llvm/include/llvm/Target/TargetMachine.h @@ -75,7 +75,8 @@ namespace Sched { None, // No preference Latency, // Scheduling for shortest total latency. RegPressure, // Scheduling for lowest register pressure. - Hybrid // Scheduling for both latency and register pressure. + Hybrid, // Scheduling for both latency and register pressure. + ILP // Scheduling for ILP in low register pressure mode. }; } @@ -244,6 +245,18 @@ public: bool = true) { return true; } + + /// addPassesToEmitMC - Add passes to the specified pass manager to get + /// machine code emitted with the MCJIT. This method returns true if machine + /// code is not supported. It fills the MCContext Ctx pointer which can be + /// used to build custom MCStreamer. + /// + virtual bool addPassesToEmitMC(PassManagerBase &, + MCContext *&, + CodeGenOpt::Level, + bool = true) { + return true; + } }; /// LLVMTargetMachine - This class describes a target machine that is @@ -287,12 +300,27 @@ public: JITCodeEmitter &MCE, CodeGenOpt::Level, bool DisableVerify = true); + + /// addPassesToEmitMC - Add passes to the specified pass manager to get + /// machine code emitted with the MCJIT. This method returns true if machine + /// code is not supported. It fills the MCContext Ctx pointer which can be + /// used to build custom MCStreamer. + /// + virtual bool addPassesToEmitMC(PassManagerBase &PM, + MCContext *&Ctx, + CodeGenOpt::Level OptLevel, + bool DisableVerify = true); /// Target-Independent Code Generator Pass Configuration Options. - - /// addInstSelector - This method should add any "last minute" LLVM->LLVM - /// passes, then install an instruction selector pass, which converts from - /// LLVM code to machine instructions. + + /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM + /// passes (which are run just before instruction selector). + virtual bool addPreISel(PassManagerBase &, CodeGenOpt::Level) { + return true; + } + + /// addInstSelector - This method should install an instruction selector pass, + /// which converts from LLVM code to machine instructions. virtual bool addInstSelector(PassManagerBase &, CodeGenOpt::Level) { return true; } diff --git a/contrib/llvm/include/llvm/Target/TargetOpcodes.h b/contrib/llvm/include/llvm/Target/TargetOpcodes.h index cb772ec..01fba66 100644 --- a/contrib/llvm/include/llvm/Target/TargetOpcodes.h +++ b/contrib/llvm/include/llvm/Target/TargetOpcodes.h @@ -25,7 +25,7 @@ namespace TargetOpcode { enum { PHI = 0, INLINEASM = 1, - DBG_LABEL = 2, + PROLOG_LABEL = 2, EH_LABEL = 3, GC_LABEL = 4, diff --git a/contrib/llvm/include/llvm/Target/TargetOptions.h b/contrib/llvm/include/llvm/Target/TargetOptions.h index b369880..97ceffd 100644 --- a/contrib/llvm/include/llvm/Target/TargetOptions.h +++ b/contrib/llvm/include/llvm/Target/TargetOptions.h @@ -71,13 +71,18 @@ namespace llvm { /// UnsafeFPMath implies LessPreciseFPMAD. extern bool UnsafeFPMath; - /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math - /// option is specified on the command line. If this returns false (default), - /// the code generator is not allowed to assume that FP arithmetic arguments - /// and results are never NaNs or +-Infs. - extern bool FiniteOnlyFPMathOption; - extern bool FiniteOnlyFPMath(); - + /// NoInfsFPMath - This flag is enabled when the + /// -enable-no-infs-fp-math flag is specified on the command line. When + /// this flag is off (the default), the code generator is not allowed to + /// assume the FP arithmetic arguments and results are never +-Infs. + extern bool NoInfsFPMath; + + /// NoNaNsFPMath - This flag is enabled when the + /// -enable-no-nans-fp-math flag is specified on the command line. When + /// this flag is off (the default), the code generator is not allowed to + /// assume the FP arithmetic arguments and results are never NaNs. + extern bool NoNaNsFPMath; + /// HonorSignDependentRoundingFPMath - This returns true when the /// -enable-sign-dependent-rounding-fp-math is specified. If this returns /// false (the default), the code generator is allowed to assume that the @@ -135,8 +140,8 @@ namespace llvm { /// StackAlignment - Override default stack alignment for target. extern unsigned StackAlignment; - /// RealignStack - This flag indicates, whether stack should be automatically - /// realigned, if needed. + /// RealignStack - This flag indicates whether the stack should be + /// automatically realigned, if needed. extern bool RealignStack; /// DisableJumpTables - This flag indicates jump tables should not be diff --git a/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h b/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h index f6ac2b7..81dec3e 100644 --- a/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h +++ b/contrib/llvm/include/llvm/Target/TargetRegisterInfo.h @@ -301,7 +301,7 @@ public: /// considered to be a 'virtual' register, which is part of the SSA /// namespace. This must be the same for all targets, which means that each /// target is limited to this fixed number of registers. - FirstVirtualRegister = 1024 + FirstVirtualRegister = 16384 }; /// isPhysicalRegister - Return true if the specified register number is in @@ -593,6 +593,13 @@ public: return false; } + /// requiresVirtualBaseRegisters - Returns true if the target wants the + /// LocalStackAllocation pass to be run and virtual base registers + /// used for more efficient stack access. + virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const { + return false; + } + /// hasFP - Return true if the specified function should have a dedicated /// frame pointer register. For most targets this is true only if the function /// has variable sized allocas or if frame pointer elimination is disabled. @@ -603,18 +610,18 @@ public: /// immediately on entry to the current function. This eliminates the need for /// add/sub sp brackets around call sites. Returns true if the call frame is /// included as part of the stack frame. - virtual bool hasReservedCallFrame(MachineFunction &MF) const { + virtual bool hasReservedCallFrame(const MachineFunction &MF) const { return !hasFP(MF); } /// canSimplifyCallFramePseudos - When possible, it's best to simplify the /// call frame pseudo ops before doing frame index elimination. This is /// possible only when frame index references between the pseudos won't - /// need adjusted for the call frame adjustments. Normally, that's true + /// need adjusting for the call frame adjustments. Normally, that's true /// if the function has a reserved call frame or a frame pointer. Some /// targets (Thumb2, for example) may have more complicated criteria, /// however, and can override this behavior. - virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const { + virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const { return hasReservedCallFrame(MF) || hasFP(MF); } @@ -624,7 +631,7 @@ public: /// reserved as its spill slot. This tells PEI not to create a new stack frame /// object for the given register. It should be called only after /// processFunctionBeforeCalleeSavedScan(). - virtual bool hasReservedSpillSlot(MachineFunction &MF, unsigned Reg, + virtual bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const { return false; } @@ -636,6 +643,44 @@ public: return false; } + /// getFrameIndexInstrOffset - Get the offset from the referenced frame + /// index in the instruction, if the is one. + virtual int64_t getFrameIndexInstrOffset(const MachineInstr *MI, + int Idx) const { + return 0; + } + + /// needsFrameBaseReg - Returns true if the instruction's frame index + /// reference would be better served by a base register other than FP + /// or SP. Used by LocalStackFrameAllocation to determine which frame index + /// references it should create new base registers for. + virtual bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const { + return false; + } + + /// materializeFrameBaseRegister - Insert defining instruction(s) for + /// BaseReg to be a pointer to FrameIdx before insertion point I. + virtual void materializeFrameBaseRegister(MachineBasicBlock::iterator I, + unsigned BaseReg, int FrameIdx, + int64_t Offset) const { + assert(0 && "materializeFrameBaseRegister does not exist on this target"); + } + + /// resolveFrameIndex - Resolve a frame index operand of an instruction + /// to reference the indicated base register plus offset instead. + virtual void resolveFrameIndex(MachineBasicBlock::iterator I, + unsigned BaseReg, int64_t Offset) const { + assert(0 && "resolveFrameIndex does not exist on this target"); + } + + /// isFrameOffsetLegal - Determine whether a given offset immediate is + /// encodable to resolve a frame index. + virtual bool isFrameOffsetLegal(const MachineInstr *MI, + int64_t Offset) const { + assert(0 && "isFrameOffsetLegal does not exist on this target"); + return false; // Must return a value in order to compile with VS 2005 + } + /// getCallFrameSetup/DestroyOpcode - These methods return the opcode of the /// frame setup/destroy instructions if they exist (-1 otherwise). Some /// targets use pseudo instructions in order to abstract away the difference @@ -671,7 +716,7 @@ public: } /// processFunctionBeforeFrameFinalized - This method is called immediately - /// before the specified functions frame layout (MF.getFrameInfo()) is + /// before the specified function's frame layout (MF.getFrameInfo()) is /// finalized. Once the frame is finalized, MO_FrameIndex operands are /// replaced with direct constants. This method is optional. /// @@ -698,14 +743,8 @@ public: /// specified instruction, as long as it keeps the iterator pointing at the /// finished product. SPAdj is the SP adjustment due to call frame setup /// instruction. - /// - /// When -enable-frame-index-scavenging is enabled, the virtual register - /// allocated for this frame index is returned and its value is stored in - /// *Value. - typedef std::pair<unsigned, int> FrameIndexValue; - virtual unsigned eliminateFrameIndex(MachineBasicBlock::iterator MI, - int SPAdj, FrameIndexValue *Value = NULL, - RegScavenger *RS=NULL) const = 0; + virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI, + int SPAdj, RegScavenger *RS=NULL) const = 0; /// emitProlog/emitEpilog - These methods insert prolog and epilog code into /// the function. diff --git a/contrib/llvm/include/llvm/Target/TargetRegistry.h b/contrib/llvm/include/llvm/Target/TargetRegistry.h index 1418bee..2817b0c 100644 --- a/contrib/llvm/include/llvm/Target/TargetRegistry.h +++ b/contrib/llvm/include/llvm/Target/TargetRegistry.h @@ -65,7 +65,8 @@ namespace llvm { const std::string &TT); typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T, const MCAsmInfo &MAI); - typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P); + typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P, + TargetMachine &TM); typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T); typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T, unsigned SyntaxVariant, @@ -237,10 +238,11 @@ namespace llvm { /// /// \arg Parser - The target independent parser implementation to use for /// parsing and lexing. - TargetAsmParser *createAsmParser(MCAsmParser &Parser) const { + TargetAsmParser *createAsmParser(MCAsmParser &Parser, + TargetMachine &TM) const { if (!AsmParserCtorFn) return 0; - return AsmParserCtorFn(*this, Parser); + return AsmParserCtorFn(*this, Parser, TM); } /// createAsmPrinter - Create a target specific assembly printer pass. This @@ -276,9 +278,9 @@ namespace llvm { /// /// \arg TT - The target triple. /// \arg Ctx - The target context. - /// \arg TAB - The target assembler backend object. + /// \arg TAB - The target assembler backend object. Takes ownership. /// \arg _OS - The stream object. - /// \arg _Emitter - The target independent assembler object. + /// \arg _Emitter - The target independent assembler object.Takes ownership. /// \arg RelaxAll - Relax all fixups? MCStreamer *createObjectStreamer(const std::string &TT, MCContext &Ctx, TargetAsmBackend &TAB, @@ -667,8 +669,9 @@ namespace llvm { } private: - static TargetAsmParser *Allocator(const Target &T, MCAsmParser &P) { - return new AsmParserImpl(T, P); + static TargetAsmParser *Allocator(const Target &T, MCAsmParser &P, + TargetMachine &TM) { + return new AsmParserImpl(T, P, TM); } }; diff --git a/contrib/llvm/include/llvm/Target/TargetSelect.h b/contrib/llvm/include/llvm/Target/TargetSelect.h index 951e7fa..1891f87 100644 --- a/contrib/llvm/include/llvm/Target/TargetSelect.h +++ b/contrib/llvm/include/llvm/Target/TargetSelect.h @@ -16,7 +16,7 @@ #ifndef LLVM_TARGET_TARGETSELECT_H #define LLVM_TARGET_TARGETSELECT_H -#include "llvm/Config/config.h" +#include "llvm/Config/llvm-config.h" extern "C" { // Declare all of the target-initialization functions that are available. @@ -100,15 +100,22 @@ namespace llvm { /// It is legal for a client to make multiple calls to this function. inline bool InitializeNativeTarget() { // If we have a native target, initialize it to ensure it is linked in. -#ifdef LLVM_NATIVE_ARCH -#define DoInit2(TARG) \ - LLVMInitialize ## TARG ## Info (); \ - LLVMInitialize ## TARG () -#define DoInit(T) DoInit2(T) - DoInit(LLVM_NATIVE_ARCH); +#ifdef LLVM_NATIVE_TARGET + LLVM_NATIVE_TARGETINFO(); + LLVM_NATIVE_TARGET(); + return false; +#else + return true; +#endif + } + + /// InitializeNativeTargetAsmPrinter - The main program should call + /// this function to initialize the native target asm printer. + inline bool InitializeNativeTargetAsmPrinter() { + // If we have a native target, initialize the corresponding asm printer. +#ifdef LLVM_NATIVE_ASMPRINTER + LLVM_NATIVE_ASMPRINTER(); return false; -#undef DoInit -#undef DoInit2 #else return true; #endif diff --git a/contrib/llvm/include/llvm/Transforms/IPO.h b/contrib/llvm/include/llvm/Transforms/IPO.h index 8fb4b63..0de1003 100644 --- a/contrib/llvm/include/llvm/Transforms/IPO.h +++ b/contrib/llvm/include/llvm/Transforms/IPO.h @@ -93,8 +93,7 @@ ModulePass *createGlobalDCEPass(); /// possible, except for the global values specified. /// ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool - deleteFn = false, - bool relinkCallees = false); + deleteFn = false); //===----------------------------------------------------------------------===// /// createFunctionInliningPass - Return a new pass object that uses a heuristic @@ -181,7 +180,7 @@ Pass *createSingleLoopExtractorPass(); /// createBlockExtractorPass - This pass extracts all blocks (except those /// specified in the argument list) from the functions in the module. /// -ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE); +ModulePass *createBlockExtractorPass(); /// createStripDeadPrototypesPass - This pass removes any function declarations /// (prototypes) that are not used. diff --git a/contrib/llvm/include/llvm/Transforms/IPO/InlinerPass.h b/contrib/llvm/include/llvm/Transforms/IPO/InlinerPass.h index 6af7ed7..3ac4c59 100644 --- a/contrib/llvm/include/llvm/Transforms/IPO/InlinerPass.h +++ b/contrib/llvm/include/llvm/Transforms/IPO/InlinerPass.h @@ -30,8 +30,8 @@ namespace llvm { /// perform the inlining operations that do not depend on the policy. /// struct Inliner : public CallGraphSCCPass { - explicit Inliner(void *ID); - explicit Inliner(void *ID, int Threshold); + explicit Inliner(char &ID); + explicit Inliner(char &ID, int Threshold); /// getAnalysisUsage - For this class, we declare that we require and preserve /// the call graph. If the derived class implements this method, it should diff --git a/contrib/llvm/include/llvm/Transforms/Scalar.h b/contrib/llvm/include/llvm/Transforms/Scalar.h index 0d338b5..0c35d7e 100644 --- a/contrib/llvm/include/llvm/Transforms/Scalar.h +++ b/contrib/llvm/include/llvm/Transforms/Scalar.h @@ -149,7 +149,6 @@ Pass *createLoopIndexSplitPass(); // ret i32 %Y // FunctionPass *createPromoteMemoryToRegisterPass(); -extern const PassInfo *const PromoteMemoryToRegisterID; //===----------------------------------------------------------------------===// // @@ -158,7 +157,7 @@ extern const PassInfo *const PromoteMemoryToRegisterID; // hacking easier. // FunctionPass *createDemoteRegisterToMemoryPass(); -extern const PassInfo *const DemoteRegisterToMemoryID; +extern char &DemoteRegisterToMemoryID; //===----------------------------------------------------------------------===// // @@ -202,7 +201,7 @@ FunctionPass *createCFGSimplificationPass(); // (set, immediate dominators, tree, and frontier) information. // FunctionPass *createBreakCriticalEdgesPass(); -extern const PassInfo *const BreakCriticalEdgesID; +extern char &BreakCriticalEdgesID; //===----------------------------------------------------------------------===// // @@ -213,7 +212,7 @@ extern const PassInfo *const BreakCriticalEdgesID; // AU.addRequiredID(LoopSimplifyID); // Pass *createLoopSimplifyPass(); -extern const PassInfo *const LoopSimplifyID; +extern char &LoopSimplifyID; //===----------------------------------------------------------------------===// // @@ -228,7 +227,7 @@ FunctionPass *createTailCallEliminationPass(); // chained binary branch instructions. // FunctionPass *createLowerSwitchPass(); -extern const PassInfo *const LowerSwitchID; +extern char &LowerSwitchID; //===----------------------------------------------------------------------===// // @@ -243,7 +242,7 @@ extern const PassInfo *const LowerSwitchID; FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0); FunctionPass *createLowerInvokePass(const TargetLowering *TLI, bool useExpensiveEHSupport); -extern const PassInfo *const LowerInvokePassID; +extern char &LowerInvokePassID; //===----------------------------------------------------------------------===// // @@ -258,7 +257,7 @@ FunctionPass *createBlockPlacementPass(); // optimizations. // Pass *createLCSSAPass(); -extern const PassInfo *const LCSSAID; +extern char &LCSSAID; //===----------------------------------------------------------------------===// // @@ -304,39 +303,31 @@ FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); // InstructionNamer - Give any unnamed non-void instructions "tmp" names. // FunctionPass *createInstructionNamerPass(); -extern const PassInfo *const InstructionNamerID; +extern char &InstructionNamerID; //===----------------------------------------------------------------------===// // -// SSI - This pass converts instructions to Static Single Information form -// on demand. -// -FunctionPass *createSSIPass(); - -//===----------------------------------------------------------------------===// -// -// SSI - This pass converts every non-void instuction to Static Single -// Information form. +// GEPSplitter - Split complex GEPs into simple ones // -FunctionPass *createSSIEverythingPass(); +FunctionPass *createGEPSplitterPass(); //===----------------------------------------------------------------------===// // -// GEPSplitter - Split complex GEPs into simple ones +// Sink - Code Sinking // -FunctionPass *createGEPSplitterPass(); +FunctionPass *createSinkingPass(); //===----------------------------------------------------------------------===// // -// ABCD - Elimination of Array Bounds Checks on Demand +// LowerAtomic - Lower atomic intrinsics to non-atomic form // -FunctionPass *createABCDPass(); +Pass *createLowerAtomicPass(); //===----------------------------------------------------------------------===// // -// Sink - Code Sinking +// ValuePropagation - Propagate CFG-derived value information // -FunctionPass *createSinkingPass(); +Pass *createCorrelatedValuePropagationPass(); } // End llvm namespace diff --git a/contrib/llvm/include/llvm/Transforms/Utils/Cloning.h b/contrib/llvm/include/llvm/Transforms/Utils/Cloning.h index 1ca4981..62bf92a 100644 --- a/contrib/llvm/include/llvm/Transforms/Utils/Cloning.h +++ b/contrib/llvm/include/llvm/Transforms/Utils/Cloning.h @@ -121,8 +121,12 @@ Loop *CloneLoop(Loop *L, LPPassManager *LPM, LoopInfo *LI, /// the function from their old to new values. The final argument captures /// information about the cloned code if non-null. /// +/// If ModuleLevelChanges is false, VMap contains no non-identity GlobalValue +/// mappings. +/// Function *CloneFunction(const Function *F, ValueMap<const Value*, Value*> &VMap, + bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo = 0); /// CloneFunction - Version of the function that doesn't need the VMap. @@ -133,13 +137,17 @@ inline Function *CloneFunction(const Function *F, ClonedCodeInfo *CodeInfo = 0){ } /// Clone OldFunc into NewFunc, transforming the old arguments into references -/// to ArgMap values. Note that if NewFunc already has basic blocks, the ones +/// to VMap values. Note that if NewFunc already has basic blocks, the ones /// cloned into it will be added to the end of the function. This function /// fills in a list of return instructions, and can optionally append the /// specified suffix to all values cloned. /// +/// If ModuleLevelChanges is false, VMap contains no non-identity GlobalValue +/// mappings. +/// void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueMap<const Value*, Value*> &VMap, + bool ModuleLevelChanges, SmallVectorImpl<ReturnInst*> &Returns, const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = 0); @@ -151,8 +159,13 @@ void CloneFunctionInto(Function *NewFunc, const Function *OldFunc, /// constant arguments cause a significant amount of code in the callee to be /// dead. Since this doesn't produce an exactly copy of the input, it can't be /// used for things like CloneFunction or CloneModule. +/// +/// If ModuleLevelChanges is false, VMap contains no non-identity GlobalValue +/// mappings. +/// void CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, ValueMap<const Value*, Value*> &VMap, + bool ModuleLevelChanges, SmallVectorImpl<ReturnInst*> &Returns, const char *NameSuffix = "", ClonedCodeInfo *CodeInfo = 0, diff --git a/contrib/llvm/include/llvm/Transforms/Utils/Local.h b/contrib/llvm/include/llvm/Transforms/Utils/Local.h index b277970..caae27f 100644 --- a/contrib/llvm/include/llvm/Transforms/Utils/Local.h +++ b/contrib/llvm/include/llvm/Transforms/Utils/Local.h @@ -118,8 +118,6 @@ bool EliminateDuplicatePHINodes(BasicBlock *BB); /// of the CFG. It returns true if a modification was made, possibly deleting /// the basic block that was pointed to. /// -/// WARNING: The entry node of a method may not be simplified. -/// bool SimplifyCFG(BasicBlock *BB, const TargetData *TD = 0); /// FoldBranchToCommonDest - If this basic block is ONLY a setcc and a branch, diff --git a/contrib/llvm/include/llvm/Transforms/Utils/SSAUpdater.h b/contrib/llvm/include/llvm/Transforms/Utils/SSAUpdater.h index ca98466..e50a6b1 100644 --- a/contrib/llvm/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/contrib/llvm/include/llvm/Transforms/Utils/SSAUpdater.h @@ -36,9 +36,11 @@ private: //typedef DenseMap<BasicBlock*, Value*> AvailableValsTy; void *AV; - /// PrototypeValue is an arbitrary representative value, which we derive names - /// and a type for PHI nodes. - Value *PrototypeValue; + /// ProtoType holds the type of the values being rewritten. + const Type *ProtoType; + + // PHI nodes are given a name based on ProtoName. + std::string ProtoName; /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that /// it creates to the vector. @@ -51,8 +53,8 @@ public: ~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); + /// updates with type 'Ty'. PHI nodes get a name based on 'Name'. + void Initialize(const Type *Ty, StringRef Name); /// AddAvailableValue - Indicate that a rewritten value is available at the /// end of the specified block with the specified value. @@ -94,6 +96,12 @@ public: /// for the use's block will be considered to be below it. void RewriteUse(Use &U); + /// RewriteUseAfterInsertions - Rewrite a use, just like RewriteUse. However, + /// this version of the method can rewrite uses in the same block as a + /// definition, because it assumes that all uses of a value are below any + /// inserted values. + void RewriteUseAfterInsertions(Use &U); + private: Value *GetValueAtEndOfBlockInternal(BasicBlock *BB); diff --git a/contrib/llvm/include/llvm/Transforms/Utils/SSI.h b/contrib/llvm/include/llvm/Transforms/Utils/SSI.h deleted file mode 100644 index 198fc82..0000000 --- a/contrib/llvm/include/llvm/Transforms/Utils/SSI.h +++ /dev/null @@ -1,93 +0,0 @@ -//===------------------- SSI.h - Creates SSI Representation -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This pass converts a list of variables to the Static Single Information -// form. This is a program representation described by Scott Ananian in his -// Master Thesis: "The Static Single Information Form (1999)". -// We are building an on-demand representation, that is, we do not convert -// every single variable in the target function to SSI form. Rather, we receive -// a list of target variables that must be converted. We also do not -// completely convert a target variable to the SSI format. Instead, we only -// change the variable in the points where new information can be attached -// to its live range, that is, at branch points. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_SSI_H -#define LLVM_TRANSFORMS_UTILS_SSI_H - -#include "llvm/InstrTypes.h" -#include "llvm/Pass.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" - -namespace llvm { - - class DominatorTree; - class PHINode; - class Instruction; - class CmpInst; - - class SSI : public FunctionPass { - public: - static char ID; // Pass identification, replacement for typeid. - SSI() : - FunctionPass(&ID) { - } - - void getAnalysisUsage(AnalysisUsage &AU) const; - - bool runOnFunction(Function&); - - void createSSI(SmallVectorImpl<Instruction *> &value); - - private: - // Variables always live - DominatorTree *DT_; - - // Stores variables created by SSI - SmallPtrSet<Instruction *, 16> created; - - // Phis created by SSI - DenseMap<PHINode *, Instruction*> phis; - - // Sigmas created by SSI - DenseMap<PHINode *, Instruction*> sigmas; - - // Phi nodes that have a phi as operand and has to be fixed - SmallPtrSet<PHINode *, 1> phisToFix; - - // List of definition points for every variable - DenseMap<Instruction*, SmallVector<BasicBlock*, 4> > defsites; - - // Basic Block of the original definition of each variable - DenseMap<Instruction*, BasicBlock*> value_original; - - // Stack of last seen definition of a variable - DenseMap<Instruction*, SmallVector<Instruction *, 1> > value_stack; - - void insertSigmaFunctions(SmallPtrSet<Instruction*, 4> &value); - void insertSigma(TerminatorInst *TI, Instruction *I); - void insertPhiFunctions(SmallPtrSet<Instruction*, 4> &value); - void renameInit(SmallPtrSet<Instruction*, 4> &value); - void rename(BasicBlock *BB); - - void substituteUse(Instruction *I); - bool dominateAny(BasicBlock *BB, Instruction *value); - void fixPhis(); - - Instruction* getPositionPhi(PHINode *PN); - Instruction* getPositionSigma(PHINode *PN); - - void init(SmallVectorImpl<Instruction *> &value); - void clean(); - }; -} // end namespace -#endif diff --git a/contrib/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/contrib/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index c2d0993..a5060e6 100644 --- a/contrib/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/contrib/llvm/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -26,7 +26,7 @@ struct UnifyFunctionExitNodes : public FunctionPass { BasicBlock *ReturnBlock, *UnwindBlock, *UnreachableBlock; public: static char ID; // Pass identification, replacement for typeid - UnifyFunctionExitNodes() : FunctionPass(&ID), + UnifyFunctionExitNodes() : FunctionPass(ID), ReturnBlock(0), UnwindBlock(0) {} // We can preserve non-critical-edgeness when we unify function exit nodes diff --git a/contrib/llvm/include/llvm/Transforms/Utils/ValueMapper.h b/contrib/llvm/include/llvm/Transforms/Utils/ValueMapper.h new file mode 100644 index 0000000..5274112 --- /dev/null +++ b/contrib/llvm/include/llvm/Transforms/Utils/ValueMapper.h @@ -0,0 +1,31 @@ +//===- ValueMapper.h - Remapping for constants and metadata -----*- 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 MapValue interface which is used by various parts of +// the Transforms/Utils library to implement cloning and linking facilities. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_VALUEMAPPER_H +#define LLVM_TRANSFORMS_UTILS_VALUEMAPPER_H + +#include "llvm/ADT/ValueMap.h" + +namespace llvm { + class Value; + class Instruction; + typedef ValueMap<const Value *, Value *> ValueToValueMapTy; + + Value *MapValue(const Value *V, ValueToValueMapTy &VM, + bool ModuleLevelChanges); + void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, + bool ModuleLevelChanges); +} // End llvm namespace + +#endif diff --git a/contrib/llvm/include/llvm/Type.h b/contrib/llvm/include/llvm/Type.h index 617ef69..f7d6fd5 100644 --- a/contrib/llvm/include/llvm/Type.h +++ b/contrib/llvm/include/llvm/Type.h @@ -82,11 +82,10 @@ public: IntegerTyID, ///< 8: Arbitrary bit width integers FunctionTyID, ///< 9: Functions StructTyID, ///< 10: Structures - UnionTyID, ///< 11: Unions - ArrayTyID, ///< 12: Arrays - PointerTyID, ///< 13: Pointers - OpaqueTyID, ///< 14: Opaque: type with unknown structure - VectorTyID, ///< 15: SIMD 'packed' format, or other vector type + ArrayTyID, ///< 11: Arrays + PointerTyID, ///< 12: Pointers + OpaqueTyID, ///< 13: Opaque: type with unknown structure + VectorTyID, ///< 14: SIMD 'packed' format, or other vector type NumTypeIDs, // Must remain as last defined ID LastPrimitiveTyID = MetadataTyID, @@ -243,10 +242,6 @@ public: /// bool isStructTy() const { return ID == StructTyID; } - /// isUnionTy - True if this is an instance of UnionType. - /// - bool isUnionTy() const { return ID == UnionTyID; } - /// isArrayTy - True if this is an instance of ArrayType. /// bool isArrayTy() const { return ID == ArrayTyID; } @@ -306,7 +301,7 @@ public: /// does not include vector types. /// inline bool isAggregateType() const { - return ID == StructTyID || ID == ArrayTyID || ID == UnionTyID; + return ID == StructTyID || ID == ArrayTyID; } /// isSized - Return true if it makes sense to take the size of this type. To @@ -319,8 +314,7 @@ public: return true; // If it is not something that can have a size (e.g. a function or label), // it doesn't have a size. - if (ID != StructTyID && ID != ArrayTyID && ID != VectorTyID && - ID != UnionTyID) + if (ID != StructTyID && ID != ArrayTyID && ID != VectorTyID) return false; // If it is something that can have a size and it's concrete, it definitely // has a size, otherwise we have to try harder to decide. diff --git a/contrib/llvm/include/llvm/Use.h b/contrib/llvm/include/llvm/Use.h index 2759338..e1ebc6a 100644 --- a/contrib/llvm/include/llvm/Use.h +++ b/contrib/llvm/include/llvm/Use.h @@ -210,30 +210,6 @@ public: unsigned getOperandNo() const; }; - -template<> struct simplify_type<value_use_iterator<User> > { - typedef User* SimpleType; - - static SimpleType getSimplifiedValue(const value_use_iterator<User> &Val) { - return *Val; - } -}; - -template<> struct simplify_type<const value_use_iterator<User> > - : public simplify_type<value_use_iterator<User> > {}; - -template<> struct simplify_type<value_use_iterator<const User> > { - typedef const User* SimpleType; - - static SimpleType getSimplifiedValue(const - value_use_iterator<const User> &Val) { - return *Val; - } -}; - -template<> struct simplify_type<const value_use_iterator<const User> > - : public simplify_type<value_use_iterator<const User> > {}; - } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/Value.h b/contrib/llvm/include/llvm/Value.h index cfb4422..8740f35 100644 --- a/contrib/llvm/include/llvm/Value.h +++ b/contrib/llvm/include/llvm/Value.h @@ -215,12 +215,10 @@ public: ConstantFPVal, // This is an instance of ConstantFP ConstantArrayVal, // This is an instance of ConstantArray ConstantStructVal, // This is an instance of ConstantStruct - ConstantUnionVal, // This is an instance of ConstantUnion ConstantVectorVal, // This is an instance of ConstantVector ConstantPointerNullVal, // This is an instance of ConstantPointerNull MDNodeVal, // This is an instance of MDNode MDStringVal, // This is an instance of MDString - NamedMDNodeVal, // This is an instance of NamedMDNode InlineAsmVal, // This is an instance of InlineAsm PseudoSourceValueVal, // This is an instance of PseudoSourceValue FixedStackPseudoSourceValueVal, // This is an instance of @@ -308,6 +306,10 @@ public: return const_cast<Value*>(this)->DoPHITranslation(CurBB, PredBB); } + /// MaximumAlignment - This is the greatest alignment value supported by + /// load, store, and alloca instructions, and global values. + static const unsigned MaximumAlignment = 1u << 29; + protected: unsigned short getSubclassDataFromValue() const { return SubclassData; } void setValueSubclassData(unsigned short D) { SubclassData = D; } diff --git a/contrib/llvm/include/llvm/ValueSymbolTable.h b/contrib/llvm/include/llvm/ValueSymbolTable.h index 7497dae..35fc97b 100644 --- a/contrib/llvm/include/llvm/ValueSymbolTable.h +++ b/contrib/llvm/include/llvm/ValueSymbolTable.h @@ -128,94 +128,6 @@ private: /// @} }; -/// This class provides a symbol table of name/NamedMDNode pairs. It is -/// essentially a StringMap wrapper. - -class MDSymbolTable { - friend class SymbolTableListTraits<NamedMDNode, Module>; -/// @name Types -/// @{ -private: - /// @brief A mapping of names to metadata - typedef StringMap<NamedMDNode*> MDMap; - -public: - /// @brief An iterator over a ValueMap. - typedef MDMap::iterator iterator; - - /// @brief A const_iterator over a ValueMap. - typedef MDMap::const_iterator const_iterator; - -/// @} -/// @name Constructors -/// @{ -public: - - MDSymbolTable(const MDNode &); // DO NOT IMPLEMENT - void operator=(const MDSymbolTable &); // DO NOT IMPLEMENT - MDSymbolTable() : mmap(0) {} - ~MDSymbolTable(); - -/// @} -/// @name Accessors -/// @{ -public: - - /// This method finds the value with the given \p Name in the - /// the symbol table. - /// @returns the NamedMDNode associated with the \p Name - /// @brief Lookup a named Value. - NamedMDNode *lookup(StringRef Name) const { return mmap.lookup(Name); } - - /// @returns true iff the symbol table is empty - /// @brief Determine if the symbol table is empty - inline bool empty() const { return mmap.empty(); } - - /// @brief The number of name/type pairs is returned. - inline unsigned size() const { return unsigned(mmap.size()); } - -/// @} -/// @name Iteration -/// @{ -public: - /// @brief Get an iterator that from the beginning of the symbol table. - inline iterator begin() { return mmap.begin(); } - - /// @brief Get a const_iterator that from the beginning of the symbol table. - inline const_iterator begin() const { return mmap.begin(); } - - /// @brief Get an iterator to the end of the symbol table. - inline iterator end() { return mmap.end(); } - - /// @brief Get a const_iterator to the end of the symbol table. - inline const_iterator end() const { return mmap.end(); } - -/// @} -/// @name Mutators -/// @{ -public: - /// insert - The method inserts a new entry into the stringmap. This will - /// replace existing entry, if any. - void insert(StringRef Name, NamedMDNode *Node) { - StringMapEntry<NamedMDNode *> &Entry = - mmap.GetOrCreateValue(Name, Node); - if (Entry.getValue() != Node) { - mmap.remove(&Entry); - (void) mmap.GetOrCreateValue(Name, Node); - } - } - - /// This method removes a NamedMDNode from the symbol table. - void remove(StringRef Name) { mmap.erase(Name); } - -/// @} -/// @name Internal Data -/// @{ -private: - MDMap mmap; ///< The map that holds the symbol table. -/// @} -}; - } // End llvm namespace #endif |