112 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// This file a TargetTransformInfoImplBase conforming object specific11/// to the WebAssembly target machine.12///13/// It uses the target's detailed information to provide more precise answers to14/// certain TTI queries, while letting the target independent and default TTI15/// implementations handle the rest.16///17//===----------------------------------------------------------------------===//18 19#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H20#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H21 22#include "WebAssemblyTargetMachine.h"23#include "llvm/CodeGen/BasicTTIImpl.h"24 25namespace llvm {26 27class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {28 typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;29 typedef TargetTransformInfo TTI;30 friend BaseT;31 32 const WebAssemblySubtarget *ST;33 const WebAssemblyTargetLowering *TLI;34 35 const WebAssemblySubtarget *getST() const { return ST; }36 const WebAssemblyTargetLowering *getTLI() const { return TLI; }37 38public:39 WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)40 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),41 TLI(ST->getTargetLowering()) {}42 43 /// \name Scalar TTI Implementations44 /// @{45 46 // TODO: Implement more Scalar TTI for WebAssembly47 48 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;49 50 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,51 TTI::UnrollingPreferences &UP,52 OptimizationRemarkEmitter *ORE) const override;53 54 /// @}55 56 /// \name Vector TTI Implementations57 /// @{58 59 bool enableInterleavedAccessVectorization() const override { return true; }60 61 unsigned getNumberOfRegisters(unsigned ClassID) const override;62 TypeSize63 getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override;64 InstructionCost getArithmeticInstrCost(65 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,66 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},67 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},68 ArrayRef<const Value *> Args = {},69 const Instruction *CxtI = nullptr) const override;70 71 InstructionCost72 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,73 TTI::CastContextHint CCH, TTI::TargetCostKind CostKind,74 const Instruction *I = nullptr) const override;75 76 TTI::MemCmpExpansionOptions77 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const override;78 79 InstructionCost getMemoryOpCost(80 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,81 TTI::TargetCostKind CostKind,82 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},83 const Instruction *I = nullptr) const override;84 InstructionCost getInterleavedMemoryOpCost(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;88 using BaseT::getVectorInstrCost;89 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,90 TTI::TargetCostKind CostKind,91 unsigned Index, const Value *Op0,92 const Value *Op1) const override;93 InstructionCost getPartialReductionCost(94 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,95 ElementCount VF, TTI::PartialReductionExtendKind OpAExtend,96 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,97 TTI::TargetCostKind CostKind) const override;98 TTI::ReductionShuffle99 getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const override;100 101 bool supportsTailCalls() const override;102 103 bool isProfitableToSinkOperands(Instruction *I,104 SmallVectorImpl<Use *> &Ops) const override;105 106 /// @}107};108 109} // end namespace llvm110 111#endif112