summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-mca/include/SourceMgr.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-mca/include/SourceMgr.h')
-rw-r--r--llvm/tools/llvm-mca/include/SourceMgr.h22
1 files changed, 7 insertions, 15 deletions
diff --git a/llvm/tools/llvm-mca/include/SourceMgr.h b/llvm/tools/llvm-mca/include/SourceMgr.h
index 89412836360..e7cd358afd4 100644
--- a/llvm/tools/llvm-mca/include/SourceMgr.h
+++ b/llvm/tools/llvm-mca/include/SourceMgr.h
@@ -27,7 +27,7 @@ typedef std::pair<unsigned, const llvm::MCInst &> SourceRef;
class SourceMgr {
llvm::ArrayRef<llvm::MCInst> Sequence;
unsigned Current;
- unsigned Iterations;
+ const unsigned Iterations;
static const unsigned DefaultIterations = 100;
public:
@@ -35,27 +35,19 @@ public:
: Sequence(MCInstSequence), Current(0),
Iterations(NumIterations ? NumIterations : DefaultIterations) {}
- unsigned getCurrentIteration() const { return Current / Sequence.size(); }
unsigned getNumIterations() const { return Iterations; }
unsigned size() const { return Sequence.size(); }
- llvm::ArrayRef<llvm::MCInst> getSequence() const { return Sequence; }
-
- bool hasNext() const { return Current < (Iterations * size()); }
- void updateNext() { Current++; }
+ bool hasNext() const { return Current < (Iterations * Sequence.size()); }
+ void updateNext() { ++Current; }
const SourceRef peekNext() const {
assert(hasNext() && "Already at end of sequence!");
- unsigned Index = getCurrentInstructionIndex();
- return SourceRef(Current, Sequence[Index]);
- }
-
- unsigned getCurrentInstructionIndex() const {
- return Current % Sequence.size();
+ return SourceRef(Current, Sequence[Current % Sequence.size()]);
}
- const llvm::MCInst &getMCInstFromIndex(unsigned Index) const {
- return Sequence[Index % size()];
- }
+ using const_iterator = llvm::ArrayRef<llvm::MCInst>::const_iterator;
+ const_iterator begin() const { return Sequence.begin(); }
+ const_iterator end() const { return Sequence.end(); }
bool isEmpty() const { return size() == 0; }
};
OpenPOWER on IntegriCloud