96b012d109b6a6d865692f78566bc6f43d144cdb
[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 : 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() {
46     pushTTIStack(this);
47   }
48
49   virtual void finalizePass() {
50     popTTIStack();
51   }
52
53   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
54     TargetTransformInfo::getAnalysisUsage(AU);
55   }
56
57   static char ID;
58
59   virtual void *getAdjustedAnalysisPointer(const void *ID) {
60     if (ID == &TargetTransformInfo::ID)
61       return (TargetTransformInfo*)this;
62     return this;
63   }
64
65   unsigned getNumberOfRegisters(bool Vector) const {
66     if (Vector) {
67        return 0;
68     }
69     return 12;
70   }
71 };
72
73 } // end anonymous namespace
74
75 INITIALIZE_AG_PASS(XCoreTTI, TargetTransformInfo, "xcoretti",
76                    "XCore Target Transform Info", true, true, false)
77 char XCoreTTI::ID = 0;
78
79
80 ImmutablePass *
81 llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) {
82   return new XCoreTTI(TM);
83 }