diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2018-08-01 14:41:45 +0000 |
|---|---|---|
| committer | Guillaume Chatelet <gchatelet@google.com> | 2018-08-01 14:41:45 +0000 |
| commit | fb94354d2dbee7628770b8b75b8289fa8d225ef3 (patch) | |
| tree | 37cd240911a715166dc635311122985a7d05e614 /llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h | |
| parent | c8e3924b3b8aacbcd089530e5fe8c1b463177780 (diff) | |
| download | bcm5719-llvm-fb94354d2dbee7628770b8b75b8289fa8d225ef3.tar.gz bcm5719-llvm-fb94354d2dbee7628770b8b75b8289fa8d225ef3.zip | |
[llvm-exegesis] Provide a way to handle memory instructions.
Summary:
And implement memory instructions on X86.
This fixes PR36906.
Reviewers: gchatelet
Reviewed By: gchatelet
Subscribers: lebedev.ri, filcab, mgorny, tschuett, RKSimon, llvm-commits
Differential Revision: https://reviews.llvm.org/D48935
llvm-svn: 338567
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h index 91d2c8e2d8c..845755ce97d 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h @@ -23,6 +23,8 @@ #include "RegisterAliasing.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/Error.h" +#include <cstdlib> +#include <memory> #include <vector> namespace exegesis { @@ -40,6 +42,7 @@ struct BenchmarkConfiguration { // measurement it should be as short as possible. It is usually used to setup // the content of the Registers. struct Setup { + std::vector<unsigned> LiveIns; // The registers that are live on entry. std::vector<unsigned> RegsToDef; }; Setup SnippetSetup; @@ -66,6 +69,23 @@ public: std::vector<unsigned> computeRegsToDef(const std::vector<InstructionInstance> &Snippet) const; + // Scratch space to run instructions that touch memory. + struct ScratchSpace { + static constexpr const size_t kAlignment = 1024; + static constexpr const size_t kSize = 1 << 20; // 1MB. + ScratchSpace() + : UnalignedPtr(llvm::make_unique<char[]>(kSize + kAlignment)), + AlignedPtr( + UnalignedPtr.get() + kAlignment - + (reinterpret_cast<intptr_t>(UnalignedPtr.get()) % kAlignment)) {} + char *ptr() const { return AlignedPtr; } + void clear() { std::memset(ptr(), 0, kSize); } + + private: + const std::unique_ptr<char[]> UnalignedPtr; + char *const AlignedPtr; + }; + protected: const LLVMState &State; const RegisterAliasingTrackerCache RATC; @@ -84,7 +104,7 @@ private: generatePrototype(unsigned Opcode) const = 0; virtual std::vector<BenchmarkMeasure> - runMeasurements(const ExecutableFunction &EF, + runMeasurements(const ExecutableFunction &EF, ScratchSpace &Scratch, const unsigned NumRepetitions) const = 0; // Internal helpers. @@ -101,6 +121,8 @@ private: llvm::ArrayRef<llvm::MCInst> Code) const; const InstructionBenchmark::ModeE Mode; + + const std::unique_ptr<ScratchSpace> Scratch; }; } // namespace exegesis |

