From 73e214244f2403b5ba0ef81b8839600f3c8ffebc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 9 Apr 2002 19:48:49 +0000 Subject: [PATCH] Move FunctionArgument out of iOther.h into Argument.h and rename class to be 'Argument' instead of FunctionArgument. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2216 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../DataStructure/FunctionRepBuilder.cpp | 18 ++++++++++-------- lib/Analysis/DataStructure/NodeImpl.cpp | 3 ++- lib/Analysis/Expressions.cpp | 2 +- lib/Analysis/InductionVariable.cpp | 2 +- lib/Bytecode/Reader/Reader.cpp | 3 ++- lib/Bytecode/Writer/SlotCalculator.cpp | 1 + lib/Bytecode/Writer/Writer.cpp | 2 +- lib/CodeGen/InstrSelection/InstrForest.cpp | 2 +- lib/Linker/LinkModules.cpp | 5 +++-- .../SparcV9/InstrSelection/InstrForest.cpp | 2 +- lib/Transforms/IPO/InlineSimple.cpp | 1 + lib/Transforms/IPO/MutateStructTypes.cpp | 6 +++--- lib/Transforms/IPO/OldPoolAllocate.cpp | 7 ++++--- lib/Transforms/Instrumentation/TraceValues.cpp | 2 +- lib/Transforms/Scalar/InductionVars.cpp | 2 +- lib/Transforms/Scalar/SCCP.cpp | 4 ++-- lib/Transforms/Utils/Linker.cpp | 5 +++-- lib/VMCore/AsmWriter.cpp | 17 +++++++++-------- lib/VMCore/Linker.cpp | 5 +++-- lib/VMCore/SlotCalculator.cpp | 1 + 20 files changed, 51 insertions(+), 39 deletions(-) diff --git a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp index 965185a3447..eda16bc6949 100644 --- a/lib/Analysis/DataStructure/FunctionRepBuilder.cpp +++ b/lib/Analysis/DataStructure/FunctionRepBuilder.cpp @@ -143,26 +143,28 @@ void FunctionRepBuilder::initializeWorkList(Function *Func) { // the worklists... // for (Function::ArgumentListType::iterator I = Func->getArgumentList().begin(), - E = Func->getArgumentList().end(); I != E; ++I) + E = Func->getArgumentList().end(); I != E; ++I) { + Value *Arg = (Value*)(*I); // Only process arguments that are of pointer type... - if (PointerType *PT = dyn_cast((*I)->getType())) { - ArgDSNode *Arg = new ArgDSNode(*I); - ArgNodes.push_back(Arg); + if (PointerType *PT = dyn_cast(Arg->getType())) { + ArgDSNode *ArgNode = new ArgDSNode(*I); + ArgNodes.push_back(ArgNode); // Add a critical shadow value for it to represent what it is pointing // to and add this to the value map... ShadowDSNode *Shad = new ShadowDSNode(PT->getElementType(), Func->getParent(), true); ShadowNodes.push_back(Shad); - ValueMap[*I].add(PointerVal(Shad), *I); + ValueMap[Arg].add(PointerVal(Shad), Arg); // The value of the argument is the shadow value... - Arg->getLink(0).add(Shad); + ArgNode->getLink(0).add(Shad); // Make sure that all users of the argument are processed... - addAllUsesToWorkList(*I); + addAllUsesToWorkList(Arg); } - + } + // Iterate over the instructions in the method. Create nodes for malloc and // call instructions. Add all uses of these to the worklist of instructions // to process. diff --git a/lib/Analysis/DataStructure/NodeImpl.cpp b/lib/Analysis/DataStructure/NodeImpl.cpp index 05ed8844ac6..6c986fe1db7 100644 --- a/lib/Analysis/DataStructure/NodeImpl.cpp +++ b/lib/Analysis/DataStructure/NodeImpl.cpp @@ -11,6 +11,7 @@ #include "llvm/BasicBlock.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" +#include "llvm/Argument.h" #include "Support/STLExtras.h" #include #include @@ -288,7 +289,7 @@ void CallDSNode::mapNode(map &NodeMap, MapPVS(ArgLinks[i], Old->ArgLinks[i], NodeMap); } -ArgDSNode::ArgDSNode(FunctionArgument *FA) +ArgDSNode::ArgDSNode(Argument *FA) : DSNode(ArgNode, FA->getType()), FuncArg(FA) { } diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 0f37c5fb7e6..e78fb1e690a 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -245,7 +245,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { std::cerr << "Bizarre thing to expr classify: " << Expr << "\n"; return Expr; case Value::GlobalVariableVal: // Global Variable & Function argument: - case Value::FunctionArgumentVal: // nothing known, return variable itself + case Value::ArgumentVal: // nothing known, return variable itself return Expr; case Value::ConstantVal: // Constant value, just return constant Constant *CPV = cast(Expr); diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 11d1a2c860e..155017480be 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -28,7 +28,7 @@ using analysis::ExprType; static bool isLoopInvariant(const Value *V, const cfg::Loop *L) { - if (isa(V) || isa(V) || isa(V)) + if (isa(V) || isa(V) || isa(V)) return true; const Instruction *I = cast(V); diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index d7c8af3de7d..fff2d02898c 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -19,6 +19,7 @@ #include "llvm/ConstantVals.h" #include "llvm/iPHINode.h" #include "llvm/iOther.h" +#include "llvm/Argument.h" #include #include #include @@ -280,7 +281,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf, const FunctionType::ParamTypes &Params = MTy->getParamTypes(); for (FunctionType::ParamTypes::const_iterator It = Params.begin(); It != Params.end(); ++It) { - FunctionArgument *FA = new FunctionArgument(*It); + Argument *FA = new Argument(*It); if (insertValue(FA, Values) == -1) { Error = "Error reading method arguments!\n"; delete M; return failure(true); diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 4a8312e6133..8bd0b494f47 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -19,6 +19,7 @@ #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" +#include "llvm/Argument.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" #include diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 0b883acd58a..ab22db3c7fb 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -73,7 +73,7 @@ void BytecodeWriter::outputConstants(bool isFunction) { ValNo = Type::FirstDerivedTyID; // Start emitting at the derived types... // Scan through and ignore function arguments... - for (; ValNo < Plane.size() && isa(Plane[ValNo]); ValNo++) + for (; ValNo < Plane.size() && isa(Plane[ValNo]); ValNo++) /*empty*/; unsigned NC = ValNo; // Number of constants diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index 95803cd1a40..e2f45a0285b 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -298,7 +298,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr) && !instr->isTerminator(); if (includeAddressOperand || isa(operand) || - isa(operand) || isa(operand) || + isa(operand) || isa(operand) || isa(operand)) { // This operand is a data value diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 9637f747e28..086c6c6b28f 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -18,6 +18,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include "llvm/Argument.h" #include using std::cerr; using std::string; @@ -301,10 +302,10 @@ static bool LinkFunctionBody(Function *Dest, const Function *Src, for (Function::ArgumentListType::const_iterator I = Src->getArgumentList().begin(), E = Src->getArgumentList().end(); I != E; ++I) { - const FunctionArgument *SMA = *I; + const Argument *SMA = *I; // Create the new method argument and add to the dest method... - FunctionArgument *DMA = new FunctionArgument(SMA->getType(),SMA->getName()); + Argument *DMA = new Argument(SMA->getType(), SMA->getName()); Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index 95803cd1a40..e2f45a0285b 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -298,7 +298,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr) && !instr->isTerminator(); if (includeAddressOperand || isa(operand) || - isa(operand) || isa(operand) || + isa(operand) || isa(operand) || isa(operand)) { // This operand is a data value diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 461f5974f4c..0a58eab83c7 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -23,6 +23,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Type.h" +#include "llvm/Argument.h" #include #include #include diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index e06ee614128..fcad5fa050b 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -22,6 +22,7 @@ #include "llvm/iMemory.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" +#include "llvm/Argument.h" #include "Support/STLExtras.h" #include using std::map; @@ -337,9 +338,8 @@ void MutateStructTypes::transformMethod(Function *m) { // Okay, first order of business, create the arguments... for (unsigned i = 0, e = M->getArgumentList().size(); i != e; ++i) { - const FunctionArgument *OFA = M->getArgumentList()[i]; - FunctionArgument *NFA = new FunctionArgument(ConvertType(OFA->getType()), - OFA->getName()); + const Argument *OFA = M->getArgumentList()[i]; + Argument *NFA = new Argument(ConvertType(OFA->getType()), OFA->getName()); NewMeth->getArgumentList().push_back(NFA); LocalValueMap[OFA] = NFA; // Keep track of value mapping } diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index 731e9e973f2..4b5c8308704 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -20,6 +20,7 @@ #include "llvm/ConstantVals.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/InstVisitor.h" +#include "llvm/Argument.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" #include @@ -677,8 +678,8 @@ void PoolAllocate::transformFunction(TransformFunctionInfo &TFI, // Add arguments to the function... starting with all of the old arguments vector ArgMap; for (unsigned i = 0, e = TFI.Func->getArgumentList().size(); i != e; ++i) { - const FunctionArgument *OFA = TFI.Func->getArgumentList()[i]; - FunctionArgument *NFA = new FunctionArgument(OFA->getType(),OFA->getName()); + const Argument *OFA = TFI.Func->getArgumentList()[i]; + Argument *NFA = new Argument(OFA->getType(), OFA->getName()); NewFunc->getArgumentList().push_back(NFA); ArgMap.push_back(NFA); // Keep track of the arguments } @@ -690,7 +691,7 @@ void PoolAllocate::transformFunction(TransformFunctionInfo &TFI, Name = "retpool"; else Name = ArgMap[TFI.ArgInfo[i].ArgNo]->getName(); // Get the arg name - FunctionArgument *NFA = new FunctionArgument(PoolTy, Name+".pool"); + Argument *NFA = new Argument(PoolTy, Name+".pool"); NewFunc->getArgumentList().push_back(NFA); } diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 7f7321dbf06..20ad1d8cc90 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -257,7 +257,7 @@ static inline void InsertCodeToShowFunctionEntry(Function *M, Function *Printf){ unsigned ArgNo = 0; for (Function::ArgumentListType::const_iterator I = argList.begin(), E = argList.end(); I != E; ++I, ++ArgNo) { - InsertVerbosePrintInst(*I, BB, BBI, + InsertVerbosePrintInst((Value*)*I, BB, BBI, " Arg #" + utostr(ArgNo), Printf); } } diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 55b227585be..9931a6b5d7a 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -37,7 +37,7 @@ using std::cerr; // an interval invariant computation. // static bool isLoopInvariant(cfg::Interval *Int, Value *V) { - assert(isa(V) || isa(V) || isa(V)); + assert(isa(V) || isa(V) || isa(V)); if (!isa(V)) return true; // Constants and arguments are always loop invariant diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index b569a5366e1..e6cf765e555 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -140,7 +140,7 @@ private: // getValueState - Return the InstVal object that corresponds to the value. // This function is neccesary because not all values should start out in the - // underdefined state... FunctionArgument's should be overdefined, and + // underdefined state... Argument's should be overdefined, and // constants should be marked as constants. If a value is not known to be an // Instruction object, then use this accessor to get its value from the map. // @@ -150,7 +150,7 @@ private: if (Constant *CPV = dyn_cast(V)) { // Constants are constant ValueState[CPV].markConstant(CPV); - } else if (isa(V)) { // FuncArgs are overdefined + } else if (isa(V)) { // Arguments are overdefined ValueState[V].markOverdefined(); } // All others are underdefined by default... diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index 9637f747e28..086c6c6b28f 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -18,6 +18,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include "llvm/Argument.h" #include using std::cerr; using std::string; @@ -301,10 +302,10 @@ static bool LinkFunctionBody(Function *Dest, const Function *Src, for (Function::ArgumentListType::const_iterator I = Src->getArgumentList().begin(), E = Src->getArgumentList().end(); I != E; ++I) { - const FunctionArgument *SMA = *I; + const Argument *SMA = *I; // Create the new method argument and add to the dest method... - FunctionArgument *DMA = new FunctionArgument(SMA->getType(),SMA->getName()); + Argument *DMA = new Argument(SMA->getType(), SMA->getName()); Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index e5f9114c8e1..6cdbf9def32 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -20,6 +20,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/SymbolTable.h" +#include "llvm/Argument.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" #include @@ -30,7 +31,7 @@ using std::vector; using std::ostream; static const Module *getModuleFromVal(const Value *V) { - if (const FunctionArgument *MA = dyn_cast(V)) + if (const Argument *MA = dyn_cast(V)) return MA->getParent() ? MA->getParent()->getParent() : 0; else if (const BasicBlock *BB = dyn_cast(V)) return BB->getParent() ? BB->getParent()->getParent() : 0; @@ -46,7 +47,7 @@ static const Module *getModuleFromVal(const Value *V) { static SlotCalculator *createSlotCalculator(const Value *V) { assert(!isa(V) && "Can't create an SC for a type!"); - if (const FunctionArgument *FA = dyn_cast(V)) { + if (const Argument *FA = dyn_cast(V)) { return new SlotCalculator(FA->getParent(), true); } else if (const Instruction *I = dyn_cast(V)) { return new SlotCalculator(I->getParent()->getParent(), true); @@ -286,7 +287,7 @@ private : void printConstant(const Constant *CPV); void printGlobal(const GlobalVariable *GV); void printFunction(const Function *F); - void printFunctionArgument(const FunctionArgument *FA); + void printArgument(const Argument *FA); void printBasicBlock(const BasicBlock *BB); void printInstruction(const Instruction *I); ostream &printType(const Type *Ty); @@ -397,7 +398,7 @@ void AssemblyWriter::printFunction(const Function *M) { if (!M->isExternal()) { for_each(M->getArgumentList().begin(), M->getArgumentList().end(), - bind_obj(this, &AssemblyWriter::printFunctionArgument)); + bind_obj(this, &AssemblyWriter::printArgument)); } else { // Loop over the arguments, printing them... const FunctionType *MT = M->getFunctionType(); @@ -432,10 +433,10 @@ void AssemblyWriter::printFunction(const Function *M) { Table.purgeFunction(); } -// printFunctionArgument - This member is called for every argument that +// printArgument - This member is called for every argument that // is passed into the function. Simply print it out // -void AssemblyWriter::printFunctionArgument(const FunctionArgument *Arg) { +void AssemblyWriter::printArgument(const Argument *Arg) { // Insert commas as we go... the first arg doesn't get a comma if (Arg != Arg->getParent()->getArgumentList().front()) Out << ", "; @@ -679,7 +680,7 @@ void Type::print(std::ostream &o) const { o << getDescription(); } -void FunctionArgument::print(std::ostream &o) const { +void Argument::print(std::ostream &o) const { o << getType() << " " << getName(); } @@ -710,7 +711,7 @@ CachedWriter &CachedWriter::operator<<(const Value *V) { case Value::ConstantVal: Out << " "; AW->write(V->getType()); Out << " " << cast(V)->getStrValue(); break; - case Value::FunctionArgumentVal: + case Value::ArgumentVal: AW->write(V->getType()); Out << " " << V->getName(); break; case Value::TypeVal: AW->write(cast(V)); break; case Value::InstructionVal: AW->write(cast(V)); break; diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index 9637f747e28..086c6c6b28f 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -18,6 +18,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include "llvm/Argument.h" #include using std::cerr; using std::string; @@ -301,10 +302,10 @@ static bool LinkFunctionBody(Function *Dest, const Function *Src, for (Function::ArgumentListType::const_iterator I = Src->getArgumentList().begin(), E = Src->getArgumentList().end(); I != E; ++I) { - const FunctionArgument *SMA = *I; + const Argument *SMA = *I; // Create the new method argument and add to the dest method... - FunctionArgument *DMA = new FunctionArgument(SMA->getType(),SMA->getName()); + Argument *DMA = new Argument(SMA->getType(), SMA->getName()); Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index 4a8312e6133..8bd0b494f47 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -19,6 +19,7 @@ #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" +#include "llvm/Argument.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" #include -- 2.34.1