-//==-- llvm/Analysis/ConstantsScanner.h - Iterate over constants -*- C++ -*-==//
+//==- llvm/Analysis/ConstantsScanner.h - Iterate over constants -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and 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
#ifndef LLVM_ANALYSIS_CONSTANTSSCANNER_H
#define LLVM_ANALYSIS_CONSTANTSSCANNER_H
-#include "llvm/Method.h"
+#include "llvm/Support/InstIterator.h"
#include "llvm/Instruction.h"
-#include <iterator>
+#include "llvm/ADT/iterator"
+
+namespace llvm {
+
class Constant;
-class constant_iterator
- : public std::forward_iterator<const Constant, ptrdiff_t> {
- Method::const_inst_iterator InstI; // Method instruction iterator
+class constant_iterator : public forward_iterator<const Constant, ptrdiff_t> {
+ const_inst_iterator InstI; // Method instruction iterator
unsigned OpIdx; // Operand index
typedef constant_iterator _Self;
}
public:
- inline constant_iterator(const Method *M) : InstI(M->inst_begin()), 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 != M->inst_end() && // InstI is valid?
+ 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(M->inst_end()), 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 &&
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