summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2018-06-05 10:56:19 +0000
committerClement Courbet <courbet@google.com>2018-06-05 10:56:19 +0000
commit53d35d2dc4a6ef270d1407d0ea0717d8ccf6fccd (patch)
tree4ab3d10b61dcbce9f5a4d31c73de7b2ce76cc5ec /llvm/tools/llvm-exegesis/llvm-exegesis.cpp
parentfef9b6eea63b095ac32526342d45d726f6704050 (diff)
downloadbcm5719-llvm-53d35d2dc4a6ef270d1407d0ea0717d8ccf6fccd.tar.gz
bcm5719-llvm-53d35d2dc4a6ef270d1407d0ea0717d8ccf6fccd.zip
[llvm-exegesis] Add instructions to BenchmarkResult Key.
We want llvm-exegesis to explore instructions (effect of initial register values, effect of operand selection). To enable this a BenchmarkResult muststore all the relevant data in its key. This patch starts adding such data. Here we simply allow to store the generated instructions, following patches will add operands and initial values for registers. https://reviews.llvm.org/D47764 Authored by: Guilluame Chatelet llvm-svn: 334008
Diffstat (limited to 'llvm/tools/llvm-exegesis/llvm-exegesis.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/llvm-exegesis.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index 3c57706a255..a1848c3f14f 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -92,6 +92,21 @@ static unsigned GetOpcodeOrDie(const llvm::MCInstrInfo &MCInstrInfo) {
llvm::report_fatal_error(llvm::Twine("unknown opcode ").concat(OpcodeName));
}
+static BenchmarkResultContext
+getBenchmarkResultContext(const LLVMState &State) {
+ BenchmarkResultContext Ctx;
+
+ const llvm::MCInstrInfo &InstrInfo = State.getInstrInfo();
+ for (unsigned E = InstrInfo.getNumOpcodes(), I = 0; I < E; ++I)
+ Ctx.addInstrEntry(I, InstrInfo.getName(I).data());
+
+ const llvm::MCRegisterInfo &RegInfo = State.getRegInfo();
+ for (unsigned E = RegInfo.getNumRegs(), I = 0; I < E; ++I)
+ Ctx.addRegEntry(I, RegInfo.getName(I));
+
+ return Ctx;
+}
+
void benchmarkMain() {
if (exegesis::pfm::pfmInitialize())
llvm::report_fatal_error("cannot initialize libpfm");
@@ -124,7 +139,7 @@ void benchmarkMain() {
llvm::report_fatal_error("--num-repetitions must be greater than zero");
Runner->run(GetOpcodeOrDie(State.getInstrInfo()), Filter, NumRepetitions)
- .writeYamlOrDie(BenchmarkFile);
+ .writeYamlOrDie(getBenchmarkResultContext(State), BenchmarkFile);
exegesis::pfm::pfmTerminate();
}
@@ -132,7 +147,7 @@ void benchmarkMain() {
// if OutputFilename is non-empty.
template <typename Pass>
static void maybeRunAnalysis(const Analysis &Analyzer, const std::string &Name,
- const std::string &OutputFilename) {
+ const std::string &OutputFilename) {
if (OutputFilename.empty())
return;
if (OutputFilename != "-") {
@@ -149,9 +164,14 @@ static void maybeRunAnalysis(const Analysis &Analyzer, const std::string &Name,
}
static void analysisMain() {
+ llvm::InitializeNativeTarget();
+ llvm::InitializeNativeTargetAsmPrinter();
+
// Read benchmarks.
+ const LLVMState State;
const std::vector<InstructionBenchmark> Points =
- InstructionBenchmark::readYamlsOrDie(BenchmarkFile);
+ InstructionBenchmark::readYamlsOrDie(getBenchmarkResultContext(State),
+ BenchmarkFile);
llvm::outs() << "Parsed " << Points.size() << " benchmark points\n";
if (Points.empty()) {
llvm::errs() << "no benchmarks to analyze\n";
@@ -160,9 +180,6 @@ static void analysisMain() {
// FIXME: Check that all points have the same triple/cpu.
// FIXME: Merge points from several runs (latency and uops).
- llvm::InitializeNativeTarget();
- llvm::InitializeNativeTargetAsmPrinter();
-
std::string Error;
const auto *TheTarget =
llvm::TargetRegistry::lookupTarget(Points[0].LLVMTriple, Error);
OpenPOWER on IntegriCloud