[InstCombine] Signed saturation patterns
[llvm-core.git] / lib / Target / SystemZ / SystemZTargetTransformInfo.h
blob3ba80b31439f3618f425e08afda4489c9c4f9088
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
12 #include "SystemZTargetMachine.h"
13 #include "llvm/Analysis/TargetTransformInfo.h"
14 #include "llvm/CodeGen/BasicTTIImpl.h"
16 namespace llvm {
18 class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
19 typedef BasicTTIImplBase<SystemZTTIImpl> BaseT;
20 typedef TargetTransformInfo TTI;
21 friend BaseT;
23 const SystemZSubtarget *ST;
24 const SystemZTargetLowering *TLI;
26 const SystemZSubtarget *getST() const { return ST; }
27 const SystemZTargetLowering *getTLI() const { return TLI; }
29 unsigned const LIBCALL_COST = 30;
31 public:
32 explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
33 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
34 TLI(ST->getTargetLowering()) {}
36 /// \name Scalar TTI Implementations
37 /// @{
39 unsigned getInliningThresholdMultiplier() { return 3; }
41 int getIntImmCost(const APInt &Imm, Type *Ty);
43 int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
44 int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
45 Type *Ty);
47 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
49 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
50 TTI::UnrollingPreferences &UP);
52 bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
53 TargetTransformInfo::LSRCost &C2);
54 /// @}
56 /// \name Vector TTI Implementations
57 /// @{
59 unsigned getNumberOfRegisters(unsigned ClassID) const;
60 unsigned getRegisterBitWidth(bool Vector) const;
62 unsigned getCacheLineSize() const override { return 256; }
63 unsigned getPrefetchDistance() const override { return 2000; }
64 unsigned getMinPrefetchStride() const override { return 2048; }
66 bool hasDivRemOp(Type *DataType, bool IsSigned);
67 bool prefersVectorizedAddressing() { return false; }
68 bool LSRWithInstrQueries() { return true; }
69 bool supportsEfficientVectorElementLoadStore() { return true; }
70 bool enableInterleavedAccessVectorization() { return true; }
72 int getArithmeticInstrCost(
73 unsigned Opcode, Type *Ty,
74 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
75 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
76 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
77 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
78 ArrayRef<const Value *> Args = ArrayRef<const Value *>());
79 int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
80 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
81 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
82 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
83 const Instruction *I);
84 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
85 const Instruction *I = nullptr);
86 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
87 const Instruction *I = nullptr);
88 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
89 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
90 int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
91 unsigned AddressSpace, const Instruction *I = nullptr);
93 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
94 unsigned Factor,
95 ArrayRef<unsigned> Indices,
96 unsigned Alignment,
97 unsigned AddressSpace,
98 bool UseMaskForCond = false,
99 bool UseMaskForGaps = false);
101 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
102 ArrayRef<Value *> Args, FastMathFlags FMF,
103 unsigned VF = 1);
104 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
105 ArrayRef<Type *> Tys, FastMathFlags FMF,
106 unsigned ScalarizationCostPassed = UINT_MAX);
107 /// @}
110 } // end namespace llvm
112 #endif