1 //===-- llvm/ConstantPool.h - Define the constant pool class ------*- C++ -*-=//
3 // This file implements a constant pool that is split into different type
4 // planes. This allows searching for a typed object to go a little faster.
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_CONSTANTPOOL_H
9 #define LLVM_CONSTANTPOOL_H
12 #include "llvm/ValueHolder.h"
20 typedef ValueHolder<ConstPoolVal, SymTabValue> PlaneType;
22 typedef vector<PlaneType*> PlanesType;
26 inline void resize(unsigned size);
28 inline ConstantPool(SymTabValue *P) { Parent = P; }
29 inline ~ConstantPool() { delete_all(); }
31 inline SymTabValue *getParent() { return Parent; }
32 inline const SymTabValue *getParent() const { return Parent; }
34 void setParent(SymTabValue *STV);
36 void dropAllReferences(); // Drop all references to other constants
38 // Constant getPlane - Returns true if the type plane does not exist,
39 // otherwise updates the pointer to point to the correct plane.
41 bool getPlane(const Type *T, const PlaneType *&Plane) const;
42 bool getPlane(const Type *T, PlaneType *&Plane);
44 // Normal getPlane - Resizes constant pool to contain type even if it doesn't
47 PlaneType &getPlane(const Type *T);
49 // insert - Add constant into the symbol table...
50 void insert(ConstPoolVal *N);
51 bool remove(ConstPoolVal *N); // Returns true on failure
55 // find - Search to see if a constant of the specified value is already in
56 // the constant table.
58 const ConstPoolVal *find(const ConstPoolVal *V) const;
59 ConstPoolVal *find(const ConstPoolVal *V) ;
60 const ConstPoolVal *find(const Type *Ty) const;
61 ConstPoolVal *find(const Type *Ty) ;
63 // Plane iteration support
65 typedef PlanesType::iterator plane_iterator;
66 typedef PlanesType::const_iterator plane_const_iterator;
68 inline plane_iterator begin() { return Planes.begin(); }
69 inline plane_const_iterator begin() const { return Planes.begin(); }
70 inline plane_iterator end() { return Planes.end(); }
71 inline plane_const_iterator end() const { return Planes.end(); }