From 3d6c35b92e874a74b9112f5b64e200a2928db835 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 9 Oct 2002 00:42:03 +0000 Subject: [PATCH] - Detemplatize UseTy<> in Value.h, because it's only instantiated for one type! llvm-svn: 4093 --- llvm/include/llvm/Value.h | 47 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/llvm/include/llvm/Value.h b/llvm/include/llvm/Value.h index e5c975e4a7d5..9627a02ca0fb 100644 --- a/llvm/include/llvm/Value.h +++ b/llvm/include/llvm/Value.h @@ -131,45 +131,42 @@ inline std::ostream &operator<<(std::ostream &OS, const Value &V) { //===----------------------------------------------------------------------===// -// UseTy Class +// Use Class //===----------------------------------------------------------------------===// -// UseTy and it's friendly typedefs (Use) are here to make keeping the "use" -// list of a definition node up-to-date really easy. +// Use is here to make keeping the "use" list of a Value up-to-date really easy. // -template -class UseTy { - ValueSubclass *Val; +class Use { + Value *Val; User *U; public: - inline UseTy(ValueSubclass *v, User *user) { + inline Use(Value *v, User *user) { Val = v; U = user; if (Val) Val->addUse(U); } - inline ~UseTy() { if (Val) Val->killUse(U); } - - inline operator ValueSubclass *() const { return Val; } - - inline UseTy(const UseTy &user) { + inline Use(const Use &user) { Val = 0; U = user.U; operator=(user.Val); } - inline ValueSubclass *operator=(ValueSubclass *V) { + inline ~Use() { if (Val) Val->killUse(U); } + inline operator Value*() const { return Val; } + + inline Value *operator=(Value *V) { if (Val) Val->killUse(U); Val = V; if (V) V->addUse(U); return V; } - inline ValueSubclass *operator->() { return Val; } - inline const ValueSubclass *operator->() const { return Val; } + inline Value *operator->() { return Val; } + inline const Value *operator->() const { return Val; } - inline ValueSubclass *get() { return Val; } - inline const ValueSubclass *get() const { return Val; } + inline Value *get() { return Val; } + inline const Value *get() const { return Val; } - inline UseTy &operator=(const UseTy &user) { + inline const Use &operator=(const Use &user) { if (Val) Val->killUse(U); Val = user.Val; Val->addUse(U); @@ -177,19 +174,17 @@ public: } }; -typedef UseTy Use; // Provide Use as a common UseTy type - -template struct simplify_type > { - typedef typename simplify_type::SimpleType SimpleType; +template<> struct simplify_type { + typedef Value* SimpleType; - static SimpleType getSimplifiedValue(const UseTy &Val) { + static SimpleType getSimplifiedValue(const Use &Val) { return (SimpleType)Val.get(); } }; -template struct simplify_type > { - typedef typename simplify_type::SimpleType SimpleType; +template<> struct simplify_type { + typedef Value* SimpleType; - static SimpleType getSimplifiedValue(const UseTy &Val) { + static SimpleType getSimplifiedValue(const Use &Val) { return (SimpleType)Val.get(); } };