diff options
author | Aiden Grossman <agrossman154@yahoo.com> | 2024-01-05 13:38:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 13:38:05 -0800 |
commit | d9c8edf08afce3d1e563e4521ae847a6809bb993 (patch) | |
tree | e6fe696fbadde57ce153076173f64de3634e218e | |
parent | 6f4cc1310b12bc59210e4596a895db4cb9ad6075 (diff) |
[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.
-rw-r--r-- | llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/X86/BenchmarkResultTest.cpp index 6c558b59be98..616f7bac54bc 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); |