1285163Sdim//==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
2285163Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6285163Sdim//
7285163Sdim//===----------------------------------------------------------------------===//
8285163Sdim///
9285163Sdim/// \file
10341825Sdim/// This file a TargetTransformInfo::Concept conforming object specific
11285163Sdim/// to the WebAssembly target machine.
12285163Sdim///
13285163Sdim/// It uses the target's detailed information to provide more precise answers to
14285163Sdim/// certain TTI queries, while letting the target independent and default TTI
15285163Sdim/// implementations handle the rest.
16285163Sdim///
17285163Sdim//===----------------------------------------------------------------------===//
18285163Sdim
19285163Sdim#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
20285163Sdim#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
21285163Sdim
22285163Sdim#include "WebAssemblyTargetMachine.h"
23285163Sdim#include "llvm/CodeGen/BasicTTIImpl.h"
24285163Sdim#include <algorithm>
25285163Sdim
26285163Sdimnamespace llvm {
27285163Sdim
28285163Sdimclass WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
29285163Sdim  typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
30285163Sdim  typedef TargetTransformInfo TTI;
31285163Sdim  friend BaseT;
32285163Sdim
33285163Sdim  const WebAssemblySubtarget *ST;
34285163Sdim  const WebAssemblyTargetLowering *TLI;
35285163Sdim
36285163Sdim  const WebAssemblySubtarget *getST() const { return ST; }
37285163Sdim  const WebAssemblyTargetLowering *getTLI() const { return TLI; }
38285163Sdim
39285163Sdimpublic:
40296417Sdim  WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
41286684Sdim      : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42285163Sdim        TLI(ST->getTargetLowering()) {}
43285163Sdim
44285163Sdim  /// \name Scalar TTI Implementations
45285163Sdim  /// @{
46285163Sdim
47285163Sdim  // TODO: Implement more Scalar TTI for WebAssembly
48285163Sdim
49296417Sdim  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const;
50285163Sdim
51285163Sdim  /// @}
52285163Sdim
53285163Sdim  /// \name Vector TTI Implementations
54285163Sdim  /// @{
55285163Sdim
56360784Sdim  unsigned getNumberOfRegisters(unsigned ClassID) const;
57321369Sdim  unsigned getRegisterBitWidth(bool Vector) const;
58309124Sdim  unsigned getArithmeticInstrCost(
59309124Sdim      unsigned Opcode, Type *Ty,
60309124Sdim      TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
61309124Sdim      TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
62309124Sdim      TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
63314564Sdim      TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
64360784Sdim      ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
65360784Sdim      const Instruction *CxtI = nullptr);
66309124Sdim  unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
67285163Sdim
68285163Sdim  /// @}
69285163Sdim};
70285163Sdim
71285163Sdim} // end namespace llvm
72285163Sdim
73285163Sdim#endif
74