[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
diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index 4f1f286..ba25b1a 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -22,6 +22,7 @@
#include "LlvmState.h"
#include "llvm/ADT/Triple.h"
#include "llvm/CodeGen/TargetPassConfig.h"
+#include "llvm/IR/CallingConv.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCRegisterInfo.h"
@@ -39,6 +40,27 @@
return {};
}
+ // Returns the register pointing to scratch memory, or 0 if this target does
+ // not support memory operands. The benchmark function uses the default
+ // calling convention.
+ virtual unsigned getScratchMemoryRegister(const llvm::Triple &) const {
+ return 0;
+ }
+
+ // Fills memory operands with references to the address at [Reg] + Offset.
+ virtual void fillMemoryOperands(InstructionInstance &II, unsigned Reg,
+ unsigned Offset) const {
+ llvm_unreachable(
+ "fillMemoryOperands() requires getScratchMemoryRegister() > 0");
+ }
+
+ // Returns the maximum number of bytes a load/store instruction can access at
+ // once. This is typically the size of the largest register available on the
+ // processor. Note that this only used as a hint to generate independant
+ // load/stores to/from memory, so the exact returned value does not really
+ // matter as long as it's large enough.
+ virtual unsigned getMaxMemoryAccessSize() const { return 0; }
+
// Creates a benchmark runner for the given mode.
std::unique_ptr<BenchmarkRunner>
createBenchmarkRunner(InstructionBenchmark::ModeE Mode,