1*9880d681SAndroid Build Coastguard Worker //===-- NVPTXTargetTransformInfo.h - NVPTX specific TTI ---------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker /// \file 10*9880d681SAndroid Build Coastguard Worker /// This file a TargetTransformInfo::Concept conforming object specific to the 11*9880d681SAndroid Build Coastguard Worker /// NVPTX target machine. It uses the target's detailed information to 12*9880d681SAndroid Build Coastguard Worker /// provide more precise answers to certain TTI queries, while letting the 13*9880d681SAndroid Build Coastguard Worker /// target independent and default TTI implementations handle the rest. 14*9880d681SAndroid Build Coastguard Worker /// 15*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETTRANSFORMINFO_H 18*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETTRANSFORMINFO_H 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker #include "NVPTX.h" 21*9880d681SAndroid Build Coastguard Worker #include "NVPTXTargetMachine.h" 22*9880d681SAndroid Build Coastguard Worker #include "llvm/Analysis/TargetTransformInfo.h" 23*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/BasicTTIImpl.h" 24*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h" 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker namespace llvm { 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker class NVPTXTTIImpl : public BasicTTIImplBase<NVPTXTTIImpl> { 29*9880d681SAndroid Build Coastguard Worker typedef BasicTTIImplBase<NVPTXTTIImpl> BaseT; 30*9880d681SAndroid Build Coastguard Worker typedef TargetTransformInfo TTI; 31*9880d681SAndroid Build Coastguard Worker friend BaseT; 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker const NVPTXSubtarget *ST; 34*9880d681SAndroid Build Coastguard Worker const NVPTXTargetLowering *TLI; 35*9880d681SAndroid Build Coastguard Worker getST()36*9880d681SAndroid Build Coastguard Worker const NVPTXSubtarget *getST() const { return ST; }; getTLI()37*9880d681SAndroid Build Coastguard Worker const NVPTXTargetLowering *getTLI() const { return TLI; }; 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker public: NVPTXTTIImpl(const NVPTXTargetMachine * TM,const Function & F)40*9880d681SAndroid Build Coastguard Worker explicit NVPTXTTIImpl(const NVPTXTargetMachine *TM, const Function &F) 41*9880d681SAndroid Build Coastguard Worker : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl()), 42*9880d681SAndroid Build Coastguard Worker TLI(ST->getTargetLowering()) {} 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Worker // Provide value semantics. MSVC requires that we spell all of these out. NVPTXTTIImpl(const NVPTXTTIImpl & Arg)45*9880d681SAndroid Build Coastguard Worker NVPTXTTIImpl(const NVPTXTTIImpl &Arg) 46*9880d681SAndroid Build Coastguard Worker : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {} NVPTXTTIImpl(NVPTXTTIImpl && Arg)47*9880d681SAndroid Build Coastguard Worker NVPTXTTIImpl(NVPTXTTIImpl &&Arg) 48*9880d681SAndroid Build Coastguard Worker : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)), 49*9880d681SAndroid Build Coastguard Worker TLI(std::move(Arg.TLI)) {} 50*9880d681SAndroid Build Coastguard Worker hasBranchDivergence()51*9880d681SAndroid Build Coastguard Worker bool hasBranchDivergence() { return true; } 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker bool isSourceOfDivergence(const Value *V); 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker // Increase the inlining cost threshold by a factor of 5, reflecting that 56*9880d681SAndroid Build Coastguard Worker // calls are particularly expensive in NVPTX. getInliningThresholdMultiplier()57*9880d681SAndroid Build Coastguard Worker unsigned getInliningThresholdMultiplier() { return 5; } 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker int getArithmeticInstrCost( 60*9880d681SAndroid Build Coastguard Worker unsigned Opcode, Type *Ty, 61*9880d681SAndroid Build Coastguard Worker TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, 62*9880d681SAndroid Build Coastguard Worker TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, 63*9880d681SAndroid Build Coastguard Worker TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, 64*9880d681SAndroid Build Coastguard Worker TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP); 67*9880d681SAndroid Build Coastguard Worker }; 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Worker #endif 72