brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · d3c85c0 Raw
66 lines · c
1//===-- ParallelSnippetGenerator.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-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// A SnippetGenerator implementation to create parallel instruction snippets.11///12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H15#define LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H16 17#include "SnippetGenerator.h"18 19namespace llvm {20namespace exegesis {21 22class ParallelSnippetGenerator : public SnippetGenerator {23public:24  using SnippetGenerator::SnippetGenerator;25  ~ParallelSnippetGenerator() override;26 27  Expected<std::vector<CodeTemplate>>28  generateCodeTemplates(InstructionTemplate Variant,29                        const BitVector &ForbiddenRegisters) const override;30 31  static constexpr size_t kMinNumDifferentAddresses = 6;32 33private:34  // Instantiates memory operands within a snippet.35  // To make computations as parallel as possible, we generate independant36  // memory locations for instructions that load and store. If there are less37  // than kMinNumDifferentAddresses in the original snippet, we duplicate38  // instructions until there are this number of instructions.39  // For example, assuming kMinNumDifferentAddresses=5 and40  // 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      MCRegister ScratchSpaceReg,59      std::vector<InstructionTemplate> &SnippetTemplate) const;60};61 62} // namespace exegesis63} // namespace llvm64 65#endif // LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H66