From d5f67d8ca64605843d6d53e27ff716218b20f42b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 16 Oct 2004 18:07:16 +0000 Subject: [PATCH] Implement UndefValue class llvm-svn: 17040 --- llvm/lib/VMCore/Constants.cpp | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 8d964bcb2424..77aa23135e5b 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -1098,6 +1098,51 @@ void ConstantPointerNull::destroyConstant() { } +//---- UndefValue::get() implementation... +// + +namespace llvm { + // UndefValue does not take extra "value" argument... + template + struct ConstantCreator { + static UndefValue *create(const Type *Ty, const ValType &V) { + return new UndefValue(Ty); + } + }; + + template<> + struct ConvertConstantType { + 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. + } + }; +} + +static ValueMap UndefValueConstants; + +static char getValType(UndefValue *) { + return 0; +} + + +UndefValue *UndefValue::get(const Type *Ty) { + return UndefValueConstants.getOrCreate(Ty, 0); +} + +// destroyConstant - Remove the constant from the constant table. +// +void UndefValue::destroyConstant() { + UndefValueConstants.remove(this); + destroyConstantImpl(); +} + + + + //---- ConstantExpr::get() implementations... // typedef std::pair > ExprMapKeyType; -- GitLab