LLVM 24.0.0git
LoongArchTargetTransformInfo.h
Go to the documentation of this file.
1//===- LoongArchTargetTransformInfo.h - LoongArch 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/// LoongArch 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_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
17#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
18
19#include "LoongArchSubtarget.h"
23
24namespace llvm {
25
26class LoongArchTTIImpl : public BasicTTIImplBase<LoongArchTTIImpl> {
28 typedef TargetTransformInfo TTI;
29 friend BaseT;
30
31 enum LoongArchRegisterClass { GPRRC, FPRRC, VRRC };
32 const LoongArchSubtarget *ST;
33 const LoongArchTargetLowering *TLI;
34
35 const LoongArchSubtarget *getST() const { return ST; }
36 const LoongArchTargetLowering *getTLI() const { return TLI; }
37
38public:
40 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
41 TLI(ST->getTargetLowering()) {}
42
45 unsigned getNumberOfRegisters(unsigned ClassID) const override;
46 unsigned getRegisterClassForType(bool Vector,
47 Type *Ty = nullptr) const override;
49 bool HasUnorderedReductions) const override;
50 const char *getRegisterClassName(unsigned ClassID) const override;
51 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
52
53 unsigned getCacheLineSize() const override;
54 unsigned getPrefetchDistance() const override;
55 bool enableWritePrefetching() const override;
56
57 bool shouldExpandReduction(const IntrinsicInst *II) const override;
58
60 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
64 const Instruction *CxtI = nullptr) const override;
65
69 unsigned Index, const Value *Op0, const Value *Op1,
71 TTI::VectorInstrContext::None) const override;
72
74 getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy,
75 TTI::TargetCostKind CostKind, ArrayRef<int> Mask, int Index,
76 VectorType *SubTp, ArrayRef<const Value *> Args = {},
77 const Instruction *CxtI = nullptr,
79 TTI::VectorInstrContext::None) const override;
80
82 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
83
85 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
87 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
89 std::optional<FastMathFlags> FMF) const override {
91 }
92};
93
94} // end namespace llvm
95
96#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHTARGETTRANSFORMINFO_H
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
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")))
#define F(x, y, z)
Definition MD5.cpp:54
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
unsigned getCacheLineSize() const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
bool shouldExpandReduction(const IntrinsicInst *II) 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
LoongArchTTIImpl(const LoongArchTargetMachine *TM, const Function &F)
unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override
const char * getRegisterClassName(unsigned ClassID) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
unsigned getPrefetchDistance() const override
bool enableWritePrefetching() const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind, std::optional< FastMathFlags > FMF) const override
virtual const DataLayout & getDataLayout() 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.
llvm::VectorInstrContext VectorInstrContext
ShuffleKind
The various kinds of shuffle patterns for vector queries.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
ArrayRef(const T &OneElt) -> ArrayRef< T >
Returns options for expansion of memcmp. IsZeroCmp is.