1 //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//
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
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"
18 class SystemZTTIImpl
: public BasicTTIImplBase
<SystemZTTIImpl
> {
19 typedef BasicTTIImplBase
<SystemZTTIImpl
> BaseT
;
20 typedef TargetTransformInfo TTI
;
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;
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
39 unsigned getInliningThresholdMultiplier() { return 3; }
41 InstructionCost
getIntImmCost(const APInt
&Imm
, Type
*Ty
,
42 TTI::TargetCostKind CostKind
);
44 InstructionCost
getIntImmCostInst(unsigned Opcode
, unsigned Idx
,
45 const APInt
&Imm
, Type
*Ty
,
46 TTI::TargetCostKind CostKind
,
47 Instruction
*Inst
= nullptr);
48 InstructionCost
getIntImmCostIntrin(Intrinsic::ID IID
, unsigned Idx
,
49 const APInt
&Imm
, Type
*Ty
,
50 TTI::TargetCostKind CostKind
);
52 TTI::PopcntSupportKind
getPopcntSupport(unsigned TyWidth
);
54 void getUnrollingPreferences(Loop
*L
, ScalarEvolution
&SE
,
55 TTI::UnrollingPreferences
&UP
,
56 OptimizationRemarkEmitter
*ORE
);
58 void getPeelingPreferences(Loop
*L
, ScalarEvolution
&SE
,
59 TTI::PeelingPreferences
&PP
);
61 bool isLSRCostLess(TargetTransformInfo::LSRCost
&C1
,
62 TargetTransformInfo::LSRCost
&C2
);
65 /// \name Vector TTI Implementations
68 unsigned getNumberOfRegisters(unsigned ClassID
) const;
69 TypeSize
getRegisterBitWidth(TargetTransformInfo::RegisterKind K
) const;
71 unsigned getCacheLineSize() const override
{ return 256; }
72 unsigned getPrefetchDistance() const override
{ return 4500; }
73 unsigned getMinPrefetchStride(unsigned NumMemAccesses
,
74 unsigned NumStridedMemAccesses
,
75 unsigned NumPrefetches
,
76 bool HasCall
) const override
;
77 bool enableWritePrefetching() const override
{ return true; }
79 bool hasDivRemOp(Type
*DataType
, bool IsSigned
);
80 bool prefersVectorizedAddressing() { return false; }
81 bool LSRWithInstrQueries() { return true; }
82 bool supportsEfficientVectorElementLoadStore() { return true; }
83 bool enableInterleavedAccessVectorization() { return true; }
85 InstructionCost
getArithmeticInstrCost(
86 unsigned Opcode
, Type
*Ty
,
87 TTI::TargetCostKind CostKind
= TTI::TCK_RecipThroughput
,
88 TTI::OperandValueKind Opd1Info
= TTI::OK_AnyValue
,
89 TTI::OperandValueKind Opd2Info
= TTI::OK_AnyValue
,
90 TTI::OperandValueProperties Opd1PropInfo
= TTI::OP_None
,
91 TTI::OperandValueProperties Opd2PropInfo
= TTI::OP_None
,
92 ArrayRef
<const Value
*> Args
= ArrayRef
<const Value
*>(),
93 const Instruction
*CxtI
= nullptr);
94 InstructionCost
getShuffleCost(TTI::ShuffleKind Kind
, VectorType
*Tp
,
95 ArrayRef
<int> Mask
, int Index
,
97 unsigned getVectorTruncCost(Type
*SrcTy
, Type
*DstTy
);
98 unsigned getVectorBitmaskConversionCost(Type
*SrcTy
, Type
*DstTy
);
99 unsigned getBoolVecToIntConversionCost(unsigned Opcode
, Type
*Dst
,
100 const Instruction
*I
);
101 InstructionCost
getCastInstrCost(unsigned Opcode
, Type
*Dst
, Type
*Src
,
102 TTI::CastContextHint CCH
,
103 TTI::TargetCostKind CostKind
,
104 const Instruction
*I
= nullptr);
105 InstructionCost
getCmpSelInstrCost(unsigned Opcode
, Type
*ValTy
, Type
*CondTy
,
106 CmpInst::Predicate VecPred
,
107 TTI::TargetCostKind CostKind
,
108 const Instruction
*I
= nullptr);
109 InstructionCost
getVectorInstrCost(unsigned Opcode
, Type
*Val
,
111 bool isFoldableLoad(const LoadInst
*Ld
, const Instruction
*&FoldedValue
);
112 InstructionCost
getMemoryOpCost(unsigned Opcode
, Type
*Src
,
113 MaybeAlign Alignment
, unsigned AddressSpace
,
114 TTI::TargetCostKind CostKind
,
115 const Instruction
*I
= nullptr);
117 InstructionCost
getInterleavedMemoryOpCost(
118 unsigned Opcode
, Type
*VecTy
, unsigned Factor
, ArrayRef
<unsigned> Indices
,
119 Align Alignment
, unsigned AddressSpace
,
120 TTI::TargetCostKind CostKind
= TTI::TCK_SizeAndLatency
,
121 bool UseMaskForCond
= false, bool UseMaskForGaps
= false);
123 InstructionCost
getIntrinsicInstrCost(const IntrinsicCostAttributes
&ICA
,
124 TTI::TargetCostKind CostKind
);
128 } // end namespace llvm