LLVM 19.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 TargetTransformInfo::Concept 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 : 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.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
41 TLI(ST->getTargetLowering()) {}
42
43 std::optional<Instruction *> instCombineIntrinsic(InstCombiner & IC,
44 IntrinsicInst & II) const;
45
46 /// \name Scalar TTI Implementations
47 /// @{
48
52
53 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
54 const APInt &Imm, Type *Ty,
56 Instruction *Inst = nullptr);
58 const APInt &Imm, Type *Ty,
60
64
68 TargetLibraryInfo *LibInfo,
69 HardwareLoopInfo &HWLoopInfo);
70 bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI,
72 TargetLibraryInfo *LibInfo);
82 bool shouldBuildRelLookupTables() const;
83 /// @}
84
85 /// \name Vector TTI Implementations
86 /// @{
88 bool enableAggressiveInterleaving(bool LoopHasReductions);
90 bool IsZeroCmp) const;
92
95 };
96 unsigned getNumberOfRegisters(unsigned ClassID) const;
97 unsigned getRegisterClassForType(bool Vector, Type *Ty = nullptr) const;
98 const char* getRegisterClassName(unsigned ClassID) const;
100 unsigned getCacheLineSize() const override;
101 unsigned getPrefetchDistance() const override;
103 InstructionCost vectorCostAdjustmentFactor(unsigned Opcode, Type *Ty1,
104 Type *Ty2);
106 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
108 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
109 ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
110 const Instruction *CxtI = nullptr);
111 InstructionCost getShuffleCost(TTI::ShuffleKind Kind, Type *Tp,
112 ArrayRef<int> Mask,
114 Type *SubTp,
115 ArrayRef<const Value *> Args = std::nullopt,
116 const Instruction *CxtI = nullptr);
117 InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
120 const Instruction *I = nullptr);
121 InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
122 const Instruction *I = nullptr);
123 InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
124 CmpInst::Predicate VecPred,
126 const Instruction *I = nullptr);
128 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
130 unsigned Index, Value *Op0, Value *Op1);
131 InstructionCost
132 getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
134 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
135 const Instruction *I = nullptr);
136 InstructionCost getInterleavedMemoryOpCost(
137 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
138 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
139 bool UseMaskForCond = false, bool UseMaskForGaps = false);
140 InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
142 bool areTypesABICompatible(const Function *Caller, const Function *Callee,
143 const ArrayRef<Type *> &Types) const;
144 bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
145 Align Alignment) const;
146 InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
147 unsigned AddressSpace,
149 const Instruction *I = nullptr);
150 bool supportsTailCallFor(const CallBase *CB) const;
151
152private:
153 // The following constant is used for estimating costs on power9.
154 static const InstructionCost::CostType P9PipelineFlushEstimate = 80;
155
156 /// @}
157};
158
159} // end namespace llvm
160
161#endif
static const Function * getParent(const Value *V)
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< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
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
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
mir Rename Register Operands
const char LLVMTargetMachineRef TM
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:76
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:80
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
Conditional or Unconditional Branch instruction.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:993
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:162
The core instruction combiner logic.
Definition: InstCombiner.h:47
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:47
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:44
The optimization diagnostic interface.
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
const char * getRegisterClassName(unsigned ClassID) const
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, Type *SubTp, ArrayRef< const Value * > Args=std::nullopt, const Instruction *CxtI=nullptr)
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool useColdCCForColdCall(Function &F)
InstructionCost vectorCostAdjustmentFactor(unsigned Opcode, Type *Ty1, Type *Ty2)
bool supportsTailCallFor(const CallBase *CB) const
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
unsigned getCacheLineSize() const override
PPCTTIImpl(const PPCTargetMachine *TM, const Function &F)
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
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=ArrayRef< const Value * >(), const Instruction *CxtI=nullptr)
unsigned getMaxInterleaveFactor(ElementCount VF)
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
bool enableAggressiveInterleaving(bool LoopHasReductions)
unsigned getPrefetchDistance() const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
unsigned getNumberOfRegisters(unsigned ClassID) const
bool hasActiveVectorLength(unsigned Opcode, Type *DataType, Align Alignment) const
bool shouldBuildRelLookupTables() const
InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind)
bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, TargetLibraryInfo *LibInfo)
InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo)
bool areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Types) const
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
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.
const DataLayout & getDataLayout() const
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
AddressSpace
Definition: NVPTXBaseInfo.h:21
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.