[llvm-exegesis] Provide a way to handle memory instructions.
[llvm-core.git] / tools / llvm-exegesis / lib / Uops.h
blob103c1783975ec5b18b7ec36454e22915259bb9b4
1 //===-- Uops.h --------------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// A BenchmarkRunner implementation to measure uop decomposition.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H
16 #define LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H
18 #include "BenchmarkRunner.h"
20 namespace exegesis {
22 class UopsBenchmarkRunner : public BenchmarkRunner {
23 public:
24 UopsBenchmarkRunner(const LLVMState &State)
25 : BenchmarkRunner(State, InstructionBenchmark::Uops) {}
26 ~UopsBenchmarkRunner() override;
28 llvm::Expected<SnippetPrototype>
29 generatePrototype(unsigned Opcode) const override;
31 static constexpr const size_t kMinNumDifferentAddresses = 6;
33 private:
34 llvm::Error isInfeasible(const llvm::MCInstrDesc &MCInstrDesc) const;
36 std::vector<BenchmarkMeasure>
37 runMeasurements(const ExecutableFunction &EF, ScratchSpace &Scratch,
38 const unsigned NumRepetitions) const override;
40 // Instantiates memory operands within a snippet.
41 // To make computations as parallel as possible, we generate independant
42 // memory locations for instructions that load and store. If there are less
43 // than kMinNumDifferentAddresses in the original snippet, we duplicate
44 // instructions until there are this number of instructions.
45 // For example, assuming kMinNumDifferentAddresses=5 and
46 // getMaxMemoryAccessSize()=64, if the original snippet is:
47 // mov eax, [memory]
48 // we might generate:
49 // mov eax, [rdi]
50 // mov eax, [rdi + 64]
51 // mov eax, [rdi + 128]
52 // mov eax, [rdi + 192]
53 // mov eax, [rdi + 256]
54 // If the original snippet is:
55 // mov eax, [memory]
56 // add eax, [memory]
57 // we might generate:
58 // mov eax, [rdi]
59 // add eax, [rdi + 64]
60 // mov eax, [rdi + 128]
61 // add eax, [rdi + 192]
62 // mov eax, [rdi + 256]
63 void
64 instantiateMemoryOperands(unsigned ScratchSpaceReg,
65 std::vector<InstructionInstance> &Snippet) const;
68 } // namespace exegesis
70 #endif // LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H