10b57cec5SDimitry Andric //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "SystemZTargetMachine.h"
130b57cec5SDimitry Andric #include "llvm/Analysis/TargetTransformInfo.h"
140b57cec5SDimitry Andric #include "llvm/CodeGen/BasicTTIImpl.h"
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric namespace llvm {
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
190b57cec5SDimitry Andric   typedef BasicTTIImplBase<SystemZTTIImpl> BaseT;
200b57cec5SDimitry Andric   typedef TargetTransformInfo TTI;
210b57cec5SDimitry Andric   friend BaseT;
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric   const SystemZSubtarget *ST;
240b57cec5SDimitry Andric   const SystemZTargetLowering *TLI;
250b57cec5SDimitry Andric 
getST()260b57cec5SDimitry Andric   const SystemZSubtarget *getST() const { return ST; }
getTLI()270b57cec5SDimitry Andric   const SystemZTargetLowering *getTLI() const { return TLI; }
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric   unsigned const LIBCALL_COST = 30;
300b57cec5SDimitry Andric 
isInt128InVR(Type * Ty)317a6dacacSDimitry Andric   bool isInt128InVR(Type *Ty) { return Ty->isIntegerTy(128) && ST->hasVector(); }
327a6dacacSDimitry Andric 
330b57cec5SDimitry Andric public:
SystemZTTIImpl(const SystemZTargetMachine * TM,const Function & F)340b57cec5SDimitry Andric   explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
350b57cec5SDimitry Andric       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
360b57cec5SDimitry Andric         TLI(ST->getTargetLowering()) {}
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   /// \name Scalar TTI Implementations
390b57cec5SDimitry Andric   /// @{
400b57cec5SDimitry Andric 
getInliningThresholdMultiplier()4106c3fb27SDimitry Andric   unsigned getInliningThresholdMultiplier() const { return 3; }
4281ad6265SDimitry Andric   unsigned adjustInliningThreshold(const CallBase *CB) const;
430b57cec5SDimitry Andric 
44fe6060f1SDimitry Andric   InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
45fe6060f1SDimitry Andric                                 TTI::TargetCostKind CostKind);
460b57cec5SDimitry Andric 
47fe6060f1SDimitry Andric   InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
48fe6060f1SDimitry Andric                                     const APInt &Imm, Type *Ty,
49fe6060f1SDimitry Andric                                     TTI::TargetCostKind CostKind,
50e8d8bef9SDimitry Andric                                     Instruction *Inst = nullptr);
51fe6060f1SDimitry Andric   InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx,
52fe6060f1SDimitry Andric                                       const APInt &Imm, Type *Ty,
53fe6060f1SDimitry Andric                                       TTI::TargetCostKind CostKind);
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric   void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
58349cc55cSDimitry Andric                                TTI::UnrollingPreferences &UP,
59349cc55cSDimitry Andric                                OptimizationRemarkEmitter *ORE);
600b57cec5SDimitry Andric 
615ffd83dbSDimitry Andric   void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
625ffd83dbSDimitry Andric                              TTI::PeelingPreferences &PP);
635ffd83dbSDimitry Andric 
6481ad6265SDimitry Andric   bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
6581ad6265SDimitry Andric                      const TargetTransformInfo::LSRCost &C2);
660b57cec5SDimitry Andric   /// @}
670b57cec5SDimitry Andric 
680b57cec5SDimitry Andric   /// \name Vector TTI Implementations
690b57cec5SDimitry Andric   /// @{
700b57cec5SDimitry Andric 
718bcb0991SDimitry Andric   unsigned getNumberOfRegisters(unsigned ClassID) const;
72fe6060f1SDimitry Andric   TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const;
730b57cec5SDimitry Andric 
getCacheLineSize()748bcb0991SDimitry Andric   unsigned getCacheLineSize() const override { return 256; }
getPrefetchDistance()755ffd83dbSDimitry Andric   unsigned getPrefetchDistance() const override { return 4500; }
765ffd83dbSDimitry Andric   unsigned getMinPrefetchStride(unsigned NumMemAccesses,
775ffd83dbSDimitry Andric                                 unsigned NumStridedMemAccesses,
785ffd83dbSDimitry Andric                                 unsigned NumPrefetches,
795ffd83dbSDimitry Andric                                 bool HasCall) const override;
enableWritePrefetching()805ffd83dbSDimitry Andric   bool enableWritePrefetching() const override { return true; }
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric   bool hasDivRemOp(Type *DataType, bool IsSigned);
prefersVectorizedAddressing()830b57cec5SDimitry Andric   bool prefersVectorizedAddressing() { return false; }
LSRWithInstrQueries()840b57cec5SDimitry Andric   bool LSRWithInstrQueries() { return true; }
supportsEfficientVectorElementLoadStore()850b57cec5SDimitry Andric   bool supportsEfficientVectorElementLoadStore() { return true; }
enableInterleavedAccessVectorization()860b57cec5SDimitry Andric   bool enableInterleavedAccessVectorization() { return true; }
870b57cec5SDimitry Andric 
88fe6060f1SDimitry Andric   InstructionCost getArithmeticInstrCost(
89349cc55cSDimitry Andric       unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
90bdd1243dSDimitry Andric       TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
91bdd1243dSDimitry Andric       TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
92480093f4SDimitry Andric       ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
93480093f4SDimitry Andric       const Instruction *CxtI = nullptr);
94fe6060f1SDimitry Andric   InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
95bdd1243dSDimitry Andric                                  ArrayRef<int> Mask,
96bdd1243dSDimitry Andric                                  TTI::TargetCostKind CostKind, int Index,
9781ad6265SDimitry Andric                                  VectorType *SubTp,
98bdd1243dSDimitry Andric                                  ArrayRef<const Value *> Args = std::nullopt);
990b57cec5SDimitry Andric   unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
1000b57cec5SDimitry Andric   unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
1010b57cec5SDimitry Andric   unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
1020b57cec5SDimitry Andric                                          const Instruction *I);
103fe6060f1SDimitry Andric   InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
104fe6060f1SDimitry Andric                                    TTI::CastContextHint CCH,
105fe6060f1SDimitry Andric                                    TTI::TargetCostKind CostKind,
1060b57cec5SDimitry Andric                                    const Instruction *I = nullptr);
107fe6060f1SDimitry Andric   InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
108e8d8bef9SDimitry Andric                                      CmpInst::Predicate VecPred,
1095ffd83dbSDimitry Andric                                      TTI::TargetCostKind CostKind,
1100b57cec5SDimitry Andric                                      const Instruction *I = nullptr);
111bdd1243dSDimitry Andric   using BaseT::getVectorInstrCost;
112fe6060f1SDimitry Andric   InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
113fe6060f1SDimitry Andric                                      TTI::TargetCostKind CostKind,
114bdd1243dSDimitry Andric                                      unsigned Index, Value *Op0, Value *Op1);
115bdd1243dSDimitry Andric   bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
116bdd1243dSDimitry Andric   InstructionCost
117bdd1243dSDimitry Andric   getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
118bdd1243dSDimitry Andric                   unsigned AddressSpace, TTI::TargetCostKind CostKind,
119bdd1243dSDimitry Andric                   TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
1205ffd83dbSDimitry Andric                   const Instruction *I = nullptr);
1210b57cec5SDimitry Andric 
122fe6060f1SDimitry Andric   InstructionCost getInterleavedMemoryOpCost(
1235ffd83dbSDimitry Andric       unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
124349cc55cSDimitry Andric       Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
1255ffd83dbSDimitry Andric       bool UseMaskForCond = false, bool UseMaskForGaps = false);
1260b57cec5SDimitry Andric 
127fe6060f1SDimitry Andric   InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
1285ffd83dbSDimitry Andric                                         TTI::TargetCostKind CostKind);
1290b57cec5SDimitry Andric   /// @}
1300b57cec5SDimitry Andric };
1310b57cec5SDimitry Andric 
1320b57cec5SDimitry Andric } // end namespace llvm
1330b57cec5SDimitry Andric 
1340b57cec5SDimitry Andric #endif
135