diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2018-06-07 07:40:40 +0000 |
|---|---|---|
| committer | Guillaume Chatelet <gchatelet@google.com> | 2018-06-07 07:40:40 +0000 |
| commit | 083a0c16211f690e34b1d97162c7168d4efbc140 (patch) | |
| tree | 23363015ead791b79358feadf260f93b8abb35a4 /llvm/unittests | |
| parent | 9212ef0a0a9a9787bcf578fc9f00cdfb52bd4ff0 (diff) | |
| download | bcm5719-llvm-083a0c16211f690e34b1d97162c7168d4efbc140.tar.gz bcm5719-llvm-083a0c16211f690e34b1d97162c7168d4efbc140.zip | |
[llvm-exegesis] Serializes instruction's operand in BenchmarkResult's key.
Summary: Follow up patch to https://reviews.llvm.org/D47764.
Reviewers: courbet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D47785
llvm-svn: 334165
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp b/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp index 181b5afc34b..4428dcf0537 100644 --- a/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp +++ b/llvm/unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp @@ -28,23 +28,46 @@ bool operator==(const BenchmarkMeasure &A, const BenchmarkMeasure &B) { return std::tie(A.Key, A.Value) == std::tie(B.Key, B.Value); } +static std::string Dump(const llvm::MCInst &McInst) { + std::string Buffer; + llvm::raw_string_ostream OS(Buffer); + McInst.print(OS); + return Buffer; +} + MATCHER(EqMCInst, "") { - return get<0>(arg).getOpcode() == get<1>(arg).getOpcode(); + const std::string Lhs = Dump(get<0>(arg)); + const std::string Rhs = Dump(get<1>(arg)); + if (Lhs != Rhs) { + *result_listener << Lhs << " <=> " << Rhs; + return false; + } + return true; } namespace { static constexpr const unsigned kInstrId = 5; static constexpr const char kInstrName[] = "Instruction5"; +static constexpr const unsigned kReg1Id = 1; +static constexpr const char kReg1Name[] = "Reg1"; +static constexpr const unsigned kReg2Id = 2; +static constexpr const char kReg2Name[] = "Reg2"; TEST(BenchmarkResultTest, WriteToAndReadFromDisk) { BenchmarkResultContext Ctx; Ctx.addInstrEntry(kInstrId, kInstrName); + Ctx.addRegEntry(kReg1Id, kReg1Name); + Ctx.addRegEntry(kReg2Id, kReg2Name); InstructionBenchmark ToDisk; ToDisk.Key.OpcodeName = "name"; - ToDisk.Key.Instructions.push_back(llvm::MCInstBuilder(kInstrId)); + ToDisk.Key.Instructions.push_back(llvm::MCInstBuilder(kInstrId) + .addReg(kReg1Id) + .addReg(kReg2Id) + .addImm(123) + .addFPImm(0.5)); ToDisk.Key.Config = "config"; ToDisk.Mode = InstructionBenchmark::Latency; ToDisk.CpuName = "cpu_name"; |

