xref: /llvm-project/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp (revision 5ad2909e529e40cbe67d74bce97b4d6b5a152d39)
1 //===-- 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 
13 namespace exegesis {
14 
15 namespace {
16 
17 class AArch64LatencyBenchmarkRunner : public LatencyBenchmarkRunner {
18 public:
19   AArch64LatencyBenchmarkRunner(const LLVMState &State)
20       : LatencyBenchmarkRunner(State) {}
21 
22 private:
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 
29 class ExegesisAArch64Target : public ExegesisTarget {
30   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 
54   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 
69 static ExegesisTarget *getTheExegesisAArch64Target() {
70   static ExegesisAArch64Target Target;
71   return &Target;
72 }
73 
74 void InitializeAArch64ExegesisTarget() {
75   ExegesisTarget::registerTarget(getTheExegesisAArch64Target());
76 }
77 
78 } // namespace exegesis
79