LLVM 22.0.0git
PPCTargetTransformInfo.h
Go to the documentation of this file.
1//===-- PPCTargetTransformInfo.h - PPC specific TTI -------------*- C++ -*-===//
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//===----------------------------------------------------------------------===//
8/// \file
9/// This file a TargetTransformInfoImplBase conforming object specific to the
10/// PPC target machine. It uses the target's detailed information to
11/// provide more precise answers to certain TTI queries, while letting the
12/// target independent and default TTI implementations handle the rest.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
17#define LLVM_LIB_TARGET_POWERPC_PPCTARGETTRANSFORMINFO_H
18
19#include "PPCTargetMachine.h"
23#include <optional>
24
25namespace llvm {
26
27class PPCTTIImpl final : public BasicTTIImplBase<PPCTTIImpl> {
30 friend BaseT;
31
32 const PPCSubtarget *ST;
33 const PPCTargetLowering *TLI;
34
35 const PPCSubtarget *getST() const { return ST; }
36 const PPCTargetLowering *getTLI() const { return TLI; }
37
38public:
39 explicit PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
40 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
41 TLI(ST->getTargetLowering()) {}
42
43 std::optional<Instruction *>
45
46 /// \name Scalar TTI Implementations
47 /// @{
48
51 TTI::TargetCostKind CostKind) const override;
52
53 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
54 const APInt &Imm, Type *Ty,
56 Instruction *Inst = nullptr) const override;
58 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
59 Type *Ty, TTI::TargetCostKind CostKind) const override;
60
63 TTI::TargetCostKind CostKind) const override;
64
65 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
68 HardwareLoopInfo &HWLoopInfo) const override;
69 bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI,
71 TargetLibraryInfo *LibInfo) const override;
73 MemIntrinsicInfo &Info) const override;
76 OptimizationRemarkEmitter *ORE) const override;
78 TTI::PeelingPreferences &PP) const override;
80 const TargetTransformInfo::LSRCost &C2) const override;
81 bool isNumRegsMajorCostOfLSR() const override;
82 bool shouldBuildRelLookupTables() const override;
83 /// @}
84
85 /// \name Vector TTI Implementations
86 /// @{
87 bool useColdCCForColdCall(Function &F) const override;
88 bool enableAggressiveInterleaving(bool LoopHasReductions) const override;
90 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
91 bool enableInterleavedAccessVectorization() const override;
92
95 };
96 unsigned getNumberOfRegisters(unsigned ClassID) const override;
97 unsigned getRegisterClassForType(bool Vector,
98 Type *Ty = nullptr) const override;
99 const char *getRegisterClassName(unsigned ClassID) const override;
102 unsigned getCacheLineSize() const override;
103 unsigned getPrefetchDistance() const override;
104 unsigned getMaxInterleaveFactor(ElementCount VF) const override;
105 InstructionCost vectorCostAdjustmentFactor(unsigned Opcode, Type *Ty1,
106 Type *Ty2) const;
108 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
110 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
111 ArrayRef<const Value *> Args = {},
112 const Instruction *CxtI = nullptr) const override;
115 ArrayRef<int> Mask, TTI::TargetCostKind CostKind, int Index,
116 VectorType *SubTp, ArrayRef<const Value *> Args = {},
117 const Instruction *CxtI = nullptr) const override;
119 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
121 const Instruction *I = nullptr) const override;
123 const Instruction *I = nullptr) const override;
125 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
127 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
128 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
129 const Instruction *I = nullptr) const override;
131 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
133 unsigned Index, const Value *Op0,
134 const Value *Op1) const override;
136 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
138 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
139 const Instruction *I = nullptr) const override;
141 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
142 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
143 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
145 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
146 TTI::TargetCostKind CostKind) const override;
147 bool areInlineCompatible(const Function *Caller,
148 const Function *Callee) const override;
149 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
150 const ArrayRef<Type *> &Types) const override;
151 bool supportsTailCallFor(const CallBase *CB) const override;
152
153private:
154 // The following constant is used for estimating costs on power9.
155 static const InstructionCost::CostType P9PipelineFlushEstimate = 80;
156
157 /// @}
158};
159
160} // end namespace llvm
161
162#endif
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint32_t Index
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
mir Rename Register Operands
uint64_t IntrinsicInst * II
This file describes how to lower LLVM code to machine code.
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
A cache of @llvm.assume calls within a function.
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:82
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
Conditional or Unconditional Branch instruction.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:678
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:165
The core instruction combiner logic.
Definition: InstCombiner.h:48
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:49
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:40
The optimization diagnostic interface.
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const override
InstructionCost vectorCostAdjustmentFactor(unsigned Opcode, Type *Ty1, Type *Ty2) const
bool areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Types) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
bool enableInterleavedAccessVectorization() const override
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, TargetLibraryInfo *LibInfo) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
unsigned getCacheLineSize() const override
PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
bool useColdCCForColdCall(Function &F) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
bool isNumRegsMajorCostOfLSR() const override
unsigned getPrefetchDistance() const override
bool areInlineCompatible(const Function *Caller, const Function *Callee) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
const char * getRegisterClassName(unsigned ClassID) const override
InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind) const override
unsigned getMaxInterleaveFactor(ElementCount VF) const override
bool shouldBuildRelLookupTables() const override
bool supportsTailCallFor(const CallBase *CB) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
bool enableAggressiveInterleaving(bool LoopHasReductions) const override
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override
Common code between 32-bit and 64-bit PowerPC targets.
The main scalar evolution driver.
Provides information about what library functions are available for the current target.
virtual const DataLayout & getDataLayout() const
virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
TargetCostKind
The kind of cost model.
PopcntSupportKind
Flags indicating the kind of support for population count.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
CastContextHint
Represents a hint about the context in which a cast is used.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Attributes of a target dependent hardware loop.
Information about a load/store intrinsic defined by the target.
Returns options for expansion of memcmp. IsZeroCmp is.
Parameters that control the generic loop unrolling transformation.