1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00
llvm-mirror/tools/llvm-exegesis/lib/ParallelSnippetGenerator.h
Roman Lebedev 92ce5b3319 [llvm-exegesis] Exploring X86::OperandType::OPERAND_COND_CODE
Summary:
Currently, we only have nice exploration for LEA instruction,
while for the rest, we rely on `randomizeUnsetVariables()`
to sometimes generate something interesting.
While that works, it isn't very reliable in coverage :)

Here, i'm making an assumption that while we may want to explore
multi-instruction configs, we are most interested in the
characteristics of the main instruction we were asked about.

Which we can do, by taking the existing `randomizeMCOperand()`,
and turning it on it's head - instead of relying on it to randomly fill
one of the interesting values, let's pregenerate all the possible interesting
values for the variable, and then generate as much `InstructionTemplate`
combinations of these possible values for variables as needed/possible.

Of course, that requires invasive changes to no longer pass just the
naked `Instruction`, but sometimes partially filled `InstructionTemplate`.

As it can be seen from the test, this allows us to explore
`X86::OperandType::OPERAND_COND_CODE` for instructions
that take such an operand.
I'm hoping this will greatly simplify exploration.

Reviewers: courbet, gchatelet

Reviewed By: gchatelet

Subscribers: orodley, mgorny, sdardis, tschuett, jrtc27, atanasyan, mstojanovic, andreadb, RKSimon, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74156
2020-02-12 21:33:52 +03:00

66 lines
2.2 KiB
C++

//===-- ParallelSnippetGenerator.h ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// A SnippetGenerator implementation to create parallel instruction snippets.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H
#define LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H
#include "SnippetGenerator.h"
namespace llvm {
namespace exegesis {
class ParallelSnippetGenerator : public SnippetGenerator {
public:
using SnippetGenerator::SnippetGenerator;
~ParallelSnippetGenerator() override;
Expected<std::vector<CodeTemplate>>
generateCodeTemplates(InstructionTemplate Variant,
const BitVector &ForbiddenRegisters) const override;
static constexpr const size_t kMinNumDifferentAddresses = 6;
private:
// Instantiates memory operands within a snippet.
// To make computations as parallel as possible, we generate independant
// memory locations for instructions that load and store. If there are less
// than kMinNumDifferentAddresses in the original snippet, we duplicate
// instructions until there are this number of instructions.
// For example, assuming kMinNumDifferentAddresses=5 and
// getMaxMemoryAccessSize()=64, if the original snippet is:
// mov eax, [memory]
// we might generate:
// mov eax, [rdi]
// mov eax, [rdi + 64]
// mov eax, [rdi + 128]
// mov eax, [rdi + 192]
// mov eax, [rdi + 256]
// If the original snippet is:
// mov eax, [memory]
// add eax, [memory]
// we might generate:
// mov eax, [rdi]
// add eax, [rdi + 64]
// mov eax, [rdi + 128]
// add eax, [rdi + 192]
// mov eax, [rdi + 256]
void instantiateMemoryOperands(
unsigned ScratchSpaceReg,
std::vector<InstructionTemplate> &SnippetTemplate) const;
};
} // namespace exegesis
} // namespace llvm
#endif // LLVM_TOOLS_LLVM_EXEGESIS_PARALLELSNIPPETGENERATOR_H