Finegrainify namespacification

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-11-19 06:14:38 +00:00
parent 1c3673b238
commit f2586d13d5

View File

@ -18,7 +18,7 @@
#include "Support/STLExtras.h" #include "Support/STLExtras.h"
#include <algorithm> #include <algorithm>
namespace llvm { using namespace llvm;
// DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are
// created and later destroyed, all in an effort to make sure that there is only // created and later destroyed, all in an effort to make sure that there is only
@ -560,6 +560,7 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2) {
// created on any given run of the compiler... note that this involves updating // created on any given run of the compiler... note that this involves updating
// our map if an abstract type gets refined somehow... // our map if an abstract type gets refined somehow...
// //
namespace llvm {
template<class ValType, class TypeClass> template<class ValType, class TypeClass>
class TypeMap { class TypeMap {
typedef std::map<ValType, TypeClass *> MapTy; typedef std::map<ValType, TypeClass *> MapTy;
@ -647,7 +648,7 @@ public:
void dump() const { print("dump output"); } void dump() const { print("dump output"); }
}; };
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -656,6 +657,7 @@ public:
// FunctionValType - Define a class to hold the key that goes into the TypeMap // FunctionValType - Define a class to hold the key that goes into the TypeMap
// //
namespace llvm {
class FunctionValType { class FunctionValType {
const Type *RetTy; const Type *RetTy;
std::vector<const Type*> ArgTypes; std::vector<const Type*> ArgTypes;
@ -684,6 +686,7 @@ public:
return ArgTypes == MTV.ArgTypes && isVarArg < MTV.isVarArg; return ArgTypes == MTV.ArgTypes && isVarArg < MTV.isVarArg;
} }
}; };
}
// Define the actual map itself now... // Define the actual map itself now...
static TypeMap<FunctionValType, FunctionType> FunctionTypes; static TypeMap<FunctionValType, FunctionType> FunctionTypes;
@ -717,6 +720,7 @@ FunctionType *FunctionType::get(const Type *ReturnType,
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Array Type Factory... // Array Type Factory...
// //
namespace llvm {
class ArrayValType { class ArrayValType {
const Type *ValTy; const Type *ValTy;
unsigned Size; unsigned Size;
@ -738,7 +742,7 @@ public:
return Size == MTV.Size && ValTy < MTV.ValTy; return Size == MTV.Size && ValTy < MTV.ValTy;
} }
}; };
}
static TypeMap<ArrayValType, ArrayType> ArrayTypes; static TypeMap<ArrayValType, ArrayType> ArrayTypes;
@ -762,6 +766,7 @@ ArrayType *ArrayType::get(const Type *ElementType, unsigned NumElements) {
// Struct Type Factory... // Struct Type Factory...
// //
namespace llvm {
// StructValType - Define a class to hold the key that goes into the TypeMap // StructValType - Define a class to hold the key that goes into the TypeMap
// //
class StructValType { class StructValType {
@ -788,6 +793,7 @@ public:
return ElTypes < STV.ElTypes; return ElTypes < STV.ElTypes;
} }
}; };
}
static TypeMap<StructValType, StructType> StructTypes; static TypeMap<StructValType, StructType> StructTypes;
@ -813,6 +819,7 @@ StructType *StructType::get(const std::vector<const Type*> &ETypes) {
// PointerValType - Define a class to hold the key that goes into the TypeMap // PointerValType - Define a class to hold the key that goes into the TypeMap
// //
namespace llvm {
class PointerValType { class PointerValType {
const Type *ValTy; const Type *ValTy;
public: public:
@ -832,6 +839,7 @@ public:
return ValTy < MTV.ValTy; return ValTy < MTV.ValTy;
} }
}; };
}
static TypeMap<PointerValType, PointerType> PointerTypes; static TypeMap<PointerValType, PointerType> PointerTypes;
@ -851,13 +859,14 @@ PointerType *PointerType::get(const Type *ValueType) {
return PT; return PT;
} }
namespace llvm {
void debug_type_tables() { void debug_type_tables() {
FunctionTypes.dump(); FunctionTypes.dump();
ArrayTypes.dump(); ArrayTypes.dump();
StructTypes.dump(); StructTypes.dump();
PointerTypes.dump(); PointerTypes.dump();
} }
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Derived Type Refinement Functions // Derived Type Refinement Functions
@ -1115,5 +1124,3 @@ void PointerType::refineAbstractType(const DerivedType *OldType,
void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { void PointerType::typeBecameConcrete(const DerivedType *AbsTy) {
refineAbstractType(AbsTy, AbsTy); refineAbstractType(AbsTy, AbsTy);
} }
} // End llvm namespace