Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
[oota-llvm.git] / lib / Target / AArch64 / AArch64TargetTransformInfo.cpp
1 //===- AArch64TargetTransformInfo.cpp - AArch64 specific TTI pass ---------===//
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 /// \file
10 /// This file implements a TargetTransformInfo analysis pass specific to the
11 /// AArch64 target machine. It uses the target's detailed information to provide
12 /// more precise answers to certain TTI queries, while letting the target
13 /// independent and default TTI implementations handle the rest.
14 ///
15 //===----------------------------------------------------------------------===//
16
17 #define DEBUG_TYPE "aarch64tti"
18 #include "AArch64.h"
19 #include "AArch64TargetMachine.h"
20 #include "llvm/Analysis/TargetTransformInfo.h"
21 #include "llvm/Support/Debug.h"
22 #include "llvm/Target/CostTable.h"
23 #include "llvm/Target/TargetLowering.h"
24 using namespace llvm;
25
26 // Declare the pass initialization routine locally as target-specific passes
27 // don't have a target-wide initialization entry point, and so we rely on the
28 // pass constructor initialization.
29 namespace llvm {
30 void initializeAArch64TTIPass(PassRegistry &);
31 }
32
33 namespace {
34
35 class AArch64TTI final : public ImmutablePass, public TargetTransformInfo {
36   const AArch64TargetMachine *TM;
37   const AArch64Subtarget *ST;
38   const AArch64TargetLowering *TLI;
39
40   /// Estimate the overhead of scalarizing an instruction. Insert and Extract
41   /// are set if the result needs to be inserted and/or extracted from vectors.
42   unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const;
43
44 public:
45   AArch64TTI() : ImmutablePass(ID), TM(0), ST(0), TLI(0) {
46     llvm_unreachable("This pass cannot be directly constructed");
47   }
48
49   AArch64TTI(const AArch64TargetMachine *TM)
50       : ImmutablePass(ID), TM(TM), ST(TM->getSubtargetImpl()),
51         TLI(TM->getTargetLowering()) {
52     initializeAArch64TTIPass(*PassRegistry::getPassRegistry());
53   }
54
55   virtual void initializePass() override {
56     pushTTIStack(this);
57   }
58
59   virtual void finalizePass() {
60     popTTIStack();
61   }
62
63   virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
64     TargetTransformInfo::getAnalysisUsage(AU);
65   }
66
67   /// Pass identification.
68   static char ID;
69
70   /// Provide necessary pointer adjustments for the two base classes.
71   virtual void *getAdjustedAnalysisPointer(const void *ID) override {
72     if (ID == &TargetTransformInfo::ID)
73       return (TargetTransformInfo*)this;
74     return this;
75   }
76
77   /// \name Scalar TTI Implementations
78   /// @{
79
80   /// @}
81
82
83   /// \name Vector TTI Implementations
84   /// @{
85
86   unsigned getNumberOfRegisters(bool Vector) const {
87     if (Vector) {
88       if (ST->hasNEON())
89         return 32;
90       return 0;
91     }
92     return 32;
93   }
94
95   unsigned getRegisterBitWidth(bool Vector) const {
96     if (Vector) {
97       if (ST->hasNEON())
98         return 128;
99       return 0;
100     }
101     return 64;
102   }
103
104   /// @}
105 };
106
107 } // end anonymous namespace
108
109 INITIALIZE_AG_PASS(AArch64TTI, TargetTransformInfo, "aarch64tti",
110                    "AArch64 Target Transform Info", true, true, false)
111 char AArch64TTI::ID = 0;
112
113 ImmutablePass *
114 llvm::createAArch64TargetTransformInfoPass(const AArch64TargetMachine *TM) {
115   return new AArch64TTI(TM);
116 }