[RISCV] Eliminate dead li after emitting VSETVLIs (#65934)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / UopsBenchmarkRunner.cpp
blob6351fdd3345a8378128def95745a11b5318bf36f
1 //===-- UopsBenchmarkRunner.cpp ---------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #include "UopsBenchmarkRunner.h"
11 #include "Target.h"
13 namespace llvm {
14 namespace exegesis {
16 UopsBenchmarkRunner::~UopsBenchmarkRunner() = default;
18 Expected<std::vector<BenchmarkMeasure>>
19 UopsBenchmarkRunner::runMeasurements(const FunctionExecutor &Executor) const {
20 std::vector<BenchmarkMeasure> Result;
21 const PfmCountersInfo &PCI = State.getPfmCounters();
22 // Uops per port.
23 for (const auto *IssueCounter = PCI.IssueCounters,
24 *IssueCounterEnd = PCI.IssueCounters + PCI.NumIssueCounters;
25 IssueCounter != IssueCounterEnd; ++IssueCounter) {
26 if (!IssueCounter->Counter)
27 continue;
28 auto ExpectedCounterValue = Executor.runAndSample(IssueCounter->Counter);
29 if (!ExpectedCounterValue)
30 return ExpectedCounterValue.takeError();
31 Result.push_back(BenchmarkMeasure::Create(IssueCounter->ProcResName,
32 (*ExpectedCounterValue)[0]));
34 // NumMicroOps.
35 if (const char *const UopsCounter = PCI.UopsCounter) {
36 auto ExpectedCounterValue = Executor.runAndSample(UopsCounter);
37 if (!ExpectedCounterValue)
38 return ExpectedCounterValue.takeError();
39 Result.push_back(
40 BenchmarkMeasure::Create("NumMicroOps", (*ExpectedCounterValue)[0]));
42 return std::move(Result);
45 } // namespace exegesis
46 } // namespace llvm