X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FConstantsScanner.h;h=bac551f0492ad764a30792b68baa71587335e323;hb=40a5a1b39ee1cd40ff9d04740386b667fb27b340;hp=1a850820020289a4f6c226095add79973869f01d;hpb=3c34a46c7e51ab290b208248461542eb83c469b0;p=oota-llvm.git diff --git a/include/llvm/Analysis/ConstantsScanner.h b/include/llvm/Analysis/ConstantsScanner.h index 1a850820020..bac551f0492 100644 --- a/include/llvm/Analysis/ConstantsScanner.h +++ b/include/llvm/Analysis/ConstantsScanner.h @@ -1,7 +1,14 @@ -//==-- llvm/Analysis/ConstantsScanner.h - Iterate over constants -*- C++ -*-==// +//==- llvm/Analysis/ConstantsScanner.h - Iterate over constants -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This class implements an iterator to walk through the constants referenced by -// a method. This is used by the Bytecode & Assembly writers to build constant +// a method. This is used by the Bitcode & Assembly writers to build constant // pools. // //===----------------------------------------------------------------------===// @@ -10,12 +17,13 @@ #define LLVM_ANALYSIS_CONSTANTSSCANNER_H #include "llvm/Support/InstIterator.h" -#include "llvm/Instruction.h" -#include +#include "llvm/ADT/iterator.h" + +namespace llvm { + class Constant; -class constant_iterator - : public std::forward_iterator { +class constant_iterator : public forward_iterator { const_inst_iterator InstI; // Method instruction iterator unsigned OpIdx; // Operand index @@ -23,24 +31,24 @@ class constant_iterator inline bool isAtConstant() const { assert(!InstI.atEnd() && OpIdx < InstI->getNumOperands() && - "isAtConstant called with invalid arguments!"); + "isAtConstant called with invalid arguments!"); return isa(InstI->getOperand(OpIdx)); } public: - inline constant_iterator(const Method *M) : InstI(inst_begin(M)), OpIdx(0) { + inline constant_iterator(const Function *F) : InstI(inst_begin(F)), OpIdx(0) { // Advance to first constant... if we are not already at constant or end - if (InstI != inst_end(M) && // InstI is valid? - (InstI->getNumOperands() == 0 || !isAtConstant())) // Not at constant? + if (InstI != inst_end(F) && // InstI is valid? + (InstI->getNumOperands() == 0 || !isAtConstant())) // Not at constant? operator++(); } - inline constant_iterator(const Method *M, bool) // end ctor - : InstI(inst_end(M)), OpIdx(0) { + inline constant_iterator(const Function *F, bool) // end ctor + : InstI(inst_end(F)), OpIdx(0) { } - inline bool operator==(const _Self& x) const { return OpIdx == x.OpIdx && - InstI == x.InstI; } + inline bool operator==(const _Self& x) const { return OpIdx == x.OpIdx && + InstI == x.InstI; } inline bool operator!=(const _Self& x) const { return !operator==(x); } inline pointer operator*() const { @@ -54,7 +62,7 @@ public: do { unsigned NumOperands = InstI->getNumOperands(); while (OpIdx < NumOperands && !isAtConstant()) { - ++OpIdx; + ++OpIdx; } if (OpIdx < NumOperands) return *this; // Found a constant! @@ -66,18 +74,20 @@ public: } inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; + _Self tmp = *this; ++*this; return tmp; } inline bool atEnd() const { return InstI.atEnd(); } }; -inline constant_iterator constant_begin(const Method *M) { - return constant_iterator(M); +inline constant_iterator constant_begin(const Function *F) { + return constant_iterator(F); } -inline constant_iterator constant_end(const Method *M) { - return constant_iterator(M, true); +inline constant_iterator constant_end(const Function *F) { + return constant_iterator(F, true); } +} // End llvm namespace + #endif