diff options
Diffstat (limited to 'include')
60 files changed, 876 insertions, 754 deletions
diff --git a/include/llvm-c/BitReader.h b/include/llvm-c/BitReader.h index 59269ce..6db6607 100644 --- a/include/llvm-c/BitReader.h +++ b/include/llvm-c/BitReader.h @@ -36,18 +36,28 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef, LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutModule, char **OutMessage); -/* Reads a module from the specified path, returning via the OutMP parameter - a module provider which performs lazy deserialization. Returns 0 on success. - Optionally returns a human-readable error message via OutMessage. */ -LLVMBool LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, - LLVMModuleProviderRef *OutMP, - char **OutMessage); +/** Reads a module from the specified path, returning via the OutMP parameter + a module provider which performs lazy deserialization. Returns 0 on success. + Optionally returns a human-readable error message via OutMessage. */ +LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef, + LLVMMemoryBufferRef MemBuf, + LLVMModuleRef *OutM, + char **OutMessage); + +LLVMBool LLVMGetBitcodeModule(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, + char **OutMessage); + +/** Deprecated: Use LLVMGetBitcodeModuleInContext instead. */ LLVMBool LLVMGetBitcodeModuleProviderInContext(LLVMContextRef ContextRef, LLVMMemoryBufferRef MemBuf, LLVMModuleProviderRef *OutMP, char **OutMessage); +/** Deprecated: Use LLVMGetBitcodeModule instead. */ +LLVMBool LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, + LLVMModuleProviderRef *OutMP, + char **OutMessage); #ifdef __cplusplus } diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 063ab91..457436d 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -92,11 +92,8 @@ typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; /** See the llvm::PassManagerBase class. */ typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; -/** - * Used to iterate through the uses of a Value, allowing access to all Values - * that use this Value. See the llvm::Use and llvm::value_use_iterator classes. - */ -typedef struct LLVMOpaqueUseIterator *LLVMUseIteratorRef; +/** Used to get the users and usees of a Value. See the llvm::Use class. */ +typedef struct LLVMOpaqueUse *LLVMUseRef; typedef enum { LLVMZExtAttribute = 1<<0, @@ -282,13 +279,19 @@ typedef enum { void LLVMDisposeMessage(char *Message); -/*===-- Modules -----------------------------------------------------------===*/ +/*===-- Contexts ----------------------------------------------------------===*/ /* Create and destroy contexts. */ LLVMContextRef LLVMContextCreate(void); LLVMContextRef LLVMGetGlobalContext(void); void LLVMContextDispose(LLVMContextRef C); +unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, + unsigned SLen); +unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); + +/*===-- Modules -----------------------------------------------------------===*/ + /* Create and destroy modules. */ /** See llvm::Module::Module. */ LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); @@ -497,6 +500,9 @@ const char *LLVMGetValueName(LLVMValueRef Val); void LLVMSetValueName(LLVMValueRef Val, const char *Name); void LLVMDumpValue(LLVMValueRef Val); void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); +int LLVMHasMetadata(LLVMValueRef Val); +LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); +void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); /* Conversion functions. Return the input value if it is an instance of the specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */ @@ -505,10 +511,10 @@ void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) /* Operations on Uses */ -LLVMUseIteratorRef LLVMGetFirstUse(LLVMValueRef Val); -LLVMUseIteratorRef LLVMGetNextUse(LLVMUseIteratorRef U); -LLVMValueRef LLVMGetUser(LLVMUseIteratorRef U); -LLVMValueRef LLVMGetUsedValue(LLVMUseIteratorRef U); +LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); +LLVMUseRef LLVMGetNextUse(LLVMUseRef U); +LLVMValueRef LLVMGetUser(LLVMUseRef U); +LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); /* Operations on Users */ LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); @@ -522,6 +528,14 @@ LLVMBool LLVMIsNull(LLVMValueRef Val); LLVMBool LLVMIsUndef(LLVMValueRef Val); LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); +/* Operations on metadata */ +LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, + unsigned SLen); +LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); +LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, + unsigned Count); +LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); + /* Operations on scalar constants */ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, LLVMBool SignExtend); @@ -551,20 +565,28 @@ 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); LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); @@ -630,6 +652,7 @@ LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, const char *AsmString, const char *Constraints, LLVMBool HasSideEffects, LLVMBool IsAlignStack); +LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); /* Operations on global variables, functions, and aliases (globals) */ LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); @@ -645,6 +668,9 @@ void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); /* Operations on global variables */ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); +LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, + const char *Name, + unsigned AddressSpace); LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); @@ -765,6 +791,11 @@ void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, const char *Name); void LLVMDisposeBuilder(LLVMBuilderRef Builder); +/* Metadata */ +void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); +LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); +void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); + /* Terminators */ LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); @@ -775,6 +806,8 @@ LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, LLVMBasicBlockRef Else, unsigned NumCases); +LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, + unsigned NumDests); LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, @@ -786,19 +819,32 @@ LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest); +/* Add a destination to the indirectbr instruction */ +void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); + /* Arithmetic */ LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); +LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); +LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); +LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, @@ -827,7 +873,14 @@ LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); +LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, + LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); +LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, + const char *Name); +LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, + const char *Name); LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); @@ -886,6 +939,8 @@ LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/ @@ -967,6 +1022,9 @@ LLVMPassManagerRef LLVMCreatePassManager(void); provider. It does not take ownership of the module provider. This type of pipeline is suitable for code generation and JIT compilation tasks. See llvm::FunctionPassManager::FunctionPassManager. */ +LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); + +/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */ LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); /** Initializes, executes on the provided module, and finalizes all of the @@ -1038,7 +1096,7 @@ namespace llvm { DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseIteratorRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef ) DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef ) /* LLVMModuleProviderRef exists for historical reasons, but now just holds a * Module. diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 151c935..5a98a77 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -55,14 +55,30 @@ void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal); /*===-- Operations on execution engines -----------------------------------===*/ +LLVMBool LLVMCreateExecutionEngineForModule(LLVMExecutionEngineRef *OutEE, + LLVMModuleRef M, + char **OutError); + +LLVMBool LLVMCreateInterpreterForModule(LLVMExecutionEngineRef *OutInterp, + LLVMModuleRef M, + char **OutError); + +LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, + LLVMModuleRef M, + unsigned OptLevel, + char **OutError); + +/** Deprecated: Use LLVMCreateExecutionEngineForModule instead. */ LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE, LLVMModuleProviderRef MP, char **OutError); +/** Deprecated: Use LLVMCreateInterpreterForModule instead. */ LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp, LLVMModuleProviderRef MP, char **OutError); +/** Deprecated: Use LLVMCreateJITCompilerForModule instead. */ LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT, LLVMModuleProviderRef MP, unsigned OptLevel, @@ -84,8 +100,15 @@ LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); +void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M); + +/** Deprecated: Use LLVMAddModule instead. */ void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP); +LLVMBool LLVMRemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M, + LLVMModuleRef *OutMod, char **OutError); + +/** Deprecated: Use LLVMRemoveModule instead. */ LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP, LLVMModuleRef *OutMod, char **OutError); diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h index f81109a..861b7b9 100644 --- a/include/llvm/ADT/APFloat.h +++ b/include/llvm/ADT/APFloat.h @@ -173,11 +173,16 @@ namespace llvm { fcZero }; + enum uninitializedTag { + uninitialized + }; + // Constructors. APFloat(const fltSemantics &); // Default construct to 0.0 APFloat(const fltSemantics &, const StringRef &); APFloat(const fltSemantics &, integerPart); - APFloat(const fltSemantics &, fltCategory, bool negative, unsigned type=0); + APFloat(const fltSemantics &, fltCategory, bool negative); + APFloat(const fltSemantics &, uninitializedTag); explicit APFloat(double d); explicit APFloat(float f); explicit APFloat(const APInt &, bool isIEEE = false); @@ -199,7 +204,26 @@ namespace llvm { /// default. The value is truncated as necessary. static APFloat getNaN(const fltSemantics &Sem, bool Negative = false, unsigned type = 0) { - return APFloat(Sem, fcNaN, Negative, type); + if (type) { + APInt fill(64, type); + return getQNaN(Sem, Negative, &fill); + } else { + return getQNaN(Sem, Negative, 0); + } + } + + /// getQNan - Factory for QNaN values. + static APFloat getQNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, false, Negative, payload); + } + + /// getSNan - Factory for SNaN values. + static APFloat getSNaN(const fltSemantics &Sem, + bool Negative = false, + const APInt *payload = 0) { + return makeNaN(Sem, true, Negative, payload); } /// getLargest - Returns the largest finite number in the given @@ -350,7 +374,9 @@ namespace llvm { opStatus modSpecials(const APFloat &); /* Miscellany. */ - void makeNaN(unsigned = 0); + static APFloat makeNaN(const fltSemantics &Sem, bool SNaN, bool Negative, + const APInt *fill); + void makeNaN(bool SNaN = false, bool Neg = false, const APInt *fill = 0); opStatus normalize(roundingMode, lostFraction); opStatus addOrSubtract(const APFloat &, roundingMode, bool subtract); cmpResult compareAbsoluteValue(const APFloat &) const; diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 88aa995..3f67ffb 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -150,7 +150,17 @@ class APInt { return isSingleWord() ? VAL : pVal[whichWord(bitPosition)]; } + /// Converts a string into a number. The string must be non-empty + /// and well-formed as a number of the given base. The bit-width + /// must be sufficient to hold the result. + /// /// This is used by the constructors that take string arguments. + /// + /// StringRef::getAsInteger is superficially similar but (1) does + /// not assume that the string is well-formed and (2) grows the + /// result to hold the input. + /// + /// @param radix 2, 8, 10, or 16 /// @brief Convert a char array into an APInt void fromString(unsigned numBits, const StringRef &str, uint8_t radix); @@ -571,6 +581,21 @@ public: /// @brief Bitwise OR assignment operator. APInt& operator|=(const APInt& RHS); + /// Performs a bitwise OR operation on this APInt and RHS. RHS is + /// logically zero-extended or truncated to match the bit-width of + /// the LHS. + /// + /// @brief Bitwise OR assignment operator. + APInt& operator|=(uint64_t RHS) { + if (isSingleWord()) { + VAL |= RHS; + clearUnusedBits(); + } else { + pVal[0] |= RHS; + } + return *this; + } + /// Performs a bitwise XOR operation on this APInt and RHS. The result is /// assigned to *this. /// @returns *this after XORing with RHS. @@ -1308,6 +1333,9 @@ public: /// Set the given bit of a bignum. Zero-based. static void tcSetBit(integerPart *, unsigned int bit); + /// Clear the given bit of a bignum. Zero-based. + static void tcClearBit(integerPart *, unsigned int bit); + /// Returns the bit number of the least or most significant set bit /// of a number. If the input number has no bits set -1U is /// returned. diff --git a/include/llvm/ADT/DeltaAlgorithm.h b/include/llvm/ADT/DeltaAlgorithm.h index 1facfa0..45ba198 100644 --- a/include/llvm/ADT/DeltaAlgorithm.h +++ b/include/llvm/ADT/DeltaAlgorithm.h @@ -52,7 +52,7 @@ private: /// \return - The test result. bool GetTestResult(const changeset_ty &Changes); - /// Split - Partition a set of changes \arg Sinto one or two subsets. + /// Split - Partition a set of changes \arg S into one or two subsets. void Split(const changeset_ty &S, changesetlist_ty &Res); /// Delta - Minimize a set of \arg Changes which has been partioned into diff --git a/include/llvm/ADT/ScopedHashTable.h b/include/llvm/ADT/ScopedHashTable.h index d538295..f325e2b 100644 --- a/include/llvm/ADT/ScopedHashTable.h +++ b/include/llvm/ADT/ScopedHashTable.h @@ -36,10 +36,10 @@ namespace llvm { -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTable; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableVal { ScopedHashTableVal *NextInScope; ScopedHashTableVal *NextForKey; @@ -61,35 +61,39 @@ public: ScopedHashTableVal *getNextInScope() { return NextInScope; } }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableScope { /// HT - The hashtable that we are active for. - ScopedHashTable<K, V> &HT; + ScopedHashTable<K, V, KInfo> &HT; /// PrevScope - This is the scope that we are shadowing in HT. ScopedHashTableScope *PrevScope; /// LastValInScope - This is the last value that was inserted for this scope /// or null if none have been inserted yet. - ScopedHashTableVal<K,V> *LastValInScope; + ScopedHashTableVal<K, V, KInfo> *LastValInScope; void operator=(ScopedHashTableScope&); // DO NOT IMPLEMENT ScopedHashTableScope(ScopedHashTableScope&); // DO NOT IMPLEMENT public: - ScopedHashTableScope(ScopedHashTable<K, V> &HT); + ScopedHashTableScope(ScopedHashTable<K, V, KInfo> &HT); ~ScopedHashTableScope(); private: - friend class ScopedHashTable<K, V>; - ScopedHashTableVal<K, V> *getLastValInScope() { return LastValInScope; } - void setLastValInScope(ScopedHashTableVal<K,V> *Val) { LastValInScope = Val; } + friend class ScopedHashTable<K, V, KInfo>; + ScopedHashTableVal<K, V, KInfo> *getLastValInScope() { + return LastValInScope; + } + void setLastValInScope(ScopedHashTableVal<K, V, KInfo> *Val) { + LastValInScope = Val; + } }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo = DenseMapInfo<K> > class ScopedHashTableIterator { - ScopedHashTableVal<K,V> *Node; + ScopedHashTableVal<K, V, KInfo> *Node; public: - ScopedHashTableIterator(ScopedHashTableVal<K,V> *node) : Node(node){} + ScopedHashTableIterator(ScopedHashTableVal<K, V, KInfo> *node) : Node(node) {} V &operator*() const { assert(Node && "Dereference end()"); @@ -117,35 +121,43 @@ public: }; -template <typename K, typename V> +template <typename K, typename V, typename KInfo> class ScopedHashTable { - DenseMap<K, ScopedHashTableVal<K,V>*> TopLevelMap; - ScopedHashTableScope<K, V> *CurScope; + DenseMap<K, ScopedHashTableVal<K, V, KInfo>*, KInfo> TopLevelMap; + ScopedHashTableScope<K, V, KInfo> *CurScope; ScopedHashTable(const ScopedHashTable&); // NOT YET IMPLEMENTED void operator=(const ScopedHashTable&); // NOT YET IMPLEMENTED - friend class ScopedHashTableScope<K, V>; + friend class ScopedHashTableScope<K, V, KInfo>; public: ScopedHashTable() : CurScope(0) {} ~ScopedHashTable() { assert(CurScope == 0 && TopLevelMap.empty() && "Scope imbalance!"); } + bool count(const K &Key) const { + return TopLevelMap.count(Key); + } + + V lookup(const K &Key) { + return TopLevelMap[Key].getValue(); + } + void insert(const K &Key, const V &Val) { assert(CurScope && "No scope active!"); - ScopedHashTableVal<K,V> *&KeyEntry = TopLevelMap[Key]; + ScopedHashTableVal<K, V, KInfo> *&KeyEntry = TopLevelMap[Key]; - KeyEntry = new ScopedHashTableVal<K,V>(CurScope->getLastValInScope(), - KeyEntry, Key, Val); + KeyEntry= new ScopedHashTableVal<K, V, KInfo>(CurScope->getLastValInScope(), + KeyEntry, Key, Val); CurScope->setLastValInScope(KeyEntry); } - typedef ScopedHashTableIterator<K, V> iterator; + typedef ScopedHashTableIterator<K, V, KInfo> iterator; iterator end() { return iterator(0); } iterator begin(const K &Key) { - typename DenseMap<K, ScopedHashTableVal<K,V>*>::iterator I = + typename DenseMap<K, ScopedHashTableVal<K, V, KInfo>*, KInfo>::iterator I = TopLevelMap.find(Key); if (I == TopLevelMap.end()) return end(); return iterator(I->second); @@ -154,28 +166,29 @@ public: /// ScopedHashTableScope ctor - Install this as the current scope for the hash /// table. -template <typename K, typename V> -ScopedHashTableScope<K, V>::ScopedHashTableScope(ScopedHashTable<K, V> &ht) - : HT(ht) { +template <typename K, typename V, typename KInfo> +ScopedHashTableScope<K, V, KInfo>:: + ScopedHashTableScope(ScopedHashTable<K, V, KInfo> &ht) : HT(ht) { PrevScope = HT.CurScope; HT.CurScope = this; LastValInScope = 0; } -template <typename K, typename V> -ScopedHashTableScope<K, V>::~ScopedHashTableScope() { +template <typename K, typename V, typename KInfo> +ScopedHashTableScope<K, V, KInfo>::~ScopedHashTableScope() { assert(HT.CurScope == this && "Scope imbalance!"); HT.CurScope = PrevScope; // Pop and delete all values corresponding to this scope. - while (ScopedHashTableVal<K, V> *ThisEntry = LastValInScope) { + while (ScopedHashTableVal<K, V, KInfo> *ThisEntry = LastValInScope) { // Pop this value out of the TopLevelMap. if (ThisEntry->getNextForKey() == 0) { assert(HT.TopLevelMap[ThisEntry->getKey()] == ThisEntry && "Scope imbalance!"); HT.TopLevelMap.erase(ThisEntry->getKey()); } else { - ScopedHashTableVal<K,V> *&KeyEntry = HT.TopLevelMap[ThisEntry->getKey()]; + ScopedHashTableVal<K, V, KInfo> *&KeyEntry = + HT.TopLevelMap[ThisEntry->getKey()]; assert(KeyEntry == ThisEntry && "Scope imbalance!"); KeyEntry = ThisEntry->getNextForKey(); } diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 3064af3..9257770 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -18,6 +18,7 @@ namespace llvm { template<typename T> class SmallVectorImpl; + class APInt; /// StringRef - Represent a constant reference to a string, i.e. a character /// array and a length, which need not be null terminated. @@ -273,6 +274,19 @@ namespace llvm { // TODO: Provide overloads for int/unsigned that check for overflow. + /// getAsInteger - Parse the current string as an integer of the + /// specified radix, or of an autosensed radix if the radix given + /// is 0. The current value in Result is discarded, and the + /// storage is changed to be wide enough to store the parsed + /// integer. + /// + /// Returns true if the string does not solely consist of a valid + /// non-empty number in the appropriate base. + /// + /// APInt::fromString is superficially similar but assumes the + /// string is well-formed in the given radix. + bool getAsInteger(unsigned Radix, APInt &Result) const; + /// @} /// @name Substring Operations /// @{ @@ -355,7 +369,7 @@ namespace llvm { /// \param A - Where to put the substrings. /// \param Separator - The string to split on. /// \param MaxSplit - The maximum number of times the string is split. - /// \parm KeepEmpty - True if empty substring should be added. + /// \param KeepEmpty - True if empty substring should be added. void split(SmallVectorImpl<StringRef> &A, StringRef Separator, int MaxSplit = -1, bool KeepEmpty = true) const; diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 8798b0e..be31ea0 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -73,6 +73,7 @@ public: x86, // X86: i[3-9]86 x86_64, // X86-64: amd64, x86_64 xcore, // XCore: xcore + mblaze, // MBlaze: mblaze InvalidArch }; diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index ccf0105..f105c20 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -459,9 +459,11 @@ namespace llvm { if (DbgNode && !isLexicalBlock()) DbgNode = 0; } - DIScope getContext() const { return getFieldAs<DIScope>(1); } - StringRef getDirectory() const { return getContext().getDirectory(); } - StringRef getFilename() const { return getContext().getFilename(); } + 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); } }; /// DINameSpace - A wrapper for a C++ style name space. @@ -636,7 +638,8 @@ namespace llvm { /// CreateLexicalBlock - This creates a descriptor for a lexical block /// with the specified parent context. - DILexicalBlock CreateLexicalBlock(DIDescriptor Context); + DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0, + unsigned Col = 0); /// CreateNameSpace - This creates new descriptor for a namespace /// with the specified parent context. diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 31c19c4..1e94f30 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -52,7 +52,7 @@ protected: Roots(), IsPostDominators(isPostDom) {} public: - /// getRoots - Return the root blocks of the current CFG. This may include + /// getRoots - Return the root blocks of the current CFG. This may include /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// @@ -225,7 +225,7 @@ protected: DenseMap<NodeT*, InfoRec> Info; void reset() { - for (typename DomTreeNodeMapType::iterator I = this->DomTreeNodes.begin(), + for (typename DomTreeNodeMapType::iterator I = this->DomTreeNodes.begin(), E = DomTreeNodes.end(); I != E; ++I) delete I->second; DomTreeNodes.clear(); @@ -248,7 +248,7 @@ protected: for (typename GraphTraits<Inverse<N> >::ChildIteratorType PI = GraphTraits<Inverse<N> >::child_begin(NewBB), PE = GraphTraits<Inverse<N> >::child_end(NewBB); PI != PE; ++PI) - PredBlocks.push_back(*PI); + PredBlocks.push_back(*PI); assert(!PredBlocks.empty() && "No predblocks??"); @@ -310,7 +310,7 @@ public: if (DomTreeNodes.size() != OtherDomTreeNodes.size()) return true; - for (typename DomTreeNodeMapType::const_iterator + for (typename DomTreeNodeMapType::const_iterator I = this->DomTreeNodes.begin(), E = this->DomTreeNodes.end(); I != E; ++I) { NodeT *BB = I->first; @@ -361,7 +361,7 @@ public: return properlyDominates(getNode(A), getNode(B)); } - bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A, + bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A, const DomTreeNodeBase<NodeT> *B) const { const DomTreeNodeBase<NodeT> *IDom; if (A == 0 || B == 0) return false; @@ -374,7 +374,7 @@ public: /// isReachableFromEntry - Return true if A is dominated by the entry /// block of the function containing it. bool isReachableFromEntry(NodeT* A) { - assert (!this->isPostDominator() + assert (!this->isPostDominator() && "This is not implemented for post dominators"); return dominates(&A->getParent()->front(), A); } @@ -384,7 +384,7 @@ public: /// inline bool dominates(const DomTreeNodeBase<NodeT> *A, const DomTreeNodeBase<NodeT> *B) { - if (B == A) + if (B == A) return true; // A node trivially dominates itself. if (A == 0 || B == 0) @@ -412,7 +412,7 @@ public: } inline bool dominates(const NodeT *A, const NodeT *B) { - if (A == B) + if (A == B) return true; // Cast away the const qualifiers here. This is ok since @@ -431,9 +431,9 @@ public: /// for basic block A and B. If there is no such block then return NULL. NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) { - assert (!this->isPostDominator() + assert (!this->isPostDominator() && "This is not implemented for post dominators"); - assert (A->getParent() == B->getParent() + assert (A->getParent() == B->getParent() && "Two blocks are not in same function"); // If either A or B is a entry block then it is nearest common dominator. @@ -478,14 +478,14 @@ public: // the CFG... /// addNewBlock - Add a new node to the dominator tree information. This - /// creates a new node as a child of DomBB dominator node,linking it into + /// creates a new node as a child of DomBB dominator node,linking it into /// the children list of the immediate dominator. DomTreeNodeBase<NodeT> *addNewBlock(NodeT *BB, NodeT *DomBB) { assert(getNode(BB) == 0 && "Block already in dominator tree!"); DomTreeNodeBase<NodeT> *IDomNode = getNode(DomBB); assert(IDomNode && "Not immediate dominator specified for block!"); DFSInfoValid = false; - return DomTreeNodes[BB] = + return DomTreeNodes[BB] = IDomNode->addChild(new DomTreeNodeBase<NodeT>(BB, IDomNode)); } @@ -503,7 +503,7 @@ public: changeImmediateDominator(getNode(BB), getNode(NewBB)); } - /// eraseNode - Removes a node from the dominator tree. Block must not + /// eraseNode - Removes a node from the dominator tree. Block must not /// domiante any other blocks. Removes node from its immediate dominator's /// children list. Deletes dominator node associated with basic block BB. void eraseNode(NodeT *BB) { @@ -708,7 +708,7 @@ public: DominatorTreeBase<BasicBlock>& getBase() { return *DT; } - /// getRoots - Return the root blocks of the current CFG. This may include + /// getRoots - Return the root blocks of the current CFG. This may include /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// @@ -785,7 +785,7 @@ public: } /// addNewBlock - Add a new node to the dominator tree information. This - /// creates a new node as a child of DomBB dominator node,linking it into + /// creates a new node as a child of DomBB dominator node,linking it into /// the children list of the immediate dominator. inline DomTreeNode *addNewBlock(BasicBlock *BB, BasicBlock *DomBB) { return DT->addNewBlock(BB, DomBB); @@ -802,7 +802,7 @@ public: DT->changeImmediateDominator(N, NewIDom); } - /// eraseNode - Removes a node from the dominator tree. Block must not + /// eraseNode - Removes a node from the dominator tree. Block must not /// domiante any other blocks. Removes node from its immediate dominator's /// children list. Deletes dominator node associated with basic block BB. inline void eraseNode(BasicBlock *BB) { @@ -820,7 +820,7 @@ public: } - virtual void releaseMemory() { + virtual void releaseMemory() { DT->releaseMemory(); } @@ -886,10 +886,10 @@ protected: const bool IsPostDominators; public: - DominanceFrontierBase(void *ID, bool isPostDom) + DominanceFrontierBase(void *ID, bool isPostDom) : FunctionPass(ID), IsPostDominators(isPostDom) {} - /// getRoots - Return the root blocks of the current CFG. This may include + /// getRoots - Return the root blocks of the current CFG. This may include /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// @@ -940,7 +940,7 @@ public: bool compareDomSet(DomSetType &DS1, const DomSetType &DS2) const { std::set<BasicBlock *> tmpSet; for (DomSetType::const_iterator I = DS2.begin(), - E = DS2.end(); I != E; ++I) + E = DS2.end(); I != E; ++I) tmpSet.insert(*I); for (DomSetType::const_iterator I = DS1.begin(), @@ -965,14 +965,14 @@ public: bool compare(DominanceFrontierBase &Other) const { DomSetMapType tmpFrontiers; for (DomSetMapType::const_iterator I = Other.begin(), - E = Other.end(); I != E; ++I) + E = Other.end(); I != E; ++I) tmpFrontiers.insert(std::make_pair(I->first, I->second)); for (DomSetMapType::iterator I = tmpFrontiers.begin(), E = tmpFrontiers.end(); I != E; ) { BasicBlock *Node = I->first; const_iterator DFI = find(Node); - if (DFI == end()) + if (DFI == end()) return true; if (compareDomSet(I->second, DFI->second)) @@ -1001,7 +1001,7 @@ public: class DominanceFrontier : public DominanceFrontierBase { public: static char ID; // Pass ID, replacement for typeid - DominanceFrontier() : + DominanceFrontier() : DominanceFrontierBase(&ID, false) {} BasicBlock *getRoot() const { @@ -1033,7 +1033,7 @@ public: /// to reflect this change. void changeImmediateDominator(BasicBlock *BB, BasicBlock *NewBB, DominatorTree *DT) { - // NewBB is now dominating BB. Which means BB's dominance + // NewBB is now dominating BB. Which means BB's dominance // frontier is now part of NewBB's dominance frontier. However, BB // itself is not member of NewBB's dominance frontier. DominanceFrontier::iterator NewDFI = find(NewBB); diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h index e6e9c71..dc616ca 100644 --- a/include/llvm/Analysis/IVUsers.h +++ b/include/llvm/Analysis/IVUsers.h @@ -61,7 +61,7 @@ public: Stride = Val; } - /// getOffset - Return the offset to add to a theoeretical induction + /// getOffset - Return the offset to add to a theoretical induction /// variable that starts at zero and counts up by the stride to compute /// the value for the use. This always has the same type as the stride. const SCEV *getOffset() const { return Offset; } @@ -116,7 +116,7 @@ private: bool IsUseOfPostIncrementedValue; /// Deleted - Implementation of CallbackVH virtual function to - /// recieve notification when the User is deleted. + /// receive notification when the User is deleted. virtual void deleted(); }; diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index d5e4d51..f792a7f 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -835,7 +835,7 @@ public: } else if (BlockLoop != Child) { LoopT *SubLoop = BlockLoop; // Reparent all of the blocks which used to belong to BlockLoops - for (unsigned j = 0, e = SubLoop->Blocks.size(); j != e; ++j) + for (unsigned j = 0, f = SubLoop->Blocks.size(); j != f; ++j) ContainingLoops[SubLoop->Blocks[j]] = Child; // There is already a loop which contains this block, that means diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index f83cc4f..f6aab03 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -249,7 +249,7 @@ namespace llvm { SmallPtrSet<Instruction*, 4> > ReverseDepMapType; ReverseDepMapType ReverseLocalDeps; - // A reverse mapping form dependencies to the non-local dependees. + // A reverse mapping from dependencies to the non-local dependees. ReverseDepMapType ReverseNonLocalDeps; /// Current AA implementation, just a cache. @@ -312,6 +312,11 @@ namespace llvm { /// value and replaces the other value with ptr. This can make Ptr available /// in more places that cached info does not necessarily keep. void invalidateCachedPointerInfo(Value *Ptr); + + /// invalidateCachedPredecessors - Clear the PredIteratorCache info. + /// This needs to be done when the CFG changes, e.g., due to splitting + /// critical edges. + void invalidateCachedPredecessors(); private: MemDepResult getPointerDependencyFrom(Value *Pointer, uint64_t MemSize, diff --git a/include/llvm/Analysis/PHITransAddr.h b/include/llvm/Analysis/PHITransAddr.h index b612316..033efba 100644 --- a/include/llvm/Analysis/PHITransAddr.h +++ b/include/llvm/Analysis/PHITransAddr.h @@ -66,9 +66,11 @@ public: bool IsPotentiallyPHITranslatable() const; /// PHITranslateValue - PHI translate the current address up the CFG from - /// CurBB to Pred, updating our state the reflect any needed changes. This - /// returns true on failure and sets Addr to null. - bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB); + /// CurBB to Pred, updating our state to reflect any needed changes. If the + /// dominator tree DT is non-null, the translated value must dominate + /// PredBB. This returns true on failure and sets Addr to null. + bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT); /// PHITranslateWithInsertion - PHI translate this value into the specified /// predecessor block, inserting a computation of the value if it is @@ -88,14 +90,8 @@ public: /// returns false. bool Verify() const; private: - Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB); - - - /// GetAvailablePHITranslatedSubExpr - Return the value computed by - /// PHITranslateSubExpr if it dominates PredBB, otherwise return null. - Value *GetAvailablePHITranslatedSubExpr(Value *V, - BasicBlock *CurBB, BasicBlock *PredBB, - const DominatorTree &DT) const; + Value *PHITranslateSubExpr(Value *V, BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT); /// InsertPHITranslatedSubExpr - Insert a computation of the PHI translated /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB diff --git a/include/llvm/Analysis/Passes.h b/include/llvm/Analysis/Passes.h index 2f39c6a..1a5cbb2 100644 --- a/include/llvm/Analysis/Passes.h +++ b/include/llvm/Analysis/Passes.h @@ -81,13 +81,6 @@ namespace llvm { //===--------------------------------------------------------------------===// // - // createAndersensPass - This pass implements Andersen's interprocedural alias - // analysis. - // - ModulePass *createAndersensPass(); - - //===--------------------------------------------------------------------===// - // // createProfileLoaderPass - This pass loads information from a profile dump // file. // diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 383ee88..96d29ba 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // The ScalarEvolution class is an LLVM pass which can be used to analyze and -// catagorize scalar expressions in loops. It specializes in recognizing +// categorize scalar expressions in loops. It specializes in recognizing // general induction variables, representing them with the abstract and opaque // SCEV class. Given this analysis, trip counts of loops and other important // properties can be obtained. @@ -55,7 +55,7 @@ namespace llvm { protected: /// SubclassData - This field is initialized to zero and may be used in - /// subclasses to store miscelaneous information. + /// subclasses to store miscellaneous information. unsigned short SubclassData; private: @@ -177,7 +177,7 @@ namespace llvm { /// LoopInfo *LI; - /// TD - The target data information for the target we are targetting. + /// TD - The target data information for the target we are targeting. /// TargetData *TD; @@ -194,7 +194,7 @@ namespace llvm { std::map<SCEVCallbackVH, const SCEV *> Scalars; /// BackedgeTakenInfo - Information about the backedge-taken count - /// of a loop. This currently inclues an exact count and a maximum count. + /// of a loop. This currently includes an exact count and a maximum count. /// struct BackedgeTakenInfo { /// Exact - An expression indicating the exact backedge-taken count of @@ -305,7 +305,7 @@ namespace llvm { /// ComputeLoadConstantCompareBackedgeTakenCount - Given an exit condition /// of 'icmp op load X, cst', try to see if we can compute the /// backedge-taken count. - const SCEV * + BackedgeTakenInfo ComputeLoadConstantCompareBackedgeTakenCount(LoadInst *LI, Constant *RHS, const Loop *L, @@ -323,12 +323,12 @@ namespace llvm { /// HowFarToZero - Return the number of times a backedge comparing the /// specified value to zero will execute. If not computable, return /// CouldNotCompute. - const SCEV *HowFarToZero(const SCEV *V, const Loop *L); + BackedgeTakenInfo HowFarToZero(const SCEV *V, const Loop *L); /// HowFarToNonZero - Return the number of times a backedge checking the /// specified value for nonzero will execute. If not computable, return /// CouldNotCompute. - const SCEV *HowFarToNonZero(const SCEV *V, const Loop *L); + BackedgeTakenInfo HowFarToNonZero(const SCEV *V, const Loop *L); /// HowManyLessThans - Return the number of times a backedge containing the /// specified less-than comparison will execute. If not computable, return @@ -353,14 +353,14 @@ namespace llvm { bool Inverse); /// isImpliedCondOperands - Test whether the condition described by Pred, - /// LHS, and RHS is true whenever the condition desribed by Pred, FoundLHS, + /// LHS, and RHS is true whenever the condition described by Pred, FoundLHS, /// and FoundRHS is true. bool isImpliedCondOperands(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, const SCEV *FoundLHS, const SCEV *FoundRHS); /// isImpliedCondOperandsHelper - Test whether the condition described by - /// Pred, LHS, and RHS is true whenever the condition desribed by Pred, + /// Pred, LHS, and RHS is true whenever the condition described by Pred, /// FoundLHS, and FoundRHS is true. bool isImpliedCondOperandsHelper(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, @@ -586,6 +586,11 @@ namespace llvm { /// compute a trip count, or if the loop is deleted. void forgetLoop(const Loop *L); + /// forgetValue - This method should be called by the client when it has + /// changed a value in a way that may effect its value, or which may + /// disconnect it from a def-use chain linking it to a loop. + void forgetValue(Value *V); + /// GetMinTrailingZeros - Determine the minimum number of zero bits that S /// is guaranteed to end in (at every loop iteration). It is, at the same /// time, the minimum number of times S is divisible by 2. For example, diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index 126c290..1296d67 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -60,11 +60,11 @@ const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point const Attributes Naked = 1<<24; ///< Naked function const Attributes InlineHint = 1<<25; ///< source said inlining was ///desirable -const Attributes StackAlignment = 31<<26; ///< Alignment of stack for - ///function (5 bits) stored as log2 - ///of alignment with +1 bias - ///0 means unaligned (different from - ///alignstack(1)) +const Attributes StackAlignment = 7<<26; ///< Alignment of stack for + ///function (3 bits) stored as log2 + ///of alignment with +1 bias + ///0 means unaligned (different from + ///alignstack(1)) /// @brief Attributes that only apply to function parameters. const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture; @@ -118,7 +118,7 @@ inline Attributes constructStackAlignmentFromInt(unsigned i) { return 0; assert(isPowerOf2_32(i) && "Alignment must be a power of two."); - assert(i <= 0x40000000 && "Alignment too large."); + assert(i <= 0x100 && "Alignment too large."); return (Log2_32(i)+1) << 26; } diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 28a1a3e..8ade1bd 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -223,7 +223,7 @@ namespace llvm { void EmitFunctionBody(); /// EmitInstruction - Targets should implement this to emit instructions. - virtual void EmitInstruction(const MachineInstr *MI) { + virtual void EmitInstruction(const MachineInstr *) { assert(0 && "EmitInstruction not implemented"); } @@ -356,6 +356,11 @@ namespace llvm { /// printOffset - This is just convenient handler for printing offsets. void printOffset(int64_t Offset) const; + /// isBlockOnlyReachableByFallthough - Return true if the basic block has + /// exactly one predecessor and the control transfer mechanism between + /// the predecessor and this block is a fall-through. + virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; + private: /// processDebugLoc - Processes the debug information of each machine diff --git a/include/llvm/CodeGen/DAGISelHeader.h b/include/llvm/CodeGen/DAGISelHeader.h deleted file mode 100644 index 7fda6f7..0000000 --- a/include/llvm/CodeGen/DAGISelHeader.h +++ /dev/null @@ -1,414 +0,0 @@ -//==-llvm/CodeGen/DAGISelHeader.h - Common DAG ISel definitions -*- 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 definitions of the common, target-independent methods and -// data, which is used by SelectionDAG-based instruction selectors. -// -// *** NOTE: This file is #included into the middle of the target -// instruction selector class. These functions are really methods. -// This is a little awkward, but it allows this code to be shared -// by all the targets while still being able to call into -// target-specific code without using a virtual function call. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_DAGISEL_HEADER_H -#define LLVM_CODEGEN_DAGISEL_HEADER_H - -/// ISelPosition - Node iterator marking the current position of -/// instruction selection as it procedes through the topologically-sorted -/// node list. -SelectionDAG::allnodes_iterator ISelPosition; - -/// IsChainCompatible - Returns true if Chain is Op or Chain does -/// not reach Op. -static bool IsChainCompatible(SDNode *Chain, SDNode *Op) { - if (Chain->getOpcode() == ISD::EntryToken) - return true; - if (Chain->getOpcode() == ISD::TokenFactor) - return false; - if (Chain->getNumOperands() > 0) { - SDValue C0 = Chain->getOperand(0); - if (C0.getValueType() == MVT::Other) - return C0.getNode() != Op && IsChainCompatible(C0.getNode(), Op); - } - return true; -} - -/// ISelUpdater - helper class to handle updates of the -/// instruciton selection graph. -class VISIBILITY_HIDDEN ISelUpdater : public SelectionDAG::DAGUpdateListener { - SelectionDAG::allnodes_iterator &ISelPosition; -public: - explicit ISelUpdater(SelectionDAG::allnodes_iterator &isp) - : ISelPosition(isp) {} - - /// NodeDeleted - Handle nodes deleted from the graph. If the - /// node being deleted is the current ISelPosition node, update - /// ISelPosition. - /// - virtual void NodeDeleted(SDNode *N, SDNode *E) { - if (ISelPosition == SelectionDAG::allnodes_iterator(N)) - ++ISelPosition; - } - - /// NodeUpdated - Ignore updates for now. - virtual void NodeUpdated(SDNode *N) {} -}; - -/// ReplaceUses - replace all uses of the old node F with the use -/// of the new node T. -DISABLE_INLINE void ReplaceUses(SDValue F, SDValue T) { - ISelUpdater ISU(ISelPosition); - CurDAG->ReplaceAllUsesOfValueWith(F, T, &ISU); -} - -/// ReplaceUses - replace all uses of the old nodes F with the use -/// of the new nodes T. -DISABLE_INLINE void ReplaceUses(const SDValue *F, const SDValue *T, - unsigned Num) { - ISelUpdater ISU(ISelPosition); - CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISU); -} - -/// ReplaceUses - replace all uses of the old node F with the use -/// of the new node T. -DISABLE_INLINE void ReplaceUses(SDNode *F, SDNode *T) { - ISelUpdater ISU(ISelPosition); - CurDAG->ReplaceAllUsesWith(F, T, &ISU); -} - -/// SelectRoot - Top level entry to DAG instruction selector. -/// Selects instructions starting at the root of the current DAG. -void SelectRoot(SelectionDAG &DAG) { - SelectRootInit(); - - // Create a dummy node (which is not added to allnodes), that adds - // a reference to the root node, preventing it from being deleted, - // and tracking any changes of the root. - HandleSDNode Dummy(CurDAG->getRoot()); - ISelPosition = llvm::next(SelectionDAG::allnodes_iterator(CurDAG->getRoot().getNode())); - - // The AllNodes list is now topological-sorted. Visit the - // nodes by starting at the end of the list (the root of the - // graph) and preceding back toward the beginning (the entry - // node). - while (ISelPosition != CurDAG->allnodes_begin()) { - SDNode *Node = --ISelPosition; - // Skip dead nodes. DAGCombiner is expected to eliminate all dead nodes, - // but there are currently some corner cases that it misses. Also, this - // makes it theoretically possible to disable the DAGCombiner. - if (Node->use_empty()) - continue; -#if 0 - DAG.setSubgraphColor(Node, "red"); -#endif - SDNode *ResNode = Select(Node); - // If node should not be replaced, continue with the next one. - if (ResNode == Node) - continue; - // Replace node. - if (ResNode) { -#if 0 - DAG.setSubgraphColor(ResNode, "yellow"); - DAG.setSubgraphColor(ResNode, "black"); -#endif - ReplaceUses(Node, ResNode); - } - // If after the replacement this node is not used any more, - // remove this dead node. - if (Node->use_empty()) { // Don't delete EntryToken, etc. - ISelUpdater ISU(ISelPosition); - CurDAG->RemoveDeadNode(Node, &ISU); - } - } - - CurDAG->setRoot(Dummy.getValue()); -} - - -/// CheckInteger - Return true if the specified node is not a ConstantSDNode or -/// if it doesn't have the specified value. -static bool CheckInteger(SDValue V, int64_t Val) { - ConstantSDNode *C = dyn_cast<ConstantSDNode>(V); - return C == 0 || C->getSExtValue() != Val; -} - -/// CheckAndImmediate - Check to see if the specified node is an and with an -/// immediate returning true on failure. -/// -/// FIXME: Inline this gunk into CheckAndMask. -bool CheckAndImmediate(SDValue V, int64_t Val) { - if (V->getOpcode() == ISD::AND) - if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(V->getOperand(1))) - if (CheckAndMask(V.getOperand(0), C, Val)) - return false; - return true; -} - -/// CheckOrImmediate - Check to see if the specified node is an or with an -/// immediate returning true on failure. -/// -/// FIXME: Inline this gunk into CheckOrMask. -bool CheckOrImmediate(SDValue V, int64_t Val) { - if (V->getOpcode() == ISD::OR) - if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(V->getOperand(1))) - if (CheckOrMask(V.getOperand(0), C, Val)) - return false; - return true; -} - -// These functions are marked always inline so that Idx doesn't get pinned to -// the stack. -ALWAYS_INLINE static int8_t -GetInt1(const unsigned char *MatcherTable, unsigned &Idx) { - return MatcherTable[Idx++]; -} - -ALWAYS_INLINE static int16_t -GetInt2(const unsigned char *MatcherTable, unsigned &Idx) { - int16_t Val = GetInt1(MatcherTable, Idx); - Val |= int16_t(GetInt1(MatcherTable, Idx)) << 8; - return Val; -} - -ALWAYS_INLINE static int32_t -GetInt4(const unsigned char *MatcherTable, unsigned &Idx) { - int32_t Val = GetInt2(MatcherTable, Idx); - Val |= int32_t(GetInt2(MatcherTable, Idx)) << 16; - return Val; -} - -ALWAYS_INLINE static int64_t -GetInt8(const unsigned char *MatcherTable, unsigned &Idx) { - int64_t Val = GetInt4(MatcherTable, Idx); - Val |= int64_t(GetInt4(MatcherTable, Idx)) << 32; - return Val; -} - -enum BuiltinOpcodes { - OPC_Emit, - OPC_Push, - OPC_Record, - OPC_MoveChild, - OPC_MoveParent, - OPC_CheckSame, - OPC_CheckPatternPredicate, - OPC_CheckPredicate, - OPC_CheckOpcode, - OPC_CheckType, - OPC_CheckInteger1, OPC_CheckInteger2, OPC_CheckInteger4, OPC_CheckInteger8, - OPC_CheckCondCode, - OPC_CheckValueType, - OPC_CheckComplexPat, - OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, - OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8, - OPC_IsProfitableToFold, - OPC_IsLegalToFold -}; - -struct MatchScope { - /// FailIndex - If this match fails, this is the index to continue with. - unsigned FailIndex; - - /// NodeStackSize - The size of the node stack when the scope was formed. - unsigned NodeStackSize; - - /// NumRecordedNodes - The number of recorded nodes when the scope was formed. - unsigned NumRecordedNodes; -}; - -SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, - unsigned TableSize) { - switch (NodeToMatch->getOpcode()) { - default: - break; - case ISD::EntryToken: // These nodes remain the same. - case ISD::BasicBlock: - case ISD::Register: - case ISD::HANDLENODE: - case ISD::TargetConstant: - case ISD::TargetConstantFP: - case ISD::TargetConstantPool: - case ISD::TargetFrameIndex: - case ISD::TargetExternalSymbol: - case ISD::TargetBlockAddress: - case ISD::TargetJumpTable: - case ISD::TargetGlobalTLSAddress: - case ISD::TargetGlobalAddress: - case ISD::TokenFactor: - case ISD::CopyFromReg: - case ISD::CopyToReg: - return 0; - case ISD::AssertSext: - case ISD::AssertZext: - ReplaceUses(SDValue(NodeToMatch, 0), NodeToMatch->getOperand(0)); - return 0; - case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch); - case ISD::EH_LABEL: return Select_EH_LABEL(NodeToMatch); - case ISD::UNDEF: return Select_UNDEF(NodeToMatch); - } - - assert(!NodeToMatch->isMachineOpcode() && "Node already selected!"); - - SmallVector<MatchScope, 8> MatchScopes; - - // RecordedNodes - This is the set of nodes that have been recorded by the - // state machine. - SmallVector<SDValue, 8> RecordedNodes; - - // Set up the node stack with NodeToMatch as the only node on the stack. - SmallVector<SDValue, 8> NodeStack; - SDValue N = SDValue(NodeToMatch, 0); - NodeStack.push_back(N); - - // Interpreter starts at opcode #0. - unsigned MatcherIndex = 0; - while (1) { - assert(MatcherIndex < TableSize && "Invalid index"); - switch ((BuiltinOpcodes)MatcherTable[MatcherIndex++]) { - case OPC_Emit: { - errs() << "EMIT NODE\n"; - return 0; - } - case OPC_Push: { - unsigned NumToSkip = MatcherTable[MatcherIndex++]; - MatchScope NewEntry; - NewEntry.FailIndex = MatcherIndex+NumToSkip; - NewEntry.NodeStackSize = NodeStack.size(); - NewEntry.NumRecordedNodes = RecordedNodes.size(); - MatchScopes.push_back(NewEntry); - continue; - } - case OPC_Record: - // Remember this node, it may end up being an operand in the pattern. - RecordedNodes.push_back(N); - continue; - - case OPC_MoveChild: { - unsigned Child = MatcherTable[MatcherIndex++]; - if (Child >= N.getNumOperands()) - break; // Match fails if out of range child #. - N = N.getOperand(Child); - NodeStack.push_back(N); - continue; - } - - case OPC_MoveParent: - // Pop the current node off the NodeStack. - NodeStack.pop_back(); - assert(!NodeStack.empty() && "Node stack imbalance!"); - N = NodeStack.back(); - continue; - - case OPC_CheckSame: { - // Accept if it is exactly the same as a previously recorded node. - unsigned RecNo = MatcherTable[MatcherIndex++]; - assert(RecNo < RecordedNodes.size() && "Invalid CheckSame"); - if (N != RecordedNodes[RecNo]) break; - continue; - } - case OPC_CheckPatternPredicate: - if (!CheckPatternPredicate(MatcherTable[MatcherIndex++])) break; - continue; - case OPC_CheckPredicate: - if (!CheckNodePredicate(N.getNode(), MatcherTable[MatcherIndex++])) break; - continue; - case OPC_CheckComplexPat: { - unsigned PatNo = MatcherTable[MatcherIndex++]; - (void)PatNo; - // FIXME: CHECK IT. - continue; - } - - case OPC_CheckOpcode: - if (N->getOpcode() != MatcherTable[MatcherIndex++]) break; - continue; - case OPC_CheckType: - if (N.getValueType() != - (MVT::SimpleValueType)MatcherTable[MatcherIndex++]) break; - continue; - case OPC_CheckCondCode: - if (cast<CondCodeSDNode>(N)->get() != - (ISD::CondCode)MatcherTable[MatcherIndex++]) break; - continue; - case OPC_CheckValueType: - if (cast<VTSDNode>(N)->getVT() != - (MVT::SimpleValueType)MatcherTable[MatcherIndex++]) break; - continue; - - case OPC_CheckInteger1: - if (CheckInteger(N, GetInt1(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckInteger2: - if (CheckInteger(N, GetInt2(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckInteger4: - if (CheckInteger(N, GetInt4(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckInteger8: - if (CheckInteger(N, GetInt8(MatcherTable, MatcherIndex))) break; - continue; - - case OPC_CheckAndImm1: - if (CheckAndImmediate(N, GetInt1(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckAndImm2: - if (CheckAndImmediate(N, GetInt2(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckAndImm4: - if (CheckAndImmediate(N, GetInt4(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckAndImm8: - if (CheckAndImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; - continue; - - case OPC_CheckOrImm1: - if (CheckOrImmediate(N, GetInt1(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckOrImm2: - if (CheckOrImmediate(N, GetInt2(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckOrImm4: - if (CheckOrImmediate(N, GetInt4(MatcherTable, MatcherIndex))) break; - continue; - case OPC_CheckOrImm8: - if (CheckOrImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; - continue; - - case OPC_IsProfitableToFold: - assert(!NodeStack.size() == 1 && "No parent node"); - if (!IsProfitableToFold(N, NodeStack[NodeStack.size()-2].getNode(), - NodeToMatch)) - break; - continue; - case OPC_IsLegalToFold: - assert(!NodeStack.size() == 1 && "No parent node"); - if (!IsLegalToFold(N, NodeStack[NodeStack.size()-2].getNode(), - NodeToMatch)) - break; - continue; - } - - // If the code reached this point, then the match failed pop out to the next - // match scope. - if (MatchScopes.empty()) { - CannotYetSelect(NodeToMatch); - return 0; - } - - RecordedNodes.resize(MatchScopes.back().NumRecordedNodes); - NodeStack.resize(MatchScopes.back().NodeStackSize); - MatcherIndex = MatchScopes.back().FailIndex; - MatchScopes.pop_back(); - } -} - - -#endif /* LLVM_CODEGEN_DAGISEL_HEADER_H */ diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 512c94d..eb5901c 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -569,6 +569,16 @@ namespace llvm { /// unsigned getSize() const; + /// isSpillable - Can this interval be spilled? + bool isSpillable() const { + return weight != HUGE_VALF; + } + + /// markNotSpillable - Mark interval as not spillable + void markNotSpillable() { + weight = HUGE_VALF; + } + /// ComputeJoinedWeight - Set the weight of a live interval after /// Other has been merged into it. void ComputeJoinedWeight(const LiveInterval &Other); diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index d7ff8da..e8856ac 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -70,8 +70,15 @@ namespace llvm { static char ID; // Pass identification, replacement for typeid LiveIntervals() : MachineFunctionPass(&ID) {} - static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) { - return (isDef + isUse) * powf(10.0F, (float)loopDepth); + // Calculate the spill weight to assign to a single instruction. + static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth); + + // After summing the spill weights of all defs and uses, the final weight + // should be normalized, dividing the weight of the interval by its size. + // This encourages spilling of intervals that are large and have few uses, + // and discourages spilling of small intervals with many uses. + void normalizeSpillWeight(LiveInterval &li) { + li.weight /= getApproximateInstructionCount(li) + 25; } typedef Reg2IntervalMap::iterator iterator; @@ -409,6 +416,9 @@ namespace llvm { DenseMap<unsigned,unsigned> &MBBVRegsMap, std::vector<LiveInterval*> &NewLIs); + // Normalize the spill weight of all the intervals in NewLIs. + void normalizeSpillWeights(std::vector<LiveInterval*> &NewLIs); + static LiveInterval* createInterval(unsigned Reg); void printInstrs(raw_ostream &O) const; diff --git a/include/llvm/CodeGen/LiveVariables.h b/include/llvm/CodeGen/LiveVariables.h index a7bf600..fc5ea6f 100644 --- a/include/llvm/CodeGen/LiveVariables.h +++ b/include/llvm/CodeGen/LiveVariables.h @@ -124,6 +124,11 @@ private: /// std::vector<VarInfo> VirtRegInfo; + /// PHIJoins - list of virtual registers that are PHI joins. These registers + /// may have multiple definitions, and they require special handling when + /// building live intervals. + SparseBitVector<> PHIJoins; + /// ReservedRegisters - This vector keeps track of which registers /// are reserved register which are not allocatable by the target machine. /// We can not track liveness for values that are in this set. @@ -295,6 +300,12 @@ public: void addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB, MachineBasicBlock *SuccBB); + + /// isPHIJoin - Return true if Reg is a phi join register. + bool isPHIJoin(unsigned Reg) { return PHIJoins.test(Reg); } + + /// setPHIJoin - Mark Reg as a phi join register. + void setPHIJoin(unsigned Reg) { PHIJoins.set(Reg); } }; } // End llvm namespace diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index db82ba5..d92650b4 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -285,11 +285,6 @@ public: /// it returns end() iterator getFirstTerminator(); - /// isOnlyReachableViaFallthough - Return true if this basic block has - /// exactly one predecessor and the control transfer mechanism between - /// the predecessor and this block is a fall-through. - bool isOnlyReachableByFallthrough() const; - void pop_front() { Insts.pop_front(); } void pop_back() { Insts.pop_back(); } void push_back(MachineInstr *MI) { Insts.push_back(MI); } diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 6e33fb3..66be26c 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -179,17 +179,16 @@ public: return MemRefsEnd - MemRefs == 1; } + enum MICheckType { + CheckDefs, // Check all operands for equality + IgnoreDefs, // Ignore all definitions + IgnoreVRegDefs // Ignore virtual register definitions + }; + /// isIdenticalTo - Return true if this instruction is identical to (same /// opcode and same operands as) the specified instruction. - bool isIdenticalTo(const MachineInstr *Other) const { - if (Other->getOpcode() != getOpcode() || - Other->getNumOperands() != getNumOperands()) - return false; - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - if (!getOperand(i).isIdenticalTo(Other->getOperand(i))) - return false; - return true; - } + bool isIdenticalTo(const MachineInstr *Other, + MICheckType Check = CheckDefs) const; /// removeFromParent - This method unlinks 'this' from the containing basic /// block, and returns it, but does not delete it. @@ -331,13 +330,13 @@ public: /// isSafeToMove - Return true if it is safe to move this instruction. If /// SawStore is set to true, it means that there is a store (or call) between /// the instruction's location and its intended destination. - bool isSafeToMove(const TargetInstrInfo *TII, bool &SawStore, - AliasAnalysis *AA) const; + bool isSafeToMove(const TargetInstrInfo *TII, AliasAnalysis *AA, + bool &SawStore) const; /// isSafeToReMat - Return true if it's safe to rematerialize the specified /// instruction which defined the specified register instead of copying it. - bool isSafeToReMat(const TargetInstrInfo *TII, unsigned DstReg, - AliasAnalysis *AA) const; + bool isSafeToReMat(const TargetInstrInfo *TII, AliasAnalysis *AA, + unsigned DstReg) const; /// hasVolatileMemoryRef - Return true if this instruction may have a /// volatile memory reference, or if the information describing the diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index a263a97..47f7cf7 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -127,7 +127,7 @@ public: return *this; } - const MachineInstrBuilder &addMetadata(MDNode *MD) const { + const MachineInstrBuilder &addMetadata(const MDNode *MD) const { MI->addOperand(MachineOperand::CreateMetadata(MD)); return *this; } diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h index dac0092..0978057 100644 --- a/include/llvm/CodeGen/MachineOperand.h +++ b/include/llvm/CodeGen/MachineOperand.h @@ -19,14 +19,14 @@ namespace llvm { -class ConstantFP; class BlockAddress; -class MachineBasicBlock; +class ConstantFP; class GlobalValue; +class MachineBasicBlock; class MachineInstr; -class TargetMachine; class MachineRegisterInfo; class MDNode; +class TargetMachine; class raw_ostream; /// MachineOperand class - Representation of each machine instruction operand. @@ -100,7 +100,7 @@ private: MachineBasicBlock *MBB; // For MO_MachineBasicBlock. const ConstantFP *CFP; // For MO_FPImmediate. int64_t ImmVal; // For MO_Immediate. - MDNode *MD; // For MO_Metadata. + const MDNode *MD; // For MO_Metadata. struct { // For MO_Register. unsigned RegNo; @@ -467,7 +467,7 @@ public: Op.setTargetFlags(TargetFlags); return Op; } - static MachineOperand CreateMetadata(MDNode *Meta) { + static MachineOperand CreateMetadata(const MDNode *Meta) { MachineOperand Op(MachineOperand::MO_Metadata); Op.Contents.MD = Meta; return Op; diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index dbc73cb..911be22 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -162,6 +162,10 @@ namespace llvm { /// 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(); @@ -187,7 +191,7 @@ namespace llvm { /// createMachineVerifierPass - This pass verifies cenerated machine code /// instructions for correctness. /// - /// @param allowPhysDoubleDefs ignore double definitions of + /// @param allowDoubleDefs ignore double definitions of /// registers. Useful before LiveVariables has run. FunctionPass *createMachineVerifierPass(bool allowDoubleDefs); diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index e628603..ad01e89 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -668,27 +668,8 @@ public: SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs, const SDValue *Ops, unsigned NumOps); - /// MorphNodeTo - These *mutate* the specified node to have the specified + /// MorphNodeTo - This *mutates* the specified node to have the specified /// return type, opcode, and operands. - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT, SDValue Op1); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT, - SDValue Op1, SDValue Op2); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT, - SDValue Op1, SDValue Op2, SDValue Op3); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT, - const SDValue *Ops, unsigned NumOps); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, EVT VT2); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, - EVT VT2, const SDValue *Ops, unsigned NumOps); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, - EVT VT2, EVT VT3, const SDValue *Ops, unsigned NumOps); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, - EVT VT2, SDValue Op1); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, - EVT VT2, SDValue Op1, SDValue Op2); - SDNode *MorphNodeTo(SDNode *N, unsigned Opc, EVT VT1, - EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps); @@ -898,6 +879,15 @@ public: /// isKnownNeverNan - Test whether the given SDValue is known to never be NaN. bool isKnownNeverNaN(SDValue Op) const; + /// isKnownNeverZero - Test whether the given SDValue is known to never be + /// positive or negative Zero. + bool isKnownNeverZero(SDValue Op) const; + + /// isEqualTo - Test whether two SDValues are known to compare equal. This + /// is true if they are the same value, or if one is negative zero and the + /// other positive zero. + bool isEqualTo(SDValue A, SDValue B) const; + /// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has /// been verified as a debug information descriptor. bool isVerifiedDebugInfoDesc(SDValue Op) const; diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 0be91b4..23ff001 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -68,12 +68,18 @@ public: unsigned MakeReg(EVT VT); virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {} - virtual void InstructionSelect() = 0; - void SelectRootInit() { - DAGSize = CurDAG->AssignTopologicalOrder(); - } - + /// PreprocessISelDAG - This hook allows targets to hack on the graph before + /// instruction selection starts. + virtual void PreprocessISelDAG() {} + + /// PostprocessISelDAG() - This hook allows the target to hack on the graph + /// right after selection. + virtual void PostprocessISelDAG() {} + + /// Select - Main hook targets implement to select a node. + virtual SDNode *Select(SDNode *N) = 0; + /// SelectInlineAsmMemoryOperand - Select the specified address as a target /// addressing mode, according to the specified constraint code. If this does /// not match or is not implemented, return true. The resultant operands @@ -91,21 +97,138 @@ public: /// IsLegalToFold - Returns true if the specific operand node N of /// U can be folded during instruction selection that starts at Root. - virtual bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const; + bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, + bool IgnoreChains = false) const; /// CreateTargetHazardRecognizer - Return a newly allocated hazard recognizer /// to use for this target when scheduling the DAG. virtual ScheduleHazardRecognizer *CreateTargetHazardRecognizer(); + + // Opcodes used by the DAG state machine: + enum BuiltinOpcodes { + OPC_Scope, + OPC_RecordNode, + OPC_RecordChild0, OPC_RecordChild1, OPC_RecordChild2, OPC_RecordChild3, + OPC_RecordChild4, OPC_RecordChild5, OPC_RecordChild6, OPC_RecordChild7, + OPC_RecordMemRef, + OPC_CaptureFlagInput, + OPC_MoveChild, + OPC_MoveParent, + OPC_CheckSame, + OPC_CheckPatternPredicate, + OPC_CheckPredicate, + OPC_CheckOpcode, + OPC_SwitchOpcode, + OPC_CheckType, + OPC_SwitchType, + OPC_CheckChild0Type, OPC_CheckChild1Type, OPC_CheckChild2Type, + OPC_CheckChild3Type, OPC_CheckChild4Type, OPC_CheckChild5Type, + OPC_CheckChild6Type, OPC_CheckChild7Type, + OPC_CheckInteger, + OPC_CheckCondCode, + OPC_CheckValueType, + OPC_CheckComplexPat, + OPC_CheckAndImm, OPC_CheckOrImm, + OPC_CheckFoldableChainNode, + + OPC_EmitInteger, + OPC_EmitRegister, + OPC_EmitConvertToTarget, + OPC_EmitMergeInputChains, + OPC_EmitCopyToReg, + OPC_EmitNodeXForm, + OPC_EmitNode, + OPC_MorphNodeTo, + OPC_MarkFlagResults, + OPC_CompleteMatch + }; + + enum { + OPFL_None = 0, // Node has no chain or flag input and isn't variadic. + OPFL_Chain = 1, // Node has a chain input. + OPFL_FlagInput = 2, // Node has a flag input. + OPFL_FlagOutput = 4, // Node has a flag output. + OPFL_MemRefs = 8, // Node gets accumulated MemRefs. + OPFL_Variadic0 = 1<<4, // Node is variadic, root has 0 fixed inputs. + OPFL_Variadic1 = 2<<4, // Node is variadic, root has 1 fixed inputs. + OPFL_Variadic2 = 3<<4, // Node is variadic, root has 2 fixed inputs. + OPFL_Variadic3 = 4<<4, // Node is variadic, root has 3 fixed inputs. + OPFL_Variadic4 = 5<<4, // Node is variadic, root has 4 fixed inputs. + OPFL_Variadic5 = 6<<4, // Node is variadic, root has 5 fixed inputs. + OPFL_Variadic6 = 7<<4, // Node is variadic, root has 6 fixed inputs. + + OPFL_VariadicInfo = OPFL_Variadic6 + }; + + /// getNumFixedFromVariadicInfo - Transform an EmitNode flags word into the + /// number of fixed arity values that should be skipped when copying from the + /// root. + static inline int getNumFixedFromVariadicInfo(unsigned Flags) { + return ((Flags&OPFL_VariadicInfo) >> 4)-1; + } + + protected: /// DAGSize - Size of DAG being instruction selected. /// unsigned DAGSize; + + /// ISelPosition - Node iterator marking the current position of + /// instruction selection as it procedes through the topologically-sorted + /// node list. + SelectionDAG::allnodes_iterator ISelPosition; + + + /// ISelUpdater - helper class to handle updates of the + /// instruction selection graph. + class ISelUpdater : public SelectionDAG::DAGUpdateListener { + SelectionDAG::allnodes_iterator &ISelPosition; + public: + explicit ISelUpdater(SelectionDAG::allnodes_iterator &isp) + : ISelPosition(isp) {} + + /// NodeDeleted - Handle nodes deleted from the graph. If the + /// node being deleted is the current ISelPosition node, update + /// ISelPosition. + /// + virtual void NodeDeleted(SDNode *N, SDNode *E) { + if (ISelPosition == SelectionDAG::allnodes_iterator(N)) + ++ISelPosition; + } + + /// NodeUpdated - Ignore updates for now. + virtual void NodeUpdated(SDNode *N) {} + }; + + /// ReplaceUses - replace all uses of the old node F with the use + /// of the new node T. + void ReplaceUses(SDValue F, SDValue T) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesOfValueWith(F, T, &ISU); + } + + /// ReplaceUses - replace all uses of the old nodes F with the use + /// of the new nodes T. + void ReplaceUses(const SDValue *F, const SDValue *T, unsigned Num) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesOfValuesWith(F, T, Num, &ISU); + } + + /// ReplaceUses - replace all uses of the old node F with the use + /// of the new node T. + void ReplaceUses(SDNode *F, SDNode *T) { + ISelUpdater ISU(ISelPosition); + CurDAG->ReplaceAllUsesWith(F, T, &ISU); + } + /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated /// by tblgen. Others should not call it. void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops); + +public: // Calls to these predicates are generated by tblgen. bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const; @@ -122,8 +245,8 @@ protected: return 0; } - /// CheckNodePredicate - This function is generated by tblgen in the - /// target. It runs node predicate #PredNo and returns true if it succeeds or + /// CheckNodePredicate - This function is generated by tblgen in the target. + /// It runs node predicate number PredNo and returns true if it succeeds or /// false if it fails. The number is a private implementation /// detail to the code tblgen produces. virtual bool CheckNodePredicate(SDNode *N, unsigned PredNo) const { @@ -131,6 +254,23 @@ protected: return 0; } + virtual bool CheckComplexPattern(SDNode *Root, SDValue N, unsigned PatternNo, + SmallVectorImpl<SDValue> &Result) { + assert(0 && "Tblgen should generate the implementation of this!"); + return false; + } + + virtual SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) { + assert(0 && "Tblgen shoudl generate this!"); + return SDValue(); + } + + SDNode *SelectCodeCommon(SDNode *NodeToMatch, + const unsigned char *MatcherTable, + unsigned TableSize); + +private: + // Calls to these functions are generated by tblgen. SDNode *Select_INLINEASM(SDNode *N); SDNode *Select_UNDEF(SDNode *N); @@ -139,6 +279,10 @@ protected: void CannotYetSelectIntrinsic(SDNode *N); private: + void DoInstructionSelection(); + SDNode *MorphNode(SDNode *Node, unsigned TargetOpc, SDVTList VTs, + const SDValue *Ops, unsigned NumOps, unsigned EmitNodeInfo); + void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, MachineModuleInfo *MMI, DwarfWriter *DW, @@ -164,6 +308,16 @@ private: /// one preferred by the target. /// ScheduleDAGSDNodes *CreateScheduler(); + + /// OpcodeOffset - This is a cache used to dispatch efficiently into isel + /// state machines that start with a OPC_SwitchOpcode node. + std::vector<unsigned> OpcodeOffset; + + void UpdateChainsAndFlags(SDNode *NodeToMatch, SDValue InputChain, + const SmallVectorImpl<SDNode*> &ChainNodesMatched, + SDValue InputFlag,const SmallVectorImpl<SDNode*> &F, + bool isMorphNodeTo); + }; } diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index df1f91b..950963e 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1595,8 +1595,10 @@ public: return SubclassData; } + // We access subclass data here so that we can check consistency + // with MachineMemOperand information. bool isVolatile() const { return (SubclassData >> 5) & 1; } - bool isNonTemporal() const { return MMO->isNonTemporal(); } + bool isNonTemporal() const { return (SubclassData >> 6) & 1; } /// Returns the SrcValue and offset that describes the location of the access const Value *getSrcValue() const { return MMO->getValue(); } @@ -1762,7 +1764,12 @@ public: bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } int getSplatIndex() const { assert(isSplat() && "Cannot get splat index for non-splat!"); - return Mask[0]; + EVT VT = getValueType(0); + for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) { + if (Mask[i] != -1) + return Mask[i]; + } + return -1; } static bool isSplatMask(const int *Mask, EVT VT); @@ -1808,6 +1815,12 @@ public: const APFloat& getValueAPF() const { return Value->getValueAPF(); } const ConstantFP *getConstantFPValue() const { return Value; } + /// isZero - Return true if the value is positive or negative zero. + bool isZero() const { return Value->isZero(); } + + /// isNaN - Return true if the value is a NaN. + bool isNaN() const { return Value->isNaN(); } + /// isExactlyValue - We don't rely on operator== working on double values, as /// it returns true for things that are clearly not equal, like -0.0 and 0.0. /// As such, this method can be used to do an exact bit-for-bit comparison of diff --git a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index c5aa626..3d99fa7 100644 --- a/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -171,6 +171,11 @@ public: virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; + + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; diff --git a/include/llvm/CompilerDriver/Common.td b/include/llvm/CompilerDriver/Common.td index 9c3e861..479bd6e 100644 --- a/include/llvm/CompilerDriver/Common.td +++ b/include/llvm/CompilerDriver/Common.td @@ -20,9 +20,12 @@ class Tool<list<dag> l> { def in_language; def out_language; def output_suffix; -def cmd_line; +def command; +def out_file_option; +def in_file_option; def join; def sink; +def works_on_empty; def actions; // Possible option types. @@ -46,6 +49,7 @@ def optional; def really_hidden; def required; def comma_separated; +def forward_not_split; // The 'case' construct. def case; @@ -81,6 +85,7 @@ def forward_as; def forward_value; def forward_transformed_value; def stop_compilation; +def no_out_file; def unpack_values; def warning; def error; diff --git a/include/llvm/CompilerDriver/Main.inc b/include/llvm/CompilerDriver/Main.inc index fc8b503..71bb8cb 100644 --- a/include/llvm/CompilerDriver/Main.inc +++ b/include/llvm/CompilerDriver/Main.inc @@ -10,7 +10,7 @@ // 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. +// with the -help option. // // This file provides the default entry point for the driver executable. // diff --git a/include/llvm/CompilerDriver/Tool.h b/include/llvm/CompilerDriver/Tool.h index a982e2d..85d1690 100644 --- a/include/llvm/CompilerDriver/Tool.h +++ b/include/llvm/CompilerDriver/Tool.h @@ -20,15 +20,19 @@ #include "llvm/ADT/StringSet.h" #include "llvm/System/Path.h" +#include <string> #include <vector> +#include <utility> namespace llvmc { class LanguageMap; + typedef std::vector<std::pair<unsigned, std::string> > ArgsVector; typedef std::vector<llvm::sys::Path> PathVector; + typedef std::vector<std::string> StrVector; typedef llvm::StringSet<> InputLanguagesSet; - /// Tool - A class + /// Tool - Represents a single tool. class Tool : public llvm::RefCountedBaseVPTR<Tool> { public: @@ -51,6 +55,7 @@ namespace llvmc { virtual const char* OutputLanguage() const = 0; virtual bool IsJoin() const = 0; + virtual bool WorksOnEmpty() const = 0; protected: /// OutFileName - Generate the output file name. @@ -58,6 +63,8 @@ namespace llvmc { const llvm::sys::Path& TempDir, bool StopCompilation, const char* OutputSuffix) const; + + StrVector SortArgs(ArgsVector& Args) const; }; /// JoinTool - A Tool that has an associated input file list. diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index bd14303d..1cebb20 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -276,6 +276,12 @@ public: return Val.isZero() && Val.isNegative(); } + /// isZero - Return true if the value is positive or negative zero. + bool isZero() const { return Val.isZero(); } + + /// isNaN - Return true if the value is a NaN. + bool isNaN() const { return Val.isNaN(); } + /// isExactlyValue - We don't rely on operator== working on double values, as /// it returns true for things that are clearly not equal, like -0.0 and 0.0. /// As such, this method can be used to do an exact bit-for-bit comparison of @@ -692,8 +698,9 @@ public: /// independent way (Note: the return type is an i64). static Constant *getAlignOf(const Type* Ty); - /// getSizeOf constant expr - computes the size of a type in a target - /// independent way (Note: the return type is an i64). + /// getSizeOf constant expr - computes the (alloc) size of a type (in + /// address-units, not bits) in a target independent way (Note: the return + /// type is an i64). /// static Constant *getSizeOf(const Type* Ty); diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 1ae495f..f07291c 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -591,7 +591,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -612,7 +612,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -631,7 +631,7 @@ public: "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa<PointerType>(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -1805,7 +1805,7 @@ public: return i/2; } - /// getIncomingBlock - Return incoming basic block #i. + /// getIncomingBlock - Return incoming basic block number @p i. /// BasicBlock *getIncomingBlock(unsigned i) const { return cast<BasicBlock>(getOperand(i*2+1)); diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index a7e2e05..ae53851 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -46,7 +46,6 @@ namespace { (void) llvm::createAggressiveDCEPass(); (void) llvm::createAliasAnalysisCounterPass(); (void) llvm::createAliasDebugger(); - (void) llvm::createAndersensPass(); (void) llvm::createArgumentPromotionPass(); (void) llvm::createStructRetPromotionPass(); (void) llvm::createBasicAliasAnalysisPass(); diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 4527f3c..882929f 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -195,12 +195,16 @@ class MCAlignFragment : public MCFragment { /// cannot be satisfied in this width then this fragment is ignored. unsigned MaxBytesToEmit; + /// EmitNops - true when aligning code and optimal nops to be used for filling + bool EmitNops; + public: MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize, - unsigned _MaxBytesToEmit, MCSectionData *SD = 0) + unsigned _MaxBytesToEmit, bool _EmitNops, + MCSectionData *SD = 0) : MCFragment(FT_Align, SD), Alignment(_Alignment), Value(_Value),ValueSize(_ValueSize), - MaxBytesToEmit(_MaxBytesToEmit) {} + MaxBytesToEmit(_MaxBytesToEmit), EmitNops(_EmitNops) {} /// @name Accessors /// @{ @@ -217,6 +221,8 @@ public: unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; } + unsigned getEmitNops() const { return EmitNops; } + /// @} static bool classof(const MCFragment *F) { diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 95c6bd4..74415e2 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -46,30 +46,28 @@ namespace llvm { /// @name Symbol Managment /// @{ - /// CreateSymbol - Create a new symbol with the specified @param Name. + /// CreateSymbol - Create a new symbol with the specified @p Name. /// /// @param Name - The symbol name, which must be unique across all symbols. MCSymbol *CreateSymbol(StringRef Name); /// GetOrCreateSymbol - Lookup the symbol inside with the specified - /// @param Name. If it exists, return it. If not, create a forward + /// @p Name. If it exists, return it. If not, create a forward /// reference and return it. /// /// @param Name - The symbol name, which must be unique across all symbols. - /// @param IsTemporary - Whether this symbol is an assembler temporary, - /// which should not survive into the symbol table for the translation unit. MCSymbol *GetOrCreateSymbol(StringRef Name); MCSymbol *GetOrCreateSymbol(const Twine &Name); /// CreateTemporarySymbol - Create a new temporary symbol with the specified - /// @param Name. + /// @p Name. /// /// @param Name - The symbol name, for debugging purposes only, temporary /// symbols do not surive assembly. If non-empty the name must be unique /// across all symbols. MCSymbol *CreateTemporarySymbol(StringRef Name = ""); - /// LookupSymbol - Get the symbol for @param Name, or null. + /// LookupSymbol - Get the symbol for \p Name, or null. MCSymbol *LookupSymbol(StringRef Name) const; /// @} diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 624d9a6..696d024 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -92,12 +92,12 @@ namespace llvm { const MCSection *getCurrentSection() const { return CurSection; } /// SwitchSection - Set the current section where code is being emitted to - /// @param Section. This is required to update CurSection. + /// @p Section. This is required to update CurSection. /// /// This corresponds to assembler directives like .section, .text, etc. virtual void SwitchSection(const MCSection *Section) = 0; - /// EmitLabel - Emit a label for @param Symbol into the current section. + /// EmitLabel - Emit a label for @p Symbol into the current section. /// /// This corresponds to an assembler statement such as: /// foo: @@ -107,10 +107,10 @@ namespace llvm { /// used in an assignment. virtual void EmitLabel(MCSymbol *Symbol) = 0; - /// EmitAssemblerFlag - Note in the output the specified @param Flag + /// EmitAssemblerFlag - Note in the output the specified @p Flag virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; - /// EmitAssignment - Emit an assignment of @param Value to @param Symbol. + /// EmitAssignment - Emit an assignment of @p Value to @p Symbol. /// /// This corresponds to an assembler statement such as: /// symbol = value @@ -123,11 +123,11 @@ namespace llvm { /// @param Value - The value for the symbol. virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0; - /// EmitSymbolAttribute - Add the given @param Attribute to @param Symbol. + /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) = 0; - /// EmitSymbolDesc - Set the @param DescValue for the @param Symbol. + /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. /// /// @param Symbol - The symbol to have its n_desc field set. /// @param DescValue - The value to set into the n_desc field. @@ -176,8 +176,8 @@ namespace llvm { /// etc. virtual void EmitBytes(StringRef Data, unsigned AddrSpace) = 0; - /// EmitValue - Emit the expression @param Value into the output as a native - /// integer of the given @param Size bytes. + /// EmitValue - Emit the expression @p Value into the output as a native + /// integer of the given @p Size bytes. /// /// This is used to implement assembler directives such as .word, .quad, /// etc. @@ -192,7 +192,7 @@ namespace llvm { /// to pass in a MCExpr for constant integers. virtual void EmitIntValue(uint64_t Value, unsigned Size,unsigned AddrSpace); - /// EmitGPRel32Value - Emit the expression @param Value into the output as a + /// EmitGPRel32Value - Emit the expression @p Value into the output as a /// gprel32 (32-bit GP relative) value. /// /// This is used to implement assembler directives such as .gprel32 on @@ -211,11 +211,11 @@ namespace llvm { } - /// EmitValueToAlignment - Emit some number of copies of @param Value until - /// the byte alignment @param ByteAlignment is reached. + /// EmitValueToAlignment - Emit some number of copies of @p Value until + /// the byte alignment @p ByteAlignment is reached. /// /// If the number of bytes need to emit for the alignment is not a multiple - /// of @param ValueSize, then the contents of the emitted fill bytes is + /// of @p ValueSize, then the contents of the emitted fill bytes is /// undefined. /// /// This used to implement the .align assembler directive. @@ -223,8 +223,8 @@ namespace llvm { /// @param ByteAlignment - The alignment to reach. This must be a power of /// two on some targets. /// @param Value - The value to use when filling bytes. - /// @param Size - The size of the integer (in bytes) to emit for @param - /// Value. This must match a native machine width. + /// @param ValueSize - The size of the integer (in bytes) to emit for + /// @p Value. This must match a native machine width. /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If /// the alignment cannot be reached in this many bytes, no bytes are /// emitted. @@ -232,8 +232,22 @@ namespace llvm { unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) = 0; - /// EmitValueToOffset - Emit some number of copies of @param Value until the - /// byte offset @param Offset is reached. + /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment + /// is reached. + /// + /// This used to align code where the alignment bytes may be executed. This + /// can emit different bytes for different sizes to optimize execution. + /// + /// @param ByteAlignment - The alignment to reach. This must be a power of + /// two on some targets. + /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If + /// the alignment cannot be reached in this many bytes, no bytes are + /// emitted. + virtual void EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit = 0) = 0; + + /// EmitValueToOffset - Emit some number of copies of @p Value until the + /// byte offset @p Offset is reached. /// /// This is used to implement assembler directives such as .org. /// @@ -254,7 +268,7 @@ namespace llvm { /// directive. virtual void EmitDwarfFileDirective(unsigned FileNo,StringRef Filename) = 0; - /// EmitInstruction - Emit the given @param Instruction into the current + /// EmitInstruction - Emit the given @p Instruction into the current /// section. virtual void EmitInstruction(const MCInst &Inst) = 0; diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h index 4e459bf..e536322 100644 --- a/include/llvm/Metadata.h +++ b/include/llvm/Metadata.h @@ -75,6 +75,7 @@ class MDNode : public Value, public FoldingSetNode { MDNode(const MDNode &); // DO NOT IMPLEMENT void operator=(const MDNode &); // DO NOT IMPLEMENT friend class MDNodeOperand; + friend class LLVMContextImpl; /// NumOperands - This many 'MDNodeOperand' items are co-allocated onto the /// end of this MDNode. @@ -103,9 +104,13 @@ class MDNode : public Value, public FoldingSetNode { FL_Yes = 1 }; - // Replace each instance of F from the operand list of this node with T. + /// replaceOperand - Replace each instance of F from the operand list of this + /// node with T. void replaceOperand(MDNodeOperand *Op, Value *NewVal); ~MDNode(); + /// replaceAllOperandsWithNull - This is used while destroying llvm context to + /// gracefully delete all nodes. This method replaces all operands with null. + void replaceAllOperandsWithNull(); protected: explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index e822a0f..8fc3a53 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -163,7 +163,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 *PI) { + virtual void *getAdjustedAnalysisPointer(const PassInfo *) { return this; } virtual ImmutablePass *getAsImmutablePass() { return 0; } diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 3ee2313..61c3256 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -93,9 +93,9 @@ enum ValueExpected { // Is a value required for the option? }; enum OptionHidden { // Control whether -help shows this option - NotHidden = 0x20, // Option included in --help & --help-hidden - Hidden = 0x40, // -help doesn't, but --help-hidden does - ReallyHidden = 0x60, // Neither --help nor --help-hidden show this arg + NotHidden = 0x20, // Option included in -help & -help-hidden + Hidden = 0x40, // -help doesn't, but -help-hidden does + ReallyHidden = 0x60, // Neither -help nor -help-hidden show this arg HiddenMask = 0x60 }; @@ -159,7 +159,7 @@ class Option { Option *NextRegistered; // Singly linked list of registered options. public: const char *ArgStr; // The argument string itself (ex: "help", "o") - const char *HelpStr; // The descriptive text message for --help + const char *HelpStr; // The descriptive text message for -help const char *ValueStr; // String describing what the value of this option is inline enum NumOccurrencesFlag getNumOccurrencesFlag() const { @@ -251,14 +251,14 @@ public: // command line option parsers... // -// desc - Modifier to set the description shown in the --help output... +// desc - Modifier to set the description shown in the -help output... struct desc { const char *Desc; desc(const char *Str) : Desc(Str) {} void apply(Option &O) const { O.setDescription(Desc); } }; -// value_desc - Modifier to set the value description shown in the --help +// value_desc - Modifier to set the value description shown in the -help // output... struct value_desc { const char *Desc; @@ -437,7 +437,7 @@ protected: // Default parser implementation - This implementation depends on having a // mapping of recognized options to values of some sort. In addition to this, // each entry in the mapping also tracks a help message that is printed with the -// command line option for --help. Because this is a simple mapping parser, the +// command line option for -help. Because this is a simple mapping parser, the // data type can be any unsupported type. // template <class DataType> @@ -1373,7 +1373,7 @@ struct extrahelp { void PrintVersionMessage(); // This function just prints the help message, exactly the same way as if the -// --help option had been given on the command line. +// -help option had been given on the command line. // NOTE: THIS FUNCTION TERMINATES THE PROGRAM! void PrintHelpMessage(); diff --git a/include/llvm/Support/Regex.h b/include/llvm/Support/Regex.h index c954c0d..591af00 100644 --- a/include/llvm/Support/Regex.h +++ b/include/llvm/Support/Regex.h @@ -56,6 +56,19 @@ namespace llvm { /// /// This returns true on a successful match. bool match(const StringRef &String, SmallVectorImpl<StringRef> *Matches=0); + + /// sub - Return the result of replacing the first match of the regex in + /// \arg String with the \arg Repl string. Backreferences like "\0" in the + /// replacement string are replaced with the appropriate match substring. + /// + /// Note that the replacement string has backslash escaping performed on + /// it. Invalid backreferences are ignored (replaced by empty strings). + /// + /// \param Error If non-null, any errors in the substitution (invalid + /// backreferences, trailing backslashes) will be recorded as a non-empty + /// string. + std::string sub(StringRef Repl, StringRef String, std::string *Error = 0); + private: struct llvm_regex *preg; int error; diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index 384c493..d34f35f 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -185,7 +185,9 @@ public: return C; // avoid calling Fold return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned)); } - + Constant *CreatePointerCast(Constant *C, const Type *DestTy) const { + return ConstantExpr::getPointerCast(C, DestTy); + } Constant *CreateBitCast(Constant *C, const Type *DestTy) const { return CreateCast(Instruction::BitCast, C, DestTy); } diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h index 1be27b2..d4af478 100644 --- a/include/llvm/System/Path.h +++ b/include/llvm/System/Path.h @@ -203,7 +203,7 @@ namespace sys { } /// Makes a copy of \p that to \p this. - /// @param \p that A StringRef denoting the path + /// @param that A StringRef denoting the path /// @returns \p this /// @brief Assignment Operator Path &operator=(StringRef that); diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index 9a117df..0cffffb 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -211,16 +211,9 @@ class Instruction { // hasSideEffects - The instruction has side effects that are not // captured by any operands of the instruction or other flags. // - // mayHaveSideEffects - Some instances of the instruction can have side - // effects. The virtual method "isReallySideEffectFree" is called to - // determine this. Load instructions are an example of where this is - // useful. In general, loads always have side effects. However, loads from - // constant pools don't. Individual back ends make this determination. - // // neverHasSideEffects - Set on an instruction with no pattern if it has no // side effects. bit hasSideEffects = 0; - bit mayHaveSideEffects = 0; bit neverHasSideEffects = 0; // Is this instruction a "real" instruction (with a distinct machine diff --git a/include/llvm/Target/TargetAsmBackend.h b/include/llvm/Target/TargetAsmBackend.h new file mode 100644 index 0000000..dfdabdb --- /dev/null +++ b/include/llvm/Target/TargetAsmBackend.h @@ -0,0 +1,35 @@ +//===-- llvm/Target/TargetAsmBackend.h - Target Asm Backend -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TARGET_TARGETASMBACKEND_H +#define LLVM_TARGET_TARGETASMBACKEND_H + +namespace llvm { +class Target; + +/// TargetAsmBackend - Generic interface to target specific assembler backends. +class TargetAsmBackend { + TargetAsmBackend(const TargetAsmBackend &); // DO NOT IMPLEMENT + void operator=(const TargetAsmBackend &); // DO NOT IMPLEMENT +protected: // Can only create subclasses. + TargetAsmBackend(const Target &); + + /// TheTarget - The Target that this machine was created for. + const Target &TheTarget; + +public: + virtual ~TargetAsmBackend(); + + const Target &getTarget() const { return TheTarget; } + +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/Target/TargetAsmParser.h b/include/llvm/Target/TargetAsmParser.h index da9ba2b..85315c1 100644 --- a/include/llvm/Target/TargetAsmParser.h +++ b/include/llvm/Target/TargetAsmParser.h @@ -42,8 +42,8 @@ public: /// line should be parsed up to and including the end-of-statement token. On /// failure, the parser is not required to read to the end of the line. // - /// \param AP - The current parser object. /// \param Name - The instruction name. + /// \param NameLoc - The source location of the name. /// \param Operands [out] - The list of parsed operands, this returns /// ownership of them to the caller. /// \return True on failure. @@ -59,7 +59,7 @@ public: /// the target, the entire line is parsed up to and including the /// end-of-statement token and false is returned. /// - /// \param ID - the identifier token of the directive. + /// \param DirectiveID - the identifier token of the directive. virtual bool ParseDirective(AsmToken DirectiveID) = 0; /// MatchInstruction - Recognize a series of operands of a parsed instruction diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index d95e4e8..4b26beb 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -19,14 +19,14 @@ namespace llvm { -class MCAsmInfo; -class TargetRegisterClass; -class TargetRegisterInfo; -class LiveVariables; class CalleeSavedInfo; +class LiveVariables; +class MCAsmInfo; +class MachineMemOperand; class SDNode; class SelectionDAG; -class MachineMemOperand; +class TargetRegisterClass; +class TargetRegisterInfo; template<class T> class SmallVectorImpl; @@ -243,13 +243,11 @@ public: virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const = 0; - /// isIdentical - Return true if two instructions are identical. This differs - /// from MachineInstr::isIdenticalTo() in that it does not require the - /// virtual destination registers to be the same. This is used by MachineLICM - /// and other MI passes to perform CSE. - virtual bool isIdentical(const MachineInstr *MI, - const MachineInstr *Other, - const MachineRegisterInfo *MRI) const = 0; + /// produceSameValue - Return true if two machine instructions would produce + /// identical values. By default, this is only true when the two instructions + /// are deemed identical except for defs. + virtual bool produceSameValue(const MachineInstr *MI0, + const MachineInstr *MI1) const = 0; /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning /// true if it cannot be understood (e.g. it's a switch dispatch or isn't @@ -560,10 +558,8 @@ public: const TargetRegisterInfo *TRI) const; virtual MachineInstr *duplicate(MachineInstr *Orig, MachineFunction &MF) const; - virtual bool isIdentical(const MachineInstr *MI, - const MachineInstr *Other, - const MachineRegisterInfo *MRI) const; - + virtual bool produceSameValue(const MachineInstr *MI0, + const MachineInstr *MI1) const; virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const; }; diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index c6ac89a..60b7ebd 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1164,7 +1164,7 @@ public: bool isVarArg, bool isInreg, unsigned NumFixedArgs, CallingConv::ID CallConv, bool isTailCall, bool isReturnValueUsed, SDValue Callee, ArgListTy &Args, - SelectionDAG &DAG, DebugLoc dl, unsigned Order); + SelectionDAG &DAG, DebugLoc dl); /// LowerCall - This hook must be implemented to lower calls into the /// the specified DAG. The outgoing arguments to the call are described diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index c496e11..a7062ac 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -189,8 +189,9 @@ public: /// is not supported, or false on success. virtual bool addPassesToEmitFile(PassManagerBase &, formatted_raw_ostream &, - CodeGenFileType Filetype, - CodeGenOpt::Level) { + CodeGenFileType, + CodeGenOpt::Level, + bool DisableVerify = true) { return true; } @@ -202,7 +203,8 @@ public: /// virtual bool addPassesToEmitMachineCode(PassManagerBase &, JITCodeEmitter &, - CodeGenOpt::Level) { + CodeGenOpt::Level, + bool DisableVerify = true) { return true; } @@ -212,7 +214,8 @@ public: virtual bool WantsWholeFile() const { return false; } virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &, CodeGenFileType, - CodeGenOpt::Level) { + CodeGenOpt::Level, + bool DisableVerify = true) { return true; } }; @@ -227,7 +230,8 @@ protected: // Can only create subclasses. /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for /// both emitting to assembly files or machine code output. /// - bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level); + bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level, + bool DisableVerify); private: virtual void setCodeModelForJIT(); @@ -242,7 +246,8 @@ public: virtual bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out, CodeGenFileType FileType, - CodeGenOpt::Level); + CodeGenOpt::Level, + bool DisableVerify = true); /// addPassesToEmitMachineCode - Add passes to the specified pass manager to /// get machine code emitted. This uses a JITCodeEmitter object to handle @@ -252,7 +257,8 @@ public: /// virtual bool addPassesToEmitMachineCode(PassManagerBase &PM, JITCodeEmitter &MCE, - CodeGenOpt::Level); + CodeGenOpt::Level, + bool DisableVerify = true); /// Target-Independent Code Generator Pass Configuration Options. diff --git a/include/llvm/Target/TargetOpcodes.h b/include/llvm/Target/TargetOpcodes.h index 10cb45f..48665b7 100644 --- a/include/llvm/Target/TargetOpcodes.h +++ b/include/llvm/Target/TargetOpcodes.h @@ -16,7 +16,7 @@ namespace llvm { -// Invariant opcodes: All instruction sets have these as their low opcodes. +/// Invariant opcodes: All instruction sets have these as their low opcodes. namespace TargetOpcode { enum { PHI = 0, @@ -63,7 +63,7 @@ namespace TargetOpcode { /// the copy are emitted with the TargetInstrInfo::copyRegToReg hook. COPY_TO_REGCLASS = 10, - // DBG_VALUE - a mapping of the llvm.dbg.value intrinsic + /// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic DBG_VALUE = 11 }; } // end namespace TargetOpcode diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index 65b60f7..212cc93 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -587,6 +587,17 @@ public: 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 + /// 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 { + return hasReservedCallFrame(MF) || hasFP(MF); + } + /// hasReservedSpillSlot - Return true if target has reserved a spill slot in /// the stack frame of the given function for the specified register. e.g. On /// x86, if the frame register is required, the first fixed stack object is diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 37380ab..a409b62 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -26,6 +26,7 @@ namespace llvm { class AsmPrinter; class Module; + class MCAssembler; class MCAsmInfo; class MCAsmParser; class MCCodeEmitter; @@ -33,6 +34,7 @@ namespace llvm { class MCDisassembler; class MCInstPrinter; class MCStreamer; + class TargetAsmBackend; class TargetAsmLexer; class TargetAsmParser; class TargetMachine; @@ -63,6 +65,8 @@ namespace llvm { MCContext &Ctx, MCStreamer &Streamer, const MCAsmInfo *MAI); + typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T, + MCAssembler &A); typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T, const MCAsmInfo &MAI); typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P); @@ -94,32 +98,35 @@ namespace llvm { bool HasJIT; AsmInfoCtorFnTy AsmInfoCtorFn; - + /// TargetMachineCtorFn - Construction function for this target's /// TargetMachine, if registered. TargetMachineCtorTy TargetMachineCtorFn; - /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter, - /// if registered. - AsmPrinterCtorTy AsmPrinterCtorFn; + /// AsmBackendCtorFn - Construction function for this target's + /// TargetAsmBackend, if registered. + AsmBackendCtorTy AsmBackendCtorFn; /// AsmLexerCtorFn - Construction function for this target's TargetAsmLexer, /// if registered. AsmLexerCtorTy AsmLexerCtorFn; - + /// AsmParserCtorFn - Construction function for this target's /// TargetAsmParser, if registered. AsmParserCtorTy AsmParserCtorFn; - + + /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter, + /// if registered. + AsmPrinterCtorTy AsmPrinterCtorFn; + /// MCDisassemblerCtorFn - Construction function for this target's /// MCDisassembler, if registered. MCDisassemblerCtorTy MCDisassemblerCtorFn; - - /// MCInstPrinterCtorFn - Construction function for this target's + /// MCInstPrinterCtorFn - Construction function for this target's /// MCInstPrinter, if registered. MCInstPrinterCtorTy MCInstPrinterCtorFn; - + /// CodeEmitterCtorFn - Construction function for this target's CodeEmitter, /// if registered. CodeEmitterCtorTy CodeEmitterCtorFn; @@ -147,12 +154,18 @@ namespace llvm { /// hasTargetMachine - Check if this target supports code generation. bool hasTargetMachine() const { return TargetMachineCtorFn != 0; } - /// hasAsmPrinter - Check if this target supports .s printing. - bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; } + /// hasAsmBackend - Check if this target supports .o generation. + bool hasAsmBackend() const { return AsmBackendCtorFn != 0; } + + /// hasAsmLexer - Check if this target supports .s lexing. + bool hasAsmLexer() const { return AsmLexerCtorFn != 0; } /// hasAsmParser - Check if this target supports .s parsing. bool hasAsmParser() const { return AsmParserCtorFn != 0; } - + + /// hasAsmPrinter - Check if this target supports .s printing. + bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; } + /// hasMCDisassembler - Check if this target has a disassembler. bool hasMCDisassembler() const { return MCDisassemblerCtorFn != 0; } @@ -165,7 +178,7 @@ namespace llvm { /// @} /// @name Feature Constructors /// @{ - + /// createAsmInfo - Create a MCAsmInfo implementation for the specified /// target triple. /// @@ -178,7 +191,7 @@ namespace llvm { return 0; return AsmInfoCtorFn(*this, Triple); } - + /// createTargetMachine - Create a target specific machine implementation /// for the specified \arg Triple. /// @@ -193,14 +206,13 @@ namespace llvm { return TargetMachineCtorFn(*this, Triple, Features); } - /// createAsmPrinter - Create a target specific assembly printer pass. This - /// takes ownership of the MCContext and MCStreamer objects but not the MAI. - AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM, - MCContext &Ctx, MCStreamer &Streamer, - const MCAsmInfo *MAI) const { - if (!AsmPrinterCtorFn) + /// createAsmBackend - Create a target specific assembly parser. + /// + /// \arg Backend - The target independent assembler object. + TargetAsmBackend *createAsmBackend(MCAssembler &Backend) const { + if (!AsmBackendCtorFn) return 0; - return AsmPrinterCtorFn(OS, TM, Ctx, Streamer, MAI); + return AsmBackendCtorFn(*this, Backend); } /// createAsmLexer - Create a target specific assembly lexer. @@ -210,7 +222,7 @@ namespace llvm { return 0; return AsmLexerCtorFn(*this, MAI); } - + /// createAsmParser - Create a target specific assembly parser. /// /// \arg Parser - The target independent parser implementation to use for @@ -220,7 +232,17 @@ namespace llvm { return 0; return AsmParserCtorFn(*this, Parser); } - + + /// createAsmPrinter - Create a target specific assembly printer pass. This + /// takes ownership of the MCContext and MCStreamer objects but not the MAI. + AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM, + MCContext &Ctx, MCStreamer &Streamer, + const MCAsmInfo *MAI) const { + if (!AsmPrinterCtorFn) + return 0; + return AsmPrinterCtorFn(OS, TM, Ctx, Streamer, MAI); + } + const MCDisassembler *createMCDisassembler() const { if (!MCDisassemblerCtorFn) return 0; @@ -234,8 +256,8 @@ namespace llvm { return 0; return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, O); } - - + + /// createCodeEmitter - Create a target specific code emitter. MCCodeEmitter *createCodeEmitter(TargetMachine &TM, MCContext &Ctx) const { if (!CodeEmitterCtorFn) @@ -270,8 +292,8 @@ namespace llvm { return *this; } iterator operator++(int) { // Postincrement - iterator tmp = *this; - ++*this; + iterator tmp = *this; + ++*this; return tmp; } @@ -313,7 +335,7 @@ namespace llvm { /// RegisterTarget - Register the given target. Attempts to register a /// target which has already been registered will be ignored. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. @@ -321,7 +343,7 @@ namespace llvm { /// @param T - The target being registered. /// @param Name - The target name. This should be a static string. /// @param ShortDesc - A short target description. This should be a static - /// string. + /// string. /// @param TQualityFn - The triple match quality computation function for /// this target. /// @param HasJIT - Whether the target supports JIT code @@ -334,11 +356,11 @@ namespace llvm { /// RegisterAsmInfo - Register a MCAsmInfo implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. - /// + /// /// @param T - The target being registered. /// @param Fn - A function to construct a MCAsmInfo for the target. static void RegisterAsmInfo(Target &T, Target::AsmInfoCtorFnTy Fn) { @@ -346,76 +368,90 @@ namespace llvm { if (!T.AsmInfoCtorFn) T.AsmInfoCtorFn = Fn; } - + /// RegisterTargetMachine - Register a TargetMachine implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. - /// + /// /// @param T - The target being registered. /// @param Fn - A function to construct a TargetMachine for the target. - static void RegisterTargetMachine(Target &T, + static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn) { // Ignore duplicate registration. if (!T.TargetMachineCtorFn) T.TargetMachineCtorFn = Fn; } - /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given - /// target. - /// + /// RegisterAsmBackend - Register a TargetAsmBackend implementation for the + /// given target. + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. /// /// @param T - The target being registered. - /// @param Fn - A function to construct an AsmPrinter for the target. - static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) { - // Ignore duplicate registration. - if (!T.AsmPrinterCtorFn) - T.AsmPrinterCtorFn = Fn; + /// @param Fn - A function to construct an AsmBackend for the target. + static void RegisterAsmBackend(Target &T, Target::AsmBackendCtorTy Fn) { + if (!T.AsmBackendCtorFn) + T.AsmBackendCtorFn = Fn; } /// RegisterAsmLexer - Register a TargetAsmLexer implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. /// /// @param T - The target being registered. - /// @param Fn - A function to construct an AsmPrinter for the target. + /// @param Fn - A function to construct an AsmLexer for the target. static void RegisterAsmLexer(Target &T, Target::AsmLexerCtorTy Fn) { if (!T.AsmLexerCtorFn) T.AsmLexerCtorFn = Fn; } - + /// RegisterAsmParser - Register a TargetAsmParser implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. /// /// @param T - The target being registered. - /// @param Fn - A function to construct an AsmPrinter for the target. + /// @param Fn - A function to construct an AsmParser for the target. static void RegisterAsmParser(Target &T, Target::AsmParserCtorTy Fn) { if (!T.AsmParserCtorFn) T.AsmParserCtorFn = Fn; } - + + /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given + /// target. + /// + /// Clients are responsible for ensuring that registration doesn't occur + /// while another thread is attempting to access the registry. Typically + /// this is done by initializing all targets at program startup. + /// + /// @param T - The target being registered. + /// @param Fn - A function to construct an AsmPrinter for the target. + static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) { + // Ignore duplicate registration. + if (!T.AsmPrinterCtorFn) + T.AsmPrinterCtorFn = Fn; + } + /// RegisterMCDisassembler - Register a MCDisassembler implementation for /// the given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. /// /// @param T - The target being registered. /// @param Fn - A function to construct an MCDisassembler for the target. - static void RegisterMCDisassembler(Target &T, + static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn) { if (!T.MCDisassemblerCtorFn) T.MCDisassemblerCtorFn = Fn; @@ -423,7 +459,7 @@ namespace llvm { /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the /// given target. - /// + /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically /// this is done by initializing all targets at program startup. @@ -435,7 +471,7 @@ namespace llvm { if (!T.MCInstPrinterCtorFn) T.MCInstPrinterCtorFn = Fn; } - + /// RegisterCodeEmitter - Register a MCCodeEmitter implementation for the /// given target. /// @@ -444,7 +480,7 @@ namespace llvm { /// this is done by initializing all targets at program startup. /// /// @param T - The target being registered. - /// @param Fn - A function to construct an AsmPrinter for the target. + /// @param Fn - A function to construct an MCCodeEmitter for the target. static void RegisterCodeEmitter(Target &T, Target::CodeEmitterCtorTy Fn) { if (!T.CodeEmitterCtorFn) T.CodeEmitterCtorFn = Fn; @@ -498,7 +534,7 @@ namespace llvm { static const MCAsmInfo *Allocator(const Target &T, StringRef TT) { return new MCAsmInfoImpl(T, TT); } - + }; /// RegisterAsmInfoFn - Helper template for registering a target assembly info @@ -537,25 +573,22 @@ namespace llvm { } }; - /// RegisterAsmPrinter - Helper template for registering a target specific - /// assembly printer, for use in the target machine initialization - /// function. Usage: + /// RegisterAsmBackend - Helper template for registering a target specific + /// assembler backend. Usage: /// - /// extern "C" void LLVMInitializeFooAsmPrinter() { + /// extern "C" void LLVMInitializeFooAsmBackend() { /// extern Target TheFooTarget; - /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget); + /// RegisterAsmBackend<FooAsmLexer> X(TheFooTarget); /// } - template<class AsmPrinterImpl> - struct RegisterAsmPrinter { - RegisterAsmPrinter(Target &T) { - TargetRegistry::RegisterAsmPrinter(T, &Allocator); + template<class AsmBackendImpl> + struct RegisterAsmBackend { + RegisterAsmBackend(Target &T) { + TargetRegistry::RegisterAsmBackend(T, &Allocator); } private: - static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM, - MCContext &Ctx, MCStreamer &Streamer, - const MCAsmInfo *MAI) { - return new AsmPrinterImpl(OS, TM, Ctx, Streamer, MAI); + static TargetAsmBackend *Allocator(const Target &T, MCAssembler &Backend) { + return new AsmBackendImpl(T, Backend); } }; @@ -572,7 +605,7 @@ namespace llvm { RegisterAsmLexer(Target &T) { TargetRegistry::RegisterAsmLexer(T, &Allocator); } - + private: static TargetAsmLexer *Allocator(const Target &T, const MCAsmInfo &MAI) { return new AsmLexerImpl(T, MAI); @@ -599,6 +632,28 @@ namespace llvm { } }; + /// RegisterAsmPrinter - Helper template for registering a target specific + /// assembly printer, for use in the target machine initialization + /// function. Usage: + /// + /// extern "C" void LLVMInitializeFooAsmPrinter() { + /// extern Target TheFooTarget; + /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget); + /// } + template<class AsmPrinterImpl> + struct RegisterAsmPrinter { + RegisterAsmPrinter(Target &T) { + TargetRegistry::RegisterAsmPrinter(T, &Allocator); + } + + private: + static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM, + MCContext &Ctx, MCStreamer &Streamer, + const MCAsmInfo *MAI) { + return new AsmPrinterImpl(OS, TM, Ctx, Streamer, MAI); + } + }; + /// RegisterCodeEmitter - Helper template for registering a target specific /// machine code emitter, for use in the target initialization /// function. Usage: diff --git a/include/llvm/Target/TargetSelectionDAG.td b/include/llvm/Target/TargetSelectionDAG.td index 4b72f81..4365d33 100644 --- a/include/llvm/Target/TargetSelectionDAG.td +++ b/include/llvm/Target/TargetSelectionDAG.td @@ -479,7 +479,6 @@ class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm> def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>; def vtFP : PatLeaf<(vt), [{ return N->getVT().isFloatingPoint(); }]>; -def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>; def immAllOnesV: PatLeaf<(build_vector), [{ return ISD::isBuildVectorAllOnes(N); }]>; @@ -496,7 +495,7 @@ def immAllZerosV_bc: PatLeaf<(bitconvert), [{ // Other helper fragments. -def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>; +def not : PatFrag<(ops node:$in), (xor node:$in, -1)>; def vnot : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV)>; def vnot_conv : PatFrag<(ops node:$in), (xor node:$in, immAllOnesV_bc)>; def ineg : PatFrag<(ops node:$in), (sub 0, node:$in)>; diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 7159f86..6893bad 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -263,7 +263,7 @@ extern const PassInfo *const LCSSAID; // GVN - This pass performs global value numbering and redundant load // elimination cotemporaneously. // -FunctionPass *createGVNPass(bool NoPRE = false, bool NoLoads = false); +FunctionPass *createGVNPass(bool NoLoads = false); //===----------------------------------------------------------------------===// // diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 3f4571e..5279e96 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -102,6 +102,12 @@ void FindFunctionBackedges(const Function &F, // void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); +/// GetSuccessorNumber - Search for the specified successor of basic block BB +/// and return its position in the terminator instruction's list of +/// successors. It is an error to call this with a block that is not a +/// successor. +unsigned GetSuccessorNumber(BasicBlock *BB, BasicBlock *Succ); + /// isCriticalEdge - Return true if the specified edge is a critical edge. /// Critical edges are edges from a block with multiple successors to a block /// with multiple predecessors. diff --git a/include/llvm/Type.h b/include/llvm/Type.h index c52419c..d09913a 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -89,7 +89,7 @@ public: VectorTyID, ///< 15: SIMD 'packed' format, or other vector type NumTypeIDs, // Must remain as last defined ID - LastPrimitiveTyID = LabelTyID, + LastPrimitiveTyID = MetadataTyID, FirstDerivedTyID = IntegerTyID }; @@ -182,6 +182,9 @@ public: // are defined in private classes defined in Type.cpp for primitive types. // + /// getDescription - Return the string representation of the type. + std::string getDescription() const; + /// getTypeID - Return the type id for the type. This will return one /// of the TypeID enum elements defined above. /// @@ -205,15 +208,21 @@ public: /// isPPC_FP128Ty - Return true if this is powerpc long double. bool isPPC_FP128Ty() const { return ID == PPC_FP128TyID; } + /// isFloatingPointTy - Return true if this is one of the five floating point + /// types + bool isFloatingPointTy() const { return ID == FloatTyID || ID == DoubleTyID || + ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID; } + + /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. + /// + bool isFPOrFPVectorTy() const; + /// isLabelTy - Return true if this is 'label'. bool isLabelTy() const { return ID == LabelTyID; } /// isMetadataTy - Return true if this is 'metadata'. bool isMetadataTy() const { return ID == MetadataTyID; } - /// getDescription - Return the string representation of the type. - std::string getDescription() const; - /// isIntegerTy - True if this is an instance of IntegerType. /// bool isIntegerTy() const { return ID == IntegerTyID; } @@ -226,15 +235,6 @@ public: /// bool isIntOrIntVectorTy() const; - /// isFloatingPointTy - Return true if this is one of the five floating point - /// types - bool isFloatingPointTy() const { return ID == FloatTyID || ID == DoubleTyID || - ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID; } - - /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. - /// - bool isFPOrFPVectorTy() const; - /// isFunctionTy - True if this is an instance of FunctionType. /// bool isFunctionTy() const { return ID == FunctionTyID; } @@ -243,6 +243,10 @@ 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; } @@ -251,6 +255,10 @@ public: /// bool isPointerTy() const { return ID == PointerTyID; } + /// isOpaqueTy - True if this is an instance of OpaqueType. + /// + bool isOpaqueTy() const { return ID == OpaqueTyID; } + /// isVectorTy - True if this is an instance of VectorType. /// bool isVectorTy() const { return ID == VectorTyID; } |