blob: fe99e96eb3b85f7fa1b57bd264210af30f8c4114 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//==- WebAssemblyTargetTransformInfo.h - WebAssembly-specific TTI -*- C++ -*-=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief This file a TargetTransformInfo::Concept conforming object specific
12/// to the WebAssembly target machine.
13///
14/// It uses the target's detailed information to provide more precise answers to
15/// certain TTI queries, while letting the target independent and default TTI
16/// implementations handle the rest.
17///
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
21#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETTRANSFORMINFO_H
22
23#include "WebAssemblyTargetMachine.h"
24#include "llvm/CodeGen/BasicTTIImpl.h"
25#include <algorithm>
26
27namespace llvm {
28
29class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
30 typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
31 typedef TargetTransformInfo TTI;
32 friend BaseT;
33
Dan Gohman10e730a2015-06-29 23:51:55 +000034 const WebAssemblySubtarget *ST;
35 const WebAssemblyTargetLowering *TLI;
36
37 const WebAssemblySubtarget *getST() const { return ST; }
38 const WebAssemblyTargetLowering *getTLI() const { return TLI; }
39
40public:
Hans Wennborg9099b5e62015-09-16 23:59:57 +000041 WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F)
JF Bastienb3796432015-07-09 21:00:09 +000042 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
Dan Gohman10e730a2015-06-29 23:51:55 +000043 TLI(ST->getTargetLowering()) {}
44
45 // Provide value semantics. MSVC requires that we spell all of these out.
46 WebAssemblyTTIImpl(const WebAssemblyTTIImpl &Arg)
JF Bastienb3796432015-07-09 21:00:09 +000047 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
Dan Gohman10e730a2015-06-29 23:51:55 +000048 WebAssemblyTTIImpl(WebAssemblyTTIImpl &&Arg)
JF Bastienb3796432015-07-09 21:00:09 +000049 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
50 TLI(std::move(Arg.TLI)) {}
Dan Gohman10e730a2015-06-29 23:51:55 +000051
52 /// \name Scalar TTI Implementations
53 /// @{
54
55 // TODO: Implement more Scalar TTI for WebAssembly
56
Dan Gohman01612f62015-08-24 16:51:46 +000057 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const;
Dan Gohman10e730a2015-06-29 23:51:55 +000058
59 /// @}
60
61 /// \name Vector TTI Implementations
62 /// @{
63
Dan Gohman73d7a552016-05-23 22:47:07 +000064 unsigned getNumberOfRegisters(bool Vector);
65 unsigned getRegisterBitWidth(bool Vector);
66 unsigned getArithmeticInstrCost(
67 unsigned Opcode, Type *Ty,
68 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
69 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
70 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
71 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
72 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
Dan Gohman10e730a2015-06-29 23:51:55 +000073
74 /// @}
75};
76
77} // end namespace llvm
78
79#endif