| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 1 | //===-- PPCTargetTransformInfo.h - PPC specific TTI -------------*- C++ -*-===// |
| 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 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 | |
| 16 | #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H |
| 17 | #define LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H |
| 18 | |
| 19 | #include "PPC.h" |
| 20 | #include "PPCTargetMachine.h" |
| 21 | #include "llvm/Analysis/TargetTransformInfo.h" |
| 22 | #include "llvm/CodeGen/BasicTTIImpl.h" |
| David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/TargetLowering.h" |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
| 27 | class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> { |
| 28 | typedef BasicTTIImplBase<PPCTTIImpl> BaseT; |
| 29 | typedef TargetTransformInfo TTI; |
| Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 30 | friend BaseT; |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 31 | |
| 32 | const PPCSubtarget *ST; |
| 33 | const PPCTargetLowering *TLI; |
| 34 | |
| Chandler Carruth | c956ab66 | 2015-02-01 14:22:17 +0000 | [diff] [blame] | 35 | const PPCSubtarget *getST() const { return ST; } |
| Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 36 | const PPCTargetLowering *getTLI() const { return TLI; } |
| 37 | |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 38 | public: |
| Eric Christopher | a4e5d3c | 2015-09-16 23:38:13 +0000 | [diff] [blame] | 39 | explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F) |
| Mehdi Amini | 5010ebf | 2015-07-09 02:08:42 +0000 | [diff] [blame] | 40 | : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), |
| 41 | TLI(ST->getTargetLowering()) {} |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 42 | |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 43 | /// \name Scalar TTI Implementations |
| 44 | /// @{ |
| 45 | |
| 46 | using BaseT::getIntImmCost; |
| Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 47 | int getIntImmCost(const APInt &Imm, Type *Ty); |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 48 | |
| Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 49 | int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty); |
| 50 | int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, |
| 51 | Type *Ty); |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 52 | |
| Graham Yiu | 488782e | 2017-10-19 18:16:31 +0000 | [diff] [blame] | 53 | unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands); |
| 54 | |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 55 | TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); |
| Geoff Berry | 66d9bdb | 2017-06-28 15:53:17 +0000 | [diff] [blame] | 56 | void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, |
| 57 | TTI::UnrollingPreferences &UP); |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 58 | |
| 59 | /// @} |
| 60 | |
| 61 | /// \name Vector TTI Implementations |
| 62 | /// @{ |
| Zaara Syeda | 1f59ae3 | 2018-01-30 16:17:22 +0000 | [diff] [blame] | 63 | bool useColdCCForColdCall(Function &F); |
| Olivier Sallenave | 049d803 | 2015-03-06 23:12:04 +0000 | [diff] [blame] | 64 | bool enableAggressiveInterleaving(bool LoopHasReductions); |
| Clement Courbet | b2c3eb8 | 2017-10-30 14:19:33 +0000 | [diff] [blame] | 65 | const TTI::MemCmpExpansionOptions *enableMemCmpExpansion( |
| 66 | bool IsZeroCmp) const; |
| Hal Finkel | 4a7be23 | 2015-09-04 00:10:41 +0000 | [diff] [blame] | 67 | bool enableInterleavedAccessVectorization(); |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 68 | unsigned getNumberOfRegisters(bool Vector); |
| Daniel Neilson | c0112ae | 2017-06-12 14:22:21 +0000 | [diff] [blame] | 69 | unsigned getRegisterBitWidth(bool Vector) const; |
| Adam Nemet | af76110 | 2016-01-21 18:28:36 +0000 | [diff] [blame] | 70 | unsigned getCacheLineSize(); |
| Adam Nemet | dadfbb5 | 2016-01-27 22:21:25 +0000 | [diff] [blame] | 71 | unsigned getPrefetchDistance(); |
| Wei Mi | 062c744 | 2015-05-06 17:12:25 +0000 | [diff] [blame] | 72 | unsigned getMaxInterleaveFactor(unsigned VF); |
| Nemanja Ivanovic | 7d007dd | 2019-01-26 01:18:48 +0000 | [diff] [blame] | 73 | int vectorCostAdjustment(int Cost, unsigned Opcode, Type *Ty1, Type *Ty2); |
| Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 74 | int getArithmeticInstrCost( |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 75 | unsigned Opcode, Type *Ty, |
| 76 | TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
| 77 | TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
| 78 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
| Mohammed Agabaria | 2c96c43 | 2017-01-11 08:23:37 +0000 | [diff] [blame] | 79 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, |
| 80 | ArrayRef<const Value *> Args = ArrayRef<const Value *>()); |
| Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 81 | int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); |
| Jonas Paulsson | fccc7d6 | 2017-04-12 11:49:08 +0000 | [diff] [blame] | 82 | int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, |
| 83 | const Instruction *I = nullptr); |
| 84 | int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, |
| 85 | const Instruction *I = nullptr); |
| Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 86 | int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
| 87 | int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
| Jonas Paulsson | fccc7d6 | 2017-04-12 11:49:08 +0000 | [diff] [blame] | 88 | unsigned AddressSpace, const Instruction *I = nullptr); |
| Hal Finkel | 4a7be23 | 2015-09-04 00:10:41 +0000 | [diff] [blame] | 89 | int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, |
| 90 | unsigned Factor, |
| 91 | ArrayRef<unsigned> Indices, |
| 92 | unsigned Alignment, |
| Dorit Nuzman | 38bbf81 | 2018-10-14 08:50:06 +0000 | [diff] [blame] | 93 | unsigned AddressSpace, |
| Dorit Nuzman | 34da6dd | 2018-10-31 09:57:56 +0000 | [diff] [blame] | 94 | bool UseMaskForCond = false, |
| 95 | bool UseMaskForGaps = false); |
| Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 96 | |
| 97 | /// @} |
| 98 | }; |
| 99 | |
| 100 | } // end namespace llvm |
| 101 | |
| 102 | #endif |