From 6bfd6a578a3a4fa95c585c988ee712ba880f9923 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 29 Mar 2002 03:44:36 +0000 Subject: [PATCH] s/Method/Function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2034 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DerivedTypes.h | 2 +- include/llvm/Type.def | 10 +++--- include/llvm/Type.h | 8 ++--- lib/Linker/LinkModules.cpp | 5 +-- lib/Transforms/Utils/Linker.cpp | 5 +-- lib/VMCore/AsmWriter.cpp | 16 ++++----- lib/VMCore/Function.cpp | 9 +++-- lib/VMCore/Linker.cpp | 5 +-- lib/VMCore/Type.cpp | 59 +++++++++++++++++---------------- 9 files changed, 61 insertions(+), 58 deletions(-) diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index da972562df6..c0d66bebad7 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(V) && classof(cast(V)); diff --git a/include/llvm/Type.def b/include/llvm/Type.def index ea4cdc1cac4..99a9569ce87 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 1bbe02337be..07d9615ba95 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 f3b0084dfcc..f3955c89b44 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 f3b0084dfcc..f3955c89b44 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 a7b6db42db1..f92fac512ad 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -147,10 +147,10 @@ static string calcTypeName(const Type *Ty, vector &TypeStack, string Result; switch (Ty->getPrimitiveID()) { - case Type::MethodTyID: { - const MethodType *MTy = cast(Ty); + case Type::FunctionTyID: { + const FunctionType *MTy = cast(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(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(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(I)) { const PointerType *PTy = dyn_cast(Operand->getType()); - const MethodType *MTy = PTy ?dyn_cast(PTy->getElementType()):0; + const FunctionType*MTy = PTy ? dyn_cast(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(RetTy)||!isa(cast(RetTy)))){ + (!isa(RetTy)||!isa(cast(RetTy)))){ Out << " "; printType(RetTy); writeOperand(Operand, false); } else { diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 1ff87aabd9d..c5e9e218192 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -25,11 +25,10 @@ template class ValueHolder; template class ValueHolder; -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(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(cast(getType())->getElementType()); +const FunctionType *Function::getFunctionType() const { + return cast(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 f3b0084dfcc..f3955c89b44 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 316f97d4392..c8a5426c142 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 &Params, - bool IsVarArgs) : DerivedType(MethodTyID), +FunctionType::FunctionType(const Type *Result, + const vector &Params, + bool IsVarArgs) : DerivedType(FunctionTyID), ResultType(PATypeHandle(Result, this)), isVarArgs(IsVarArgs) { ParamTys.reserve(Params.size()); @@ -271,11 +272,11 @@ static string getTypeProps(const Type *Ty, vector &TypeStack, TypeStack.push_back(Ty); // Add us to the stack.. switch (Ty->getPrimitiveID()) { - case Type::MethodTyID: { - const MethodType *MTy = cast(Ty); + case Type::FunctionTyID: { + const FunctionType *MTy = cast(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(Ty)) { if (ATy->getNumElements() != cast(Ty2)->getNumElements()) return false; - } else if (const MethodType *MTy = dyn_cast(Ty)) { - if (MTy->isVarArg() != cast(Ty2)->isVarArg()) + } else if (const FunctionType *MTy = dyn_cast(Ty)) { + if (MTy->isVarArg() != cast(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 { +class FunctionValType : public ValTypeBase { PATypeHandle RetTy; vector > ArgTypes; bool isVarArg; public: - MethodValType(const Type *ret, const vector &args, - bool IVA, TypeMap &Tab) - : ValTypeBase(Tab), RetTy(ret, this), + FunctionValType(const Type *ret, const vector &args, + bool IVA, TypeMap &Tab) + : ValTypeBase(Tab), RetTy(ret, this), isVarArg(IVA) { for (unsigned i = 0; i < args.size(); ++i) ArgTypes.push_back(PATypeHandle(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(MVT), RetTy(MVT.RetTy, this), + FunctionValType(const FunctionValType &MVT) + : ValTypeBase(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 MethodTypes; +static TypeMap FunctionTypes; -// MethodType::get - The factory function for the MethodType class... -MethodType *MethodType::get(const Type *ReturnType, - const vector &Params, - bool isVarArg) { - MethodValType VT(ReturnType, Params, isVarArg, MethodTypes); - MethodType *MT = MethodTypes.get(VT); +// FunctionType::get - The factory function for the FunctionType class... +FunctionType *FunctionType::get(const Type *ReturnType, + const vector &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 {