[ARM] Add support for MVE pre and post inc loads and stores
[llvm-core.git] / tools / llvm-exegesis / lib / Uops.h
blob077c9a85bd51a64c10f34991c445b9277ee9b25b
1 //===-- Uops.h --------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// A BenchmarkRunner implementation to measure uop decomposition.
11 ///
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H
15 #define LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H
17 #include "BenchmarkRunner.h"
18 #include "SnippetGenerator.h"
20 namespace llvm {
21 namespace exegesis {
23 class UopsSnippetGenerator : public SnippetGenerator {
24 public:
25 UopsSnippetGenerator(const LLVMState &State) : SnippetGenerator(State) {}
26 ~UopsSnippetGenerator() override;
28 llvm::Expected<std::vector<CodeTemplate>>
29 generateCodeTemplates(const Instruction &Instr) const override;
31 static constexpr const size_t kMinNumDifferentAddresses = 6;
33 private:
34 // Instantiates memory operands within a snippet.
35 // To make computations as parallel as possible, we generate independant
36 // memory locations for instructions that load and store. If there are less
37 // than kMinNumDifferentAddresses in the original snippet, we duplicate
38 // instructions until there are this number of instructions.
39 // For example, assuming kMinNumDifferentAddresses=5 and
40 // getMaxMemoryAccessSize()=64, if the original snippet is:
41 // mov eax, [memory]
42 // we might generate:
43 // mov eax, [rdi]
44 // mov eax, [rdi + 64]
45 // mov eax, [rdi + 128]
46 // mov eax, [rdi + 192]
47 // mov eax, [rdi + 256]
48 // If the original snippet is:
49 // mov eax, [memory]
50 // add eax, [memory]
51 // we might generate:
52 // mov eax, [rdi]
53 // add eax, [rdi + 64]
54 // mov eax, [rdi + 128]
55 // add eax, [rdi + 192]
56 // mov eax, [rdi + 256]
57 void instantiateMemoryOperands(
58 unsigned ScratchSpaceReg,
59 std::vector<InstructionTemplate> &SnippetTemplate) const;
62 class UopsBenchmarkRunner : public BenchmarkRunner {
63 public:
64 UopsBenchmarkRunner(const LLVMState &State)
65 : BenchmarkRunner(State, InstructionBenchmark::Uops) {}
66 ~UopsBenchmarkRunner() override;
68 static constexpr const size_t kMinNumDifferentAddresses = 6;
70 private:
71 llvm::Expected<std::vector<BenchmarkMeasure>>
72 runMeasurements(const FunctionExecutor &Executor) const override;
75 } // namespace exegesis
76 } // namespace llvm
78 #endif // LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H