[llvm-commits] [bug_122] CVS: llvm/lib/VMCore/Type.cpp

LLVM llvm at cs.uiuc.edu
Sun May 16 19:02:01 PDT 2004


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.99 -> 1.99.2.1

---
Log message:

Changes resulting from making Type not be a Value. Moved the implementation
of PrintableItem here as well as PATypeHandle and PATypeHolder which used
to be in Type.h. Removed unnecessary constructor parameters and global 
variables pertaining to TypeTy and TypeTyID which do not exist any more.


---
Diffs of the changes:  (+58 -37)

Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.99 llvm/lib/VMCore/Type.cpp:1.99.2.1
--- llvm/lib/VMCore/Type.cpp:1.99	Sun Apr  4 20:30:19 2004
+++ llvm/lib/VMCore/Type.cpp	Sun May 16 19:02:32 2004
@@ -18,6 +18,7 @@
 #include "Support/StringExtras.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
+
 using namespace llvm;
 
 // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are
@@ -27,6 +28,39 @@
 //#define DEBUG_MERGE_TYPES 1
 
 AbstractTypeUser::~AbstractTypeUser() {}
+PrintableItem::~PrintableItem() {}
+
+void PATypeHandle::addUser() {
+  assert(Ty && "Type Handle has a null type!");
+  if (Ty->isAbstract())
+    Ty->addAbstractTypeUser(User);
+}
+                                                                                                                                            
+void PATypeHandle::removeUser() {
+  if (Ty->isAbstract())
+    Ty->removeAbstractTypeUser(User);
+}
+
+void PATypeHandle::removeUserFromConcrete() {
+  if (!Ty->isAbstract())
+    Ty->removeAbstractTypeUser(User);
+}
+
+const Type* PATypeHolder::get() const {
+  const Type *NewTy = Ty->getForwardedType();
+  if (!NewTy) return Ty;
+  return *const_cast<PATypeHolder*>(this) = NewTy;
+}
+
+void PATypeHolder::addRef() {
+  if (Ty->isAbstract())
+    Ty->addRef();
+}
+                                                                                                                                            
+void PATypeHolder::dropRef() {
+  if (Ty->isAbstract())
+    Ty->dropRef();
+}
 
 //===----------------------------------------------------------------------===//
 //                         Type Class Implementation
@@ -42,23 +76,14 @@
 static std::map<const Type*, std::string> ConcreteTypeDescriptions;
 static std::map<const Type*, std::string> AbstractTypeDescriptions;
 
