diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-12 17:45:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-12 17:45:29 +0000 |
commit | 58d74910c6b82e622ecbb57d6644d48fec5a5c0f (patch) | |
tree | f04d1ab294b3379bf97d9f727d4ade9e7079ca48 /lib/Bitcode/Writer/ValueEnumerator.h | |
parent | 37f603f5d78f735e8de92113429b67c77aa58086 (diff) |
Reimplement the parameter attributes support, phase #1. hilights:
1. There is now a "PAListPtr" class, which is a smart pointer around
the underlying uniqued parameter attribute list object, and manages
its refcount. It is now impossible to mess up the refcount.
2. PAListPtr is now the main interface to the underlying object, and
the underlying object is now completely opaque.
3. Implementation details like SmallVector and FoldingSet are now no
longer part of the interface.
4. You can create a PAListPtr with an arbitrary sequence of
ParamAttrsWithIndex's, no need to make a SmallVector of a specific
size (you can just use an array or scalar or vector if you wish).
5. All the client code that had to check for a null pointer before
dereferencing the pointer is simplified to just access the
PAListPtr directly.
6. The interfaces for adding attrs to a list and removing them is a
bit simpler.
Phase #2 will rename some stuff (e.g. PAListPtr) and do other less
invasive changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48289 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.h')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.h b/lib/Bitcode/Writer/ValueEnumerator.h index 9fb916a515..dc40d016dc 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.h +++ b/lib/Bitcode/Writer/ValueEnumerator.h @@ -15,6 +15,7 @@ #define VALUE_ENUMERATOR_H #include "llvm/ADT/DenseMap.h" +#include "llvm/ParameterAttributes.h" #include <vector> namespace llvm { @@ -24,7 +25,7 @@ class Value; class BasicBlock; class Function; class Module; -class ParamAttrsList; +class PAListPtr; class TypeSymbolTable; class ValueSymbolTable; @@ -44,9 +45,9 @@ private: ValueMapType ValueMap; ValueList Values; - typedef DenseMap<const ParamAttrsList*, unsigned> ParamAttrMapType; + typedef DenseMap<void*, unsigned> ParamAttrMapType; ParamAttrMapType ParamAttrMap; - std::vector<const ParamAttrsList*> ParamAttrs; + std::vector<PAListPtr> ParamAttrs; /// BasicBlocks - This contains all the basic blocks for the currently /// incorporated function. Their reverse mapping is stored in ValueMap. @@ -75,9 +76,9 @@ public: return I->second-1; } - unsigned getParamAttrID(const ParamAttrsList *PAL) const { - if (PAL == 0) return 0; // Null maps to zero. - ParamAttrMapType::const_iterator I = ParamAttrMap.find(PAL); + unsigned getParamAttrID(const PAListPtr &PAL) const { + if (PAL.isEmpty()) return 0; // Null maps to zero. + ParamAttrMapType::const_iterator I = ParamAttrMap.find(PAL.getRawPointer()); assert(I != ParamAttrMap.end() && "ParamAttr not in ValueEnumerator!"); return I->second; } @@ -94,7 +95,7 @@ public: const std::vector<const BasicBlock*> &getBasicBlocks() const { return BasicBlocks; } - const std::vector<const ParamAttrsList*> &getParamAttrs() const { + const std::vector<PAListPtr> &getParamAttrs() const { return ParamAttrs; } @@ -115,7 +116,7 @@ private: void EnumerateValue(const Value *V); void EnumerateType(const Type *T); void EnumerateOperandType(const Value *V); - void EnumerateParamAttrs(const ParamAttrsList *PAL); + void EnumerateParamAttrs(const PAListPtr &PAL); void EnumerateTypeSymbolTable(const TypeSymbolTable &ST); void EnumerateValueSymbolTable(const ValueSymbolTable &ST); |