xref: /aosp_15_r20/external/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker ///
10*9880d681SAndroid Build Coastguard Worker /// \file
11*9880d681SAndroid Build Coastguard Worker /// \brief This file a TargetTransformInfo::Concept conforming object specific
12*9880d681SAndroid Build Coastguard Worker /// to the WebAssembly target machine.
13*9880d681SAndroid Build Coastguard Worker ///
14*9880d681SAndroid Build Coastguard Worker /// It uses the target's detailed information to provide more precise answers to
15*9880d681SAndroid Build Coastguard Worker /// certain TTI queries, while letting the target independent and default TTI
16*9880d681SAndroid Build Coastguard Worker /// implementations handle the rest.
17*9880d681SAndroid Build Coastguard Worker ///
18*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
19*9880d681SAndroid Build Coastguard Worker 
20*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
21*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker #include "WebAssemblyTargetMachine.h"
24*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/BasicTTIImpl.h"
25*9880d681SAndroid Build Coastguard Worker #include <algorithm>
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker namespace llvm {
28*9880d681SAndroid Build Coastguard Worker 
29*9880d681SAndroid Build Coastguard Worker class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
30*9880d681SAndroid Build Coastguard Worker   typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
31*9880d681SAndroid Build Coastguard Worker   typedef TargetTransformInfo TTI;
32*9880d681SAndroid Build Coastguard Worker   friend BaseT;
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker   const WebAssemblySubtarget *ST;
35*9880d681SAndroid Build Coastguard Worker   const WebAssemblyTargetLowering *TLI;
36*9880d681SAndroid Build Coastguard Worker 
getST()37*9880d681SAndroid Build Coastguard Worker   const WebAssemblySubtarget *getST() const { return ST; }
getTLI()38*9880d681SAndroid Build Coastguard Worker   const WebAssemblyTargetLowering *getTLI() const { return TLI; }
39*9880d681SAndroid Build Coastguard Worker 
40*9880d681SAndroid Build Coastguard Worker public:
WebAssemblyTTIImpl(const WebAssemblyTargetMachine * TM,const Function & F)41*9880d681SAndroid Build Coastguard Worker   WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
42*9880d681SAndroid Build Coastguard Worker       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
43*9880d681SAndroid Build Coastguard Worker         TLI(ST->getTargetLowering()) {}
44*9880d681SAndroid Build Coastguard Worker 
45*9880d681SAndroid Build Coastguard Worker   // Provide value semantics. MSVC requires that we spell all of these out.
WebAssemblyTTIImpl(const WebAssemblyTTIImpl & Arg)46*9880d681SAndroid Build Coastguard Worker   WebAssemblyTTIImpl(const WebAssemblyTTIImpl &Arg)
47*9880d681SAndroid Build Coastguard Worker       : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
WebAssemblyTTIImpl(WebAssemblyTTIImpl && Arg)48*9880d681SAndroid Build Coastguard Worker   WebAssemblyTTIImpl(WebAssemblyTTIImpl &&Arg)
49*9880d681SAndroid Build Coastguard Worker       : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
50*9880d681SAndroid Build Coastguard Worker         TLI(std::move(Arg.TLI)) {}
51*9880d681SAndroid Build Coastguard Worker 
52*9880d681SAndroid Build Coastguard Worker   /// \name Scalar TTI Implementations
53*9880d681SAndroid Build Coastguard Worker   /// @{
54*9880d681SAndroid Build Coastguard Worker 
55*9880d681SAndroid Build Coastguard Worker   // TODO: Implement more Scalar TTI for WebAssembly
56*9880d681SAndroid Build Coastguard Worker 
57*9880d681SAndroid Build Coastguard Worker   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const;
58*9880d681SAndroid Build Coastguard Worker 
59*9880d681SAndroid Build Coastguard Worker   /// @}
60*9880d681SAndroid Build Coastguard Worker 
61*9880d681SAndroid Build Coastguard Worker   /// \name Vector TTI Implementations
62*9880d681SAndroid Build Coastguard Worker   /// @{
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker   unsigned getNumberOfRegisters(bool Vector);
65*9880d681SAndroid Build Coastguard Worker   unsigned getRegisterBitWidth(bool Vector);
66*9880d681SAndroid Build Coastguard Worker   unsigned getArithmeticInstrCost(
67*9880d681SAndroid Build Coastguard Worker       unsigned Opcode, Type *Ty,
68*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
69*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
70*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
71*9880d681SAndroid Build Coastguard Worker       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
72*9880d681SAndroid Build Coastguard Worker   unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
73*9880d681SAndroid Build Coastguard Worker 
74*9880d681SAndroid Build Coastguard Worker   /// @}
75*9880d681SAndroid Build Coastguard Worker };
76*9880d681SAndroid Build Coastguard Worker 
77*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker #endif
80