blob: fe9d253f80f40d05e7c40ced4f203b38a97d926b [file] [log] [blame]
John Brawnc4ed6002018-07-03 10:10:29 +00001//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#include "../Target.h"
10#include "../Latency.h"
11#include "AArch64.h"
12
13namespace exegesis {
14
15namespace {
16
17class AArch64LatencyBenchmarkRunner : public LatencyBenchmarkRunner {
18public:
19 AArch64LatencyBenchmarkRunner(const LLVMState &State)
20 : LatencyBenchmarkRunner(State) {}
21
22private:
23 const char *getCounterName() const override {
24 // All AArch64 subtargets have CPU_CYCLES as the cycle counter name
25 return "CPU_CYCLES";
26 }
27};
28
29class ExegesisAArch64Target : public ExegesisTarget {
Guillaume Chatelet5ad29092018-09-18 11:26:27 +000030 std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
Simon Pilgrim02426892018-09-18 15:35:49 +000031 const llvm::APInt &Value,
32 unsigned Reg) const override {
33 llvm_unreachable("Not yet implemented");
34 }
35
36 unsigned getScratchMemoryRegister(const llvm::Triple &) const override {
37 llvm_unreachable("Not yet implemented");
38 }
39
40 void fillMemoryOperands(InstructionBuilder &IB, unsigned Reg,
41 unsigned Offset) const override {
42 llvm_unreachable("Not yet implemented");
43 }
44
45 unsigned getMaxMemoryAccessSize() const override {
46 llvm_unreachable("Not yet implemented");
Guillaume Chatelet5ad29092018-09-18 11:26:27 +000047 }
48
John Brawnc4ed6002018-07-03 10:10:29 +000049 bool matchesArch(llvm::Triple::ArchType Arch) const override {
50 return Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be;
51 }
52 void addTargetSpecificPasses(llvm::PassManagerBase &PM) const override {
53 // Function return is a pseudo-instruction that needs to be expanded
54 PM.add(llvm::createAArch64ExpandPseudoPass());
55 }
John Brawnc4ed6002018-07-03 10:10:29 +000056 std::unique_ptr<BenchmarkRunner>
57 createLatencyBenchmarkRunner(const LLVMState &State) const override {
58 return llvm::make_unique<AArch64LatencyBenchmarkRunner>(State);
59 }
60};
61
62} // namespace
63
64static ExegesisTarget *getTheExegesisAArch64Target() {
65 static ExegesisAArch64Target Target;
66 return &Target;
67}
68
69void InitializeAArch64ExegesisTarget() {
70 ExegesisTarget::registerTarget(getTheExegesisAArch64Target());
71}
72
73} // namespace exegesis