1 //===-- Uops.h --------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// A BenchmarkRunner implementation to measure uop decomposition.
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"
23 class UopsSnippetGenerator
: public SnippetGenerator
{
25 using SnippetGenerator::SnippetGenerator
;
26 ~UopsSnippetGenerator() override
;
28 Expected
<std::vector
<CodeTemplate
>>
29 generateCodeTemplates(const Instruction
&Instr
,
30 const BitVector
&ForbiddenRegisters
) const override
;
32 static constexpr const size_t kMinNumDifferentAddresses
= 6;
35 // Instantiates memory operands within a snippet.
36 // To make computations as parallel as possible, we generate independant
37 // memory locations for instructions that load and store. If there are less
38 // than kMinNumDifferentAddresses in the original snippet, we duplicate
39 // instructions until there are this number of instructions.
40 // For example, assuming kMinNumDifferentAddresses=5 and
41 // getMaxMemoryAccessSize()=64, if the original snippet is:
45 // mov eax, [rdi + 64]
46 // mov eax, [rdi + 128]
47 // mov eax, [rdi + 192]
48 // mov eax, [rdi + 256]
49 // If the original snippet is:
54 // add eax, [rdi + 64]
55 // mov eax, [rdi + 128]
56 // add eax, [rdi + 192]
57 // mov eax, [rdi + 256]
58 void instantiateMemoryOperands(
59 unsigned ScratchSpaceReg
,
60 std::vector
<InstructionTemplate
> &SnippetTemplate
) const;
63 class UopsBenchmarkRunner
: public BenchmarkRunner
{
65 UopsBenchmarkRunner(const LLVMState
&State
)
66 : BenchmarkRunner(State
, InstructionBenchmark::Uops
) {}
67 ~UopsBenchmarkRunner() override
;
69 static constexpr const size_t kMinNumDifferentAddresses
= 6;
72 Expected
<std::vector
<BenchmarkMeasure
>>
73 runMeasurements(const FunctionExecutor
&Executor
) const override
;
76 } // namespace exegesis
79 #endif // LLVM_TOOLS_LLVM_EXEGESIS_UOPS_H