Skip to content

Commit d9c8edf

Browse files
[llvm-exegesis] Add matcher for register initial values (#76666)
Currently, the unit tests for the BenchmarkResult struct do not check if the register initial values can be parsed back in. This patch adds a matcher and tests that the register initial values can be parsed correctly. This exercises code already contained within the benchmark to yaml infrastructure.
1 parent 6f4cc13 commit d9c8edf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ MATCHER(EqMCInst, "") {
4646
return true;
4747
}
4848

49+
MATCHER(EqRegValue, "") {
50+
const RegisterValue Lhs = get<0>(arg);
51+
const RegisterValue Rhs = get<1>(arg);
52+
if (Lhs.Register != Rhs.Register || Lhs.Value != Rhs.Value)
53+
return false;
54+
55+
return true;
56+
}
57+
4958
namespace {
5059

5160
TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
@@ -120,6 +129,8 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
120129
EXPECT_THAT(FromDisk.Key.Instructions,
121130
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
122131
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
132+
EXPECT_THAT(FromDisk.Key.RegisterInitialValues,
133+
Pointwise(EqRegValue(), ToDisk.Key.RegisterInitialValues));
123134
EXPECT_EQ(FromDisk.Mode, ToDisk.Mode);
124135
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
125136
EXPECT_EQ(FromDisk.LLVMTriple, ToDisk.LLVMTriple);
@@ -137,6 +148,8 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
137148
EXPECT_THAT(FromDisk.Key.Instructions,
138149
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
139150
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
151+
EXPECT_THAT(FromDisk.Key.RegisterInitialValues,
152+
Pointwise(EqRegValue(), ToDisk.Key.RegisterInitialValues));
140153
EXPECT_EQ(FromDisk.Mode, ToDisk.Mode);
141154
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
142155
EXPECT_EQ(FromDisk.LLVMTriple, ToDisk.LLVMTriple);

0 commit comments

Comments
 (0)