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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.186 - 1.187
---
Log message:

if functiontype is going to have a pointer to a paramattr object, it better
be const.  The only way to get a pointer to these returns a const pointer.


---
Diffs of the changes:  (+2 -2)

 Type.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.186 llvm/lib/VMCore/Type.cpp:1.187
--- llvm/lib/VMCore/Type.cpp:1.186  Sun Apr 22 17:16:55 2007
+++ llvm/lib/VMCore/Type.cppThu May  3 22:39:28 2007
@@ -417,7 +417,7 @@
 
 FunctionType::FunctionType(const Type *Result,
const std::vectorconst Type* Params,
-   bool IsVarArgs, ParamAttrsList *Attrs) 
+   bool IsVarArgs, const ParamAttrsList *Attrs) 
   : DerivedType(FunctionTyID), isVarArgs(IsVarArgs), ParamAttrs(Attrs) {
   ContainedTys = reinterpret_castPATypeHandle*(this+1);
   NumContainedTys = Params.size() + 1; // + 1 for result type
@@ -1084,7 +1084,7 @@
 FunctionType *FunctionType::get(const Type *ReturnType,
 const std::vectorconst Type* Params,
 bool isVarArg,
-ParamAttrsList *Attrs) {
+const ParamAttrsList *Attrs) {
 
   FunctionValType VT(ReturnType, Params, isVarArg, Attrs);
   FunctionType *FT = FunctionTypes-get(VT);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-22 Thread Jeff Cohen


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.185 - 1.186
---
Log message:

Have compiler enforce this.

---
Diffs of the changes:  (+0 -1)

 Type.cpp |1 -
 1 files changed, 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.185 llvm/lib/VMCore/Type.cpp:1.186
--- llvm/lib/VMCore/Type.cpp:1.185  Sun Apr 22 00:46:44 2007
+++ llvm/lib/VMCore/Type.cppSun Apr 22 17:16:55 2007
@@ -11,7 +11,6 @@
 //
 
//===--===//
 
-#include llvm/AbstractTypeUser.h
 #include llvm/DerivedTypes.h
 #include llvm/ParameterAttributes.h
 #include llvm/Constants.h



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-20 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.183 - 1.184
---
Log message:

Fix a problem where primitive types lose their name after llvm_shutdown is 
called.
This also reduces the amount of work done at static construction time.


---
Diffs of the changes:  (+16 -12)

 Type.cpp |   28 
 1 files changed, 16 insertions(+), 12 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.183 llvm/lib/VMCore/Type.cpp:1.184
--- llvm/lib/VMCore/Type.cpp:1.183  Mon Apr 16 22:26:42 2007
+++ llvm/lib/VMCore/Type.cppFri Apr 20 17:33:47 2007
@@ -63,13 +63,6 @@
 static ManagedStaticstd::mapconst Type*,
   std::string  AbstractTypeDescriptions;
 
-Type::Type(const char *Name, TypeID id)
-  : ID(id), Abstract(false),  SubclassData(0), RefCount(0), ForwardType(0),
-NumContainedTys(0),  ContainedTys(0) {
-  assert(Name  Name[0]  Should use other ctor if no name!);
-  (*ConcreteTypeDescriptions)[this] = Name;
-}
-
 /// Because of the way Type subclasses are allocated, this function is 
necessary
 /// to use the correct kind of delete operator to deallocate the Type object.
 /// Some type objects (FunctionTy, StructTy) allocate additional space after 
@@ -250,7 +243,18 @@
   if (!Ty-isAbstract()) {   // Base case for the recursion
 std::mapconst Type*, std::string::iterator I =
   ConcreteTypeDescriptions-find(Ty);
-if (I != ConcreteTypeDescriptions-end()) return I-second;
+if (I != ConcreteTypeDescriptions-end()) 
+  return I-second;
+
+if (Ty-isPrimitiveType()) {
+  switch (Ty-getTypeID()) {
+  default: assert(0  Unknown prim type!);
+  case Type::VoidTyID:   return (*ConcreteTypeDescriptions)[Ty] = void;
+  case Type::FloatTyID:  return (*ConcreteTypeDescriptions)[Ty] = float;
+  case Type::DoubleTyID: return (*ConcreteTypeDescriptions)[Ty] = double;
+  case Type::LabelTyID:  return (*ConcreteTypeDescriptions)[Ty] = label;
+  }
+}
   }
 
   // Check to see if the Type is already on the stack...
@@ -391,10 +395,10 @@
 //  Primitive 'Type' data
 
//===--===//
 
-const Type *Type::VoidTy   = new Type(void, Type::VoidTyID);
-const Type *Type::FloatTy  = new Type(float, Type::FloatTyID);
-const Type *Type::DoubleTy = new Type(double, Type::DoubleTyID);
-const Type *Type::LabelTy  = new Type(label, Type::LabelTyID);
+const Type *Type::VoidTy   = new Type(Type::VoidTyID);
+const Type *Type::FloatTy  = new Type(Type::FloatTyID);
+const Type *Type::DoubleTy = new Type(Type::DoubleTyID);
+const Type *Type::LabelTy  = new Type(Type::LabelTyID);
 
 namespace {
   struct BuiltinIntegerType : public IntegerType {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-09 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.178 - 1.179
---
Log message:

For PR1146: http://llvm.org/PR1146 :
Move parameter attributes functionality to ParamAttrsList class.


---
Diffs of the changes:  (+106 -52)

 Type.cpp |  158 ++-
 1 files changed, 106 insertions(+), 52 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.178 llvm/lib/VMCore/Type.cpp:1.179
--- llvm/lib/VMCore/Type.cpp:1.178  Thu Apr  5 21:02:20 2007
+++ llvm/lib/VMCore/Type.cppMon Apr  9 01:07:52 2007
@@ -13,6 +13,7 @@
 
 #include llvm/AbstractTypeUser.h
 #include llvm/DerivedTypes.h
+#include llvm/ParameterAttributes.h
 #include llvm/Constants.h
 #include llvm/ADT/DepthFirstIterator.h
 #include llvm/ADT/StringExtras.h
@@ -279,11 +280,13 @@
   Result +=  ;
 Result += getTypeDescription(FTy-getReturnType(), TypeStack) +  (;
 unsigned Idx = 1;
+const ParamAttrsList *Attrs = FTy-getParamAttrs();
 for (FunctionType::param_iterator I = FTy-param_begin(),
E = FTy-param_end(); I != E; ++I) {
   if (I != FTy-param_begin())
 Result += , ;
-  Result +=  FunctionType::getParamAttrsText(FTy-getParamAttrs(Idx));
+  if (Attrs  Attrs-getParamAttrs(Idx) != NoAttributeSet)
+Result += Attrs-getParamAttrsTextByIndex(Idx);
   Idx++;
   Result += getTypeDescription(*I, TypeStack);
 }
@@ -292,8 +295,8 @@
   Result += ...;
 }
 Result += );
-if (FTy-getParamAttrs(0)) {
-  Result +=   + FunctionType::getParamAttrsText(FTy-getParamAttrs(0));
+if (Attrs  Attrs-getParamAttrs(0) != NoAttributeSet) {
+  Result +=   + Attrs-getParamAttrsTextByIndex(0);
 }
 break;
   }
@@ -411,8 +414,8 @@
 
 FunctionType::FunctionType(const Type *Result,
const std::vectorconst Type* Params,
-   bool IsVarArgs, const ParamAttrsList Attrs) 
-  : DerivedType(FunctionTyID), isVarArgs(IsVarArgs), ParamAttrs(0) {
+   bool IsVarArgs, ParamAttrsList *Attrs) 
+  : DerivedType(FunctionTyID), isVarArgs(IsVarArgs), ParamAttrs(Attrs) {
   ContainedTys = reinterpret_castPATypeHandle*(this+1);
   NumContainedTys = Params.size() + 1; // + 1 for result type
   assert((Result-isFirstClassType() || Result == Type::VoidTy ||
@@ -428,12 +431,6 @@
 isAbstract |= Params[i]-isAbstract();
   }
 
-  // Set the ParameterAttributes
-  if (!Attrs.empty()) 
-ParamAttrs = new ParamAttrsList(Attrs);
-  else
-ParamAttrs = 0;
-
   // Calculate whether or not this type is abstract
   setAbstract(isAbstract);
 
@@ -639,12 +636,24 @@
 const FunctionType *FTy2 = castFunctionType(Ty2);
 if (FTy-isVarArg() != FTy2-isVarArg() ||
 FTy-getNumParams() != FTy2-getNumParams() ||
-FTy-getNumAttrs() != FTy2-getNumAttrs() ||
-FTy-getParamAttrs(0) != FTy2-getParamAttrs(0) ||
 !TypesEqual(FTy-getReturnType(), FTy2-getReturnType(), EqTypes))
   return false;
+const ParamAttrsList *Attrs1 = FTy-getParamAttrs();
+const ParamAttrsList *Attrs2 = FTy2-getParamAttrs();
+if ((!Attrs1  Attrs2  !Attrs2-empty()) ||
+(!Attrs2  Attrs1  !Attrs1-empty()) ||
+(Attrs1  Attrs2  (Attrs1-size() != Attrs2-size() ||
+ (Attrs1-size()  0  
+  Attrs1-getParamAttrs(0) != Attrs2-getParamAttrs(0)
+  return false;
+ParamAttrsList PAL1;
+if (Attrs1)
+  PAL1 = *Attrs1;
+ParamAttrsList PAL2;
+if (Attrs2)
+  PAL2 = *Attrs2;
 for (unsigned i = 0, e = FTy2-getNumParams(); i != e; ++i) {
-  if (FTy-getParamAttrs(i+1) != FTy-getParamAttrs(i+1))
+  if (PAL1.getParamAttrs(i+1) != PAL2.getParamAttrs(i+1))
 return false;
   if (!TypesEqual(FTy-getParamType(i), FTy2-getParamType(i), EqTypes))
 return false;
@@ -1024,22 +1033,23 @@
 class FunctionValType {
   const Type *RetTy;
   std::vectorconst Type* ArgTypes;
-  std::vectorFunctionType::ParameterAttributes ParamAttrs;
+  const ParamAttrsList *ParamAttrs;
   bool isVarArg;
 public:
   FunctionValType(const Type *ret, const std::vectorconst Type* args,
-  bool IVA, const FunctionType::ParamAttrsList attrs) 
-: RetTy(ret), isVarArg(IVA) {
+  bool IVA, const ParamAttrsList *attrs) 
+: RetTy(ret), ParamAttrs(attrs), isVarArg(IVA) {
 for (unsigned i = 0; i  args.size(); ++i)
   ArgTypes.push_back(args[i]);
-for (unsigned i = 0; i  attrs.size(); ++i)
-  ParamAttrs.push_back(attrs[i]);
   }
 
   static FunctionValType get(const FunctionType *FT);
 
   static unsigned hashTypeStructure(const FunctionType *FT) {
-return FT-getNumParams()*64+FT-getNumAttrs()*2+FT-isVarArg();
+unsigned Result = FT-getNumParams()*64 + FT-isVarArg();
+if (FT-getParamAttrs())
+  Result += FT-getParamAttrs()-size()*2;
+return Result;
   }
 
   inline bool operator(const FunctionValType MTV) const {
@@ -1048,7 +1058,20 @@
  

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

2007-04-09 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.180 - 1.181
---
Log message:

Remove a memory leak, until ParamAttrsList is uniqued.


---
Diffs of the changes:  (+5 -1)

 Type.cpp |6 +-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.180 llvm/lib/VMCore/Type.cpp:1.181
--- llvm/lib/VMCore/Type.cpp:1.180  Mon Apr  9 10:01:12 2007
+++ llvm/lib/VMCore/Type.cppMon Apr  9 12:20:18 2007
@@ -1098,7 +1098,11 @@
 
   FunctionValType VT(ReturnType, Params, isVarArg, Attrs);
   FunctionType *MT = FunctionTypes-get(VT);
-  if (MT) return MT;
+  if (MT) { 
+delete Attrs; // not needed any more
+return MT;
+  }
+
 
   MT = (FunctionType*) new char[sizeof(FunctionType) + 
 sizeof(PATypeHandle)*(Params.size()+1)];



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-05 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.177 - 1.178
---
Log message:

For PR1209: http://llvm.org/PR1209 :
Implement Type class's ContainedTys without using a std::vector.


---
Diffs of the changes:  (+63 -17)

 Type.cpp |   80 +--
 1 files changed, 63 insertions(+), 17 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.177 llvm/lib/VMCore/Type.cpp:1.178
--- llvm/lib/VMCore/Type.cpp:1.177  Wed Mar 21 21:14:48 2007
+++ llvm/lib/VMCore/Type.cppThu Apr  5 21:02:20 2007
@@ -63,11 +63,52 @@
   std::string  AbstractTypeDescriptions;
 
 Type::Type(const char *Name, TypeID id)
-  : ID(id), Abstract(false),  SubclassData(0), RefCount(0), ForwardType(0) {
+  : ID(id), Abstract(false),  SubclassData(0), RefCount(0), ForwardType(0),
+NumContainedTys(0),  ContainedTys(0) {
   assert(Name  Name[0]  Should use other ctor if no name!);
   (*ConcreteTypeDescriptions)[this] = Name;
 }
 
+/// Because of the way Type subclasses are allocated, this function is 
necessary
+/// to use the correct kind of delete operator to deallocate the Type object.
+/// Some type objects (FunctionTy, StructTy) allocate additional space after 
+/// the space for their derived type to hold the contained types array of
+/// PATypeHandles. Using this allocation scheme means all the PATypeHandles are
+/// allocated with the type object, decreasing allocations and eliminating the
+/// need for a std::vector to be used in the Type class itself. 
+/// @brief Type destruction function
+void Type::destroy() const {
+
+  // Structures and Functions allocate their contained types past the end of
+  // the type object itself. These need to be destroyed differently than the
+  // other types.
+  if (isaFunctionType(this) || isaStructType(this)) {
+// First, make sure we destruct any PATypeHandles allocated by these
+// subclasses.  They must be manually destructed. 
+for (unsigned i = 0; i  NumContainedTys; ++i)
+  ContainedTys[i].PATypeHandle::~PATypeHandle();
+
+// Now call the destructor for the subclass directly because we're going
+// to delete this as an array of char.
+if (isaFunctionType(this))
+  ((FunctionType*)this)-FunctionType::~FunctionType();
+else
+  ((StructType*)this)-StructType::~StructType();
+
+// Finally, remove the memory as an array deallocation of the chars it was
+// constructed from.
+delete [] reinterpret_castconst char*(this); 
+
+return;
+  }
+
+  // For all the other type subclasses, there is either no contained types or 
+  // just one (all Sequentials). For Sequentials, the PATypeHandle is not
+  // allocated past the type object, its included directly in the 
SequentialType
+  // class. This means we can safely just do normal delete of this object and
+  // all the destructors that need to run will be run.
+  delete this; 
+}
 
 const Type *Type::getPrimitiveType(TypeID IDNumber) {
   switch (IDNumber) {
@@ -330,7 +371,7 @@
   // Structure indexes require 32-bit integer constants.
   if (V-getType() == Type::Int32Ty)
 if (const ConstantInt *CU = dyn_castConstantInt(V))
-  return CU-getZExtValue()  ContainedTys.size();
+  return CU-getZExtValue()  NumContainedTys;
   return false;
 }
 
@@ -371,19 +412,19 @@
 FunctionType::FunctionType(const Type *Result,
const std::vectorconst Type* Params,
bool IsVarArgs, const ParamAttrsList Attrs) 
-  : DerivedType(FunctionTyID), isVarArgs(IsVarArgs) {
+  : DerivedType(FunctionTyID), isVarArgs(IsVarArgs), ParamAttrs(0) {
+  ContainedTys = reinterpret_castPATypeHandle*(this+1);
+  NumContainedTys = Params.size() + 1; // + 1 for result type
   assert((Result-isFirstClassType() || Result == Type::VoidTy ||
  isaOpaqueType(Result)) 
  LLVM functions cannot return aggregates);
   bool isAbstract = Result-isAbstract();
-  ContainedTys.reserve(Params.size()+1);
-  ContainedTys.push_back(PATypeHandle(Result, this));
+  new (ContainedTys[0]) PATypeHandle(Result, this);
 
   for (unsigned i = 0; i != Params.size(); ++i) {
 assert((Params[i]-isFirstClassType() || isaOpaqueType(Params[i])) 
Function arguments must be value types!);
-
-ContainedTys.push_back(PATypeHandle(Params[i], this));
+new (ContainedTys[i+1]) PATypeHandle(Params[i],this);
 isAbstract |= Params[i]-isAbstract();
   }
 
@@ -400,12 +441,13 @@
 
 StructType::StructType(const std::vectorconst Type* Types, bool isPacked)
   : CompositeType(StructTyID) {
+  ContainedTys = reinterpret_castPATypeHandle*(this + 1);
+  NumContainedTys = Types.size();
   setSubclassData(isPacked);
-  ContainedTys.reserve(Types.size());
   bool isAbstract = false;
   for (unsigned i = 0; i  Types.size(); ++i) {
 assert(Types[i] != Type::VoidTy  Void type for structure field!!);
-ContainedTys.push_back(PATypeHandle(Types[i], this));
+

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

2007-03-21 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.176 - 1.177
---
Log message:

Add the NoUnwind function attribute.


---
Diffs of the changes:  (+2 -0)

 Type.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.176 llvm/lib/VMCore/Type.cpp:1.177
--- llvm/lib/VMCore/Type.cpp:1.176  Wed Feb 28 22:02:06 2007
+++ llvm/lib/VMCore/Type.cppWed Mar 21 21:14:48 2007
@@ -1073,6 +1073,8 @@
 Result += sext ;
   if (Attr  NoReturnAttribute)
 Result += noreturn ;
+  if (Attr  NoUnwindAttribute)
+Result += nounwind ;
   if (Attr  InRegAttribute)
 Result += inreg ;
   if (Attr  StructRetAttribute)



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.174 - 1.175
---
Log message:

remove dead method


---
Diffs of the changes:  (+1 -9)

 Type.cpp |   10 +-
 1 files changed, 1 insertion(+), 9 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.174 llvm/lib/VMCore/Type.cpp:1.175
--- llvm/lib/VMCore/Type.cpp:1.174  Wed Feb 14 21:39:18 2007
+++ llvm/lib/VMCore/Type.cppMon Feb 19 23:29:47 2007
@@ -783,15 +783,7 @@
 print(add);
   }
   
-  void clear(std::vectorType * DerivedTypes) {
-for (typename std::mapValType, PATypeHolder::iterator I = Map.begin(),
- E = Map.end(); I != E; ++I)
-  DerivedTypes.push_back(I-second.get());
-TypesByHash.clear();
-Map.clear();
-  }
-
- /// RefineAbstractType - This method is called after we have merged a type
+  /// RefineAbstractType - This method is called after we have merged a type
   /// with another one.  We must now either merge the type away with
   /// some other type or reinstall it in the map with it's new configuration.
   void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType,



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.172 - 1.173
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Change a comment: Packed Type - Vector Type


---
Diffs of the changes:  (+1 -1)

 Type.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.172 llvm/lib/VMCore/Type.cpp:1.173
--- llvm/lib/VMCore/Type.cpp:1.172  Wed Feb 14 20:26:10 2007
+++ llvm/lib/VMCore/Type.cppWed Feb 14 21:11:50 2007
@@ -1129,7 +1129,7 @@
 
 
 
//===--===//
-// Packed Type Factory...
+// Vector Type Factory...
 //
 namespace llvm {
 class VectorValType {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-09 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.168 - 1.169
---
Log message:

Fix clients like this:
  
  delete ParseBytecodeFile(InputFilename, 0, ErrorMessage);
  llvm_shutdown();
  delete ParseBytecodeFile(InputFilename, 0, ErrorMessage);

The primitive type objects failed to ressurect themselves after shutdown, 
leading
to crashes in clients that used them after llvm_shutdown().

This solution isn't wonderful, because we clearly have static ctors.  However,
the code it replaces was just as bad, so it's not a regression.



---
Diffs of the changes:  (+15 -28)

 Type.cpp |   43 +++
 1 files changed, 15 insertions(+), 28 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.168 llvm/lib/VMCore/Type.cpp:1.169
--- llvm/lib/VMCore/Type.cpp:1.168  Mon Feb  5 14:47:20 2007
+++ llvm/lib/VMCore/Type.cppFri Feb  9 16:24:04 2007
@@ -347,34 +347,21 @@
 //  Primitive 'Type' data
 
//===--===//
 
-#define DeclarePrimType(TY, Str)   \
-  namespace {  \
-struct VISIBILITY_HIDDEN TY##Type : public Type {  \
-  TY##Type() : Type(Str, Type::TY##TyID) {}\
-}; \
-  }\
-  static ManagedStaticTY##Type The##TY##Ty;  \
-  const Type *Type::TY##Ty = *The##TY##Ty
-
-#define DeclareIntegerType(TY, BitWidth) \
-  namespace {\
-struct VISIBILITY_HIDDEN TY##Type : public IntegerType { \
-  TY##Type() : IntegerType(BitWidth) {}  \
-};   \
-  }  \
-  static ManagedStaticTY##Type The##TY##Ty;\
-  const IntegerType *Type::TY##Ty = *The##TY##Ty
-
-DeclarePrimType(Void,   void);
-DeclarePrimType(Float,  float);
-DeclarePrimType(Double, double);
-DeclarePrimType(Label,  label);
-DeclareIntegerType(Int1,1);
-DeclareIntegerType(Int8,8);
-DeclareIntegerType(Int16,  16);
-DeclareIntegerType(Int32,  32);
-DeclareIntegerType(Int64,  64);
-#undef DeclarePrimType
+const Type *Type::VoidTy   = new Type(void, Type::VoidTyID);
+const Type *Type::FloatTy  = new Type(float, Type::FloatTyID);
+const Type *Type::DoubleTy = new Type(double, Type::DoubleTyID);
+const Type *Type::LabelTy  = new Type(label, Type::LabelTyID);
+
+namespace {
+  struct BuiltinIntegerType : public IntegerType {
+BuiltinIntegerType(unsigned W) : IntegerType(W) {}
+  };
+}
+const IntegerType *Type::Int1Ty  = new BuiltinIntegerType(1);
+const IntegerType *Type::Int8Ty  = new BuiltinIntegerType(8);
+const IntegerType *Type::Int16Ty = new BuiltinIntegerType(16);
+const IntegerType *Type::Int32Ty = new BuiltinIntegerType(32);
+const IntegerType *Type::Int64Ty = new BuiltinIntegerType(64);
 
 
 
//===--===//



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-25 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.165 - 1.166
---
Log message:

IntegerType is a sized DerivedType too.


---
Diffs of the changes:  (+3 -0)

 Type.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.165 llvm/lib/VMCore/Type.cpp:1.166
--- llvm/lib/VMCore/Type.cpp:1.165  Fri Jan 19 15:25:12 2007
+++ llvm/lib/VMCore/Type.cppFri Jan 26 01:51:36 2007
@@ -139,6 +139,9 @@
 /// iff all of the members of the type are sized as well.  Since asking for
 /// their size is relatively uncommon, move this operation out of line.
 bool Type::isSizedDerivedType() const {
+  if (isaIntegerType(this))
+return true;
+
   if (const ArrayType *ATy = dyn_castArrayType(this))
 return ATy-getElementType()-isSized();
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-19 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.164 - 1.165
---
Log message:

Remove dead methods in the ValTypes.


---
Diffs of the changes:  (+0 -31)

 Type.cpp |   31 ---
 1 files changed, 31 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.164 llvm/lib/VMCore/Type.cpp:1.165
--- llvm/lib/VMCore/Type.cpp:1.164  Fri Jan 19 15:13:56 2007
+++ llvm/lib/VMCore/Type.cppFri Jan 19 15:25:12 2007
@@ -1013,13 +1013,6 @@
 return FT-getNumParams()*64+FT-getNumAttrs()*2+FT-isVarArg();
   }
 
-  // Subclass should override this... to update self as usual
-  void doRefinement(const DerivedType *OldType, const Type *NewType) {
-if (RetTy == OldType) RetTy = NewType;
-for (unsigned i = 0, e = ArgTypes.size(); i != e; ++i)
-  if (ArgTypes[i] == OldType) ArgTypes[i] = NewType;
-  }
-
   inline bool operator(const FunctionValType MTV) const {
 if (RetTy  MTV.RetTy) return true;
 if (RetTy  MTV.RetTy) return false;
@@ -1114,12 +1107,6 @@
 return (unsigned)AT-getNumElements();
   }
 
-  // Subclass should override this... to update self as usual
-  void doRefinement(const DerivedType *OldType, const Type *NewType) {
-assert(ValTy == OldType);
-ValTy = NewType;
-  }
-
   inline bool operator(const ArrayValType MTV) const {
 if (Size  MTV.Size) return true;
 return Size == MTV.Size  ValTy  MTV.ValTy;
@@ -1164,12 +1151,6 @@
 return PT-getNumElements();
   }
 
-  // Subclass should override this... to update self as usual
-  void doRefinement(const DerivedType *OldType, const Type *NewType) {
-assert(ValTy == OldType);
-ValTy = NewType;
-  }
-
   inline bool operator(const PackedValType MTV) const {
 if (Size  MTV.Size) return true;
 return Size == MTV.Size  ValTy  MTV.ValTy;
@@ -1223,12 +1204,6 @@
 return ST-getNumElements();
   }
 
-  // Subclass should override this... to update self as usual
-  void doRefinement(const DerivedType *OldType, const Type *NewType) {
-for (unsigned i = 0; i  ElTypes.size(); ++i)
-  if (ElTypes[i] == OldType) ElTypes[i] = NewType;
-  }
-
   inline bool operator(const StructValType STV) const {
 if (ElTypes  STV.ElTypes) return true;
 else if (ElTypes  STV.ElTypes) return false;
@@ -1276,12 +1251,6 @@
 return getSubElementHash(PT);
   }
 
-  // Subclass should override this... to update self as usual
-  void doRefinement(const DerivedType *OldType, const Type *NewType) {
-assert(ValTy == OldType);
-ValTy = NewType;
-  }
-
   bool operator(const PointerValType MTV) const {
 return ValTy  MTV.ValTy;
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-18 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.162 - 1.163
---
Log message:

Use a cheaper computation.


---
Diffs of the changes:  (+1 -1)

 Type.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.162 llvm/lib/VMCore/Type.cpp:1.163
--- llvm/lib/VMCore/Type.cpp:1.162  Wed Jan 17 20:59:54 2007
+++ llvm/lib/VMCore/Type.cppThu Jan 18 12:14:49 2007
@@ -977,7 +977,7 @@
 
 bool IntegerType::isPowerOf2ByteWidth() const {
   unsigned BitWidth = getBitWidth();
-  return (BitWidth  7  Log2_32(BitWidth) == Log2_32_Ceil(BitWidth));
+  return (BitWidth  7)  isPowerOf2_32(BitWidth);
 }
 
 // FunctionValType - Define a class to hold the key that goes into the TypeMap



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-17 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.161 - 1.162
---
Log message:

Provide an isPowerOf2ByteWidth method for the IntegerType class. This will
mostly be used by back ends that wish to distinguish between integer types
that fit evenly within a natural integer type and those that don't.


---
Diffs of the changes:  (+5 -0)

 Type.cpp |5 +
 1 files changed, 5 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.161 llvm/lib/VMCore/Type.cpp:1.162
--- llvm/lib/VMCore/Type.cpp:1.161  Sun Jan 14 20:27:26 2007
+++ llvm/lib/VMCore/Type.cppWed Jan 17 20:59:54 2007
@@ -975,6 +975,11 @@
   return ITy;
 }
 
+bool IntegerType::isPowerOf2ByteWidth() const {
+  unsigned BitWidth = getBitWidth();
+  return (BitWidth  7  Log2_32(BitWidth) == Log2_32_Ceil(BitWidth));
+}
+
 // FunctionValType - Define a class to hold the key that goes into the TypeMap
 //
 namespace llvm {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-17 Thread Chris Lattner
 +bool IntegerType::isPowerOf2ByteWidth() const {
 +  unsigned BitWidth = getBitWidth();
 +  return (BitWidth  7  Log2_32(BitWidth) == Log2_32_Ceil 
 (BitWidth));
 +}
 +

Please use the isPowerOf2_32 function or use ((BitWidth-1)   
BitWidth) == 0 instead of two Log2_32 calls.

Thanks,

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-12 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.158 - 1.159
---
Log message:

Make sure the IntegerValType has enough space for 2^23 bits.


---
Diffs of the changes:  (+1 -1)

 Type.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.158 llvm/lib/VMCore/Type.cpp:1.159
--- llvm/lib/VMCore/Type.cpp:1.158  Fri Jan 12 01:05:14 2007
+++ llvm/lib/VMCore/Type.cppFri Jan 12 18:12:29 2007
@@ -929,7 +929,7 @@
 //
 namespace llvm {
 class IntegerValType {
-  uint16_t bits;
+  uint32_t bits;
 public:
   IntegerValType(uint16_t numbits) : bits(numbits) {}
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-12 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.159 - 1.160
---
Log message:

Fix a FIXME. 1 bit integer types are now printed as i1 not bool.


---
Diffs of the changes:  (+1 -4)

 Type.cpp |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.159 llvm/lib/VMCore/Type.cpp:1.160
--- llvm/lib/VMCore/Type.cpp:1.159  Fri Jan 12 18:12:29 2007
+++ llvm/lib/VMCore/Type.cppFri Jan 12 19:09:33 2007
@@ -218,10 +218,7 @@
   switch (Ty-getTypeID()) {
   case Type::IntegerTyID: {
 const IntegerType *ITy = castIntegerType(Ty);
-if (ITy-getBitWidth() == 1)
-  Result = bool; // FIXME: eventually this becomes i1
-else
-  Result = i + utostr(ITy-getBitWidth());
+Result = i + utostr(ITy-getBitWidth());
 break;
   }
   case Type::FunctionTyID: {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-08 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.155 - 1.156
---
Log message:

Parameter attributes are part of a FunctionType and deserve to be factored
into comparisons of two FunctionTypes. Make it so.


---
Diffs of the changes:  (+6 -1)

 Type.cpp |7 ++-
 1 files changed, 6 insertions(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.155 llvm/lib/VMCore/Type.cpp:1.156
--- llvm/lib/VMCore/Type.cpp:1.155  Fri Jan  5 11:06:19 2007
+++ llvm/lib/VMCore/Type.cppMon Jan  8 13:41:01 2007
@@ -607,11 +607,16 @@
 const FunctionType *FTy2 = castFunctionType(Ty2);
 if (FTy-isVarArg() != FTy2-isVarArg() ||
 FTy-getNumParams() != FTy2-getNumParams() ||
+FTy-getNumAttrs() != FTy2-getNumAttrs() ||
+FTy-getParamAttrs(0) != FTy2-getParamAttrs(0) ||
 !TypesEqual(FTy-getReturnType(), FTy2-getReturnType(), EqTypes))
   return false;
-for (unsigned i = 0, e = FTy2-getNumParams(); i != e; ++i)
+for (unsigned i = 0, e = FTy2-getNumParams(); i != e; ++i) {
+  if (FTy-getParamAttrs(i+1) != FTy-getParamAttrs(i+1))
+return false;
   if (!TypesEqual(FTy-getParamType(i), FTy2-getParamType(i), EqTypes))
 return false;
+}
 return true;
   } else {
 assert(0  Unknown derived type!);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-05 Thread Chris Lattner

 +  if (getTypeID() == Type::PointerTyID)
 +return isaPointerType(Ty);
return false;  // Other types have no identity values
  }

 What is Type::canLosslesslyBitCastTo used by now?  Can we just
 eliminate it?

 InstCombine.

-raise is now the only pass using it.  I added a note to PR1072 so  
that it is removed when -raise is.



 +FunctionType::ParameterAttributes
 +FunctionType::getParamAttrs(unsigned Idx) const {
 +  if (!ParamAttrs)
 +return ParameterAttributes(0);
 +  if (Idx  ParamAttrs-size())
 +return ParameterAttributes(0);
 +  return (*ParamAttrs)[Idx];
 +}

 Why does this map an out-of-range index onto attr 0?  Shouldn't this
 be an assert?

 No, I'm trying to save space. If you don't set any attributes or don't
 set them on all the parameters then it isn't an error, you just get
 none Set. In a subsequent patch I made this clear by returning
 NoAttributeSet enum (has value 0).

 This saves space by not requiring the ParamAttrs vector to have an  
 entry
 for each parameter and not requiring it to even be allocated if there
 aren't any parameter attributes.

Ah, cool!

Thanks Reid,

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-04 Thread Chris Lattner
There is a typo in the function header (lossleslly) of  
Type::canLosslesslyBitCastTo:


// canLosslesllyBitCastTo - Return true if this type can be converted to
// 'Ty' without any reinterpretation of bits.  For example, uint to int.
//

// At this point we have only various mismatches of the first  
 class types
// remaining and ptr-ptr. Just select the lossless conversions.  
 Everything
// else is not lossless.

This comment needs to be updated.

 -  switch (getTypeID()) {
 -  case Type::UByteTyID:   return Ty == Type::SByteTy;
 -  case Type::SByteTyID:   return Ty == Type::UByteTy;
 -  case Type::UShortTyID:  return Ty == Type::ShortTy;
 -  case Type::ShortTyID:   return Ty == Type::UShortTy;
 -  case Type::UIntTyID:return Ty == Type::IntTy;
 -  case Type::IntTyID: return Ty == Type::UIntTy;
 -  case Type::ULongTyID:   return Ty == Type::LongTy;
 -  case Type::LongTyID:return Ty == Type::ULongTy;
 -  case Type::PointerTyID: return isaPointerType(Ty);
 -  default:
 -break;
 -  }
 +  if (getTypeID() == Type::PointerTyID)
 +return isaPointerType(Ty);
return false;  // Other types have no identity values
  }

What is Type::canLosslesslyBitCastTo used by now?  Can we just  
eliminate it?


 +FunctionType::ParameterAttributes
 +FunctionType::getParamAttrs(unsigned Idx) const {
 +  if (!ParamAttrs)
 +return ParameterAttributes(0);
 +  if (Idx  ParamAttrs-size())
 +return ParameterAttributes(0);
 +  return (*ParamAttrs)[Idx];
 +}

Why does this map an out-of-range index onto attr 0?  Shouldn't this  
be an assert?

-Chris


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-04 Thread Reid Spencer
On Thu, 2007-01-04 at 10:58 -0800, Chris Lattner wrote:
 There is a typo in the function header (lossleslly) of  
 Type::canLosslesslyBitCastTo:
 
 
 // canLosslesllyBitCastTo - Return true if this type can be converted to
 // 'Ty' without any reinterpretation of bits.  For example, uint to int.
 //

Okay.

 
 // At this point we have only various mismatches of the first  
  class types
 // remaining and ptr-ptr. Just select the lossless conversions.  
  Everything
 // else is not lossless.
 
 This comment needs to be updated.
 
  -  switch (getTypeID()) {
  -  case Type::UByteTyID:   return Ty == Type::SByteTy;
  -  case Type::SByteTyID:   return Ty == Type::UByteTy;
  -  case Type::UShortTyID:  return Ty == Type::ShortTy;
  -  case Type::ShortTyID:   return Ty == Type::UShortTy;
  -  case Type::UIntTyID:return Ty == Type::IntTy;
  -  case Type::IntTyID: return Ty == Type::UIntTy;
  -  case Type::ULongTyID:   return Ty == Type::LongTy;
  -  case Type::LongTyID:return Ty == Type::ULongTy;
  -  case Type::PointerTyID: return isaPointerType(Ty);
  -  default:
  -break;
  -  }
  +  if (getTypeID() == Type::PointerTyID)
  +return isaPointerType(Ty);
 return false;  // Other types have no identity values
   }
 
 What is Type::canLosslesslyBitCastTo used by now?  Can we just  
 eliminate it?

InstCombine. 

 
 
  +FunctionType::ParameterAttributes
  +FunctionType::getParamAttrs(unsigned Idx) const {
  +  if (!ParamAttrs)
  +return ParameterAttributes(0);
  +  if (Idx  ParamAttrs-size())
  +return ParameterAttributes(0);
  +  return (*ParamAttrs)[Idx];
  +}
 
 Why does this map an out-of-range index onto attr 0?  Shouldn't this  
 be an assert?

No, I'm trying to save space. If you don't set any attributes or don't
set them on all the parameters then it isn't an error, you just get
none Set. In a subsequent patch I made this clear by returning
NoAttributeSet enum (has value 0).

This saves space by not requiring the ParamAttrs vector to have an entry
for each parameter and not requiring it to even be allocated if there
aren't any parameter attributes.



 
 -Chris
 
 


signature.asc
Description: This is a digitally signed message part
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-01-04 Thread Reid Spencer
On Thu, 2007-01-04 at 10:58 -0800, Chris Lattner wrote:
 There is a typo in the function header (lossleslly) of  
 Type::canLosslesslyBitCastTo:
 
 
 // canLosslesllyBitCastTo - Return true if this type can be converted to
 // 'Ty' without any reinterpretation of bits.  For example, uint to int.
 //

That's already been fixed.

Reid.


signature.asc
Description: This is a digitally signed message part
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-12-31 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.153 - 1.154
---
Log message:

Fix a bug in getParamAttrs where an invalid value would be returned if the
index passed in was out of range for the number of parameter attributes set.


---
Diffs of the changes:  (+3 -3)

 Type.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.153 llvm/lib/VMCore/Type.cpp:1.154
--- llvm/lib/VMCore/Type.cpp:1.153  Sat Dec 30 23:25:34 2006
+++ llvm/lib/VMCore/Type.cppSun Dec 31 11:50:33 2006
@@ -1015,9 +1015,9 @@
 FunctionType::ParameterAttributes 
 FunctionType::getParamAttrs(unsigned Idx) const {
   if (!ParamAttrs)
-return ParameterAttributes(0);
-  if (Idx  ParamAttrs-size())
-return ParameterAttributes(0);
+return NoAttributeSet;
+  if (Idx = ParamAttrs-size())
+return NoAttributeSet;
   return (*ParamAttrs)[Idx];
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-12-30 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.152 - 1.153
---
Log message:

For PR950: http://llvm.org/PR950 :
Implement signless integer types and FunctionType parameter attributes.


---
Diffs of the changes:  (+90 -98)

 Type.cpp |  188 ++-
 1 files changed, 90 insertions(+), 98 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.152 llvm/lib/VMCore/Type.cpp:1.153
--- llvm/lib/VMCore/Type.cpp:1.152  Fri Dec  8 12:06:16 2006
+++ llvm/lib/VMCore/Type.cppSat Dec 30 23:25:34 2006
@@ -74,14 +74,10 @@
   switch (IDNumber) {
   case VoidTyID  : return VoidTy;
   case BoolTyID  : return BoolTy;
-  case UByteTyID : return UByteTy;
-  case SByteTyID : return SByteTy;
-  case UShortTyID: return UShortTy;
-  case ShortTyID : return ShortTy;
-  case UIntTyID  : return UIntTy;
-  case IntTyID   : return IntTy;
-  case ULongTyID : return ULongTy;
-  case LongTyID  : return LongTy;
+  case Int8TyID  : return Int8Ty; 
+  case Int16TyID : return Int16Ty; 
+  case Int32TyID : return Int32Ty;
+  case Int64TyID : return Int64Ty;
   case FloatTyID : return FloatTy;
   case DoubleTyID: return DoubleTy;
   case LabelTyID : return LabelTy;
@@ -120,57 +116,11 @@
   // At this point we have only various mismatches of the first class types
   // remaining and ptr-ptr. Just select the lossless conversions. Everything
   // else is not lossless.
-  switch (getTypeID()) {
-  case Type::UByteTyID:   return Ty == Type::SByteTy;
-  case Type::SByteTyID:   return Ty == Type::UByteTy;
-  case Type::UShortTyID:  return Ty == Type::ShortTy;
-  case Type::ShortTyID:   return Ty == Type::UShortTy;
-  case Type::UIntTyID:return Ty == Type::IntTy;
-  case Type::IntTyID: return Ty == Type::UIntTy;
-  case Type::ULongTyID:   return Ty == Type::LongTy;
-  case Type::LongTyID:return Ty == Type::ULongTy;
-  case Type::PointerTyID: return isaPointerType(Ty);
-  default:
-break;
-  }
+  if (getTypeID() == Type::PointerTyID)
+return isaPointerType(Ty);
   return false;  // Other types have no identity values
 }
 
-/// getUnsignedVersion - If this is an integer type, return the unsigned
-/// variant of this type.  For example int - uint.
-const Type *Type::getUnsignedVersion() const {
-  switch (getTypeID()) {
-  default:
-assert(isInteger()Type::getUnsignedVersion is only valid for 
integers!);
-  case Type::UByteTyID:
-  case Type::SByteTyID:   return Type::UByteTy;
-  case Type::UShortTyID:
-  case Type::ShortTyID:   return Type::UShortTy;
-  case Type::UIntTyID:
-  case Type::IntTyID: return Type::UIntTy;
-  case Type::ULongTyID:
-  case Type::LongTyID:return Type::ULongTy;
-  }
-}
-
-/// getSignedVersion - If this is an integer type, return the signed variant
-/// of this type.  For example uint - int.
-const Type *Type::getSignedVersion() const {
-  switch (getTypeID()) {
-  default:
-assert(isInteger()  Type::getSignedVersion is only valid for 
integers!);
-  case Type::UByteTyID:
-  case Type::SByteTyID:   return Type::SByteTy;
-  case Type::UShortTyID:
-  case Type::ShortTyID:   return Type::ShortTy;
-  case Type::UIntTyID:
-  case Type::IntTyID: return Type::IntTy;
-  case Type::ULongTyID:
-  case Type::LongTyID:return Type::LongTy;
-  }
-}
-
-
 // getPrimitiveSize - Return the basic size of this type if it is a primitive
 // type.  These are fixed by LLVM and are not target dependent.  This will
 // return zero if the type does not have a size or is not a primitive type.
@@ -178,15 +128,11 @@
 unsigned Type::getPrimitiveSize() const {
   switch (getTypeID()) {
   case Type::BoolTyID:
-  case Type::SByteTyID:
-  case Type::UByteTyID: return 1;
-  case Type::UShortTyID:
-  case Type::ShortTyID: return 2;
+  case Type::Int8TyID:  return 1;
+  case Type::Int16TyID: return 2;
   case Type::FloatTyID:
-  case Type::IntTyID:
-  case Type::UIntTyID: return 4;
-  case Type::LongTyID:
-  case Type::ULongTyID:
+  case Type::Int32TyID: return 4;
+  case Type::Int64TyID:
   case Type::DoubleTyID: return 8;
   default: return 0;
   }
@@ -195,15 +141,11 @@
 unsigned Type::getPrimitiveSizeInBits() const {
   switch (getTypeID()) {
   case Type::BoolTyID:  return 1;
-  case Type::SByteTyID:
-  case Type::UByteTyID: return 8;
-  case Type::UShortTyID:
-  case Type::ShortTyID: return 16;
+  case Type::Int8TyID:  return 8;
+  case Type::Int16TyID: return 16;
   case Type::FloatTyID:
-  case Type::IntTyID:
-  case Type::UIntTyID: return 32;
-  case Type::LongTyID:
-  case Type::ULongTyID:
+  case Type::Int32TyID:return 32;
+  case Type::Int64TyID:
   case Type::DoubleTyID: return 64;
   case Type::PackedTyID: {
 const PackedType *PTy = castPackedType(this);
@@ -303,11 +245,21 @@
   switch (Ty-getTypeID()) {
   case Type::FunctionTyID: {
 const FunctionType *FTy = castFunctionType(Ty);
-Result = getTypeDescription(FTy-getReturnType(), TypeStack) +  (;
+Result = 

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

2006-10-15 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.146 - 1.147
---
Log message:

label* is not a valid type, add an assertion.


---
Diffs of the changes:  (+1 -0)

 Type.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.146 llvm/lib/VMCore/Type.cpp:1.147
--- llvm/lib/VMCore/Type.cpp:1.146  Thu Sep 28 18:45:00 2006
+++ llvm/lib/VMCore/Type.cppSun Oct 15 18:21:12 2006
@@ -1204,6 +1204,7 @@
   assert(ValueType  Can't get a pointer to null type!);
   assert(ValueType != Type::VoidTy 
  Pointer to void is not valid, use sbyte* instead!);
+  assert(ValueType != Type::LabelTy  Pointer to label is not valid!);
   PointerValType PVT(ValueType);
 
   PointerType *PT = PointerTypes-get(PVT);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-09-28 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.144 - 1.145
---
Log message:

Now that ConstantBool::True/False are gone, we can modify Type.cpp to
eliminate its static dtors, without having code that depends on order of 
initialization.  Eliminate static ctors/dtors from Type.cpp.


---
Diffs of the changes:  (+73 -91)

 Type.cpp |  164 ---
 1 files changed, 73 insertions(+), 91 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.144 llvm/lib/VMCore/Type.cpp:1.145
--- llvm/lib/VMCore/Type.cpp:1.144  Sun Aug 27 07:54:02 2006
+++ llvm/lib/VMCore/Type.cppThu Sep 28 18:38:07 2006
@@ -21,6 +21,7 @@
 #include llvm/ADT/STLExtras.h
 #include llvm/Support/MathExtras.h
 #include llvm/Support/Compiler.h
+#include llvm/Support/ManagedStatic.h
 #include algorithm
 #include iostream
 using namespace llvm;
@@ -57,13 +58,15 @@
 // for types as they are needed.  Because resolution of types must invalidate
 // all of the abstract type descriptions, we keep them in a seperate map to 
make
 // this easy.
-static std::mapconst Type*, std::string ConcreteTypeDescriptions;
-static std::mapconst Type*, std::string AbstractTypeDescriptions;
+static ManagedStaticstd::mapconst Type*, 
+  std::string  ConcreteTypeDescriptions;
+static ManagedStaticstd::mapconst Type*,
+  std::string  AbstractTypeDescriptions;
 
 Type::Type(const char *Name, TypeID id)
   : ID(id), Abstract(false),  RefCount(0), ForwardType(0) {
   assert(Name  Name[0]  Should use other ctor if no name!);
-  ConcreteTypeDescriptions[this] = Name;
+  (*ConcreteTypeDescriptions)[this] = Name;
 }
 
 
@@ -250,18 +253,18 @@
   std::vectorconst Type * TypeStack) {
   if (isaOpaqueType(Ty)) { // Base case for the recursion
 std::mapconst Type*, std::string::iterator I =
-  AbstractTypeDescriptions.lower_bound(Ty);
-if (I != AbstractTypeDescriptions.end()  I-first == Ty)
+  AbstractTypeDescriptions-lower_bound(Ty);
+if (I != AbstractTypeDescriptions-end()  I-first == Ty)
   return I-second;
 std::string Desc = opaque;
-AbstractTypeDescriptions.insert(std::make_pair(Ty, Desc));
+AbstractTypeDescriptions-insert(std::make_pair(Ty, Desc));
 return Desc;
   }
 
   if (!Ty-isAbstract()) {   // Base case for the recursion
 std::mapconst Type*, std::string::iterator I =
-  ConcreteTypeDescriptions.find(Ty);
-if (I != ConcreteTypeDescriptions.end()) return I-second;
+  ConcreteTypeDescriptions-find(Ty);
+if (I != ConcreteTypeDescriptions-end()) return I-second;
   }
 
   // Check to see if the Type is already on the stack...
@@ -354,9 +357,9 @@
 
 const std::string Type::getDescription() const {
   if (isAbstract())
-return getOrCreateDesc(AbstractTypeDescriptions, this);
+return getOrCreateDesc(*AbstractTypeDescriptions, this);
   else
-return getOrCreateDesc(ConcreteTypeDescriptions, this);
+return getOrCreateDesc(*ConcreteTypeDescriptions, this);
 }
 
 
@@ -382,39 +385,41 @@
 //   Static 'Type' data
 
//===--===//
 
-namespace {
-  struct VISIBILITY_HIDDEN PrimType : public Type {
-PrimType(const char *S, TypeID ID) : Type(S, ID) {}
-  };
-}
+#define DeclarePrimType(TY, Str) \
+  struct VISIBILITY_HIDDEN TY##Type : public Type {  \
+TY##Type() : Type(Str, Type::TY##TyID) {}\
+  }; \
+  static ManagedStaticTY##Type The##TY##Ty
 
-static PrimType TheVoidTy  (void  , Type::VoidTyID);
-static PrimType TheBoolTy  (bool  , Type::BoolTyID);
-static PrimType TheSByteTy (sbyte , Type::SByteTyID);
-static PrimType TheUByteTy (ubyte , Type::UByteTyID);
-static PrimType TheShortTy (short , Type::ShortTyID);
-static PrimType TheUShortTy(ushort, Type::UShortTyID);
-static PrimType TheIntTy   (int   , Type::IntTyID);
-static PrimType TheUIntTy  (uint  , Type::UIntTyID);
-static PrimType TheLongTy  (long  , Type::LongTyID);
-static PrimType TheULongTy (ulong , Type::ULongTyID);
-static PrimType TheFloatTy (float , Type::FloatTyID);
-static PrimType TheDoubleTy(double, Type::DoubleTyID);
-static PrimType TheLabelTy (label , Type::LabelTyID);
-
-Type *Type::VoidTy   = TheVoidTy;
-Type *Type::BoolTy   = TheBoolTy;
-Type *Type::SByteTy  = TheSByteTy;
-Type *Type::UByteTy  = TheUByteTy;
-Type *Type::ShortTy  = TheShortTy;
-Type *Type::UShortTy = TheUShortTy;
-Type *Type::IntTy= TheIntTy;
-Type *Type::UIntTy   = TheUIntTy;
-Type *Type::LongTy   = TheLongTy;
-Type *Type::ULongTy  = TheULongTy;
-Type *Type::FloatTy  = TheFloatTy;
-Type *Type::DoubleTy = TheDoubleTy;
-Type *Type::LabelTy  = TheLabelTy;
+namespace {
+  DeclarePrimType(Void,   void);
+  DeclarePrimType(Bool,   bool);
+  DeclarePrimType(SByte,  

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

2006-09-28 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.145 - 1.146
---
Log message:

Minor cleanups


---
Diffs of the changes:  (+24 -36)

 Type.cpp |   60 
 1 files changed, 24 insertions(+), 36 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.145 llvm/lib/VMCore/Type.cpp:1.146
--- llvm/lib/VMCore/Type.cpp:1.145  Thu Sep 28 18:38:07 2006
+++ llvm/lib/VMCore/Type.cppThu Sep 28 18:45:00 2006
@@ -382,44 +382,32 @@
 
 
 
//===--===//
-//   Static 'Type' data
+//  Primitive 'Type' data
 
//===--===//
 
-#define DeclarePrimType(TY, Str) \
-  struct VISIBILITY_HIDDEN TY##Type : public Type {  \
-TY##Type() : Type(Str, Type::TY##TyID) {}\
-  }; \
-  static ManagedStaticTY##Type The##TY##Ty
-
-namespace {
-  DeclarePrimType(Void,   void);
-  DeclarePrimType(Bool,   bool);
-  DeclarePrimType(SByte,  sbyte);
-  DeclarePrimType(UByte,  ubyte);
-  DeclarePrimType(Short,  short);
-  DeclarePrimType(UShort, ushort);
-  DeclarePrimType(Int,int);
-  DeclarePrimType(UInt,   uint);
-  DeclarePrimType(Long,   long);
-  DeclarePrimType(ULong,  ulong);
-  DeclarePrimType(Float,  float);
-  DeclarePrimType(Double, double);
-  DeclarePrimType(Label,  label);
-}
-
-Type *Type::VoidTy   = *TheVoidTy;
-Type *Type::BoolTy   = *TheBoolTy;
-Type *Type::SByteTy  = *TheSByteTy;
-Type *Type::UByteTy  = *TheUByteTy;
-Type *Type::ShortTy  = *TheShortTy;
-Type *Type::UShortTy = *TheUShortTy;
-Type *Type::IntTy= *TheIntTy;
-Type *Type::UIntTy   = *TheUIntTy;
-Type *Type::LongTy   = *TheLongTy;
-Type *Type::ULongTy  = *TheULongTy;
-Type *Type::FloatTy  = *TheFloatTy;
-Type *Type::DoubleTy = *TheDoubleTy;
-Type *Type::LabelTy  = *TheLabelTy;
+#define DeclarePrimType(TY, Str)   \
+  namespace {  \
+struct VISIBILITY_HIDDEN TY##Type : public Type {  \
+  TY##Type() : Type(Str, Type::TY##TyID) {}\
+}; \
+  }\
+  static ManagedStaticTY##Type The##TY##Ty;  \
+  Type *Type::TY##Ty = *The##TY##Ty
+
+DeclarePrimType(Void,   void);
+DeclarePrimType(Bool,   bool);
+DeclarePrimType(SByte,  sbyte);
+DeclarePrimType(UByte,  ubyte);
+DeclarePrimType(Short,  short);
+DeclarePrimType(UShort, ushort);
+DeclarePrimType(Int,int);
+DeclarePrimType(UInt,   uint);
+DeclarePrimType(Long,   long);
+DeclarePrimType(ULong,  ulong);
+DeclarePrimType(Float,  float);
+DeclarePrimType(Double, double);
+DeclarePrimType(Label,  label);
+#undef DeclarePrimType
 
 
 
//===--===//



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-07-26 Thread Jim Laskey


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.142 - 1.143
---
Log message:

No Need to live in the past.


---
Diffs of the changes:  (+0 -3)

 Type.cpp |3 ---
 1 files changed, 3 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.142 llvm/lib/VMCore/Type.cpp:1.143
--- llvm/lib/VMCore/Type.cpp:1.142  Tue Jul 25 18:22:00 2006
+++ llvm/lib/VMCore/Type.cppWed Jul 26 04:59:01 2006
@@ -38,9 +38,6 @@
 // Type PATypeHolder Implementation
 
//===--===//
 
-// This routine was moved here to resolve a cyclic dependency caused by
-// inline heuristics.
-
 /// get - This implements the forwarding part of the union-find algorithm for
 /// abstract types.  Before every access to the Type*, we check to see if the
 /// type we are pointing to is forwarding to a new type.  If so, we drop our



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-07-25 Thread Jim Laskey


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.141 - 1.142
---
Log message:

Moving this function to a permanent home to prevent a dependency cycle created
by the inline heuristic.  Was preventing llvm-gcc4 from building.


---
Diffs of the changes:  (+19 -0)

 Type.cpp |   19 +++
 1 files changed, 19 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.141 llvm/lib/VMCore/Type.cpp:1.142
--- llvm/lib/VMCore/Type.cpp:1.141  Wed Jun 28 16:38:54 2006
+++ llvm/lib/VMCore/Type.cppTue Jul 25 18:22:00 2006
@@ -33,6 +33,25 @@
 
 AbstractTypeUser::~AbstractTypeUser() {}
 
+
+//===--===//
+// Type PATypeHolder Implementation
+//===--===//
+
+// This routine was moved here to resolve a cyclic dependency caused by
+// inline heuristics.
+
+/// get - This implements the forwarding part of the union-find algorithm for
+/// abstract types.  Before every access to the Type*, we check to see if the
+/// type we are pointing to is forwarding to a new type.  If so, we drop our
+/// reference to the type.
+///
+Type* PATypeHolder::get() const {
+  const Type *NewTy = Ty-getForwardedType();
+  if (!NewTy) return const_castType*(Ty);
+  return *const_castPATypeHolder*(this) = NewTy;
+}
+
 
//===--===//
 // Type Class Implementation
 
//===--===//



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-05-28 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.139 - 1.140
---
Log message:

Fix grammar in a comment.


---
Diffs of the changes:  (+1 -1)

 Type.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.139 llvm/lib/VMCore/Type.cpp:1.140
--- llvm/lib/VMCore/Type.cpp:1.139  Fri Apr 21 10:33:35 2006
+++ llvm/lib/VMCore/Type.cppSun May 28 21:34:34 2006
@@ -1246,7 +1246,7 @@
 }
 
 
-// refineAbstractTypeTo - This function is used to when it is discovered that
+// refineAbstractTypeTo - This function is used when it is discovered that
 // the 'this' abstract type is actually equivalent to the NewType specified.
 // This causes all users of 'this' to switch to reference the more concrete 
type
 // NewType and for 'this' to be deleted.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-04-21 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.138 - 1.139
---
Log message:

Remove a hack required by V9.


---
Diffs of the changes:  (+2 -4)

 Type.cpp |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.138 llvm/lib/VMCore/Type.cpp:1.139
--- llvm/lib/VMCore/Type.cpp:1.138  Sat Apr  1 23:40:28 2006
+++ llvm/lib/VMCore/Type.cppFri Apr 21 10:33:35 2006
@@ -1192,10 +1192,8 @@
 
 PointerType *PointerType::get(const Type *ValueType) {
   assert(ValueType  Can't get a pointer to null type!);
-  // FIXME: The sparc backend makes void pointers, which is horribly broken.
-  // Fix it, then reenable this assertion.
-  //assert(ValueType != Type::VoidTy 
-  //   Pointer to void is not valid, use sbyte* instead!);
+  assert(ValueType != Type::VoidTy 
+ Pointer to void is not valid, use sbyte* instead!);
   PointerValType PVT(ValueType);
 
   PointerType *PT = PointerTypes.get(PVT);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2006-04-01 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.137 - 1.138
---
Log message:

vector casts never reinterpret bits


---
Diffs of the changes:  (+5 -0)

 Type.cpp |5 +
 1 files changed, 5 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.137 llvm/lib/VMCore/Type.cpp:1.138
--- llvm/lib/VMCore/Type.cpp:1.137  Wed Nov 16 00:09:47 2005
+++ llvm/lib/VMCore/Type.cppSat Apr  1 23:40:28 2006
@@ -75,6 +75,11 @@
 //
 bool Type::isLosslesslyConvertibleTo(const Type *Ty) const {
   if (this == Ty) return true;
+  
+  // Packed type conversions are always bitwise.
+  if (isaPackedType(this)  isaPackedType(Ty))
+return true;
+  
   if ((!isPrimitiveType() !isaPointerType(this)) ||
   (!isaPointerType(Ty)  !Ty-isPrimitiveType())) return false;
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-11-15 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.136 - 1.137
---
Log message:

* Fix DerivedType::dropAllTypeUses to not change the number of types in a 
  type when it gets refined.  This allows us to hash on this crucial value.
* Fix several issues in TypeMap::RefineAbstractType that prevent it from
  handling hash values that change correctly.
* Define hashTypeStructure to not always return 0.  :)

This last part (which depends on the first two) speeds up gccld time on eon
from 3.78s to 2.75s with a release build (a 28% speedup!).  This resolves
PR474: http://llvm.cs.uiuc.edu/PR474 .



---
Diffs of the changes:  (+65 -22)

 Type.cpp |   87 +++
 1 files changed, 65 insertions(+), 22 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.136 llvm/lib/VMCore/Type.cpp:1.137
--- llvm/lib/VMCore/Type.cpp:1.136  Sat Nov 12 21:26:33 2005
+++ llvm/lib/VMCore/Type.cppWed Nov 16 00:09:47 2005
@@ -471,14 +471,17 @@
 // types, to avoid some circular reference problems.
 void DerivedType::dropAllTypeUses() {
   if (!ContainedTys.empty()) {
-while (ContainedTys.size()  1)
-  ContainedTys.pop_back();
-
 // The type must stay abstract.  To do this, we insert a pointer to a type
 // that will never get resolved, thus will always be abstract.
 static Type *AlwaysOpaqueTy = OpaqueType::get();
 static PATypeHolder Holder(AlwaysOpaqueTy);
 ContainedTys[0] = AlwaysOpaqueTy;
+
+// Change the rest of the types to be intty's.  It doesn't matter what we
+// pick so long as it doesn't point back to this type.  We choose something
+// concrete to avoid overhead for adding to AbstracTypeUser lists and 
stuff.
+for (unsigned i = 1, e = ContainedTys.size(); i != e; ++i)
+  ContainedTys[i] = Type::IntTy;
   }
 }
 
@@ -680,6 +683,37 @@
   return false;
 }
 
+/// getSubElementHash - Generate a hash value for all of the SubType's of this
+/// type.  The hash value is guaranteed to be zero if any of the subtypes are 
+/// an opaque type.  Otherwise we try to mix them in as well as possible, but 
do
+/// not look at the subtype's subtype's.
+static unsigned getSubElementHash(const Type *Ty) {
+  unsigned HashVal = 0;
+  for (Type::subtype_iterator I = Ty-subtype_begin(), E = Ty-subtype_end();
+   I != E; ++I) {
+HashVal *= 32;
+const Type *SubTy = I-get();
+HashVal += SubTy-getTypeID();
+switch (SubTy-getTypeID()) {
+default: break;
+case Type::OpaqueTyID: return 0;// Opaque - hash = 0 no matter what.
+case Type::FunctionTyID:
+  HashVal ^= castFunctionType(SubTy)-getNumParams()*2 + 
+ castFunctionType(SubTy)-isVarArg();
+  break;
+case Type::ArrayTyID:
+  HashVal ^= castArrayType(SubTy)-getNumElements();
+  break;
+case Type::PackedTyID:
+  HashVal ^= castPackedType(SubTy)-getNumElements();
+  break;
+case Type::StructTyID:
+  HashVal ^= castStructType(SubTy)-getNumElements();
+  break;
+}
+  }
+  return HashVal ? HashVal : 1;  // Do not return zero unless opaque subty.
+}
 
 
//===--===//
 //   Derived Type Factory Functions
@@ -697,12 +731,18 @@
 public:
   void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) {
 std::multimapunsigned, PATypeHolder::iterator I =
-TypesByHash.lower_bound(Hash);
-while (I-second != Ty) {
-  ++I;
-  assert(I != TypesByHash.end()  I-first == Hash);
+  TypesByHash.lower_bound(Hash);
+for (; I != TypesByHash.end()  I-first == Hash; ++I) {
+  if (I-second == Ty) {
+TypesByHash.erase(I);
+return;
+  }
 }
-TypesByHash.erase(I);
+
+// This must be do to an opaque type that was resolved.  Switch down to 
hash
+// code of zero.
+assert(Hash  Didn't find type entry!);
+RemoveFromTypesByHash(0, Ty);
   }
   
   /// TypeBecameConcrete - When Ty gets a notification that TheType just became
@@ -803,7 +843,6 @@
 
   tie(I, Inserted) = Map.insert(std::make_pair(ValType::get(Ty), Ty));
   if (!Inserted) {
-assert(OldType != NewType);
 // Refined to a different type altogether?
 RemoveFromTypesByHash(OldTypeHash, Ty);
 
@@ -819,7 +858,7 @@
   // gets refined to the pre-existing type.
   //
   std::multimapunsigned, PATypeHolder::iterator I, E, Entry;
-  tie(I, E) = TypesByHash.equal_range(OldTypeHash);
+  tie(I, E) = TypesByHash.equal_range(NewTypeHash);
   Entry = E;
   for (; I != E; ++I) {
 if (I-second == Ty) {
@@ -829,16 +868,23 @@
   if (TypesEqual(Ty, I-second)) {
 TypeClass *NewTy = castTypeClass((Type*)I-second.get());
 
-if (Entry == E) {
-  // Find the location of Ty in the TypesByHash structure if we
-  // haven't seen it already.
-  while (I-second != Ty) {

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

2005-11-12 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.132 - 1.133
---
Log message:

Separate the type-became-concrete case from the type-is-resolved case, the
former of which takes much less work than the later.  This speeds up linking
eon from 3.749 to 3.637s with a release build (about 3%).


---
Diffs of the changes:  (+31 -21)

 Type.cpp |   52 +++-
 1 files changed, 31 insertions(+), 21 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.132 llvm/lib/VMCore/Type.cpp:1.133
--- llvm/lib/VMCore/Type.cpp:1.132  Sat Nov 12 02:39:48 2005
+++ llvm/lib/VMCore/Type.cppSat Nov 12 19:27:50 2005
@@ -736,15 +736,35 @@
   /// The specified iterator tells us what the type USED to look like.
   void finishRefinement(TypeClass *Ty, const DerivedType *OldType,
 const Type *NewType) {
-// Either NewTy == OldTy (in which case the specified type just became
-// concrete) or they are different an the Ty is thought to be abstract.
-assert((Ty-isAbstract() || OldType == NewType) 
-   Refining a non-abstract type!);
 #ifdef DEBUG_MERGE_TYPES
 std::cerr  refineAbstractTy(  (void*)OldType  [  *OldType
-   ],   (void*)NewType   [  *NewType  ])\n;
+ ],   (void*)NewType   [  *NewType  ])\n;
 #endif
+// If NewTy == OldTy, then the type just became concrete.  In this case, we
+// don't need to change the current type, we just need to drop uses of the
+// type and potentially mark Ty as concrete now too.
+if (OldType == NewType) {
+  // If the element just became concrete, remove 'ty' from the abstract
+  // type user list for the type.  Do this for as many times as Ty uses
+  // OldType.
+  for (unsigned i = 0, e = Ty-ContainedTys.size(); i != e; ++i)
+if (Ty-ContainedTys[i] == OldType)
+  OldType-removeAbstractTypeUser(Ty);
 
+  // If the type is currently thought to be abstract, rescan all of our
+  // subtypes to see if the type has just become concrete!  Note that this
+  // may send out notifications to AbstractTypeUsers that types become
+  // concrete.
+  if (Ty-isAbstract())
+Ty-PromoteAbstractToConcrete();
+  return;
+}
+
+
+// Otherwise, we are changing one subelement type into another.  Clearly 
the
+// OldType must have been abstract, making us abstract.
+assert(Ty-isAbstract()  Refining a non-abstract type!);
+
 // Make a temporary type holder for the type so that it doesn't disappear 
on
 // us when we erase the entry from the map.
 PATypeHolder TyHolder = Ty;
@@ -759,31 +779,23 @@
 unsigned OldTypeHash = ValType::hashTypeStructure(Ty);
 
 // Find the type element we are refining... and change it now!
-if (!OldType-isAbstract()) {
-  // If the element just became concrete, remove 'ty' from the abstract
-  // type user list for the type.
-  for (unsigned i = 0, e = Ty-ContainedTys.size(); i != e; ++i)
-if (Ty-ContainedTys[i] == OldType)
-  OldType-removeAbstractTypeUser(Ty);
-} else {
-  assert(OldType != NewType  Unknown case!);
-  for (unsigned i = 0, e = Ty-ContainedTys.size(); i != e; ++i)
-if (Ty-ContainedTys[i] == OldType)
-  Ty-ContainedTys[i] = NewType;
-}
+for (unsigned i = 0, e = Ty-ContainedTys.size(); i != e; ++i)
+  if (Ty-ContainedTys[i] == OldType)
+Ty-ContainedTys[i] = NewType;
 unsigned NewTypeHash = ValType::hashTypeStructure(Ty);
 
 // If there are no cycles going through this node, we can do a simple,
 // efficient lookup in the map, instead of an inefficient nasty linear
 // lookup.
-if (!Ty-isAbstract() || !TypeHasCycleThroughItself(Ty)) {
+if (!TypeHasCycleThroughItself(Ty)) {
   typename std::mapValType, PATypeHolder::iterator I;
   bool Inserted;
 
   tie(I, Inserted) = Map.insert(std::make_pair(ValType::get(Ty), Ty));
   if (!Inserted) {
+assert(OldType != NewType);
 // Refined to a different type altogether?
-RemoveFromTypesByHash(NewTypeHash, Ty);
+RemoveFromTypesByHash(OldTypeHash, Ty);
 
 // We already have this type in the table.  Get rid of the newly 
refined
 // type.
@@ -792,8 +804,6 @@
 return;
   }
 } else {
-  assert(Ty-isAbstract()  Potentially replacing a non-abstract type?);
-
   // Now we check to see if there is an existing entry in the table which 
is
   // structurally identical to the newly refined type.  If so, this type
   // gets refined to the pre-existing type.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-11-12 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.134 - 1.135
---
Log message:

Move some methods around.  Refactor the parts of TypeMap that do not depend
on its template arguments into a base class so that the code isn't duplicated
5 times.


---
Diffs of the changes:  (+52 -50)

 Type.cpp |  102 ---
 1 files changed, 52 insertions(+), 50 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.134 llvm/lib/VMCore/Type.cpp:1.135
--- llvm/lib/VMCore/Type.cpp:1.134  Sat Nov 12 19:58:06 2005
+++ llvm/lib/VMCore/Type.cppSat Nov 12 21:14:09 2005
@@ -43,14 +43,13 @@
 static std::mapconst Type*, std::string ConcreteTypeDescriptions;
 static std::mapconst Type*, std::string AbstractTypeDescriptions;
 
-Type::Type( const std::string name, TypeID id )
-  : RefCount(0), ForwardType(0) {
-  if (!name.empty())
-ConcreteTypeDescriptions[this] = name;
-  ID = id;
-  Abstract = false;
+Type::Type(const char *Name, TypeID id)
+  : ID(id), Abstract(false),  RefCount(0), ForwardType(0) {
+  assert(Name  Name[0]  Should use other ctor if no name!);
+  ConcreteTypeDescriptions[this] = Name;
 }
 
+
 const Type *Type::getPrimitiveType(TypeID IDNumber) {
   switch (IDNumber) {
   case VoidTyID  : return VoidTy;
@@ -678,66 +677,35 @@
 //   Derived Type Factory Functions
 
//===--===//
 
-// TypeMap - Make sure that only one instance of a particular type may be
-// created on any given run of the compiler... note that this involves updating
-// our map if an abstract type gets refined somehow.
-//
 namespace llvm {
-templateclass ValType, class TypeClass
-class TypeMap {
-  std::mapValType, PATypeHolder Map;
-
+class TypeMapBase {
+protected:
   /// TypesByHash - Keep track of types by their structure hash value.  Note
   /// that we only keep track of types that have cycles through themselves in
   /// this map.
   ///
   std::multimapunsigned, PATypeHolder TypesByHash;
 
-  friend void Type::clearAllTypeMaps();
-
-private:
-  void clear(std::vectorType * DerivedTypes) {
-for (typename std::mapValType, PATypeHolder::iterator I = Map.begin(),
- E = Map.end(); I != E; ++I)
-  DerivedTypes.push_back(I-second.get());
-TypesByHash.clear();
-Map.clear();
-  }
 public:
-  typedef typename std::mapValType, PATypeHolder::iterator iterator;
-  ~TypeMap() { print(ON EXIT); }
-
-  inline TypeClass *get(const ValType V) {
-iterator I = Map.find(V);
-return I != Map.end() ? castTypeClass((Type*)I-second.get()) : 0;
-  }
-
-  inline void add(const ValType V, TypeClass *Ty) {
-Map.insert(std::make_pair(V, Ty));
-
-// If this type has a cycle, remember it.
-TypesByHash.insert(std::make_pair(ValType::hashTypeStructure(Ty), Ty));
-print(add);
-  }
-
   void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) {
 std::multimapunsigned, PATypeHolder::iterator I =
-  TypesByHash.lower_bound(Hash);
+TypesByHash.lower_bound(Hash);
 while (I-second != Ty) {
   ++I;
   assert(I != TypesByHash.end()  I-first == Hash);
 }
 TypesByHash.erase(I);
   }
-
+  
   /// TypeBecameConcrete - When Ty gets a notification that TheType just became
   /// concrete, drop uses and make Ty non-abstract if we should.
-  void TypeBecameConcrete(TypeClass *Ty, const DerivedType *TheType) {
+  void TypeBecameConcrete(DerivedType *Ty, const DerivedType *TheType) {
 // If the element just became concrete, remove 'ty' from the abstract
 // type user list for the type.  Do this for as many times as Ty uses
 // OldType.
-for (unsigned i = 0, e = Ty-ContainedTys.size(); i != e; ++i)
-  if (Ty-ContainedTys[i] == TheType)
+for (Type::subtype_iterator I = Ty-subtype_begin(), E = Ty-subtype_end();
+ I != E; ++I)
+  if (I-get() == TheType)
 TheType-removeAbstractTypeUser(Ty);
 
 // If the type is currently thought to be abstract, rescan all of our
@@ -747,8 +715,44 @@
 if (Ty-isAbstract())
   Ty-PromoteAbstractToConcrete();
   }
+};
+}
+
+
+// TypeMap - Make sure that only one instance of a particular type may be
+// created on any given run of the compiler... note that this involves updating
+// our map if an abstract type gets refined somehow.
+//
+namespace llvm {
+templateclass ValType, class TypeClass
+class TypeMap : public TypeMapBase {
+  std::mapValType, PATypeHolder Map;
+public:
+  typedef typename std::mapValType, PATypeHolder::iterator iterator;
+  ~TypeMap() { print(ON EXIT); }
+
+  inline TypeClass *get(const ValType V) {
+iterator I = Map.find(V);
+return I != Map.end() ? castTypeClass((Type*)I-second.get()) : 0;
+  }
+
+  inline void add(const ValType V, TypeClass *Ty) {
+Map.insert(std::make_pair(V, Ty));
+
+// If this type has a cycle, remember it.
+TypesByHash.insert(std::make_pair(ValType::hashTypeStructure(Ty), 

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

2005-11-09 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.129 - 1.130
---
Log message:

Force packed vectors to be a power of two in length.


---
Diffs of the changes:  (+2 -0)

 Type.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.129 llvm/lib/VMCore/Type.cpp:1.130
--- llvm/lib/VMCore/Type.cpp:1.129  Wed Jul 27 01:12:34 2005
+++ llvm/lib/VMCore/Type.cppWed Nov  9 19:40:59 2005
@@ -19,6 +19,7 @@
 #include llvm/ADT/StringExtras.h
 #include llvm/ADT/SCCIterator.h
 #include llvm/ADT/STLExtras.h
+#include llvm/Support/MathExtras.h
 #include algorithm
 #include iostream
 using namespace llvm;
@@ -1005,6 +1006,7 @@
 
 PackedType *PackedType::get(const Type *ElementType, unsigned NumElements) {
   assert(ElementType  Can't get packed of null types!);
+  assert(isPowerOf2_32(NumElements)  Vector length should be a power of 
2!);
 
   PackedValType PVT(ElementType, NumElements);
   PackedType *PT = PackedTypes.get(PVT);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits