diff options
author | Clement Courbet <courbet@google.com> | 2018-05-14 09:01:22 +0000 |
---|---|---|
committer | Clement Courbet <courbet@google.com> | 2018-05-14 09:01:22 +0000 |
commit | 7b7c27afca5605a543dadb72954bfc62f29d1a48 (patch) | |
tree | dd632f9770ba57539834ca4657de9d1f04a0a6d8 /llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | |
parent | 617d4a8199c294228ef427dc6241b4d099fd8caf (diff) | |
download | bcm5719-llvm-7b7c27afca5605a543dadb72954bfc62f29d1a48.tar.gz bcm5719-llvm-7b7c27afca5605a543dadb72954bfc62f29d1a48.zip |
[llvm-exegesis] Allow lists of BenchmarkResults to be parsed as std::vector<BenchmarkResult>.
llvm-svn: 332221
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp')
-rw-r--r-- | llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index e9b8d29aaec..dcc798d71c0 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -54,18 +54,34 @@ template <> struct MappingTraits<exegesis::InstructionBenchmark> { } // namespace yaml } // namespace llvm +LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(exegesis::InstructionBenchmark) + namespace exegesis { -InstructionBenchmark -InstructionBenchmark::readYamlOrDie(llvm::StringRef Filename) { +namespace { + +template <typename ObjectOrList> +ObjectOrList readYamlOrDieCommon(llvm::StringRef Filename) { std::unique_ptr<llvm::MemoryBuffer> MemBuffer = llvm::cantFail( llvm::errorOrToExpected(llvm::MemoryBuffer::getFile(Filename))); llvm::yaml::Input Yin(*MemBuffer); - InstructionBenchmark Benchmark; + ObjectOrList Benchmark; Yin >> Benchmark; return Benchmark; } +} // namespace + +InstructionBenchmark +InstructionBenchmark::readYamlOrDie(llvm::StringRef Filename) { + return readYamlOrDieCommon<InstructionBenchmark>(Filename); +} + +std::vector<InstructionBenchmark> +InstructionBenchmark::readYamlsOrDie(llvm::StringRef Filename) { + return readYamlOrDieCommon<std::vector<InstructionBenchmark>>(Filename); +} + void InstructionBenchmark::writeYamlOrDie(const llvm::StringRef Filename) { if (Filename == "-") { llvm::yaml::Output Yout(llvm::outs()); |