summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkResult.h')
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkResult.h47
1 files changed, 6 insertions, 41 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
index c9e77ca4922..83451ca0396 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.h
@@ -16,6 +16,7 @@
#ifndef LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
#define LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
+#include "LlvmState.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCInst.h"
@@ -28,8 +29,6 @@
namespace exegesis {
-struct BenchmarkResultContext; // Forward declaration.
-
struct InstructionBenchmarkKey {
// The LLVM opcode name.
std::vector<llvm::MCInst> Instructions;
@@ -62,19 +61,17 @@ struct InstructionBenchmark {
// Read functions.
static llvm::Expected<InstructionBenchmark>
- readYaml(const BenchmarkResultContext &Context, llvm::StringRef Filename);
+ readYaml(const LLVMState &State, llvm::StringRef Filename);
static llvm::Expected<std::vector<InstructionBenchmark>>
- readYamls(const BenchmarkResultContext &Context, llvm::StringRef Filename);
+ readYamls(const LLVMState &State, llvm::StringRef Filename);
- void readYamlFrom(const BenchmarkResultContext &Context,
- llvm::StringRef InputContent);
+ void readYamlFrom(const LLVMState &State, llvm::StringRef InputContent);
// Write functions, non-const because of YAML traits.
- void writeYamlTo(const BenchmarkResultContext &Context, llvm::raw_ostream &S);
+ void writeYamlTo(const LLVMState &State, llvm::raw_ostream &S);
- llvm::Error writeYaml(const BenchmarkResultContext &Context,
- const llvm::StringRef Filename);
+ llvm::Error writeYaml(const LLVMState &State, const llvm::StringRef Filename);
};
//------------------------------------------------------------------------------
@@ -102,38 +99,6 @@ private:
double MinValue = std::numeric_limits<double>::max();
};
-// This context is used when de/serializing InstructionBenchmark to guarantee
-// that Registers and Instructions are human readable and preserved accross
-// different versions of LLVM.
-struct BenchmarkResultContext {
- BenchmarkResultContext() = default;
- BenchmarkResultContext(BenchmarkResultContext &&) = default;
- BenchmarkResultContext &operator=(BenchmarkResultContext &&) = default;
- BenchmarkResultContext(const BenchmarkResultContext &) = delete;
- BenchmarkResultContext &operator=(const BenchmarkResultContext &) = delete;
-
- // Populate Registers and Instruction mapping.
- void addRegEntry(unsigned RegNo, llvm::StringRef Name);
- void addInstrEntry(unsigned Opcode, llvm::StringRef Name);
-
- // Register accessors.
- llvm::StringRef getRegName(unsigned RegNo) const;
- unsigned getRegNo(llvm::StringRef Name) const; // 0 is not found.
-
- // Instruction accessors.
- llvm::StringRef getInstrName(unsigned Opcode) const;
- unsigned getInstrOpcode(llvm::StringRef Name) const; // 0 is not found.
-
-private:
- // Ideally we would like to use MCRegisterInfo and MCInstrInfo but doing so
- // would make testing harder, instead we create a mapping that we can easily
- // populate.
- std::unordered_map<unsigned, llvm::StringRef> InstrOpcodeToName;
- std::unordered_map<unsigned, llvm::StringRef> RegNoToName;
- llvm::StringMap<unsigned> InstrNameToOpcode;
- llvm::StringMap<unsigned> RegNameToNo;
-};
-
} // namespace exegesis
#endif // LLVM_TOOLS_LLVM_EXEGESIS_BENCHMARKRESULT_H
OpenPOWER on IntegriCloud