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 
260b57cec5SDimitry Andric   const SystemZSubtarget *getST() const { return ST; }
270b57cec5SDimitry Andric   const SystemZTargetLowering *getTLI() const { return TLI; }
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric   unsigned const LIBCALL_COST = 30;
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric public:
320b57cec5SDimitry Andric   explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
330b57cec5SDimitry Andric       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
340b57cec5SDimitry Andric         TLI(ST->getTargetLowering()) {}
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric   /// \name Scalar TTI Implementations
370b57cec5SDimitry Andric   /// @{
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric   unsigned getInliningThresholdMultiplier() { return 3; }
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric   int getIntImmCost(const APInt &Imm, Type *Ty);
420b57cec5SDimitry Andric 
43480093f4SDimitry Andric   int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
44480093f4SDimitry Andric   int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
450b57cec5SDimitry Andric                           Type *Ty);
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric   void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
500b57cec5SDimitry Andric                                TTI::UnrollingPreferences &UP);
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric   bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
530b57cec5SDimitry Andric                      TargetTransformInfo::LSRCost &C2);
540b57cec5SDimitry Andric   /// @}
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric   /// \name Vector TTI Implementations
570b57cec5SDimitry Andric   /// @{
580b57cec5SDimitry Andric 
598bcb0991SDimitry Andric   unsigned getNumberOfRegisters(unsigned ClassID) const;
600b57cec5SDimitry Andric   unsigned getRegisterBitWidth(bool Vector) const;
610b57cec5SDimitry Andric 
628bcb0991SDimitry Andric   unsigned getCacheLineSize() const override { return 256; }
638bcb0991SDimitry Andric   unsigned getPrefetchDistance() const override { return 2000; }
648bcb0991SDimitry Andric   unsigned getMinPrefetchStride() const override { return 2048; }
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric   bool hasDivRemOp(Type *DataType, bool IsSigned);
670b57cec5SDimitry Andric   bool prefersVectorizedAddressing() { return false; }
680b57cec5SDimitry Andric   bool LSRWithInstrQueries() { return true; }
690b57cec5SDimitry Andric   bool supportsEfficientVectorElementLoadStore() { return true; }
700b57cec5SDimitry Andric   bool enableInterleavedAccessVectorization() { return true; }
710b57cec5SDimitry Andric 
720b57cec5SDimitry Andric   int getArithmeticInstrCost(
730b57cec5SDimitry Andric       unsigned Opcode, Type *Ty,
740b57cec5SDimitry Andric       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
750b57cec5SDimitry Andric       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
760b57cec5SDimitry Andric       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
770b57cec5SDimitry Andric       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
78480093f4SDimitry Andric       ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
79480093f4SDimitry Andric       const Instruction *CxtI = nullptr);
800b57cec5SDimitry Andric   int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
810b57cec5SDimitry Andric   unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
820b57cec5SDimitry Andric   unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
830b57cec5SDimitry Andric   unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
840b57cec5SDimitry Andric                                          const Instruction *I);
850b57cec5SDimitry Andric   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
860b57cec5SDimitry Andric                        const Instruction *I = nullptr);
870b57cec5SDimitry Andric   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
880b57cec5SDimitry Andric                          const Instruction *I = nullptr);
890b57cec5SDimitry Andric   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
900b57cec5SDimitry Andric   bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
91480093f4SDimitry Andric   int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
920b57cec5SDimitry Andric                       unsigned AddressSpace, const Instruction *I = nullptr);
930b57cec5SDimitry Andric 
940b57cec5SDimitry Andric   int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
950b57cec5SDimitry Andric                                  unsigned Factor,
960b57cec5SDimitry Andric                                  ArrayRef<unsigned> Indices,
970b57cec5SDimitry Andric                                  unsigned Alignment,
980b57cec5SDimitry Andric                                  unsigned AddressSpace,
990b57cec5SDimitry Andric                                  bool UseMaskForCond = false,
1000b57cec5SDimitry Andric                                  bool UseMaskForGaps = false);
1010b57cec5SDimitry Andric 
1020b57cec5SDimitry Andric   int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
1030b57cec5SDimitry Andric                             ArrayRef<Value *> Args, FastMathFlags FMF,
1040b57cec5SDimitry Andric                             unsigned VF = 1);
1050b57cec5SDimitry Andric   int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
1060b57cec5SDimitry Andric                             ArrayRef<Type *> Tys, FastMathFlags FMF,
1070b57cec5SDimitry Andric                             unsigned ScalarizationCostPassed = UINT_MAX);
1080b57cec5SDimitry Andric   /// @}
1090b57cec5SDimitry Andric };
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric } // end namespace llvm
1120b57cec5SDimitry Andric 
1130b57cec5SDimitry Andric #endif
114