[WebAssembly] Initial WebAssembly backend
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyTargetTransformInfo.h
1 //==- 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
27 namespace llvm {
28
29 class WebAssemblyTTIImpl final : public BasicTTIImplBase<WebAssemblyTTIImpl> {
30   typedef BasicTTIImplBase<WebAssemblyTTIImpl> BaseT;
31   typedef TargetTransformInfo TTI;
32   friend BaseT;
33
34   const WebAssemblyTargetMachine *TM;
35   const WebAssemblySubtarget *ST;
36   const WebAssemblyTargetLowering *TLI;
37
38   const WebAssemblySubtarget *getST() const { return ST; }
39   const WebAssemblyTargetLowering *getTLI() const { return TLI; }
40
41 public:
42   WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, Function &F)
43       : BaseT(TM), TM(TM), ST(TM->getSubtargetImpl(F)),
44         TLI(ST->getTargetLowering()) {}
45
46   // Provide value semantics. MSVC requires that we spell all of these out.
47   WebAssemblyTTIImpl(const WebAssemblyTTIImpl &Arg)
48       : BaseT(static_cast<const BaseT &>(Arg)), TM(Arg.TM), ST(Arg.ST),
49         TLI(Arg.TLI) {}
50   WebAssemblyTTIImpl(WebAssemblyTTIImpl &&Arg)
51       : BaseT(std::move(static_cast<BaseT &>(Arg))), TM(std::move(Arg.TM)),
52         ST(std::move(Arg.ST)), TLI(std::move(Arg.TLI)) {}
53   WebAssemblyTTIImpl &operator=(const WebAssemblyTTIImpl &RHS) {
54     BaseT::operator=(static_cast<const BaseT &>(RHS));
55     TM = RHS.TM;
56     ST = RHS.ST;
57     TLI = RHS.TLI;
58     return *this;
59   }
60   WebAssemblyTTIImpl &operator=(WebAssemblyTTIImpl &&RHS) {
61     BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
62     TM = std::move(RHS.TM);
63     ST = std::move(RHS.ST);
64     TLI = std::move(RHS.TLI);
65     return *this;
66   }
67
68   /// \name Scalar TTI Implementations
69   /// @{
70
71   // TODO: Implement more Scalar TTI for WebAssembly
72
73   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
74
75   /// @}
76
77   /// \name Vector TTI Implementations
78   /// @{
79
80   // TODO: Implement Vector TTI for WebAssembly
81
82   /// @}
83 };
84
85 } // end namespace llvm
86
87 #endif