File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed
tools/llvm-exegesis/lib/RISCV
unittests/tools/llvm-exegesis/RISCV Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ tablegen(LLVM RISCVGenRegisterBank.inc -gen-register-bank)
1515tablegen(LLVM RISCVGenRegisterInfo.inc -gen-register-info)
1616tablegen(LLVM RISCVGenSearchableTables.inc -gen-searchable-tables)
1717tablegen(LLVM RISCVGenSubtargetInfo.inc -gen-subtarget)
18+ tablegen(LLVM RISCVGenExegesis.inc -gen-exegesis)
1819
1920set (LLVM_TARGET_DEFINITIONS RISCVGISel.td)
2021tablegen(LLVM RISCVGenGlobalISel.inc -gen-global -isel)
Original file line number Diff line number Diff line change @@ -63,6 +63,12 @@ include "RISCVSchedXiangShanNanHu.td"
6363
6464include "RISCVProcessors.td"
6565
66+ //===----------------------------------------------------------------------===//
67+ // Pfm Counters
68+ //===----------------------------------------------------------------------===//
69+
70+ include "RISCVPfmCounters.td"
71+
6672//===----------------------------------------------------------------------===//
6773// Define the RISC-V target.
6874//===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change 1+ //===---- RISCVPfmCounters.td - RISC-V Hardware Counters ---*- tablegen -*-===//
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+ // This describes the available hardware counters for RISC-V.
10+ //
11+ //===----------------------------------------------------------------------===//
12+
13+ def CpuCyclesPfmCounter : PfmCounter<"CYCLES">;
14+
15+ def DefaultPfmCounters : ProcPfmCounters {
16+ let CycleCounter = CpuCyclesPfmCounter;
17+ }
18+ def : PfmCountersDefaultBinding<DefaultPfmCounters>;
Original file line number Diff line number Diff line change 2424namespace llvm {
2525namespace exegesis {
2626
27+ #include " RISCVGenExegesis.inc"
28+
2729namespace {
2830
2931// Stores constant value to a general-purpose (integer) register.
@@ -132,8 +134,7 @@ class ExegesisRISCVTarget : public ExegesisTarget {
132134};
133135
134136ExegesisRISCVTarget::ExegesisRISCVTarget ()
135- : ExegesisTarget(ArrayRef<CpuAndPfmCounters>{},
136- RISCV_MC::isOpcodeAvailable) {}
137+ : ExegesisTarget(RISCVCpuPfmCounters, RISCV_MC::isOpcodeAvailable) {}
137138
138139bool ExegesisRISCVTarget::matchesArch (Triple::ArchType Arch) const {
139140 return Arch == Triple::riscv32 || Arch == Triple::riscv64;
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ TEST_F(RISCVTargetTest, SetRegToConstant) {
4242 EXPECT_THAT (Insts, Not (IsEmpty ()));
4343}
4444
45+ TEST_F (RISCVTargetTest, DefaultPfmCounters) {
46+ const std::string Expected = " CYCLES" ;
47+ EXPECT_EQ (State.getExegesisTarget ().getPfmCounters (" " ).CycleCounter ,
48+ Expected);
49+ EXPECT_EQ (
50+ State.getExegesisTarget ().getPfmCounters (" unknown_cpu" ).CycleCounter ,
51+ Expected);
52+ }
53+
4554} // namespace
4655} // namespace exegesis
4756} // namespace llvm
You can’t perform that action at this time.
0 commit comments