[PM] Change the core design of the TTI analysis to use a polymorphic
[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 #include "XCore.h"
18 #include "XCoreTargetMachine.h"
19 #include "llvm/Analysis/TargetTransformInfo.h"
20 #include "llvm/CodeGen/BasicTTIImpl.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 #define DEBUG_TYPE "xcoretti"
27
28 namespace {
29
30 class XCoreTTIImpl : public BasicTTIImplBase<XCoreTTIImpl> {
31   typedef BasicTTIImplBase<XCoreTTIImpl> BaseT;
32   typedef TargetTransformInfo TTI;
33
34 public:
35   explicit XCoreTTIImpl(const XCoreTargetMachine *TM = nullptr) : BaseT(TM) {}
36
37   // Provide value semantics. MSVC requires that we spell all of these out.
38   XCoreTTIImpl(const XCoreTTIImpl &Arg)
39       : BaseT(static_cast<const BaseT &>(Arg)) {}
40   XCoreTTIImpl(XCoreTTIImpl &&Arg)
41       : BaseT(std::move(static_cast<BaseT &>(Arg))) {}
42   XCoreTTIImpl &operator=(const XCoreTTIImpl &RHS) {
43     BaseT::operator=(static_cast<const BaseT &>(RHS));
44     return *this;
45   }
46   XCoreTTIImpl &operator=(XCoreTTIImpl &&RHS) {
47     BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
48     return *this;
49   }
50
51   unsigned getNumberOfRegisters(bool Vector) {
52     if (Vector) {
53        return 0;
54     }
55     return 12;
56   }
57 };
58
59 } // end anonymous namespace
60
61 ImmutablePass *
62 llvm::createXCoreTargetTransformInfoPass(const XCoreTargetMachine *TM) {
63   return new TargetTransformInfoWrapperPass(XCoreTTIImpl(TM));
64 }