[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Oct 16 11:07:57 PDT 2004
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.107 -> 1.108
---
Log message:
Implement UndefValue class
---
Diffs of the changes: (+45 -0)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.107 llvm/lib/VMCore/Constants.cpp:1.108
--- llvm/lib/VMCore/Constants.cpp:1.107 Mon Oct 11 17:52:25 2004
+++ llvm/lib/VMCore/Constants.cpp Sat Oct 16 13:07:16 2004
@@ -1098,6 +1098,51 @@
}
+//---- UndefValue::get() implementation...
+//
+
+namespace llvm {
+ // 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.
+ }
+ };
+}
+
+static ValueMap<char, Type, UndefValue> 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<unsigned, std::vector<Constant*> > ExprMapKeyType;
More information about the llvm-commits
mailing list