-Type::Type(const std::string &name, PrimitiveID id)
-  : Value(Type::TypeTy, Value::TypeVal), RefCount(0), ForwardType(0) {
-  if (!name.empty())
-    ConcreteTypeDescriptions[this] = name;
+Type::Type(PrimitiveID id)
+  : RefCount(0), ForwardType(0) {
   ID = id;
   Abstract = false;
   UID = CurUID++;       // Assign types UID's as they are created
   UIDMappings.push_back(this);
 }
 
-void Type::setName(const std::string &Name, SymbolTable *ST) {
-  assert(ST && "Type::setName - Must provide symbol table argument!");
-
-  if (Name.size()) ST->insert(Name, this);
-}
-
-
 const Type *Type::getUniqueIDType(unsigned UID) {
   assert(UID < UIDMappings.size() && 
          "Type::getPrimitiveType: UID out of range!");
@@ -79,7 +104,6 @@
   case LongTyID  : return LongTy;
   case FloatTyID : return FloatTy;
   case DoubleTyID: return DoubleTy;
-  case TypeTyID  : return TypeTy;
   case LabelTyID : return LabelTy;
   default:
     return 0;
@@ -319,7 +343,7 @@
 // type.
 //
 struct SignedIntType : public Type {
-  SignedIntType(const std::string &Name, PrimitiveID id) : Type(Name, id) {}
+  SignedIntType(PrimitiveID id) : Type(id) {}
 
   // isSigned - Return whether a numeric type is signed.
   virtual bool isSigned() const { return 1; }
@@ -331,7 +355,7 @@
 };
 
 struct UnsignedIntType : public Type {
-  UnsignedIntType(const std::string &N, PrimitiveID id) : Type(N, id) {}
+  UnsignedIntType(PrimitiveID id) : Type(id) {}
 
   // isUnsigned - Return whether a numeric type is signed.
   virtual bool isUnsigned() const { return 1; }
@@ -343,31 +367,27 @@
 };
 
 struct OtherType : public Type {
-  OtherType(const std::string &N, PrimitiveID id) : Type(N, id) {}
+  OtherType(PrimitiveID id) : Type(id) {}
 };
 
-static struct TypeType : public Type {
-  TypeType() : Type("type", TypeTyID) {}
-} TheTypeTy;   // Implement the type that is global.
-
 
 //===----------------------------------------------------------------------===//
 //                           Static 'Type' data
 //===----------------------------------------------------------------------===//
 
-static OtherType       TheVoidTy  ("void"  , Type::VoidTyID);
-static OtherType       TheBoolTy  ("bool"  , Type::BoolTyID);
-static SignedIntType   TheSByteTy ("sbyte" , Type::SByteTyID);
-static UnsignedIntType TheUByteTy ("ubyte" , Type::UByteTyID);
-static SignedIntType   TheShortTy ("short" , Type::ShortTyID);
-static UnsignedIntType TheUShortTy("ushort", Type::UShortTyID);
-static SignedIntType   TheIntTy   ("int"   , Type::IntTyID); 
-static UnsignedIntType TheUIntTy  ("uint"  , Type::UIntTyID);
-static SignedIntType   TheLongTy  ("long"  , Type::LongTyID);
-static UnsignedIntType TheULongTy ("ulong" , Type::ULongTyID);
-static OtherType       TheFloatTy ("float" , Type::FloatTyID);
-static OtherType       TheDoubleTy("double", Type::DoubleTyID);
-static OtherType       TheLabelTy ("label" , Type::LabelTyID);
+static OtherType       TheVoidTy  ( Type::VoidTyID );
+static OtherType       TheBoolTy  ( Type::BoolTyID );
+static SignedIntType   TheSByteTy ( Type::SByteTyID );
+static UnsignedIntType TheUByteTy ( Type::UByteTyID );
+static SignedIntType   TheShortTy ( Type::ShortTyID );
+static UnsignedIntType TheUShortTy( Type::UShortTyID );
+static SignedIntType   TheIntTy   ( Type::IntTyID ); 
+static UnsignedIntType TheUIntTy  ( Type::UIntTyID );
+static SignedIntType   TheLongTy  ( Type::LongTyID );
+static UnsignedIntType TheULongTy ( Type::ULongTyID );
+static OtherType       TheFloatTy ( Type::FloatTyID );
+static OtherType       TheDoubleTy( Type::DoubleTyID );
+static OtherType       TheLabelTy ( Type::LabelTyID );
 
 Type *Type::VoidTy   = &TheVoidTy;
 Type *Type::BoolTy   = &TheBoolTy;
@@ -381,7 +401,6 @@
 Type *Type::ULongTy  = &TheULongTy;
 Type *Type::FloatTy  = &TheFloatTy;
 Type *Type::DoubleTy = &TheDoubleTy;
-Type *Type::TypeTy   = &TheTypeTy;
 Type *Type::LabelTy  = &TheLabelTy;
 
 
@@ -502,7 +521,7 @@
 // that assumes that two graphs are the same until proven otherwise.
 //
 static bool TypesEqual(const Type *Ty, const Type *Ty2,
-		       std::map<const Type *, const Type *> &EqTypes) {
+                       std::map<const Type *, const Type *> &EqTypes) {
   if (Ty == Ty2) return true;
   if (Ty->getPrimitiveID() != Ty2->getPrimitiveID()) return false;
   if (isa<OpaqueType>(Ty))
@@ -1130,7 +1149,7 @@
 // concrete type.
 //
 void ArrayType::refineAbstractType(const DerivedType *OldType,
-				   const Type *NewType) {
+                                   const Type *NewType) {
   ArrayTypes.finishRefinement(this, OldType, NewType);
 }
 
@@ -1144,7 +1163,7 @@
 // concrete type.
 //
 void StructType::refineAbstractType(const DerivedType *OldType,
-				    const Type *NewType) {
+                                    const Type *NewType) {
   StructTypes.finishRefinement(this, OldType, NewType);
 }
 
@@ -1157,10 +1176,12 @@
 // concrete type.
 //
 void PointerType::refineAbstractType(const DerivedType *OldType,
-				     const Type *NewType) {
+                                     const Type *NewType) {
   PointerTypes.finishRefinement(this, OldType, NewType);
 }
 
 void PointerType::typeBecameConcrete(const DerivedType *AbsTy) {
   refineAbstractType(AbsTy, AbsTy);
 }
+
+// vim: sw=2





More information about the llvm-commits mailing list