aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/LLVMContextImpl.h
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-31 22:45:43 +0000
committerOwen Anderson <resistor@mac.com>2009-07-31 22:45:43 +0000
commitf74a1f0d5782f09cb031805c9c74a6855a36d011 (patch)
treee94f6a29e29fd037e8844cd8b4b5a1d9348546d4 /lib/VMCore/LLVMContextImpl.h
parent45ab48e34fe0f640ee1587f6edb157a03b02a315 (diff)
downloadexternal_llvm-f74a1f0d5782f09cb031805c9c74a6855a36d011.zip
external_llvm-f74a1f0d5782f09cb031805c9c74a6855a36d011.tar.gz
external_llvm-f74a1f0d5782f09cb031805c9c74a6855a36d011.tar.bz2
Privatize all but one of the remaining constant tables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.h')
-rw-r--r--lib/VMCore/LLVMContextImpl.h58
1 files changed, 51 insertions, 7 deletions
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h
index 7a29a84..6d18933 100644
--- a/lib/VMCore/LLVMContextImpl.h
+++ b/lib/VMCore/LLVMContextImpl.h
@@ -71,6 +71,20 @@ struct ConstantCreator<ConstantAggregateZero, Type, ValType> {
};
template<>
+struct ConvertConstantType<ConstantVector, VectorType> {
+ static void convert(ConstantVector *OldC, const VectorType *NewTy) {
+ // Make everyone now use a constant of the new type...
+ std::vector<Constant*> C;
+ for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
+ C.push_back(cast<Constant>(OldC->getOperand(i)));
+ Constant *New = ConstantVector::get(NewTy, C);
+ assert(New != OldC && "Didn't replace constant??");
+ OldC->uncheckedReplaceAllUsesWith(New);
+ OldC->destroyConstant(); // This constant is now dead, destroy it.
+ }
+};
+
+template<>
struct ConvertConstantType<ConstantAggregateZero, Type> {
static void convert(ConstantAggregateZero *OldC, const Type *NewTy) {
// Make everyone now use a constant of the new type...
@@ -110,17 +124,41 @@ struct ConvertConstantType<ConstantStruct, StructType> {
}
};
+// ConstantPointerNull does not take extra "value" argument...
+template<class ValType>
+struct ConstantCreator<ConstantPointerNull, PointerType, ValType> {
+ static ConstantPointerNull *create(const PointerType *Ty, const ValType &V){
+ return new ConstantPointerNull(Ty);
+ }
+};
+
template<>
-struct ConvertConstantType<ConstantVector, VectorType> {
- static void convert(ConstantVector *OldC, const VectorType *NewTy) {
+struct ConvertConstantType<ConstantPointerNull, PointerType> {
+ static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) {
// Make everyone now use a constant of the new type...
- std::vector<Constant*> C;
- for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i)
- C.push_back(cast<Constant>(OldC->getOperand(i)));
- Constant *New = ConstantVector::get(NewTy, C);
+ Constant *New = ConstantPointerNull::get(NewTy);
assert(New != OldC && "Didn't replace constant??");
OldC->uncheckedReplaceAllUsesWith(New);
- OldC->destroyConstant(); // This constant is now dead, destroy it.
+ OldC->destroyConstant(); // This constant is now dead, destroy it.
+ }
+};
+
+// UndefValue does not take extra "value" argument...
+template<class ValType>
+struct ConstantCreator<UndefValue, Type, ValType> {
+ static UndefValue *create(const Type *Ty, const ValType &V) {
+ return new UndefValue(Ty);
+ }
+};
+
+template<>
+struct ConvertConstantType<UndefValue, Type> {
+ static void convert(UndefValue *OldC, const Type *NewTy) {
+ // Make everyone now use a constant of the new type.
+ Constant *New = UndefValue::get(NewTy);
+ assert(New != OldC && "Didn't replace constant??");
+ OldC->uncheckedReplaceAllUsesWith(New);
+ OldC->destroyConstant(); // This constant is now dead, destroy it.
}
};
@@ -449,6 +487,10 @@ class LLVMContextImpl {
ConstantVector> VectorConstantsTy;
VectorConstantsTy VectorConstants;
+ ValueMap<char, PointerType, ConstantPointerNull> NullPtrConstants;
+
+ ValueMap<char, Type, UndefValue> UndefValueConstants;
+
LLVMContext &Context;
ConstantInt *TheTrueVal;
ConstantInt *TheFalseVal;
@@ -464,6 +506,8 @@ class LLVMContextImpl {
friend class ConstantAggregateZero;
friend class MDNode;
friend class MDString;
+ friend class ConstantPointerNull;
+ friend class UndefValue;
public:
LLVMContextImpl(LLVMContext &C);
};