Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 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 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 34 | const WebAssemblySubtarget *ST; |
| 35 | const WebAssemblyTargetLowering *TLI; |
| 36 | |
| 37 | const WebAssemblySubtarget *getST() const { return ST; } |
| 38 | const WebAssemblyTargetLowering *getTLI() const { return TLI; } |
| 39 | |
| 40 | public: |
Hans Wennborg | 9099b5e6 | 2015-09-16 23:59:57 +0000 | [diff] [blame] | 41 | WebAssemblyTTIImpl(const WebAssemblyTargetMachine *TM, const Function &F) |
JF Bastien | b379643 | 2015-07-09 21:00:09 +0000 | [diff] [blame] | 42 | : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 43 | TLI(ST->getTargetLowering()) {} |
| 44 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 45 | /// \name Scalar TTI Implementations |
| 46 | /// @{ |
| 47 | |
| 48 | // TODO: Implement more Scalar TTI for WebAssembly |
| 49 | |
Dan Gohman | 01612f6 | 2015-08-24 16:51:46 +0000 | [diff] [blame] | 50 | TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 51 | |
| 52 | /// @} |
| 53 | |
| 54 | /// \name Vector TTI Implementations |
| 55 | /// @{ |
| 56 | |
Dan Gohman | 73d7a55 | 2016-05-23 22:47:07 +0000 | [diff] [blame] | 57 | unsigned getNumberOfRegisters(bool Vector); |
| 58 | unsigned getRegisterBitWidth(bool Vector); |
| 59 | unsigned getArithmeticInstrCost( |
| 60 | unsigned Opcode, Type *Ty, |
| 61 | TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
| 62 | TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
| 63 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
| 64 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); |
| 65 | unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 66 | |
| 67 | /// @} |
| 68 | }; |
| 69 | |
| 70 | } // end namespace llvm |
| 71 | |
| 72 | #endif |