brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.8 KiB · fc681de Raw
157 lines · c
1//===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H10#define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H11 12#include "SystemZTargetMachine.h"13#include "llvm/Analysis/TargetTransformInfo.h"14#include "llvm/CodeGen/BasicTTIImpl.h"15 16namespace llvm {17 18class SystemZTTIImpl final : public BasicTTIImplBase<SystemZTTIImpl> {19  typedef BasicTTIImplBase<SystemZTTIImpl> BaseT;20  typedef TargetTransformInfo TTI;21  friend BaseT;22 23  const SystemZSubtarget *ST;24  const SystemZTargetLowering *TLI;25 26  const SystemZSubtarget *getST() const { return ST; }27  const SystemZTargetLowering *getTLI() const { return TLI; }28 29  unsigned const LIBCALL_COST = 30;30 31  bool isInt128InVR(Type *Ty) const {32    return Ty->isIntegerTy(128) && ST->hasVector();33  }34 35public:36  explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)37      : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),38        TLI(ST->getTargetLowering()) {}39 40  /// \name Scalar TTI Implementations41  /// @{42 43  unsigned adjustInliningThreshold(const CallBase *CB) const override;44 45  InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,46                                TTI::TargetCostKind CostKind) const override;47 48  InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,49                                    const APInt &Imm, Type *Ty,50                                    TTI::TargetCostKind CostKind,51                                    Instruction *Inst = nullptr) const override;52  InstructionCost53  getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,54                      Type *Ty, TTI::TargetCostKind CostKind) const override;55 56  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;57 58  void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,59                               TTI::UnrollingPreferences &UP,60                               OptimizationRemarkEmitter *ORE) const override;61 62  void getPeelingPreferences(Loop *L, ScalarEvolution &SE,63                             TTI::PeelingPreferences &PP) const override;64 65  bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,66                     const TargetTransformInfo::LSRCost &C2) const override;67 68  /// @}69 70  /// \name Vector TTI Implementations71  /// @{72 73  unsigned getNumberOfRegisters(unsigned ClassID) const override;74  TypeSize75  getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override;76 77  unsigned getCacheLineSize() const override { return 256; }78  unsigned getPrefetchDistance() const override { return 4500; }79  unsigned getMinPrefetchStride(unsigned NumMemAccesses,80                                unsigned NumStridedMemAccesses,81                                unsigned NumPrefetches,82                                bool HasCall) const override;83  bool enableWritePrefetching() const override { return true; }84 85  bool hasDivRemOp(Type *DataType, bool IsSigned) const override;86  bool prefersVectorizedAddressing() const override { return false; }87  bool LSRWithInstrQueries() const override { return true; }88  InstructionCost getScalarizationOverhead(89      VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,90      TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,91      ArrayRef<Value *> VL = {}) const override;92  bool supportsEfficientVectorElementLoadStore() const override { return true; }93  bool enableInterleavedAccessVectorization() const override { return true; }94 95  InstructionCost getArithmeticInstrCost(96      unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,97      TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},98      TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},99      ArrayRef<const Value *> Args = {},100      const Instruction *CxtI = nullptr) const override;101  InstructionCost102  getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy,103                 ArrayRef<int> Mask, TTI::TargetCostKind CostKind, int Index,104                 VectorType *SubTp, ArrayRef<const Value *> Args = {},105                 const Instruction *CxtI = nullptr) const override;106  unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const;107  unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const;108  unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,109                                         const Instruction *I) const;110  InstructionCost111  getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,112                   TTI::CastContextHint CCH, TTI::TargetCostKind CostKind,113                   const Instruction *I = nullptr) const override;114  InstructionCost getCmpSelInstrCost(115      unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,116      TTI::TargetCostKind CostKind,117      TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},118      TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},119      const Instruction *I = nullptr) const override;120  using BaseT::getVectorInstrCost;121  InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,122                                     TTI::TargetCostKind CostKind,123                                     unsigned Index, const Value *Op0,124                                     const Value *Op1) const override;125  bool isFoldableLoad(const LoadInst *Ld,126                      const Instruction *&FoldedValue) const;127  InstructionCost getMemoryOpCost(128      unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,129      TTI::TargetCostKind CostKind,130      TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},131      const Instruction *I = nullptr) const override;132 133  InstructionCost getInterleavedMemoryOpCost(134      unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,135      Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,136      bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;137 138  InstructionCost139  getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,140                             std::optional<FastMathFlags> FMF,141                             TTI::TargetCostKind CostKind) const override;142  InstructionCost143  getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,144                         TTI::TargetCostKind CostKind) const override;145 146  InstructionCost147  getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,148                        TTI::TargetCostKind CostKind) const override;149 150  bool shouldExpandReduction(const IntrinsicInst *II) const override;151  /// @}152};153 154} // end namespace llvm155 156#endif157