LLVM  8.0.1
SourceMgr.h
Go to the documentation of this file.
1 //===--------------------- SourceMgr.h --------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This file implements class SourceMgr. Class SourceMgr abstracts the input
11 /// code sequence (a sequence of MCInst), and assings unique identifiers to
12 /// every instruction in the sequence.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_MCA_SOURCEMGR_H
17 #define LLVM_MCA_SOURCEMGR_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 
21 namespace llvm {
22 namespace mca {
23 
25 
26 typedef std::pair<unsigned, const Instruction &> SourceRef;
27 
28 class SourceMgr {
29  using UniqueInst = std::unique_ptr<Instruction>;
30  ArrayRef<UniqueInst> Sequence;
31  unsigned Current;
32  const unsigned Iterations;
33  static const unsigned DefaultIterations = 100;
34 
35 public:
36  SourceMgr(ArrayRef<UniqueInst> S, unsigned Iter)
37  : Sequence(S), Current(0), Iterations(Iter ? Iter : DefaultIterations) {}
38 
39  unsigned getNumIterations() const { return Iterations; }
40  unsigned size() const { return Sequence.size(); }
41  bool hasNext() const { return Current < (Iterations * Sequence.size()); }
42  void updateNext() { ++Current; }
43 
44  SourceRef peekNext() const {
45  assert(hasNext() && "Already at end of sequence!");
46  return SourceRef(Current, *Sequence[Current % Sequence.size()]);
47  }
48 
50  const_iterator begin() const { return Sequence.begin(); }
51  const_iterator end() const { return Sequence.end(); }
52 };
53 
54 } // namespace mca
55 } // namespace llvm
56 
57 #endif // LLVM_MCA_SOURCEMGR_H
An instruction propagated through the simulated instruction pipeline.
Definition: Instruction.h:407
This class represents lattice values for constants.
Definition: AllocatorList.h:24
const_iterator end() const
Definition: SourceMgr.h:51
iterator begin() const
Definition: ArrayRef.h:137
bool hasNext() const
Definition: SourceMgr.h:41
unsigned size() const
Definition: SourceMgr.h:40
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
SourceRef peekNext() const
Definition: SourceMgr.h:44
iterator end() const
Definition: ArrayRef.h:138
ArrayRef< UniqueInst >::const_iterator const_iterator
Definition: SourceMgr.h:49
std::pair< unsigned, const Instruction & > SourceRef
Definition: SourceMgr.h:24
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getNumIterations() const
Definition: SourceMgr.h:39
SourceMgr(ArrayRef< UniqueInst > S, unsigned Iter)
Definition: SourceMgr.h:36
const_iterator begin() const
Definition: SourceMgr.h:50