1 //===-- LanaiTargetTransformInfo.h - Lanai specific TTI ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file a TargetTransformInfo::Concept conforming object specific to the
11 // Lanai target machine. It uses the target's detailed information to
12 // provide more precise answers to certain TTI queries, while letting the
13 // target independent and default TTI implementations handle the rest.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
21 #include "LanaiSubtarget.h"
22 #include "LanaiTargetMachine.h"
23 #include "llvm/Analysis/TargetTransformInfo.h"
24 #include "llvm/CodeGen/BasicTTIImpl.h"
25 #include "llvm/Target/TargetLowering.h"
28 class LanaiTTIImpl : public BasicTTIImplBase<LanaiTTIImpl> {
29 typedef BasicTTIImplBase<LanaiTTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
33 const LanaiSubtarget *ST;
34 const LanaiTargetLowering *TLI;
36 const LanaiSubtarget *getST() const { return ST; }
37 const LanaiTargetLowering *getTLI() const { return TLI; }
40 explicit LanaiTTIImpl(const LanaiTargetMachine *TM, const Function &F)
41 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42 TLI(ST->getTargetLowering()) {}
44 LanaiTTIImpl(const LanaiTTIImpl &Arg)
45 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
46 LanaiTTIImpl(LanaiTTIImpl &&Arg)
47 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(Arg.ST), TLI(Arg.TLI) {}
49 bool shouldBuildLookupTables() const { return false; }
51 TargetTransformInfo::PopcntSupportKind getPopcntSupport(unsigned TyWidth) {
53 return TTI::PSK_FastHardware;
54 return TTI::PSK_Software;
57 unsigned getArithmeticInstrCost(
58 unsigned Opcode, Type *Ty,
59 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
60 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
61 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
62 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None) {
63 int ISD = TLI->InstructionOpcodeToISD(Opcode);
67 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
68 Opd1PropInfo, Opd2PropInfo);
73 // This increases the cost associated with multiplication and division
74 // to 64 times what the baseline arithmetic cost is. The arithmetic
75 // instruction cost was arbitrarily chosen to reduce the desirability
76 // of emitting arithmetic instructions that are emulated in software.
77 // TODO: Investigate the performance impact given specialized lowerings.
78 return 64 * BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
79 Opd1PropInfo, Opd2PropInfo);
84 } // end namespace llvm
86 #endif // LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H