LLVM 22.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#include <algorithm>
25
26namespace llvm {
27
28class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
30 typedef TargetTransformInfo TTI;
31 friend BaseT;
32
33 const WebAssemblySubtarget *ST;
35
36 const WebAssemblySubtarget *getST() const { return ST; }
37 const WebAssemblyTargetLowering *getTLI() const { return TLI; }
38
39public:
41 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
42 TLI(ST->getTargetLowering()) {}
43
44 /// \name Scalar TTI Implementations
45 /// @{
46
47 // TODO: Implement more Scalar TTI for WebAssembly
48
49 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
50
53 OptimizationRemarkEmitter *ORE) const override;
54
55 /// @}
56
57 /// \name Vector TTI Implementations
58 /// @{
59
60 bool enableInterleavedAccessVectorization() const override { return true; }
61
62 unsigned getNumberOfRegisters(unsigned ClassID) const override;
66 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
70 const Instruction *CxtI = nullptr) const override;
71
73 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
75 const Instruction *I = nullptr) const override;
76
78 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;
79
81 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
84 const Instruction *I = nullptr) const override;
86 unsigned Opcode, Type *Ty, unsigned Factor, ArrayRef<unsigned> Indices,
87 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
88 bool UseMaskForCond, bool UseMaskForGaps) const override;
90 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
92 unsigned Index, const Value *Op0,
93 const Value *Op1) const override;
95 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
96 ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,
97 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
98 TTI::TargetCostKind CostKind) const override;
100 getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const override;
101
102 bool supportsTailCalls() const override;
103
104 bool isProfitableToSinkOperands(Instruction *I,
105 SmallVectorImpl<Use *> &Ops) const override;
106
107 /// @}
108};
109
110} // end namespace llvm
111
112#endif
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")))
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
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) 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.
PopcntSupportKind
Flags indicating the kind of support for population count.
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
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 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
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) 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
bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const override
bool enableInterleavedAccessVectorization() 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) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) 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 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.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
ArrayRef(const T &OneElt) -> ArrayRef< T >
Returns options for expansion of memcmp. IsZeroCmp is.
Parameters that control the generic loop unrolling transformation.