aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/DerivedTypes.h2
-rw-r--r--include/llvm/Type.def10
-rw-r--r--include/llvm/Type.h8
-rw-r--r--lib/Linker/LinkModules.cpp5
-rw-r--r--lib/Transforms/Utils/Linker.cpp5
-rw-r--r--lib/VMCore/AsmWriter.cpp16
-rw-r--r--lib/VMCore/Function.cpp9
-rw-r--r--lib/VMCore/Linker.cpp5
-rw-r--r--lib/VMCore/Type.cpp61
9 files changed, 62 insertions, 59 deletions
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index da972562df..c0d66bebad 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -138,7 +138,7 @@ public:
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const FunctionType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == MethodTyID;
+ return T->getPrimitiveID() == FunctionTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<const Type>(V));
diff --git a/include/llvm/Type.def b/include/llvm/Type.def
index ea4cdc1cac..99a9569ce8 100644
--- a/include/llvm/Type.def
+++ b/include/llvm/Type.def
@@ -47,11 +47,11 @@ HANDLE_PRIM_TYPE(Label , 8)
// Type Name: This is the symbolic name of the type, without the trailing Ty.
// Class Name: This is the subclass that implements the derived type.
//
-HANDLE_DERV_TYPE(Method , MethodType)
-HANDLE_DERV_TYPE(Array , ArrayType)
-HANDLE_DERV_TYPE(Pointer, PointerType)
-HANDLE_DERV_TYPE(Struct , StructType)
-HANDLE_DERV_TYPE(Opaque , OpaqueType)
+HANDLE_DERV_TYPE(Function, FunctionType)
+HANDLE_DERV_TYPE(Array , ArrayType)
+HANDLE_DERV_TYPE(Pointer , PointerType)
+HANDLE_DERV_TYPE(Struct , StructType)
+HANDLE_DERV_TYPE(Opaque , OpaqueType)
// Kill the macros on exit...
#undef HANDLE_PRIM_TYPE
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 1bbe02337b..07d9615ba9 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -30,7 +30,7 @@
#include "Support/GraphTraits.h"
class DerivedType;
-class MethodType;
+class FunctionType;
class ArrayType;
class PointerType;
class StructType;
@@ -58,14 +58,14 @@ public:
// Derived types... see DerivedTypes.h file...
// Make sure FirstDerivedTyID stays up to date!!!
- MethodTyID , StructTyID, // Methods... Structs...
+ FunctionTyID , StructTyID, // Functions... Structs...
ArrayTyID , PointerTyID, // Array... pointer...
OpaqueTyID, // Opaque type instances...
//PackedTyID , // SIMD 'packed' format... TODO
//...
NumPrimitiveIDs, // Must remain as last defined ID
- FirstDerivedTyID = MethodTyID,
+ FirstDerivedTyID = FunctionTyID,
};
private:
@@ -151,7 +151,7 @@ public:
// TargetData subsystem to do this.
//
bool isSized() const {
- return ID != TypeTyID && ID != MethodTyID && ID != OpaqueTyID;
+ return ID != TypeTyID && ID != FunctionTyID && ID != OpaqueTyID;
}
//===--------------------------------------------------------------------===//
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index f3b0084dfc..f3955c89b4 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -263,7 +263,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// Check to make sure the method is not defined in both modules...
if (!SM->isExternal() && !DM->isExternal())
return Error(Err, "Function '" +
- SM->getMethodType()->getDescription() + "':\"" +
+ SM->getFunctionType()->getDescription() + "':\"" +
SM->getName() + "\" - Function is already defined!");
// Otherwise, just remember this mapping...
@@ -271,7 +271,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
} else {
// Function does not already exist, simply insert an external method
// signature identical to SM into the dest module...
- Function *DM = new Function(SM->getMethodType(), SM->hasInternalLinkage(),
+ Function *DM = new Function(SM->getFunctionType(),
+ SM->hasInternalLinkage(),
SM->getName());
// Add the method signature to the dest module...
diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp
index f3b0084dfc..f3955c89b4 100644
--- a/lib/Transforms/Utils/Linker.cpp
+++ b/lib/Transforms/Utils/Linker.cpp
@@ -263,7 +263,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// Check to make sure the method is not defined in both modules...
if (!SM->isExternal() && !DM->isExternal())
return Error(Err, "Function '" +
- SM->getMethodType()->getDescription() + "':\"" +
+ SM->getFunctionType()->getDescription() + "':\"" +
SM->getName() + "\" - Function is already defined!");
// Otherwise, just remember this mapping...
@@ -271,7 +271,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
} else {
// Function does not already exist, simply insert an external method
// signature identical to SM into the dest module...
- Function *DM = new Function(SM->getMethodType(), SM->hasInternalLinkage(),
+ Function *DM = new Function(SM->getFunctionType(),
+ SM->hasInternalLinkage(),
SM->getName());
// Add the method signature to the dest module...
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index a7b6db42db..f92fac512a 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -147,10 +147,10 @@ static string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack,
string Result;
switch (Ty->getPrimitiveID()) {
- case Type::MethodTyID: {
- const MethodType *MTy = cast<const MethodType>(Ty);
+ case Type::FunctionTyID: {
+ const FunctionType *MTy = cast<const FunctionType>(Ty);
Result = calcTypeName(MTy->getReturnType(), TypeStack, TypeNames) + " (";
- for (MethodType::ParamTypes::const_iterator
+ for (FunctionType::ParamTypes::const_iterator
I = MTy->getParamTypes().begin(),
E = MTy->getParamTypes().end(); I != E; ++I) {
if (I != MTy->getParamTypes().begin())
@@ -395,15 +395,15 @@ void AssemblyWriter::printFunction(const Function *M) {
Table.incorporateMethod(M);
// Loop over the arguments, printing them...
- const MethodType *MT = cast<const MethodType>(M->getMethodType());
+ const FunctionType *MT = M->getFunctionType();
if (!M->isExternal()) {
for_each(M->getArgumentList().begin(), M->getArgumentList().end(),
bind_obj(this, &AssemblyWriter::printFunctionArgument));
} else {
// Loop over the arguments, printing them...
- const MethodType *MT = cast<const MethodType>(M->getMethodType());
- for (MethodType::ParamTypes::const_iterator I = MT->getParamTypes().begin(),
+ const FunctionType *MT = M->getFunctionType();
+ for (FunctionType::ParamTypes::const_iterator I = MT->getParamTypes().begin(),
E = MT->getParamTypes().end(); I != E; ++I) {
if (I != MT->getParamTypes().begin()) Out << ", ";
printType(*I);
@@ -538,7 +538,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
Out << " void";
} else if (isa<CallInst>(I)) {
const PointerType *PTy = dyn_cast<PointerType>(Operand->getType());
- const MethodType *MTy = PTy ?dyn_cast<MethodType>(PTy->getElementType()):0;
+ const FunctionType*MTy = PTy ? dyn_cast<FunctionType>(PTy->getElementType()):0;
const Type *RetTy = MTy ? MTy->getReturnType() : 0;
// If possible, print out the short form of the call instruction, but we can
@@ -546,7 +546,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
// and if the value returned is not a pointer to a method.
//
if (RetTy && !MTy->isVarArg() &&
- (!isa<PointerType>(RetTy)||!isa<MethodType>(cast<PointerType>(RetTy)))){
+ (!isa<PointerType>(RetTy)||!isa<FunctionType>(cast<PointerType>(RetTy)))){
Out << " "; printType(RetTy);
writeOperand(Operand, false);
} else {
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 1ff87aabd9..c5e9e21819 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -25,11 +25,10 @@
template class ValueHolder<FunctionArgument, Function, Function>;
template class ValueHolder<BasicBlock , Function, Function>;
-Function::Function(const MethodType *Ty, bool isInternal,
+Function::Function(const FunctionType *Ty, bool isInternal,
const std::string &name)
: GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name),
SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
- assert(::isa<MethodType>(Ty) && "Function signature must be of method type!");
}
Function::~Function() {
@@ -62,12 +61,12 @@ void Function::setParent(Module *parent) {
setParentSymTab(Parent ? Parent->getSymbolTableSure() : 0);
}
-const MethodType *Function::getMethodType() const {
- return cast<MethodType>(cast<PointerType>(getType())->getElementType());
+const FunctionType *Function::getFunctionType() const {
+ return cast<FunctionType>(getType()->getElementType());
}
const Type *Function::getReturnType() const {
- return getMethodType()->getReturnType();
+ return getFunctionType()->getReturnType();
}
// dropAllReferences() - This function causes all the subinstructions to "let
diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp
index f3b0084dfc..f3955c89b4 100644
--- a/lib/VMCore/Linker.cpp
+++ b/lib/VMCore/Linker.cpp
@@ -263,7 +263,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// Check to make sure the method is not defined in both modules...
if (!SM->isExternal() && !DM->isExternal())
return Error(Err, "Function '" +
- SM->getMethodType()->getDescription() + "':\"" +
+ SM->getFunctionType()->getDescription() + "':\"" +
SM->getName() + "\" - Function is already defined!");
// Otherwise, just remember this mapping...
@@ -271,7 +271,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
} else {
// Function does not already exist, simply insert an external method
// signature identical to SM into the dest module...
- Function *DM = new Function(SM->getMethodType(), SM->hasInternalLinkage(),
+ Function *DM = new Function(SM->getFunctionType(),
+ SM->hasInternalLinkage(),
SM->getName());
// Add the method signature to the dest module...
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 316f97d439..c8a5426c14 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -194,8 +194,9 @@ Type *Type::VoidTy = new Type("void" , VoidTyID),
// Derived Type Constructors
//===----------------------------------------------------------------------===//
-MethodType::MethodType(const Type *Result, const vector<const Type*> &Params,
- bool IsVarArgs) : DerivedType(MethodTyID),
+FunctionType::FunctionType(const Type *Result,
+ const vector<const Type*> &Params,
+ bool IsVarArgs) : DerivedType(FunctionTyID),
ResultType(PATypeHandle<Type>(Result, this)),
isVarArgs(IsVarArgs) {
ParamTys.reserve(Params.size());
@@ -271,11 +272,11 @@ static string getTypeProps(const Type *Ty, vector<const Type *> &TypeStack,
TypeStack.push_back(Ty); // Add us to the stack..
switch (Ty->getPrimitiveID()) {
- case Type::MethodTyID: {
- const MethodType *MTy = cast<const MethodType>(Ty);
+ case Type::FunctionTyID: {
+ const FunctionType *MTy = cast<const FunctionType>(Ty);
Result = getTypeProps(MTy->getReturnType(), TypeStack,
isAbstract, isRecursive)+" (";
- for (MethodType::ParamTypes::const_iterator
+ for (FunctionType::ParamTypes::const_iterator
I = MTy->getParamTypes().begin(),
E = MTy->getParamTypes().end(); I != E; ++I) {
if (I != MTy->getParamTypes().begin())
@@ -381,8 +382,8 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2,
if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
if (ATy->getNumElements() != cast<const ArrayType>(Ty2)->getNumElements())
return false;
- } else if (const MethodType *MTy = dyn_cast<MethodType>(Ty)) {
- if (MTy->isVarArg() != cast<const MethodType>(Ty2)->isVarArg())
+ } else if (const FunctionType *MTy = dyn_cast<FunctionType>(Ty)) {
+ if (MTy->isVarArg() != cast<const FunctionType>(Ty2)->isVarArg())
return false;
}
@@ -522,29 +523,29 @@ protected:
//===----------------------------------------------------------------------===//
-// Method Type Factory and Value Class...
+// Function Type Factory and Value Class...
//
-// MethodValType - 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
//
-class MethodValType : public ValTypeBase<MethodValType, MethodType> {
+class FunctionValType : public ValTypeBase<FunctionValType, FunctionType> {
PATypeHandle<Type> RetTy;
vector<PATypeHandle<Type> > ArgTypes;
bool isVarArg;
public:
- MethodValType(const Type *ret, const vector<const Type*> &args,
- bool IVA, TypeMap<MethodValType, MethodType> &Tab)
- : ValTypeBase<MethodValType, MethodType>(Tab), RetTy(ret, this),
+ FunctionValType(const Type *ret, const vector<const Type*> &args,
+ bool IVA, TypeMap<FunctionValType, FunctionType> &Tab)
+ : ValTypeBase<FunctionValType, FunctionType>(Tab), RetTy(ret, this),
isVarArg(IVA) {
for (unsigned i = 0; i < args.size(); ++i)
ArgTypes.push_back(PATypeHandle<Type>(args[i], this));
}
// We *MUST* have an explicit copy ctor so that the TypeHandles think that
- // this MethodValType owns them, not the old one!
+ // this FunctionValType owns them, not the old one!
//
- MethodValType(const MethodValType &MVT)
- : ValTypeBase<MethodValType, MethodType>(MVT), RetTy(MVT.RetTy, this),
+ FunctionValType(const FunctionValType &MVT)
+ : ValTypeBase<FunctionValType, FunctionType>(MVT), RetTy(MVT.RetTy, this),
isVarArg(MVT.isVarArg) {
ArgTypes.reserve(MVT.ArgTypes.size());
for (unsigned i = 0; i < MVT.ArgTypes.size(); ++i)
@@ -565,7 +566,7 @@ public:
if (ArgTypes[i] == Ty) ArgTypes[i].removeUserFromConcrete();
}
- inline bool operator<(const MethodValType &MTV) const {
+ inline bool operator<(const FunctionValType &MTV) const {
if (RetTy.get() < MTV.RetTy.get()) return true;
if (RetTy.get() > MTV.RetTy.get()) return false;
@@ -575,17 +576,17 @@ public:
};
// Define the actual map itself now...
-static TypeMap<MethodValType, MethodType> MethodTypes;
-
-// MethodType::get - The factory function for the MethodType class...
-MethodType *MethodType::get(const Type *ReturnType,
- const vector<const Type*> &Params,
- bool isVarArg) {
- MethodValType VT(ReturnType, Params, isVarArg, MethodTypes);
- MethodType *MT = MethodTypes.get(VT);
+static TypeMap<FunctionValType, FunctionType> FunctionTypes;
+
+// FunctionType::get - The factory function for the FunctionType class...
+FunctionType *FunctionType::get(const Type *ReturnType,
+ const vector<const Type*> &Params,
+ bool isVarArg) {
+ FunctionValType VT(ReturnType, Params, isVarArg, FunctionTypes);
+ FunctionType *MT = FunctionTypes.get(VT);
if (MT) return MT;
- MethodTypes.add(VT, MT = new MethodType(ReturnType, Params, isVarArg));
+ FunctionTypes.add(VT, MT = new FunctionType(ReturnType, Params, isVarArg));
#ifdef DEBUG_MERGE_TYPES
cerr << "Derived new type: " << MT << endl;
@@ -910,10 +911,10 @@ void DerivedType::typeIsRefined() {
// concrete - this could potentially change us from an abstract type to a
// concrete type.
//
-void MethodType::refineAbstractType(const DerivedType *OldType,
- const Type *NewType) {
+void FunctionType::refineAbstractType(const DerivedType *OldType,
+ const Type *NewType) {
#ifdef DEBUG_MERGE_TYPES
- cerr << "MethodTy::refineAbstractTy(" << (void*)OldType << "["
+ cerr << "FunctionTy::refineAbstractTy(" << (void*)OldType << "["
<< OldType->getDescription() << "], " << (void*)NewType << " ["
<< NewType->getDescription() << "])\n";
#endif
@@ -931,7 +932,7 @@ void MethodType::refineAbstractType(const DerivedType *OldType,
if (ParamTys[i] == OldType) ParamTys[i] = NewType;
}
- const MethodType *MT = MethodTypes.containsEquivalent(this);
+ const FunctionType *MT = FunctionTypes.containsEquivalent(this);
if (MT && MT != this) {
refineAbstractTypeTo(MT); // Different type altogether...
} else {