blob: a65713b9f42ba41e6681d90a491ea5d3aa566ec9 [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> setRegToConstant(const llvm::MCSubtargetInfo &STI,
31 unsigned Reg) const override {
32 llvm_unreachable("Not yet implemented");
33 }
34
35 std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
36 const llvm::APInt &Value,
37 unsigned Reg) const override {
38 llvm_unreachable("Not yet implemented");
39 }
40
41 unsigned getScratchMemoryRegister(const llvm::Triple &) const override {
42 llvm_unreachable("Not yet implemented");
43 }
44
45 void fillMemoryOperands(InstructionBuilder &IB, unsigned Reg,
46 unsigned Offset) const override {
47 llvm_unreachable("Not yet implemented");
48 }
49
50 unsigned getMaxMemoryAccessSize() const override {
51 llvm_unreachable("Not yet implemented");
52 }
53
John Brawnc4ed6002018-07-03 10:10:29 +000054 bool matchesArch(llvm::Triple::ArchType Arch) const override {
55 return Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be;
56 }
57 void addTargetSpecificPasses(llvm::PassManagerBase &PM) const override {
58 // Function return is a pseudo-instruction that needs to be expanded
59 PM.add(llvm::createAArch64ExpandPseudoPass());
60 }
61 std::unique_ptr<BenchmarkRunner>
62 createLatencyBenchmarkRunner(const LLVMState &State) const override {
63 return llvm::make_unique<AArch64LatencyBenchmarkRunner>(State);
64 }
65};
66
67} // namespace
68
69static ExegesisTarget *getTheExegesisAArch64Target() {
70 static ExegesisAArch64Target Target;
71 return &Target;
72}
73
74void InitializeAArch64ExegesisTarget() {
75 ExegesisTarget::registerTarget(getTheExegesisAArch64Target());
76}
77
78} // namespace exegesis