ARM: enable tail call optimisation on Thumb 2
[oota-llvm.git] / lib / Target / XCore / XCoreTargetTransformInfo.cpp
1 //===-- XCoreTargetTransformInfo.cpp - XCore 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 /// XCore 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 "xcoretti"
18 #include "XCore.h"
19 #include "llvm/Analysis/TargetTransformInfo.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Target/CostTable.h"
22 #include "llvm/Target/TargetLowering.h"
23 using namespace llvm;
24
25 // Declare the pass initialization routine locally as target-specific passes
26 // don't havve a target-wide initialization entry point, and so we rely on the
27 // pass constructor initialization.
28 namespace llvm {
29 void initializeXCoreTTIPass(PassRegistry &);
30 }
31
32 namespace {
33
34 class XCoreTTI final : public ImmutablePass, public TargetTransformInfo {
35 public:
36   XCoreTTI() : ImmutablePass(ID) {
37     llvm_unreachable("This pass cannot be directly constructed");
38   }
39
40   XCoreTTI(const XCoreTargetMachine *TM)
41       : ImmutablePass(ID) {
42     initializeXCoreTTIPass(*PassRegistry::getPassRegistry());
43   }
44
45   virtual void initializePass() override {
46     pushTTIStack(this);
47   }
48
49   virtual void getAnalysisUsage(AnalysisUsage &AU) const override {
50     TargetTransformInfo::getAnalysisUsage(AU);
51   }
52
53   static char ID;
54
55   virtual void *getAdjustedAnalysisPointer(const void *ID) override {
56     if (ID == &TargetTransformInfo::ID)
57       return (TargetTransformInfo*)this;
58     return this;
59   }
60
61   unsigned getNumberOfRegisters(bool Vector) const override {
62     if (Vector) {
63        return 0;
64     }
65     return 12;
66   }
67 };
68
69 } // end anonymous namespace
70
71 INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti",
72                    "XCore Target Transform Info", true, true, false)
73 char XCoreTTI::ID = 0;
74
75
76 ImmutablePass *
77 llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) {
78   return new XCoreTTI(TM);
79 }