Switch lowering: Take branch weight into account when ordering for fall-through
[oota-llvm.git] / lib / Target / XCore / XCoreTargetTransformInfo.h
1 //===-- XCoreTargetTransformInfo.h - XCore specific TTI ---------*- 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 /// \file
10 /// This file a TargetTransformInfo::Concept conforming object specific to the
11 /// XCore target machine. It uses the target's detailed information to
12 /// provide more precise answers to certain TTI queries, while letting the
13 /// target independent and default TTI implementations handle the rest.
14 ///
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_LIB_TARGET_XCORE_XCORETARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_XCORE_XCORETARGETTRANSFORMINFO_H
19
20 #include "XCore.h"
21 #include "XCoreTargetMachine.h"
22 #include "llvm/Analysis/TargetTransformInfo.h"
23 #include "llvm/CodeGen/BasicTTIImpl.h"
24 #include "llvm/Target/TargetLowering.h"
25
26 namespace llvm {
27
28 class XCoreTTIImpl : public BasicTTIImplBase<XCoreTTIImpl> {
29   typedef BasicTTIImplBase<XCoreTTIImpl> BaseT;
30   typedef TargetTransformInfo TTI;
31   friend BaseT;
32
33   const XCoreSubtarget *ST;
34   const XCoreTargetLowering *TLI;
35
36   const XCoreSubtarget *getST() const { return ST; }
37   const XCoreTargetLowering *getTLI() const { return TLI; }
38
39 public:
40   explicit XCoreTTIImpl(const XCoreTargetMachine *TM)
41       : BaseT(TM), ST(TM->getSubtargetImpl()), TLI(ST->getTargetLowering()) {}
42
43   // Provide value semantics. MSVC requires that we spell all of these out.
44   XCoreTTIImpl(const XCoreTTIImpl &Arg)
45       : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
46   XCoreTTIImpl(XCoreTTIImpl &&Arg)
47       : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
48         TLI(std::move(Arg.TLI)) {}
49   XCoreTTIImpl &operator=(const XCoreTTIImpl &RHS) {
50     BaseT::operator=(static_cast<const BaseT &>(RHS));
51     ST = RHS.ST;
52     TLI = RHS.TLI;
53     return *this;
54   }
55   XCoreTTIImpl &operator=(XCoreTTIImpl &&RHS) {
56     BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
57     ST = std::move(RHS.ST);
58     TLI = std::move(RHS.TLI);
59     return *this;
60   }
61
62   unsigned getNumberOfRegisters(bool Vector) {
63     if (Vector) {
64       return 0;
65     }
66     return 12;
67   }
68 };
69
70 } // end namespace llvm
71
72 #endif