summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
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/unittests
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/unittests')
-rw-r--r--llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp
index d3e3a5fd60e..2c12c82d2f4 100644
--- a/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp
@@ -16,18 +16,35 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+using ::testing::AllOf;
+using ::testing::Eq;
+using ::testing::get;
+using ::testing::Pointwise;
+using ::testing::Property;
+
namespace exegesis {
bool operator==(const BenchmarkMeasure &A, const BenchmarkMeasure &B) {
return std::tie(A.Key, A.Value) == std::tie(B.Key, B.Value);
}
+MATCHER(EqMCInst, "") {
+ return get<0>(arg).getOpcode() == get<1>(arg).getOpcode();
+}
+
namespace {
+static constexpr const unsigned kInstrId = 5;
+static constexpr const char kInstrName[] = "Instruction5";
+
TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
+ BenchmarkResultContext Ctx;
+ Ctx.addInstrEntry(kInstrId, kInstrName);
+
InstructionBenchmark ToDisk;
ToDisk.Key.OpcodeName = "name";
+ ToDisk.Key.Instructions.push_back(llvm::MCInstBuilder(kInstrId));
ToDisk.Key.Mode = InstructionBenchmarkKey::Latency;
ToDisk.Key.Config = "config";
ToDisk.CpuName = "cpu_name";
@@ -43,14 +60,15 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
EC = llvm::sys::fs::createUniqueDirectory("BenchmarkResultTestDir", Filename);
ASSERT_FALSE(EC);
llvm::sys::path::append(Filename, "data.yaml");
-
- ToDisk.writeYamlOrDie(Filename);
+ ToDisk.writeYamlOrDie(Ctx, Filename);
{
// One-element version.
- const auto FromDisk = InstructionBenchmark::readYamlOrDie(Filename);
+ const auto FromDisk = InstructionBenchmark::readYamlOrDie(Ctx, Filename);
EXPECT_EQ(FromDisk.Key.OpcodeName, ToDisk.Key.OpcodeName);
+ EXPECT_THAT(FromDisk.Key.Instructions,
+ Pointwise(EqMCInst(), ToDisk.Key.Instructions));
EXPECT_EQ(FromDisk.Key.Mode, ToDisk.Key.Mode);
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
@@ -62,10 +80,13 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
}
{
// Vector version.
- const auto FromDiskVector = InstructionBenchmark::readYamlsOrDie(Filename);
+ const auto FromDiskVector =
+ InstructionBenchmark::readYamlsOrDie(Ctx, Filename);
ASSERT_EQ(FromDiskVector.size(), size_t{1});
const auto FromDisk = FromDiskVector[0];
EXPECT_EQ(FromDisk.Key.OpcodeName, ToDisk.Key.OpcodeName);
+ EXPECT_THAT(FromDisk.Key.Instructions,
+ Pointwise(EqMCInst(), ToDisk.Key.Instructions));
EXPECT_EQ(FromDisk.Key.Mode, ToDisk.Key.Mode);
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
OpenPOWER on IntegriCloud