• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- HexagonTargetTransformInfo.cpp - Hexagon 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 /// \file
9 /// This file implements a TargetTransformInfo analysis pass specific to the
10 /// Hexagon target machine. It uses the target's detailed information to provide
11 /// more precise answers to certain TTI queries, while letting the target
12 /// independent and default TTI implementations handle the rest.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONTARGETTRANSFORMINFO_H
17 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONTARGETTRANSFORMINFO_H
18 
19 #include "Hexagon.h"
20 #include "HexagonTargetMachine.h"
21 #include "llvm/Analysis/TargetTransformInfo.h"
22 #include "llvm/CodeGen/BasicTTIImpl.h"
23 #include "llvm/Target/TargetLowering.h"
24 
25 namespace llvm {
26 
27 class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
28   typedef BasicTTIImplBase<HexagonTTIImpl> BaseT;
29   typedef TargetTransformInfo TTI;
30   friend BaseT;
31 
32   const HexagonSubtarget *ST;
33   const HexagonTargetLowering *TLI;
34 
getST()35   const HexagonSubtarget *getST() const { return ST; }
getTLI()36   const HexagonTargetLowering *getTLI() const { return TLI; }
37 
38 public:
HexagonTTIImpl(const HexagonTargetMachine * TM,const Function & F)39   explicit HexagonTTIImpl(const HexagonTargetMachine *TM, const Function &F)
40       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
41         TLI(ST->getTargetLowering()) {}
42 
43   // Provide value semantics. MSVC requires that we spell all of these out.
HexagonTTIImpl(const HexagonTTIImpl & Arg)44   HexagonTTIImpl(const HexagonTTIImpl &Arg)
45       : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
HexagonTTIImpl(HexagonTTIImpl && Arg)46   HexagonTTIImpl(HexagonTTIImpl &&Arg)
47       : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
48         TLI(std::move(Arg.TLI)) {}
49 
50   /// \name Scalar TTI Implementations
51   /// @{
52 
53   TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const;
54 
55   // The Hexagon target can unroll loops with run-time trip counts.
56   void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
57 
58   /// @}
59 
60   /// \name Vector TTI Implementations
61   /// @{
62 
63   unsigned getNumberOfRegisters(bool vector) const;
64 
65   /// @}
66 };
67 
68 } // end namespace llvm
69 
70 #endif
71