[PATCH] D80610: [llvm-exegesis] Make createCounter a virtual method on Target to allow targets to create target-specific counters
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 21:15:50 PDT 2020
oontvoo created this revision.
oontvoo added a reviewer: courbet.
Herald added subscribers: llvm-commits, mstojanovic.
Herald added a project: LLVM.
Depends on D80603 <https://reviews.llvm.org/D80603>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80610
Files:
llvm/tools/llvm-exegesis/lib/Target.cpp
llvm/tools/llvm-exegesis/lib/Target.h
Index: llvm/tools/llvm-exegesis/lib/Target.h
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.h
+++ llvm/tools/llvm-exegesis/lib/Target.h
@@ -27,6 +27,7 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/Support/Error.h"
namespace llvm {
namespace exegesis {
@@ -65,6 +66,10 @@
explicit ExegesisTarget(ArrayRef<CpuAndPfmCounters> CpuPfmCounters)
: CpuPfmCounters(CpuPfmCounters) {}
+ // Targets can use this to create target-specific perf counters.
+ virtual Expected<std::unique_ptr<pfm::Counter>>
+ createCounter(const char *CounterName, const LLVMState &State) const;
+
// Targets can use this to add target-specific passes in assembleToStream();
virtual void addTargetSpecificPasses(PassManagerBase &PM) const {}
Index: llvm/tools/llvm-exegesis/lib/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -11,6 +11,8 @@
#include "ParallelSnippetGenerator.h"
#include "SerialSnippetGenerator.h"
#include "UopsBenchmarkRunner.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Error.h"
namespace llvm {
namespace exegesis {
@@ -27,6 +29,19 @@
return nullptr;
}
+Expected<std::unique_ptr<pfm::Counter>>
+ExegesisTarget::createCounter(const char *CounterName,
+ const LLVMState &) const {
+ pfm::PerfEvent Event(CounterName);
+ if (!Event.valid())
+ return llvm::make_error<Failure>(
+ llvm::Twine("Unable to create counter with name '")
+ .concat(CounterName)
+ .concat("'"));
+
+ return std::make_unique<pfm::Counter>(std::move(Event));
+}
+
void ExegesisTarget::registerTarget(ExegesisTarget *Target) {
if (FirstTarget == nullptr) {
FirstTarget = Target;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80610.266414.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/6d59b069/attachment.bin>
More information about the llvm-commits
mailing list