[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp
LLVM
llvm at cs.uiuc.edu
Sun Jul 4 07:15:01 PDT 2004
Changes in directory llvm/lib/VMCore:
Type.cpp updated: 1.103 -> 1.104
---
Log message:
- Changes for bug 122: http://llvm.cs.uiuc.edu/PR122
- Remove Tabs
- Add inserters needed since Value doesn't implement them any more
- Move some functions here to avoid cyclic header file dependencies.
---
Diffs of the changes: (+46 -21)
Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.103 llvm/lib/VMCore/Type.cpp:1.104
--- llvm/lib/VMCore/Type.cpp:1.103 Fri Jul 2 18:20:17 2004
+++ llvm/lib/VMCore/Type.cpp Sun Jul 4 07:14:17 2004
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/AbstractTypeUser.h"
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/Constants.h"
@@ -18,6 +19,7 @@
#include "Support/StringExtras.h"
#include "Support/STLExtras.h"
#include <algorithm>
+#include <iostream>
using namespace llvm;
// DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are
@@ -42,8 +44,8 @@
static std::map<const Type*, std::string> ConcreteTypeDescriptions;
static std::map<const Type*, std::string> AbstractTypeDescriptions;
-Type::Type(const std::string &name, TypeID id)
- : Value(Type::TypeTy, Value::TypeVal), RefCount(0), ForwardType(0) {
+Type::Type( const std::string& name, TypeID id )
+ : RefCount(0), ForwardType(0) {
if (!name.empty())
ConcreteTypeDescriptions[this] = name;
ID = id;
@@ -57,7 +59,6 @@
if (!Name.empty()) ST->insert(Name, this);
}
-
const Type *Type::getUniqueIDType(unsigned UID) {
assert(UID < UIDMappings.size() &&
"Type::getPrimitiveType: UID out of range!");
@@ -78,7 +79,6 @@
case LongTyID : return LongTy;
case FloatTyID : return FloatTy;
case DoubleTyID: return DoubleTy;
- case TypeTyID : return TypeTy;
case LabelTyID : return LabelTy;
default:
return 0;
@@ -333,7 +333,7 @@
// type.
//
struct SignedIntType : public Type {
- SignedIntType(const std::string &Name, TypeID id) : Type(Name, id) {}
+ SignedIntType(std::string name, TypeID id) : Type(name, id) {}
// isSigned - Return whether a numeric type is signed.
virtual bool isSigned() const { return 1; }
@@ -345,7 +345,7 @@
};
struct UnsignedIntType : public Type {
- UnsignedIntType(const std::string &N, TypeID id) : Type(N, id) {}
+ UnsignedIntType(std::string name, TypeID id) : Type(name,id) {}
// isUnsigned - Return whether a numeric type is signed.
virtual bool isUnsigned() const { return 1; }
@@ -357,13 +357,9 @@
};
struct OtherType : public Type {
- OtherType(const std::string &N, TypeID id) : Type(N, id) {}
+ OtherType(std:;string name, TypeID id) : Type(name,id) {}
};
-static struct TypeType : public Type {
- TypeType() : Type("type", TypeTyID) {}
-} TheTypeTy; // Implement the type that is global.
-
//===----------------------------------------------------------------------===//
// Static 'Type' data
@@ -375,7 +371,7 @@
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 SignedIntType TheIntTy ("int" , Type::IntTyID);
static UnsignedIntType TheUIntTy ("uint" , Type::UIntTyID);
static SignedIntType TheLongTy ("long" , Type::LongTyID);
static UnsignedIntType TheULongTy ("ulong" , Type::ULongTyID);
@@ -395,7 +391,6 @@
Type *Type::ULongTy = &TheULongTy;
Type *Type::FloatTy = &TheFloatTy;
Type *Type::DoubleTy = &TheDoubleTy;
-Type *Type::TypeTy = &TheTypeTy;
Type *Type::LabelTy = &TheLabelTy;
@@ -490,7 +485,7 @@
// Scan all of the sub-types. If any of them are abstract, than so is this
// one!
- for (Type::subtype_iterator I = subtype_begin(), E = subtype_end();
+ for (Type::subtype_iterator I = subtype_begin(), E = subtype_end();
I != E; ++I)
if (const_cast<Type*>(I->get())->isTypeAbstract()) {
setAbstract(true); // Restore the abstract bit.
@@ -516,7 +511,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->getTypeID() != Ty2->getTypeID()) return false;
if (isa<OpaqueType>(Ty))
@@ -582,8 +577,8 @@
return false;
VisitedTypes.insert(VTI, CurTy);
- for (Type::subtype_iterator I = CurTy->subtype_begin(),
- E = CurTy->subtype_end(); I != E; ++I)
+ for (Type::subtype_iterator I = CurTy->subtype_begin(),
+ E = CurTy->subtype_end(); I != E; ++I)
if (TypeHasCycleThrough(TargetTy, *I, VisitedTypes))
return true;
return false;
@@ -595,7 +590,7 @@
static bool TypeHasCycleThroughItself(const Type *Ty) {
assert(Ty->isAbstract() && "This code assumes that Ty was abstract!");
std::set<const Type*> VisitedTypes;
- for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
+ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
I != E; ++I)
if (TypeHasCycleThrough(Ty, *I, VisitedTypes))
return true;
@@ -1144,7 +1139,7 @@
// concrete type.
//
void ArrayType::refineAbstractType(const DerivedType *OldType,
- const Type *NewType) {
+ const Type *NewType) {
ArrayTypes.finishRefinement(this, OldType, NewType);
}
@@ -1158,7 +1153,7 @@
// concrete type.
//
void StructType::refineAbstractType(const DerivedType *OldType,
- const Type *NewType) {
+ const Type *NewType) {
StructTypes.finishRefinement(this, OldType, NewType);
}
@@ -1171,10 +1166,40 @@
// 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);
}
+
+bool SequentialType::indexValid(const Value *V) const {
+ const Type *Ty = V->getType();
+ switch (Ty->getTypeID()) {
+ case Type::IntTyID:
+ case Type::UIntTyID:
+ case Type::LongTyID:
+ case Type::ULongTyID:
+ return true;
+ default:
+ return false;
+ }
+}
+
+namespace llvm {
+std::ostream &operator<<(std::ostream &OS, const Type *T) {
+ if (T == 0)
+ OS << "<null> value!\n";
+ else
+ T->print(OS);
+ return OS;
+}
+
+std::ostream &operator<<(std::ostream &OS, const Type &T) {
+ T.print(OS);
+ return OS;
+}
+}
+
+// vim: sw=2
More information about the llvm-commits
mailing list