[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / X86 / X86Counter.h
blob73e4dc5b990a0fa1a6dc0754390e83df501547cf
1 //===-- X86Counter.h --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// Perf counter that reads the LBRs for measuring the benchmarked block's
11 /// throughput.
12 ///
13 /// More info at: https://lwn.net/Articles/680985
14 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_LIB_X86_X86COUNTER_H
16 #define LLVM_TOOLS_LLVM_EXEGESIS_LIB_X86_X86COUNTER_H
18 #include "../PerfHelper.h"
19 #include "llvm/Support/Error.h"
21 // FIXME: Use appropriate wrappers for poll.h and mman.h
22 // to support Windows and remove this linux-only guard.
23 #if defined(__linux__) && defined(HAVE_LIBPFM) && \
24 defined(LIBPFM_HAS_FIELD_CYCLES)
26 namespace llvm {
27 namespace exegesis {
29 class X86LbrPerfEvent : public pfm::PerfEvent {
30 public:
31 X86LbrPerfEvent(unsigned SamplingPeriod);
34 class X86LbrCounter : public pfm::Counter {
35 public:
36 static llvm::Error checkLbrSupport();
38 explicit X86LbrCounter(pfm::PerfEvent &&Event);
40 virtual ~X86LbrCounter();
42 void start() override;
44 llvm::Expected<llvm::SmallVector<int64_t, 4>>
45 readOrError(StringRef FunctionBytes) const override;
47 private:
48 llvm::Expected<llvm::SmallVector<int64_t, 4>>
49 doReadCounter(const void *From, const void *To) const;
51 void *MMappedBuffer = nullptr;
54 } // namespace exegesis
55 } // namespace llvm
57 #endif // defined(__linux__) && defined(HAVE_LIBPFM) &&
58 // defined(LIBPFM_HAS_FIELD_CYCLES)
60 #endif // LLVM_TOOLS_LLVM_EXEGESIS_LIB_X86_X86COUNTER_H