LLVM 24.0.0git
WebAssemblyTargetTransformInfo.h
Go to the documentation of this file.
1//==- WebAssemblyTargetTransformInfo.h - WebAssembly-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///
9/// \file
10/// This file a TargetTransformInfoImplBase conforming object specific
11/// to the WebAssembly target machine.
12///
13/// It uses the target's detailed information to provide more precise answers to
14/// certain TTI queries, while letting the target independent and default TTI
15/// implementations handle the rest.
16///
17//===----------------------------------------------------------------------===//
18
19#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
20#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
21
24
25namespace llvm {
26
27class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
29 typedef TargetTransformInfo TTI;
30 friend BaseT;
31
32 const WebAssemblySubtarget *ST;
34
35 const WebAssemblySubtarget *getST() const { return ST; }
36 const WebAssemblyTargetLowering *getTLI() const { return TLI; }
37
38public:
40 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
41 TLI(ST->getTargetLowering()) {}
42
43 /// \name Scalar TTI Implementations
44 /// @{
45
46 // TODO: Implement more Scalar TTI for WebAssembly
47
50 OptimizationRemarkEmitter *ORE) const override;
51
52 /// @}
53
54 /// \name Vector TTI Implementations
55 /// @{
56
57 bool enableInterleavedAccessVectorization() const override { return true; }
58
59 unsigned getNumberOfRegisters(unsigned ClassID) const override;
60 unsigned getMinVectorRegisterBitWidth() const override { return 32; }
64 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
67 ArrayRef<const Value *> Args = {}, const Instruction *CtxI = nullptr,
68 const TargetLibraryInfo *TLibInfo = nullptr,
69 ArrayRef<const Value *> Scalars = {}) const override;
70
72 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
74 const Instruction *I = nullptr) const override;
75
77 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
78
80 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
81 TTI::TargetCostKind CostKind,
83 const Instruction *I = nullptr) const override;
85 unsigned Opcode, Type *Ty, unsigned Factor, ArrayRef<unsigned> Indices,
86 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
87 bool UseMaskForCond, bool UseMaskForGaps) const override;
89 getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy,
90 TTI::TargetCostKind CostKind, ArrayRef<int> Mask, int Index,
91 VectorType *SubTp, ArrayRef<const Value *> Args = {},
92 const Instruction *CtxI = nullptr,
94 TTI::VectorInstrContext::None) const override;
95
98 getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind,
99 unsigned Index, const Value *Op0, const Value *Op1,
101 TTI::VectorInstrContext::None) const override;
103 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
104 ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,
105 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
106 TTI::TargetCostKind CostKind,
107 std::optional<FastMathFlags> FMF) const override;
108
110 getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const override;
111
112 bool supportsTailCalls() const override;
113
114 bool isProfitableToSinkOperands(Instruction *I,
115 SmallVectorImpl<Use *> &Ops) const override;
116
117 std::optional<Instruction *>
118 instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override;
119
120 /// @}
121};
122
123} // end namespace llvm
124
125#endif
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine InstCombiner
uint64_t IntrinsicInst * II
This file declares the WebAssembly-specific subclass of TargetMachine.
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)
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
The optimization diagnostic interface.
The main scalar evolution driver.
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.
llvm::VectorInstrContext VectorInstrContext
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:46
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *Ty, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond, bool UseMaskForGaps) 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
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 *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) 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
WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const override
bool enableInterleavedAccessVectorization() 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 *CtxI=nullptr, const TargetLibraryInfo *TLibInfo=nullptr, ArrayRef< const Value * > Scalars={}) const override
unsigned getMinVectorRegisterBitWidth() const override
TTI::ReductionShuffle getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const override
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) 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
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
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.
Parameters that control the generic loop unrolling transformation.