From e443a8ff8ddf9c82e35b8cfdcd440bb1d4dc90d6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 14 Dec 2001 16:41:56 +0000 Subject: [PATCH] Remove unsized array support Add new SequentialType class llvm-svn: 1470 --- lib/VMCore/Type.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index b13bb602f7c..cbcdf3f37d0 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -187,7 +187,7 @@ Type *Type::VoidTy = new Type("void" , VoidTyID), //===----------------------------------------------------------------------===// MethodType::MethodType(const Type *Result, const vector &Params, - bool IsVarArgs) : DerivedType("", MethodTyID), + bool IsVarArgs) : DerivedType(MethodTyID), ResultType(PATypeHandle(Result, this)), isVarArgs(IsVarArgs) { ParamTys.reserve(Params.size()); @@ -197,14 +197,8 @@ MethodType::MethodType(const Type *Result, const vector &Params, setDerivedTypeProperties(); } -ArrayType::ArrayType(const Type *ElType, int NumEl) - : CompositeType("", ArrayTyID), ElementType(PATypeHandle(ElType, this)){ - NumElements = NumEl; - setDerivedTypeProperties(); -} - StructType::StructType(const vector &Types) - : CompositeType("", StructTyID) { + : CompositeType(StructTyID) { ETypes.reserve(Types.size()); for (unsigned i = 0; i < Types.size(); ++i) { assert(Types[i] != Type::VoidTy && "Void type in method prototype!!"); @@ -213,12 +207,17 @@ StructType::StructType(const vector &Types) setDerivedTypeProperties(); } -PointerType::PointerType(const Type *E) : DerivedType("", PointerTyID), - ValueType(PATypeHandle(E, this)) { +ArrayType::ArrayType(const Type *ElType, unsigned NumEl) + : SequentialType(ArrayTyID, ElType) { + NumElements = NumEl; setDerivedTypeProperties(); } -OpaqueType::OpaqueType() : DerivedType("", OpaqueTyID) { +PointerType::PointerType(const Type *E) : SequentialType(PointerTyID, E) { + setDerivedTypeProperties(); +} + +OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { setAbstract(true); setDescription("opaque"+utostr(getUniqueID())); #ifdef DEBUG_MERGE_TYPES @@ -303,9 +302,9 @@ static string getTypeProps(const Type *Ty, vector &TypeStack, } case Type::ArrayTyID: { const ArrayType *ATy = cast(Ty); - int NumElements = ATy->getNumElements(); + unsigned NumElements = ATy->getNumElements(); Result = "["; - if (NumElements != -1) Result += itostr(NumElements) + " x "; + Result += utostr(NumElements) + " x "; Result += getTypeProps(ATy->getElementType(), TypeStack, isAbstract, isRecursive) + "]"; break; @@ -591,7 +590,7 @@ MethodType *MethodType::get(const Type *ReturnType, // class ArrayValType : public ValTypeBase { PATypeHandle ValTy; - int Size; + unsigned Size; public: ArrayValType(const Type *val, int sz, TypeMap &Tab) : ValTypeBase(Tab), ValTy(val, this), Size(sz) {} @@ -622,7 +621,7 @@ public: static TypeMap ArrayTypes; -ArrayType *ArrayType::get(const Type *ElementType, int NumElements = -1) { +ArrayType *ArrayType::get(const Type *ElementType, unsigned NumElements) { assert(ElementType && "Can't get array of null types!"); ArrayValType AVT(ElementType, NumElements, ArrayTypes); @@ -947,7 +946,7 @@ void ArrayType::refineAbstractType(const DerivedType *OldType, #endif if (!OldType->isAbstract()) { - assert(ElementType == OldType); + assert(getElementType() == OldType); ElementType.removeUserFromConcrete(); } @@ -1008,11 +1007,11 @@ void PointerType::refineAbstractType(const DerivedType *OldType, #endif if (!OldType->isAbstract()) { - assert(ValueType == OldType); - ValueType.removeUserFromConcrete(); + assert(ElementType == OldType); + ElementType.removeUserFromConcrete(); } - ValueType = NewType; + ElementType = NewType; const PointerType *PT = PointerTypes.containsEquivalent(this); if (PT && PT != this) {