diff options
| author | Ralf Luther <luther.ralf@gmail.com> | 2019-03-27 20:23:17 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@aicp-server-3> | 2019-03-27 20:23:17 +0000 |
| commit | 1ce3a9d272e564b22a1333a1e36a3d3ab7cfab01 (patch) | |
| tree | 391382eadd4fec5bb480f2e8934fa352770221d1 /clang-r353983/include/llvm/MCA/SourceMgr.h | |
| parent | d1d48b140bafaa8a50107292f5fce95562575765 (diff) | |
| parent | 4f56932d3416ac03f646bc1a611b3135fec2fe08 (diff) | |
Merge "Update prebuilt Clang to r353983." into p9.0HEADp9.0-backupp9.0
Diffstat (limited to 'clang-r353983/include/llvm/MCA/SourceMgr.h')
| -rw-r--r-- | clang-r353983/include/llvm/MCA/SourceMgr.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/clang-r353983/include/llvm/MCA/SourceMgr.h b/clang-r353983/include/llvm/MCA/SourceMgr.h new file mode 100644 index 00000000..dbe31db1 --- /dev/null +++ b/clang-r353983/include/llvm/MCA/SourceMgr.h @@ -0,0 +1,56 @@ +//===--------------------- SourceMgr.h --------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// \file +/// This file implements class SourceMgr. Class SourceMgr abstracts the input +/// code sequence (a sequence of MCInst), and assings unique identifiers to +/// every instruction in the sequence. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MCA_SOURCEMGR_H +#define LLVM_MCA_SOURCEMGR_H + +#include "llvm/ADT/ArrayRef.h" + +namespace llvm { +namespace mca { + +class Instruction; + +typedef std::pair<unsigned, const Instruction &> SourceRef; + +class SourceMgr { + using UniqueInst = std::unique_ptr<Instruction>; + ArrayRef<UniqueInst> Sequence; + unsigned Current; + const unsigned Iterations; + static const unsigned DefaultIterations = 100; + +public: + SourceMgr(ArrayRef<UniqueInst> S, unsigned Iter) + : Sequence(S), Current(0), Iterations(Iter ? Iter : DefaultIterations) {} + + unsigned getNumIterations() const { return Iterations; } + unsigned size() const { return Sequence.size(); } + bool hasNext() const { return Current < (Iterations * Sequence.size()); } + void updateNext() { ++Current; } + + SourceRef peekNext() const { + assert(hasNext() && "Already at end of sequence!"); + return SourceRef(Current, *Sequence[Current % Sequence.size()]); + } + + using const_iterator = ArrayRef<UniqueInst>::const_iterator; + const_iterator begin() const { return Sequence.begin(); } + const_iterator end() const { return Sequence.end(); } +}; + +} // namespace mca +} // namespace llvm + +#endif // LLVM_MCA_SOURCEMGR_H |
