PPCTargetTransformInfo.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //===-- PPCTargetTransformInfo.h - PPC specific TTI -------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. /// This file a TargetTransformInfo::Concept conforming object specific to the
  10. /// PPC target machine. It uses the target's detailed information to
  11. /// provide more precise answers to certain TTI queries, while letting the
  12. /// target independent and default TTI implementations handle the rest.
  13. ///
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
  16. #define LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
  17. #include "PPCTargetMachine.h"
  18. #include "llvm/Analysis/TargetTransformInfo.h"
  19. #include "llvm/CodeGen/BasicTTIImpl.h"
  20. #include "llvm/CodeGen/TargetLowering.h"
  21. namespace llvm {
  22. class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
  23. typedef BasicTTIImplBase<PPCTTIImpl> BaseT;
  24. typedef TargetTransformInfo TTI;
  25. friend BaseT;
  26. const PPCSubtarget *ST;
  27. const PPCTargetLowering *TLI;
  28. const PPCSubtarget *getST() const { return ST; }
  29. const PPCTargetLowering *getTLI() const { return TLI; }
  30. bool mightUseCTR(BasicBlock *BB, TargetLibraryInfo *LibInfo,
  31. SmallPtrSetImpl<const Value *> &Visited);
  32. public:
  33. explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
  34. : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
  35. TLI(ST->getTargetLowering()) {}
  36. Optional<Instruction *> instCombineIntrinsic(InstCombiner &IC,
  37. IntrinsicInst &II) const;
  38. /// \name Scalar TTI Implementations
  39. /// @{
  40. using BaseT::getIntImmCost;
  41. int getIntImmCost(const APInt &Imm, Type *Ty,
  42. TTI::TargetCostKind CostKind);
  43. int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm,
  44. Type *Ty, TTI::TargetCostKind CostKind,
  45. Instruction *Inst = nullptr);
  46. int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
  47. Type *Ty, TTI::TargetCostKind CostKind);
  48. unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands,
  49. TTI::TargetCostKind CostKind);
  50. TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
  51. bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
  52. AssumptionCache &AC,
  53. TargetLibraryInfo *LibInfo,
  54. HardwareLoopInfo &HWLoopInfo);
  55. bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI,
  56. DominatorTree *DT, AssumptionCache *AC,
  57. TargetLibraryInfo *LibInfo);
  58. bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info);
  59. void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
  60. TTI::UnrollingPreferences &UP);
  61. void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
  62. TTI::PeelingPreferences &PP);
  63. bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
  64. TargetTransformInfo::LSRCost &C2);
  65. bool isNumRegsMajorCostOfLSR();
  66. /// @}
  67. /// \name Vector TTI Implementations
  68. /// @{
  69. bool useColdCCForColdCall(Function &F);
  70. bool enableAggressiveInterleaving(bool LoopHasReductions);
  71. TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize,
  72. bool IsZeroCmp) const;
  73. bool enableInterleavedAccessVectorization();
  74. enum PPCRegisterClass {
  75. GPRRC, FPRRC, VRRC, VSXRC
  76. };
  77. unsigned getNumberOfRegisters(unsigned ClassID) const;
  78. unsigned getRegisterClassForType(bool Vector, Type *Ty = nullptr) const;
  79. const char* getRegisterClassName(unsigned ClassID) const;
  80. unsigned getRegisterBitWidth(bool Vector) const;
  81. unsigned getCacheLineSize() const override;
  82. unsigned getPrefetchDistance() const override;
  83. unsigned getMaxInterleaveFactor(unsigned VF);
  84. int vectorCostAdjustment(int Cost, unsigned Opcode, Type *Ty1, Type *Ty2);
  85. int getArithmeticInstrCost(
  86. unsigned Opcode, Type *Ty,
  87. TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
  88. TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
  89. TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
  90. TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
  91. TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
  92. ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
  93. const Instruction *CxtI = nullptr);
  94. int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
  95. int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
  96. TTI::CastContextHint CCH, TTI::TargetCostKind CostKind,
  97. const Instruction *I = nullptr);
  98. int getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind);
  99. int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
  100. CmpInst::Predicate VecPred,
  101. TTI::TargetCostKind CostKind,
  102. const Instruction *I = nullptr);
  103. int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
  104. int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
  105. unsigned AddressSpace,
  106. TTI::TargetCostKind CostKind,
  107. const Instruction *I = nullptr);
  108. int getInterleavedMemoryOpCost(
  109. unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
  110. Align Alignment, unsigned AddressSpace,
  111. TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
  112. bool UseMaskForCond = false, bool UseMaskForGaps = false);
  113. unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
  114. TTI::TargetCostKind CostKind);
  115. bool areFunctionArgsABICompatible(const Function *Caller,
  116. const Function *Callee,
  117. SmallPtrSetImpl<Argument *> &Args) const;
  118. /// @}
  119. };
  120. } // end namespace llvm
  121. #endif