[llvm] d9c8edf - [llvm-exegesis] Add matcher for register initial values (#76666)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 5 13:38:09 PST 2024
Author: Aiden Grossman
Date: 2024-01-05T13:38:05-08:00
New Revision: d9c8edf08afce3d1e563e4521ae847a6809bb993
URL: https://github.com/llvm/llvm-project/commit/d9c8edf08afce3d1e563e4521ae847a6809bb993
DIFF: https://github.com/llvm/llvm-project/commit/d9c8edf08afce3d1e563e4521ae847a6809bb993.diff
LOG: [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.
Added:
Modified:
llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
index 6c558b59be982d..616f7bac54bc43 100644
--- a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
+++ b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp
@@ -46,6 +46,15 @@ MATCHER(EqMCInst, "") {
return true;
}
+MATCHER(EqRegValue, "") {
+ const RegisterValue Lhs = get<0>(arg);
+ const RegisterValue Rhs = get<1>(arg);
+ if (Lhs.Register != Rhs.Register || Lhs.Value != Rhs.Value)
+ return false;
+
+ return true;
+}
+
namespace {
TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
@@ -120,6 +129,8 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
EXPECT_THAT(FromDisk.Key.Instructions,
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
+ EXPECT_THAT(FromDisk.Key.RegisterInitialValues,
+ Pointwise(EqRegValue(), ToDisk.Key.RegisterInitialValues));
EXPECT_EQ(FromDisk.Mode, ToDisk.Mode);
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
EXPECT_EQ(FromDisk.LLVMTriple, ToDisk.LLVMTriple);
@@ -137,6 +148,8 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
EXPECT_THAT(FromDisk.Key.Instructions,
Pointwise(EqMCInst(), ToDisk.Key.Instructions));
EXPECT_EQ(FromDisk.Key.Config, ToDisk.Key.Config);
+ EXPECT_THAT(FromDisk.Key.RegisterInitialValues,
+ Pointwise(EqRegValue(), ToDisk.Key.RegisterInitialValues));
EXPECT_EQ(FromDisk.Mode, ToDisk.Mode);
EXPECT_EQ(FromDisk.CpuName, ToDisk.CpuName);
EXPECT_EQ(FromDisk.LLVMTriple, ToDisk.LLVMTriple);
More information about the llvm-commits
mailing list