blob: 1b11b4b631eb930e051c87026b7063a1b2a0b4c1 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dan Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file a TargetTransformInfo::Concept conforming object specific
Dan Gohman10e730a2015-06-29 23:51:55 +000011/// 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
22#include "WebAssemblyTargetMachine.h"
23#include "llvm/CodeGen/BasicTTIImpl.h"
24#include <algorithm>
25
26namespace llvm {
27
28class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
29 typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
31 friend BaseT;
32
Dan Gohman10e730a2015-06-29 23:51:55 +000033 const WebAssemblySubtarget *ST;
34 const WebAssemblyTargetLowering *TLI;
35
36 const WebAssemblySubtarget *getST() const { return ST; }
37 const WebAssemblyTargetLowering *getTLI() const { return TLI; }
38
39public:
Hans Wennborg9099b5e62015-09-16 23:59:57 +000040 WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
JF Bastienb3796432015-07-09 21:00:09 +000041 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
Dan Gohman10e730a2015-06-29 23:51:55 +000042 TLI(ST->getTargetLowering()) {}
43
Dan Gohman10e730a2015-06-29 23:51:55 +000044 /// \name Scalar TTI Implementations
45 /// @{
46
47 // TODO: Implement more Scalar TTI for WebAssembly
48
Dan Gohman01612f62015-08-24 16:51:46 +000049 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const;
Dan Gohman10e730a2015-06-29 23:51:55 +000050
51 /// @}
52
53 /// \name Vector TTI Implementations
54 /// @{
55
Dan Gohman73d7a552016-05-23 22:47:07 +000056 unsigned getNumberOfRegisters(bool Vector);
Daniel Neilsonc0112ae2017-06-12 14:22:21 +000057 unsigned getRegisterBitWidth(bool Vector) const;
Dan Gohman73d7a552016-05-23 22:47:07 +000058 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,
Mohammed Agabaria2c96c432017-01-11 08:23:37 +000063 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
64 ArrayRef<const Value *> Args = ArrayRef<const Value *>());
Dan Gohman73d7a552016-05-23 22:47:07 +000065 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
Dan Gohman10e730a2015-06-29 23:51:55 +000066
67 /// @}
68};
69
70} // end namespace llvm
71
72#endif