xref: /aosp_15_r20/external/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- PPCTargetTransformInfo.h - PPC specific TTI -------------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker /// \file
10*9880d681SAndroid Build Coastguard Worker /// This file a TargetTransformInfo::Concept conforming object specific to the
11*9880d681SAndroid Build Coastguard Worker /// PPC target machine. It uses the target's detailed information to
12*9880d681SAndroid Build Coastguard Worker /// provide more precise answers to certain TTI queries, while letting the
13*9880d681SAndroid Build Coastguard Worker /// target independent and default TTI implementations handle the rest.
14*9880d681SAndroid Build Coastguard Worker ///
15*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
18*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
19*9880d681SAndroid Build Coastguard Worker 
20*9880d681SAndroid Build Coastguard Worker #include "PPC.h"
21*9880d681SAndroid Build Coastguard Worker #include "PPCTargetMachine.h"
22*9880d681SAndroid Build Coastguard Worker #include "llvm/Analysis/TargetTransformInfo.h"
23*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/BasicTTIImpl.h"
24*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h"
25*9880d681SAndroid Build Coastguard Worker 
26*9880d681SAndroid Build Coastguard Worker namespace llvm {
27*9880d681SAndroid Build Coastguard Worker 
28*9880d681SAndroid Build Coastguard Worker class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
29*9880d681SAndroid Build Coastguard Worker   typedef BasicTTIImplBase<PPCTTIImpl> BaseT;
30*9880d681SAndroid Build Coastguard Worker   typedef TargetTransformInfo TTI;
31*9880d681SAndroid Build Coastguard Worker   friend BaseT;
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker   const PPCSubtarget *ST;
34*9880d681SAndroid Build Coastguard Worker   const PPCTargetLowering *TLI;
35*9880d681SAndroid Build Coastguard Worker 
getST()36*9880d681SAndroid Build Coastguard Worker   const PPCSubtarget *getST() const { return ST; }
getTLI()37*9880d681SAndroid Build Coastguard Worker   const PPCTargetLowering *getTLI() const { return TLI; }
38*9880d681SAndroid Build Coastguard Worker 
39*9880d681SAndroid Build Coastguard Worker public:
PPCTTIImpl(const PPCTargetMachine * TM,const Function & F)40*9880d681SAndroid Build Coastguard Worker   explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
41*9880d681SAndroid Build Coastguard Worker       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42*9880d681SAndroid Build Coastguard Worker         TLI(ST->getTargetLowering()) {}
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker   // Provide value semantics. MSVC requires that we spell all of these out.
PPCTTIImpl(const PPCTTIImpl & Arg)45*9880d681SAndroid Build Coastguard Worker   PPCTTIImpl(const PPCTTIImpl &Arg)
46*9880d681SAndroid Build Coastguard Worker       : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
PPCTTIImpl(PPCTTIImpl && Arg)47*9880d681SAndroid Build Coastguard Worker   PPCTTIImpl(PPCTTIImpl &&Arg)
48*9880d681SAndroid Build Coastguard Worker       : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
49*9880d681SAndroid Build Coastguard Worker         TLI(std::move(Arg.TLI)) {}
50*9880d681SAndroid Build Coastguard Worker 
51*9880d681SAndroid Build Coastguard Worker   /// \name Scalar TTI Implementations
52*9880d681SAndroid Build Coastguard Worker   /// @{
53*9880d681SAndroid Build Coastguard Worker 
54*9880d681SAndroid Build Coastguard Worker   using BaseT::getIntImmCost;
55*9880d681SAndroid Build Coastguard Worker   int getIntImmCost(const APInt &Imm, Type *Ty);
56*9880d681SAndroid Build Coastguard Worker 
57*9880d681SAndroid Build Coastguard Worker   int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
58*9880d681SAndroid Build Coastguard Worker   int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
59*9880d681SAndroid Build Coastguard Worker                     Type *Ty);
60*9880d681SAndroid Build Coastguard Worker 
61*9880d681SAndroid Build Coastguard Worker   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
62*9880d681SAndroid Build Coastguard Worker   void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker   /// @}
65*9880d681SAndroid Build Coastguard Worker 
66*9880d681SAndroid Build Coastguard Worker   /// \name Vector TTI Implementations
67*9880d681SAndroid Build Coastguard Worker   /// @{
68*9880d681SAndroid Build Coastguard Worker 
69*9880d681SAndroid Build Coastguard Worker   bool enableAggressiveInterleaving(bool LoopHasReductions);
70*9880d681SAndroid Build Coastguard Worker   bool enableInterleavedAccessVectorization();
71*9880d681SAndroid Build Coastguard Worker   unsigned getNumberOfRegisters(bool Vector);
72*9880d681SAndroid Build Coastguard Worker   unsigned getRegisterBitWidth(bool Vector);
73*9880d681SAndroid Build Coastguard Worker   unsigned getCacheLineSize();
74*9880d681SAndroid Build Coastguard Worker   unsigned getPrefetchDistance();
75*9880d681SAndroid Build Coastguard Worker   unsigned getMaxInterleaveFactor(unsigned VF);
76*9880d681SAndroid Build Coastguard Worker   int getArithmeticInstrCost(
77*9880d681SAndroid Build Coastguard Worker       unsigned Opcode, Type *Ty,
78*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
79*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
80*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
81*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
82*9880d681SAndroid Build Coastguard Worker   int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
83*9880d681SAndroid Build Coastguard Worker   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
84*9880d681SAndroid Build Coastguard Worker   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
85*9880d681SAndroid Build Coastguard Worker   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
86*9880d681SAndroid Build Coastguard Worker   int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
87*9880d681SAndroid Build Coastguard Worker                       unsigned AddressSpace);
88*9880d681SAndroid Build Coastguard Worker   int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
89*9880d681SAndroid Build Coastguard Worker                                  unsigned Factor,
90*9880d681SAndroid Build Coastguard Worker                                  ArrayRef<unsigned> Indices,
91*9880d681SAndroid Build Coastguard Worker                                  unsigned Alignment,
92*9880d681SAndroid Build Coastguard Worker                                  unsigned AddressSpace);
93*9880d681SAndroid Build Coastguard Worker 
94*9880d681SAndroid Build Coastguard Worker   /// @}
95*9880d681SAndroid Build Coastguard Worker };
96*9880d681SAndroid Build Coastguard Worker 
97*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
98*9880d681SAndroid Build Coastguard Worker 
99*9880d681SAndroid Build Coastguard Worker #endif
100