From: Jay Foad Date: Wed, 22 Jun 2011 08:50:06 +0000 (+0000) Subject: Extend ConstantUniqueMap with a new template parameter ValRefType, X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2a4a6fecf0b8c92223f8fdf19545b564b7d3fcde;p=oota-llvm.git Extend ConstantUniqueMap with a new template parameter ValRefType, representing a constant reference to ValType. Normally this is just "const ValType &", but when ValType is a std::vector we want to use ArrayRef as the reference type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133611 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 97e42cb2660..a7e268b0993 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -124,6 +124,13 @@ namespace llvm { return std::vector(Data, Data+Length); } + /// @} + /// @name Conversion operators + /// @{ + operator std::vector() const { + return std::vector(Data, Data+Length); + } + /// @} }; diff --git a/include/llvm/InlineAsm.h b/include/llvm/InlineAsm.h index ed8f0f7f615..0d8608605d1 100644 --- a/include/llvm/InlineAsm.h +++ b/include/llvm/InlineAsm.h @@ -25,15 +25,16 @@ class PointerType; class FunctionType; class Module; struct InlineAsmKeyType; -template +template class ConstantUniqueMap; template struct ConstantCreator; class InlineAsm : public Value { friend struct ConstantCreator; - friend class ConstantUniqueMap; + friend class ConstantUniqueMap; InlineAsm(const InlineAsm &); // do not implement void operator=(const InlineAsm&); // do not implement diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h index 13957545786..ea6ebe9eaa9 100644 --- a/lib/VMCore/ConstantsContext.h +++ b/lib/VMCore/ConstantsContext.h @@ -568,7 +568,7 @@ struct ConstantKeyData { } }; -template class ConstantUniqueMap : public AbstractTypeUser { public: @@ -656,7 +656,7 @@ private: } } - ConstantClass* Create(const TypeClass *Ty, const ValType &V, + ConstantClass* Create(const TypeClass *Ty, ValRefType V, typename MapTy::iterator I) { ConstantClass* Result = ConstantCreator::create(Ty, V); @@ -675,7 +675,7 @@ public: /// getOrCreate - Return the specified constant from the map, creating it if /// necessary. - ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { + ConstantClass *getOrCreate(const TypeClass *Ty, ValRefType V) { MapKey Lookup(Ty, V); ConstantClass* Result = 0; diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h index d1ff0ecd637..d8808b0ab8d 100644 --- a/lib/VMCore/LLVMContextImpl.h +++ b/lib/VMCore/LLVMContextImpl.h @@ -25,6 +25,7 @@ #include "llvm/Support/ValueHandle.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/SmallPtrSet.h" @@ -138,27 +139,30 @@ public: // on Context destruction. SmallPtrSet NonUniquedMDNodes; - ConstantUniqueMap AggZeroConstants; + ConstantUniqueMap AggZeroConstants; - typedef ConstantUniqueMap, ArrayType, - ConstantArray, true /*largekey*/> ArrayConstantsTy; + typedef ConstantUniqueMap, ArrayRef, + ArrayType, ConstantArray, true /*largekey*/> ArrayConstantsTy; ArrayConstantsTy ArrayConstants; - typedef ConstantUniqueMap, StructType, - ConstantStruct, true /*largekey*/> StructConstantsTy; + typedef ConstantUniqueMap, ArrayRef, + StructType, ConstantStruct, true /*largekey*/> StructConstantsTy; StructConstantsTy StructConstants; - typedef ConstantUniqueMap, VectorType, - ConstantVector> VectorConstantsTy; + typedef ConstantUniqueMap, ArrayRef, + VectorType, ConstantVector> VectorConstantsTy; VectorConstantsTy VectorConstants; - ConstantUniqueMap NullPtrConstants; - ConstantUniqueMap UndefValueConstants; + ConstantUniqueMap + NullPtrConstants; + ConstantUniqueMap UndefValueConstants; DenseMap , BlockAddress*> BlockAddresses; - ConstantUniqueMap ExprConstants; + ConstantUniqueMap + ExprConstants; - ConstantUniqueMap InlineAsms; + ConstantUniqueMap InlineAsms; ConstantInt *TheTrueVal; ConstantInt *TheFalseVal;