Home | History | Annotate | Download | only in AArch64
      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   bool matchesArch(llvm::Triple::ArchType Arch) const override {
     31     return Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be;
     32   }
     33   void addTargetSpecificPasses(llvm::PassManagerBase &PM) const override {
     34     // Function return is a pseudo-instruction that needs to be expanded
     35     PM.add(llvm::createAArch64ExpandPseudoPass());
     36   }
     37   std::unique_ptr<BenchmarkRunner>
     38   createLatencyBenchmarkRunner(const LLVMState &State) const override {
     39     return llvm::make_unique<AArch64LatencyBenchmarkRunner>(State);
     40   }
     41 };
     42 
     43 } // namespace
     44 
     45 static ExegesisTarget *getTheExegesisAArch64Target() {
     46   static ExegesisAArch64Target Target;
     47   return &Target;
     48 }
     49 
     50 void InitializeAArch64ExegesisTarget() {
     51   ExegesisTarget::registerTarget(getTheExegesisAArch64Target());
     52 }
     53 
     54 } // namespace exegesis
     55