From 735f2700d691ad666ad9e50e4927bde1d3431d1e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 8 Jul 2004 22:30:50 +0000 Subject: [PATCH] Eliminate uses of the UniqueID field on Type objects git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14707 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/llvmAsmParser.y | 41 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 8c571f4d779..dbb4546b4f3 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -59,13 +59,13 @@ static bool ObsoleteVarArgs; // destroyed when the function is completed. // typedef std::vector ValueList; // Numbered defs -static void ResolveDefinitions(std::map &LateResolvers, - std::map *FutureLateResolvers = 0); +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers = 0); static struct PerModuleInfo { Module *CurrentModule; - std::map Values; // Module level numbered definitions - std::map LateResolveValues; + std::map Values; // Module level numbered definitions + std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; @@ -146,8 +146,8 @@ static struct PerModuleInfo { static struct PerFunctionInfo { Function *CurrentFunction; // Pointer to current function being created - std::map Values; // Keep track of numbered definitions - std::map LateResolveValues; + std::map Values; // Keep track of #'d definitions + std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; SymbolTable LocalSymtab; @@ -173,9 +173,8 @@ static struct PerFunctionInfo { if (CurrentFunction->hasName()) { FID = ValID::create((char*)CurrentFunction->getName().c_str()); } else { - unsigned Slot = CurrentFunction->getType()->getUniqueID(); // Figure out which slot number if is... - ValueList &List = CurModule.Values[Slot]; + ValueList &List = CurModule.Values[CurrentFunction->getType()]; for (unsigned i = 0; ; ++i) { assert(i < List.size() && "Function not found!"); if (List[i] == CurrentFunction) { @@ -201,15 +200,13 @@ static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } // Code to handle definitions of all the types //===----------------------------------------------------------------------===// -static int InsertValue(Value *D, - std::map &ValueTab = CurFun.Values) { - if (D->hasName()) return -1; // Is this a numbered definition? +static int InsertValue(Value *V, + std::map &ValueTab = CurFun.Values) { + if (V->hasName()) return -1; // Is this a numbered definition? // Yes, insert the value into the value table... - unsigned type = D->getType()->getUniqueID(); - //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D); - ValueList &List = ValueTab[type]; - List.push_back(D); + ValueList &List = ValueTab[V->getType()]; + List.push_back(V); return List.size()-1; } @@ -296,11 +293,10 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { switch (D.Type) { case ValID::NumberVal: { // Is it a numbered definition? - unsigned type = Ty->getUniqueID(); unsigned Num = (unsigned)D.Num; // Module constants occupy the lowest numbered slots... - std::map::iterator VI = CurModule.Values.find(type); + std::map::iterator VI = CurModule.Values.find(Ty); if (VI != CurModule.Values.end()) { if (Num < VI->second.size()) return VI->second[Num]; @@ -308,7 +304,7 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) { } // Make sure that our type is within bounds - VI = CurFun.Values.find(type); + VI = CurFun.Values.find(Ty); if (VI == CurFun.Values.end()) return 0; // Check that the number is within bounds... @@ -418,10 +414,10 @@ static Value *getVal(const Type *Ty, const ValID &D) { // time (forward branches, phi functions for loops, etc...) resolve the // defs now... // -static void ResolveDefinitions(std::map &LateResolvers, - std::map *FutureLateResolvers) { +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers) { // Loop over LateResolveDefs fixing up stuff that couldn't be resolved - for (std::map::iterator LRI = LateResolvers.begin(), + for (std::map::iterator LRI = LateResolvers.begin(), E = LateResolvers.end(); LRI != E; ++LRI) { ValueList &List = LRI->second; while (!List.empty()) { @@ -429,8 +425,7 @@ static void ResolveDefinitions(std::map &LateResolvers, List.pop_back(); ValID &DID = getValIDFromPlaceHolder(V); - Value *TheRealValue = - getValNonImprovising(Type::getUniqueIDType(LRI->first), DID); + Value *TheRealValue = getValNonImprovising(LRI->first, DID); if (TheRealValue) { V->replaceAllUsesWith(TheRealValue); delete V; -- 2.34.1