1 //==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
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
7 //===----------------------------------------------------------------------===//
10 /// This file a TargetTransformInfo::Concept conforming object specific
11 /// to the WebAssembly target machine.
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.
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
20 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
22 #include "WebAssemblyTargetMachine.h"
23 #include "llvm/CodeGen/BasicTTIImpl.h"
28 class WebAssemblyTTIImpl final
: public BasicTTIImplBase
<WebAssemblyTTIImpl
> {
29 typedef BasicTTIImplBase
<WebAssemblyTTIImpl
> BaseT
;
30 typedef TargetTransformInfo TTI
;
33 const WebAssemblySubtarget
*ST
;
34 const WebAssemblyTargetLowering
*TLI
;
36 const WebAssemblySubtarget
*getST() const { return ST
; }
37 const WebAssemblyTargetLowering
*getTLI() const { return TLI
; }
40 WebAssemblyTTIImpl(const WebAssemblyTargetMachine
*TM
, const Function
&F
)
41 : BaseT(TM
, F
.getParent()->getDataLayout()), ST(TM
->getSubtargetImpl(F
)),
42 TLI(ST
->getTargetLowering()) {}
44 /// \name Scalar TTI Implementations
47 // TODO: Implement more Scalar TTI for WebAssembly
49 TTI::PopcntSupportKind
getPopcntSupport(unsigned TyWidth
) const;
53 /// \name Vector TTI Implementations
56 unsigned getNumberOfRegisters(bool Vector
);
57 unsigned getRegisterBitWidth(bool Vector
) const;
58 unsigned getArithmeticInstrCost(
59 unsigned Opcode
, Type
*Ty
,
60 TTI::OperandValueKind Opd1Info
= TTI::OK_AnyValue
,
61 TTI::OperandValueKind Opd2Info
= TTI::OK_AnyValue
,
62 TTI::OperandValueProperties Opd1PropInfo
= TTI::OP_None
,
63 TTI::OperandValueProperties Opd2PropInfo
= TTI::OP_None
,
64 ArrayRef
<const Value
*> Args
= ArrayRef
<const Value
*>());
65 unsigned getVectorInstrCost(unsigned Opcode
, Type
*Val
, unsigned Index
);
70 } // end namespace llvm