diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index 6c2458d9d08..7a9acdab1dd 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -25,7 +25,7 @@ public: Parent = 0; } - // Specialize setName to handle symbol table majik... + /// setName - Specialize setName to handle symbol table majik... virtual void setName(const std::string &name, SymbolTable *ST = 0); inline const Function *getParent() const { return Parent; } @@ -39,7 +39,9 @@ public: virtual void print(std::ostream &OS) const; - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// classof - Methods for support type inquiry through isa, cast, and + /// dyn_cast: + /// static inline bool classof(const Argument *) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == ArgumentVal; diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 2ea5e6ad553..bf0e19d8026 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -1,20 +1,22 @@ //===-- llvm/BasicBlock.h - Represent a basic block in the VM ----*- C++ -*--=// -// -// This file contains the declaration of the BasicBlock class, which represents -// a single basic block in the VM. -// -// Note that basic blocks themselves are Value's, because they are referenced -// by instructions like branches and can go in switch tables and stuff... -// -//===----------------------------------------------------------------------===// -// -// Note that well formed basic blocks are formed of a list of instructions -// followed by a single TerminatorInst instruction. TerminatorInst's may not -// occur in the middle of basic blocks, and must terminate the blocks. -// -// This code allows malformed basic blocks to occur, because it may be useful -// in the intermediate stage of analysis or modification of a program. -// +/// +/// \class BasicBlock +/// +/// This file contains the declaration of the BasicBlock class, which represents +/// a single basic block in the VM. +/// +/// Note that basic blocks themselves are Value's, because they are referenced +/// by instructions like branches and can go in switch tables and stuff... +/// +///===---------------------------------------------------------------------===// +/// +/// Note that well formed basic blocks are formed of a list of instructions +/// followed by a single TerminatorInst instruction. TerminatorInst's may not +/// occur in the middle of basic blocks, and must terminate the blocks. +/// +/// This code allows malformed basic blocks to occur, because it may be useful +/// in the intermediate stage modification to a program. +/// //===----------------------------------------------------------------------===// #ifndef LLVM_BASICBLOCK_H @@ -74,10 +76,10 @@ public: BasicBlock *getPrev() { return Prev; } const BasicBlock *getPrev() const { return Prev; } - // getTerminator() - If this is a well formed basic block, then this returns - // a pointer to the terminator instruction. If it is not, then you get a null - // pointer back. - // + /// getTerminator() - If this is a well formed basic block, then this returns + /// a pointer to the terminator instruction. If it is not, then you get a + /// null pointer back. + /// TerminatorInst *getTerminator(); const TerminatorInst *const getTerminator() const; @@ -111,57 +113,57 @@ public: inline const Instruction &back() const { return InstList.back(); } inline Instruction &back() { return InstList.back(); } - // getInstList() - Return the underlying instruction list container. You need - // to access it directly if you want to modify it currently. - // + /// getInstList() - Return the underlying instruction list container. You + /// need to access it directly if you want to modify it currently. + /// const InstListType &getInstList() const { return InstList; } InstListType &getInstList() { return InstList; } virtual void print(std::ostream &OS) const; - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const BasicBlock *BB) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::BasicBlockVal; } - // hasConstantReferences() - This predicate is true if there is a - // reference to this basic block in the constant pool for this method. For - // example, if a block is reached through a switch table, that table resides - // in the constant pool, and the basic block is reference from it. - // + /// hasConstantReferences() - This predicate is true if there is a + /// reference to this basic block in the constant pool for this method. For + /// example, if a block is reached through a switch table, that table resides + /// in the constant pool, and the basic block is reference from it. + /// bool hasConstantReferences() const; - // dropAllReferences() - This function causes all the subinstructions to "let - // go" of all references that they are maintaining. This allows one to - // 'delete' a whole class at a time, even though there may be circular - // references... first all references are dropped, and all use counts go to - // zero. Then everything is delete'd for real. Note that no operations are - // valid on an object that has "dropped all references", except operator - // delete. - // + /// dropAllReferences() - This function causes all the subinstructions to "let + /// go" of all references that they are maintaining. This allows one to + /// 'delete' a whole class at a time, even though there may be circular + /// references... first all references are dropped, and all use counts go to + /// zero. Then everything is delete'd for real. Note that no operations are + /// valid on an object that has "dropped all references", except operator + /// delete. + /// void dropAllReferences(); - // removePredecessor - This method is used to notify a BasicBlock that the - // specified Predecessor of the block is no longer able to reach it. This is - // actually not used to update the Predecessor list, but is actually used to - // update the PHI nodes that reside in the block. Note that this should be - // called while the predecessor still refers to this block. - // + /// removePredecessor - This method is used to notify a BasicBlock that the + /// specified Predecessor of the block is no longer able to reach it. This is + /// actually not used to update the Predecessor list, but is actually used to + /// update the PHI nodes that reside in the block. Note that this should be + /// called while the predecessor still refers to this block. + /// void removePredecessor(BasicBlock *Pred); - // splitBasicBlock - This splits a basic block into two at the specified - // instruction. Note that all instructions BEFORE the specified iterator stay - // as part of the original basic block, an unconditional branch is added to - // the new BB, and the rest of the instructions in the BB are moved to the new - // BB, including the old terminator. The newly formed BasicBlock is returned. - // This function invalidates the specified iterator. - // - // Note that this only works on well formed basic blocks (must have a - // terminator), and 'I' must not be the end of instruction list (which would - // cause a degenerate basic block to be formed, having a terminator inside of - // the basic block). - // + /// splitBasicBlock - This splits a basic block into two at the specified + /// instruction. Note that all instructions BEFORE the specified iterator + /// stay as part of the original basic block, an unconditional branch is added + /// to the new BB, and the rest of the instructions in the BB are moved to the + /// new BB, including the old terminator. The newly formed BasicBlock is + /// returned. This function invalidates the specified iterator. + /// + /// Note that this only works on well formed basic blocks (must have a + /// terminator), and 'I' must not be the end of instruction list (which would + /// cause a degenerate basic block to be formed, having a terminator inside of + /// the basic block). + /// BasicBlock *splitBasicBlock(iterator I); }; diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index af46dbe15cf..708573874d6 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -16,40 +16,40 @@ protected: void destroyConstantImpl(); public: - // Specialize setName to handle symbol table majik... + /// setName - Specialize setName to handle symbol table majik... virtual void setName(const std::string &name, SymbolTable *ST = 0); - // Static constructor to get a '0' constant of arbitrary type... + /// Static constructor to get a '0' constant of arbitrary type... static Constant *getNullValue(const Type *Ty); - // isNullValue - Return true if this is the value that would be returned by - // getNullValue. + /// isNullValue - Return true if this is the value that would be returned by + /// getNullValue. virtual bool isNullValue() const = 0; virtual void print(std::ostream &O) const; - // isConstantExpr - Return true if this is a ConstantExpr + /// isConstantExpr - Return true if this is a ConstantExpr virtual bool isConstantExpr() const { return false; } - // destroyConstant - Called if some element of this constant is no longer - // valid. At this point only other constants may be on the use_list for this - // constant. Any constants on our Use list must also be destroy'd. The - // implementation must be sure to remove the constant from the list of - // available cached constants. Implementations should call - // destroyConstantImpl as the last thing they do, to destroy all users and - // delete this. - // - // Note that this call is only valid on non-primitive constants: You cannot - // destroy an integer constant for example. This API is used to delete - // constants that have ConstantPointerRef's embeded in them when the module is - // deleted, and it is used by GlobalDCE to remove ConstantPointerRefs that are - // unneeded, allowing globals to be DCE'd. - // + /// destroyConstant - Called if some element of this constant is no longer + /// valid. At this point only other constants may be on the use_list for this + /// constant. Any constants on our Use list must also be destroy'd. The + /// implementation must be sure to remove the constant from the list of + /// available cached constants. Implementations should call + /// destroyConstantImpl as the last thing they do, to destroy all users and + /// delete this. + /// + /// Note that this call is only valid on non-primitive constants: You cannot + /// destroy an integer constant for example. This API is used to delete + /// constants that have ConstantPointerRef's embeded in them when the module + /// is deleted, and it is used by GlobalDCE to remove ConstantPointerRefs that + /// are unneeded, allowing globals to be DCE'd. + /// virtual void destroyConstant() { assert(0 && "Not reached!"); } - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Constant *) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::ConstantVal; diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 66a372e711b..81dcf825127 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -77,8 +77,10 @@ public: const Type *getReturnType() const; // Return the type of the ret val const FunctionType *getFunctionType() const; // Return the FunctionType for me - // Is the body of this function unknown? (the basic block list is empty if so) - // this is true for external functions, defined as forward "declare"ations + /// isExternal - Is the body of this function unknown? (the basic block list + /// is empty if so) this is true for external functions, defined as forward + /// "declare"ations + /// bool isExternal() const { return BasicBlocks.empty(); } // getNext/Prev - Return the next or previous instruction in the list. The @@ -88,9 +90,9 @@ public: Function *getPrev() { return Prev; } const Function *getPrev() const { return Prev; } - // Get the underlying elements of the Function... both the argument list and - // basic block list are empty for external functions. - // + /// Get the underlying elements of the Function... both the argument list and + /// basic block list are empty for external functions. + /// const ArgumentListType &getArgumentList() const { return ArgumentList; } ArgumentListType &getArgumentList() { return ArgumentList; } @@ -103,21 +105,21 @@ public: //===--------------------------------------------------------------------===// // Symbol Table Accessing functions... - // hasSymbolTable() - Returns true if there is a symbol table allocated to - // this object AND if there is at least one name in it! - // + /// hasSymbolTable() - Returns true if there is a symbol table allocated to + /// this object AND if there is at least one name in it! + /// bool hasSymbolTable() const; - // CAUTION: The current symbol table may be null if there are no names (ie, - // the symbol table is empty) - // + /// getSymbolTable() - CAUTION: The current symbol table may be null if there + /// are no names (ie, the symbol table is empty) + /// inline SymbolTable *getSymbolTable() { return SymTab; } inline const SymbolTable *getSymbolTable() const { return SymTab; } - // getSymbolTableSure is guaranteed to not return a null pointer, because if - // the function does not already have a symtab, one is created. Use this if - // you intend to put something into the symbol table for the function. - // + /// getSymbolTableSure is guaranteed to not return a null pointer, because if + /// the function does not already have a symtab, one is created. Use this if + /// you intend to put something into the symbol table for the function. + /// SymbolTable *getSymbolTableSure(); // Implemented in Value.cpp @@ -163,20 +165,20 @@ public: virtual void print(std::ostream &OS) const; - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Function *) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::FunctionVal; } - // dropAllReferences() - This function causes all the subinstructions to "let - // go" of all references that they are maintaining. This allows one to - // 'delete' a whole class at a time, even though there may be circular - // references... first all references are dropped, and all use counts go to - // zero. Then everything is delete'd for real. Note that no operations are - // valid on an object that has "dropped all references", except operator - // delete. - // + /// dropAllReferences() - This function causes all the subinstructions to "let + /// go" of all references that they are maintaining. This allows one to + /// 'delete' a whole class at a time, even though there may be circular + /// references... first all references are dropped, and all use counts go to + /// zero. Then everything is delete'd for real. Note that no operations are + /// valid on an object that has "dropped all references", except operator + /// delete. + /// void dropAllReferences(); }; diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index ccce21a8398..22039a9a011 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -15,9 +15,9 @@ // TerminatorInst Class //===----------------------------------------------------------------------===// -// TerminatorInst - Subclasses of this class are all able to terminate a basic -// block. Thus, these are all the flow control type of operations. -// +/// TerminatorInst - Subclasses of this class are all able to terminate a basic +/// block. Thus, these are all the flow control type of operations. +/// class TerminatorInst : public Instruction { protected: TerminatorInst(Instruction::TermOps iType); @@ -25,17 +25,17 @@ protected: const std::string &Name = ""); public: - // Terminators must implement the methods required by Instruction... + /// Terminators must implement the methods required by Instruction... virtual Instruction *clone() const = 0; - // Additionally, they must provide a method to get at the successors of this - // terminator instruction. 'idx' may not be >= the number of successors - // returned by getNumSuccessors()! - // + /// Additionally, they must provide a method to get at the successors of this + /// terminator instruction. 'idx' may not be >= the number of successors + /// returned by getNumSuccessors()! + /// virtual const BasicBlock *getSuccessor(unsigned idx) const = 0; virtual unsigned getNumSuccessors() const = 0; - // Set a successor at a given index + /// Set a successor at a given index virtual void setSuccessor(unsigned idx, BasicBlock *B) = 0; inline BasicBlock *getSuccessor(unsigned idx) { @@ -71,29 +71,29 @@ protected: public: - // create() - Construct a binary instruction, given the opcode - // and the two operands. - // + /// create() - Construct a binary instruction, given the opcode + /// and the two operands. + /// static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, const std::string &Name = ""); - // Helper functions to construct and inspect unary operations (NEG and NOT) - // via binary operators SUB and XOR: - // - // createNeg, createNot - Create the NEG and NOT - // instructions out of SUB and XOR instructions. - // - // isNeg, isNot - Check if the given Value is a NEG or NOT instruction. - // - // getNegArgument, getNotArgument - Helper functions to extract the - // unary argument of a NEG or NOT operation implemented via Sub or Xor. - // + /// Helper functions to construct and inspect unary operations (NEG and NOT) + /// via binary operators SUB and XOR: + /// + /// createNeg, createNot - Create the NEG and NOT + /// instructions out of SUB and XOR instructions. + /// static BinaryOperator *createNeg(Value *Op, const std::string &Name = ""); static BinaryOperator *createNot(Value *Op, const std::string &Name = ""); + /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction. + /// static bool isNeg(const Value *V); static bool isNot(const Value *V); + /// getNegArgument, getNotArgument - Helper functions to extract the + /// unary argument of a NEG or NOT operation implemented via Sub or Xor. + /// static const Value* getNegArgument(const BinaryOperator* Bop); static Value* getNegArgument( BinaryOperator* Bop); static const Value* getNotArgument(const BinaryOperator* Bop); @@ -107,13 +107,13 @@ public: return create(getOpcode(), Operands[0], Operands[1]); } - // swapOperands - Exchange the two operands to this instruction. - // This instruction is safe to use on any binary instruction and - // does not modify the semantics of the instruction. If the - // instruction is order dependant (SetLT f.e.) the opcode is - // changed. If the instruction cannot be reversed (ie, it's a Div), - // then return true. - // + /// swapOperands - Exchange the two operands to this instruction. + /// This instruction is safe to use on any binary instruction and + /// does not modify the semantics of the instruction. If the + /// instruction is order dependant (SetLT f.e.) the opcode is + /// changed. If the instruction cannot be reversed (ie, it's a Div), + /// then return true. + /// bool swapOperands(); // Methods for support type inquiry through isa, cast, and dyn_cast: diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index d2804ab7041..805371bd157 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -34,11 +34,11 @@ public: // Specialize setName to handle symbol table majik... virtual void setName(const std::string &name, SymbolTable *ST = 0); - // clone() - Create a copy of 'this' instruction that is identical in all ways - // except the following: - // * The instruction has no parent - // * The instruction has no name - // + /// clone() - Create a copy of 'this' instruction that is identical in all + /// ways except the following: + /// * The instruction has no parent + /// * The instruction has no name + /// virtual Instruction *clone() const = 0; // Accessor methods... @@ -56,9 +56,9 @@ public: virtual bool hasSideEffects() const { return false; } // Memory & Call insts // --------------------------------------------------------------------------- - // Subclass classification... getOpcode() returns a member of - // one of the enums that is coming soon (down below)... - // + /// Subclass classification... getOpcode() returns a member of + /// one of the enums that is coming soon (down below)... + /// unsigned getOpcode() const { return iType; } virtual const char *getOpcodeName() const { return getOpcodeName(getOpcode()); @@ -74,7 +74,7 @@ public: virtual void print(std::ostream &OS) const; - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Instruction *I) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::InstructionVal; diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 3496e71616b..b34c06b9f57 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -69,28 +69,28 @@ public: Module(); ~Module(); - // getOrInsertFunction - Look up the specified function in the module symbol - // table. If it does not exist, add a prototype for the function and return - // it. + /// getOrInsertFunction - Look up the specified function in the module symbol + /// table. If it does not exist, add a prototype for the function and return + /// it. Function *getOrInsertFunction(const std::string &Name, const FunctionType *T); - // getFunction - Look up the specified function in the module symbol table. - // If it does not exist, return null. - // + /// getFunction - Look up the specified function in the module symbol table. + /// If it does not exist, return null. + /// Function *getFunction(const std::string &Name, const FunctionType *Ty); - // addTypeName - Insert an entry in the symbol table mapping Str to Type. If - // there is already an entry for this name, true is returned and the symbol - // table is not modified. - // + /// addTypeName - Insert an entry in the symbol table mapping Str to Type. If + /// there is already an entry for this name, true is returned and the symbol + /// table is not modified. + /// bool addTypeName(const std::string &Name, const Type *Ty); - // getTypeName - If there is at least one entry in the symbol table for the - // specified type, return it. - // + /// getTypeName - If there is at least one entry in the symbol table for the + /// specified type, return it. + /// std::string getTypeName(const Type *Ty); - // Get the underlying elements of the Module... + /// Get the underlying elements of the Module... inline const GlobalListType &getGlobalList() const { return GlobalList; } inline GlobalListType &getGlobalList() { return GlobalList; } inline const FunctionListType &getFunctionList() const { return FunctionList;} @@ -100,21 +100,21 @@ public: //===--------------------------------------------------------------------===// // Symbol table support functions... - // hasSymbolTable() - Returns true if there is a symbol table allocated to - // this object AND if there is at least one name in it! - // + /// hasSymbolTable() - Returns true if there is a symbol table allocated to + /// this object AND if there is at least one name in it! + /// bool hasSymbolTable() const; - // CAUTION: The current symbol table may be null if there are no names (ie, - // the symbol table is empty) - // + /// getSymbolTable() - CAUTION: The current symbol table may be null if there + /// are no names (ie, the symbol table is empty) + /// inline SymbolTable *getSymbolTable() { return SymTab; } inline const SymbolTable *getSymbolTable() const { return SymTab; } - - // getSymbolTableSure is guaranteed to not return a null pointer, because if - // the method does not already have a symtab, one is created. Use this if - // you intend to put something into the symbol table for the method. - // + + /// getSymbolTableSure is guaranteed to not return a null pointer, because if + /// the method does not already have a symtab, one is created. Use this if + /// you intend to put something into the symbol table for the method. + /// SymbolTable *getSymbolTableSure(); @@ -160,14 +160,14 @@ public: void print(std::ostream &OS) const; void dump() const; - // dropAllReferences() - This function causes all the subinstructions to "let - // go" of all references that they are maintaining. This allows one to - // 'delete' a whole class at a time, even though there may be circular - // references... first all references are dropped, and all use counts go to - // zero. Then everything is delete'd for real. Note that no operations are - // valid on an object that has "dropped all references", except operator - // delete. - // + /// dropAllReferences() - This function causes all the subinstructions to "let + /// go" of all references that they are maintaining. This allows one to + /// 'delete' a whole class at a time, even though there may be circular + /// references... first all references are dropped, and all use counts go to + /// zero. Then everything is delete'd for real. Note that no operations are + /// valid on an object that has "dropped all references", except operator + /// delete. + /// void dropAllReferences(); }; diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index eaa8fda71c2..e717b1971ca 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -39,10 +39,10 @@ struct AnalysisResolver; typedef const PassInfo* AnalysisID; //===----------------------------------------------------------------------===// -// Pass interface - Implemented by all 'passes'. Subclass this if you are an -// interprocedural optimization or you do not fit into any of the more -// constrained passes described below. -// +/// Pass interface - Implemented by all 'passes'. Subclass this if you are an +/// interprocedural optimization or you do not fit into any of the more +/// constrained passes described below. +/// class Pass { friend class AnalysisResolver; AnalysisResolver *Resolver; // AnalysisResolver this pass is owned by... @@ -53,56 +53,56 @@ public: Pass() : Resolver(0), PassInfoCache(0) {} virtual ~Pass() {} // Destructor is virtual so we can be subclassed - // getPassName - Return a nice clean name for a pass. This usually - // implemented in terms of the name that is registered by one of the - // Registration templates, but can be overloaded directly, and if nothing else - // is available, C++ RTTI will be consulted to get a SOMEWHAT intelligable - // name for the pass. - // + /// getPassName - Return a nice clean name for a pass. This usually + /// implemented in terms of the name that is registered by one of the + /// Registration templates, but can be overloaded directly, and if nothing + /// else is available, C++ RTTI will be consulted to get a SOMEWHAT + /// intelligable name for the pass. + /// virtual const char *getPassName() const; - // getPassInfo - Return the PassInfo data structure that corresponds to this - // pass... If the pass has not been registered, this will return null. - // + /// getPassInfo - Return the PassInfo data structure that corresponds to this + /// pass... If the pass has not been registered, this will return null. + /// const PassInfo *getPassInfo() const; - // run - Run this pass, returning true if a modification was made to the - // module argument. This should be implemented by all concrete subclasses. - // + /// run - Run this pass, returning true if a modification was made to the + /// module argument. This should be implemented by all concrete subclasses. + /// virtual bool run(Module &M) = 0; - // print - Print out the internal state of the pass. This is called by - // Analyze to print out the contents of an analysis. Otherwise it is not - // neccesary to implement this method. Beware that the module pointer MAY be - // null. This automatically forwards to a virtual function that does not - // provide the Module* in case the analysis doesn't need it it can just be - // ignored. - // + /// print - Print out the internal state of the pass. This is called by + /// Analyze to print out the contents of an analysis. Otherwise it is not + /// neccesary to implement this method. Beware that the module pointer MAY be + /// null. This automatically forwards to a virtual function that does not + /// provide the Module* in case the analysis doesn't need it it can just be + /// ignored. + /// virtual void print(std::ostream &O, const Module *M) const { print(O); } virtual void print(std::ostream &O) const; void dump() const; // dump - call print(std::cerr, 0); - // getAnalysisUsage - This function should be overriden by passes that need - // analysis information to do their job. If a pass specifies that it uses a - // particular analysis result to this function, it can then use the - // getAnalysis() function, below. - // + /// getAnalysisUsage - This function should be overriden by passes that need + /// analysis information to do their job. If a pass specifies that it uses a + /// particular analysis result to this function, it can then use the + /// getAnalysis() function, below. + /// virtual void getAnalysisUsage(AnalysisUsage &Info) const { // By default, no analysis results are used, all are invalidated. } - // releaseMemory() - This member can be implemented by a pass if it wants to - // be able to release its memory when it is no longer needed. The default - // behavior of passes is to hold onto memory for the entire duration of their - // lifetime (which is the entire compile time). For pipelined passes, this - // is not a big deal because that memory gets recycled every time the pass is - // invoked on another program unit. For IP passes, it is more important to - // free memory when it is unused. - // - // Optionally implement this function to release pass memory when it is no - // longer used. - // + /// releaseMemory() - This member can be implemented by a pass if it wants to + /// be able to release its memory when it is no longer needed. The default + /// behavior of passes is to hold onto memory for the entire duration of their + /// lifetime (which is the entire compile time). For pipelined passes, this + /// is not a big deal because that memory gets recycled every time the pass is + /// invoked on another program unit. For IP passes, it is more important to + /// free memory when it is unused. + /// + /// Optionally implement this function to release pass memory when it is no + /// longer used. + /// virtual void releaseMemory() {} // dumpPassStructure - Implement the -debug-passes=PassStructure option @@ -121,10 +121,10 @@ public: protected: - // getAnalysis() - This function is used by subclasses to get to - // the analysis information that they claim to use by overriding the - // getAnalysisUsage function. - // + /// getAnalysis() - This function is used by subclasses to get + /// to the analysis information that they claim to use by overriding the + /// getAnalysisUsage function. + /// template AnalysisType &getAnalysis() { assert(Resolver && "Pass has not been inserted into a PassManager object!"); @@ -149,12 +149,12 @@ protected: return *(AnalysisType*)Resolver->getAnalysis(PI); } - // getAnalysisToUpdate() - This function is used by subclasses - // to get to the analysis information that might be around that needs to be - // updated. This is different than getAnalysis in that it can fail (ie the - // analysis results haven't been computed), so should only be used if you - // provide the capability to update an analysis that exists. - // + /// getAnalysisToUpdate() - This function is used by subclasses + /// to get to the analysis information that might be around that needs to be + /// updated. This is different than getAnalysis in that it can fail (ie the + /// analysis results haven't been computed), so should only be used if you + /// provide the capability to update an analysis that exists. + /// template AnalysisType *getAnalysisToUpdate() { assert(Resolver && "Pass not resident in a PassManager object!"); @@ -176,37 +176,38 @@ inline std::ostream &operator<<(std::ostream &OS, const Pass &P) { } //===----------------------------------------------------------------------===// -// FunctionPass class - This class is used to implement most global -// optimizations. Optimizations should subclass this class if they meet the -// following constraints: -// -// 1. Optimizations are organized globally, ie a function at a time -// 2. Optimizing a function does not cause the addition or removal of any -// functions in the module -// +/// FunctionPass class - This class is used to implement most global +/// optimizations. Optimizations should subclass this class if they meet the +/// following constraints: +/// +/// 1. Optimizations are organized globally, ie a function at a time +/// 2. Optimizing a function does not cause the addition or removal of any +/// functions in the module +/// struct FunctionPass : public Pass { - // doInitialization - Virtual method overridden by subclasses to do - // any neccesary per-module initialization. - // + /// doInitialization - Virtual method overridden by subclasses to do + /// any neccesary per-module initialization. + /// virtual bool doInitialization(Module &M) { return false; } - // runOnFunction - Virtual method overriden by subclasses to do the - // per-function processing of the pass. - // + /// runOnFunction - Virtual method overriden by subclasses to do the + /// per-function processing of the pass. + /// virtual bool runOnFunction(Function &F) = 0; - // doFinalization - Virtual method overriden by subclasses to do any post - // processing needed after all passes have run. - // + /// doFinalization - Virtual method overriden by subclasses to do any post + /// processing needed after all passes have run. + /// virtual bool doFinalization(Module &M) { return false; } - // run - On a module, we run this pass by initializing, ronOnFunction'ing once - // for every function in the module, then by finalizing. - // + /// run - On a module, we run this pass by initializing, ronOnFunction'ing + /// once for every function in the module, then by finalizing. + /// virtual bool run(Module &M); - // run - On a function, we simply initialize, run the function, then finalize. - // + /// run - On a function, we simply initialize, run the function, then + /// finalize. + /// bool run(Function &F); private: @@ -220,29 +221,29 @@ private: //===----------------------------------------------------------------------===// -// BasicBlockPass class - This class is used to implement most local -// optimizations. Optimizations should subclass this class if they -// meet the following constraints: -// 1. Optimizations are local, operating on either a basic block or -// instruction at a time. -// 2. Optimizations do not modify the CFG of the contained function, or any -// other basic block in the function. -// 3. Optimizations conform to all of the contstraints of FunctionPass's. -// +/// BasicBlockPass class - This class is used to implement most local +/// optimizations. Optimizations should subclass this class if they +/// meet the following constraints: +/// 1. Optimizations are local, operating on either a basic block or +/// instruction at a time. +/// 2. Optimizations do not modify the CFG of the contained function, or any +/// other basic block in the function. +/// 3. Optimizations conform to all of the contstraints of FunctionPass's. +/// struct BasicBlockPass : public FunctionPass { - // runOnBasicBlock - Virtual method overriden by subclasses to do the - // per-basicblock processing of the pass. - // + /// runOnBasicBlock - Virtual method overriden by subclasses to do the + /// per-basicblock processing of the pass. + /// virtual bool runOnBasicBlock(BasicBlock &BB) = 0; - // To run this pass on a function, we simply call runOnBasicBlock once for - // each function. - // + /// To run this pass on a function, we simply call runOnBasicBlock once for + /// each function. + /// virtual bool runOnFunction(Function &F); - // To run directly on the basic block, we initialize, runOnBasicBlock, then - // finalize. - // + /// To run directly on the basic block, we initialize, runOnBasicBlock, then + /// finalize. + /// bool run(BasicBlock &BB); private: diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index c012379b5ad..ae603b1828d 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -20,16 +20,16 @@ public: PassManager(); ~PassManager(); - // add - Add a pass to the queue of passes to run. This passes ownership of - // the Pass to the PassManager. When the PassManager is destroyed, the pass - // will be destroyed as well, so there is no need to delete the pass. This - // implies that all passes MUST be allocated with 'new'. - // + /// add - Add a pass to the queue of passes to run. This passes ownership of + /// the Pass to the PassManager. When the PassManager is destroyed, the pass + /// will be destroyed as well, so there is no need to delete the pass. This + /// implies that all passes MUST be allocated with 'new'. + /// void add(Pass *P); - // run - Execute all of the passes scheduled for execution. Keep track of - // whether any of the functions modifies the program, and if so, return true. - // + /// run - Execute all of the passes scheduled for execution. Keep track of + /// whether any of the functions modifies the program, and if so, return true. + /// bool run(Module &M); }; diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 8cb4b581fcf..a86c220382f 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -39,12 +39,12 @@ class OpaqueType; class Type : public Value { public: - //===--------------------------------------------------------------------===// - // Definitions of all of the base types for the Type system. Based on this - // value, you can cast to a "DerivedType" subclass (see DerivedTypes.h) - // Note: If you add an element to this, you need to add an element to the - // Type::getPrimitiveType function, or else things will break! - // + ///===-------------------------------------------------------------------===// + /// Definitions of all of the base types for the Type system. Based on this + /// value, you can cast to a "DerivedType" subclass (see DerivedTypes.h) + /// Note: If you add an element to this, you need to add an element to the + /// Type::getPrimitiveType function, or else things will break! + /// enum PrimitiveID { VoidTyID = 0 , BoolTyID, // 0, 1: Basics... UByteTyID , SByteTyID, // 2, 3: 8 bit types... @@ -77,106 +77,107 @@ private: bool Recursive; // True if the type is recursive protected: - // ctor is protected, so only subclasses can create Type objects... + /// ctor is protected, so only subclasses can create Type objects... Type(const std::string &Name, PrimitiveID id); virtual ~Type() {} - // When types are refined, they update their description to be more concrete. - // + /// When types are refined, they update their description to be more concrete. + /// inline void setDescription(const std::string &D) { Desc = D; } - // setName - Associate the name with this type in the symbol table, but don't - // set the local name to be equal specified name. - // + /// setName - Associate the name with this type in the symbol table, but don't + /// set the local name to be equal specified name. + /// virtual void setName(const std::string &Name, SymbolTable *ST = 0); - // Types can become nonabstract later, if they are refined. - // + /// Types can become nonabstract later, if they are refined. + /// inline void setAbstract(bool Val) { Abstract = Val; } - // Types can become recursive later, if they are refined. - // + /// Types can become recursive later, if they are refined. + /// inline void setRecursive(bool Val) { Recursive = Val; } public: virtual void print(std::ostream &O) const; //===--------------------------------------------------------------------===// - // Property accessors for dealing with types... + // Property accessors for dealing with types... Some of these virtual methods + // are defined in private classes defined in Type.cpp for primitive types. // - // getPrimitiveID - Return the base type of the type. This will return one - // of the PrimitiveID enum elements defined above. - // + /// getPrimitiveID - Return the base type of the type. This will return one + /// of the PrimitiveID enum elements defined above. + /// inline PrimitiveID getPrimitiveID() const { return ID; } - // getUniqueID - Returns the UID of the type. This can be thought of as a - // small integer version of the pointer to the type class. Two types that are - // structurally different have different UIDs. This can be used for indexing - // types into an array. - // + /// getUniqueID - Returns the UID of the type. This can be thought of as a + /// small integer version of the pointer to the type class. Two types that + /// are structurally different have different UIDs. This can be used for + /// indexing types into an array. + /// inline unsigned getUniqueID() const { return UID; } - // getDescription - Return the string representation of the type... + /// getDescription - Return the string representation of the type... inline const std::string &getDescription() const { return Desc; } - // isSigned - Return whether a numeric type is signed. + /// isSigned - Return whether a numeric type is signed. virtual bool isSigned() const { return 0; } - // isUnsigned - Return whether a numeric type is unsigned. This is not - // quite the complement of isSigned... nonnumeric types return false as they - // do with isSigned. - // + /// isUnsigned - Return whether a numeric type is unsigned. This is not + /// quite the complement of isSigned... nonnumeric types return false as they + /// do with isSigned. + /// virtual bool isUnsigned() const { return 0; } - // isIntegral - Equilivent to isSigned() || isUnsigned, but with only a single - // virtual function invocation. - // + /// isIntegral - Equilivent to isSigned() || isUnsigned, but with only a + /// single virtual function invocation. + /// virtual bool isIntegral() const { return 0; } - // isFloatingPoint - Return true if this is one of the two floating point - // types + /// isFloatingPoint - Return true if this is one of the two floating point + /// types bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID; } - // isAbstract - True if the type is either an Opaque type, or is a derived - // type that includes an opaque type somewhere in it. - // + /// isAbstract - True if the type is either an Opaque type, or is a derived + /// type that includes an opaque type somewhere in it. + /// inline bool isAbstract() const { return Abstract; } - // isRecursive - True if the type graph contains a cycle. - // + /// isRecursive - True if the type graph contains a cycle. + /// inline bool isRecursive() const { return Recursive; } - // isLosslesslyConvertableTo - Return true if this type can be converted to - // 'Ty' without any reinterpretation of bits. For example, uint to int. - // + /// isLosslesslyConvertableTo - Return true if this type can be converted to + /// 'Ty' without any reinterpretation of bits. For example, uint to int. + /// bool isLosslesslyConvertableTo(const Type *Ty) const; - // Here are some useful little methods to query what type derived types are - // Note that all other types can just compare to see if this == Type::xxxTy; - // + /// Here are some useful little methods to query what type derived types are + /// Note that all other types can just compare to see if this == Type::xxxTy; + /// inline bool isPrimitiveType() const { return ID < FirstDerivedTyID; } inline bool isDerivedType() const { return ID >= FirstDerivedTyID; } - // isFirstClassType - Return true if the value is holdable in a register. + /// isFirstClassType - Return true if the value is holdable in a register. inline bool isFirstClassType() const { return isPrimitiveType() || ID == PointerTyID; } - // isSized - Return true if it makes sense to take the size of this type. To - // get the actual size for a particular target, it is reasonable to use the - // TargetData subsystem to do this. - // + /// isSized - Return true if it makes sense to take the size of this type. To + /// get the actual size for a particular target, it is reasonable to use the + /// TargetData subsystem to do this. + /// bool isSized() const { return ID != VoidTyID && ID != TypeTyID && ID != FunctionTyID && ID != LabelTyID && ID != OpaqueTyID; } - // getPrimitiveSize - Return the basic size of this type if it is a primative - // type. These are fixed by LLVM and are not target dependant. This will - // return zero if the type does not have a size or is not a primitive type. - // + /// getPrimitiveSize - Return the basic size of this type if it is a primative + /// type. These are fixed by LLVM and are not target dependant. This will + /// return zero if the type does not have a size or is not a primitive type. + /// unsigned getPrimitiveSize() const; @@ -188,15 +189,15 @@ public: inline subtype_iterator subtype_begin() const; // DEFINED BELOW inline subtype_iterator subtype_end() const; // DEFINED BELOW - // getContainedType - This method is used to implement the type iterator - // (defined a the end of the file). For derived types, this returns the types - // 'contained' in the derived type, returning 0 when 'i' becomes invalid. This - // allows the user to iterate over the types in a struct, for example, really - // easily. - // + /// getContainedType - This method is used to implement the type iterator + /// (defined a the end of the file). For derived types, this returns the + /// types 'contained' in the derived type, returning 0 when 'i' becomes + /// invalid. This allows the user to iterate over the types in a struct, for + /// example, really easily. + /// virtual const Type *getContainedType(unsigned i) const { return 0; } - // getNumContainedTypes - Return the number of types in the derived type + /// getNumContainedTypes - Return the number of types in the derived type virtual unsigned getNumContainedTypes() const { return 0; } //===--------------------------------------------------------------------===// @@ -204,7 +205,7 @@ public: // instances of Type. // - // getPrimitiveType/getUniqueIDType - Return a type based on an identifier. + /// getPrimitiveType/getUniqueIDType - Return a type based on an identifier. static const Type *getPrimitiveType(PrimitiveID IDNumber); static const Type *getUniqueIDType(unsigned UID); @@ -220,7 +221,7 @@ public: static Type *TypeTy , *LabelTy; - // Methods for support type inquiry through isa, cast, and dyn_cast: + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Type *T) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::TypeVal; diff --git a/include/llvm/User.h b/include/llvm/User.h index e78d21bbca0..e9dea8bcbff 100644 --- a/include/llvm/User.h +++ b/include/llvm/User.h @@ -59,9 +59,9 @@ public: Operands.clear(); } - // replaceUsesOfWith - Replaces all references to the "From" definition with - // references to the "To" definition. (defined in Value.cpp) - // + /// replaceUsesOfWith - Replaces all references to the "From" definition with + /// references to the "To" definition. + /// void replaceUsesOfWith(Value *From, Value *To); // Methods for support type inquiry through isa, cast, and dyn_cast: diff --git a/include/llvm/Value.h b/include/llvm/Value.h index fdde5aed96e..6a39109f32a 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -31,6 +31,9 @@ class SymbolTable; // Value Class //===----------------------------------------------------------------------===// +/// Value - The base class of all values computed by a program that may be used +/// as operands to other values. +/// class Value : public Annotable, // Values are annotable public AbstractTypeUser { // Values use potentially abstract types public: @@ -58,13 +61,16 @@ public: Value(const Type *Ty, ValueTy vty, const std::string &name = ""); virtual ~Value(); - // Support for debugging + /// dump - Support for debugging, callable in GDB: V->dump() + // void dump() const; - // Implement operator<< on Value... + /// print - Implement operator<< on Value... + /// virtual void print(std::ostream &O) const = 0; - // All values can potentially be typed + /// All values are typed, get the type of this value. + /// inline const Type *getType() const { return Ty; } // All values can potentially be named... @@ -75,27 +81,20 @@ public: Name = name; } - // Methods for determining the subtype of this Value. The getValueType() - // method returns the type of the value directly. The cast*() methods are - // equivalent to using dynamic_cast<>... if the cast is successful, this is - // returned, otherwise you get a null pointer. - // - // The family of functions Val->castAsserting() is used in the same - // way as the Val->cast() instructions, but they assert the expected - // type instead of checking it at runtime. - // + /// getValueType - Return the immediate subclass of this Value. + /// inline ValueTy getValueType() const { return VTy; } - // replaceAllUsesWith - Go through the uses list for this definition and make - // each use point to "D" instead of "this". After this completes, 'this's - // use list should be empty. - // - void replaceAllUsesWith(Value *D); + /// replaceAllUsesWith - Go through the uses list for this definition and make + /// each use point to "V" instead of "this". After this completes, 'this's + /// use list is guaranteed to be empty. + /// + void replaceAllUsesWith(Value *V); - // refineAbstractType - This function is implemented because we use - // potentially abstract types, and these types may be resolved to more - // concrete types after we are constructed. - // + /// refineAbstractType - This function is implemented because we use + /// potentially abstract types, and these types may be resolved to more + /// concrete types after we are constructed. + /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); //----------------------------------------------------------------------