comparison lib/Target/Lanai/LanaiTargetTransformInfo.h @ 120:1172e4bd9c6f

update 4.0.0
author mir3636
date Fri, 25 Nov 2016 19:14:25 +0900
parents
children 803732b1fca8
comparison
equal deleted inserted replaced
101:34baf5011add 120:1172e4bd9c6f
1 //===-- LanaiTargetTransformInfo.h - Lanai 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 // 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.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H
19
20 #include "Lanai.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"
26
27 namespace llvm {
28 class LanaiTTIImpl : public BasicTTIImplBase<LanaiTTIImpl> {
29 typedef BasicTTIImplBase<LanaiTTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
31 friend BaseT;
32
33 const LanaiSubtarget *ST;
34 const LanaiTargetLowering *TLI;
35
36 const LanaiSubtarget *getST() const { return ST; }
37 const LanaiTargetLowering *getTLI() const { return TLI; }
38
39 public:
40 explicit LanaiTTIImpl(const LanaiTargetMachine *TM, const Function &F)
41 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42 TLI(ST->getTargetLowering()) {}
43
44 bool shouldBuildLookupTables() const { return false; }
45
46 TargetTransformInfo::PopcntSupportKind getPopcntSupport(unsigned TyWidth) {
47 if (TyWidth == 32)
48 return TTI::PSK_FastHardware;
49 return TTI::PSK_Software;
50 }
51
52 unsigned getArithmeticInstrCost(
53 unsigned Opcode, Type *Ty,
54 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
55 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
56 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
57 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None) {
58 int ISD = TLI->InstructionOpcodeToISD(Opcode);
59
60 switch (ISD) {
61 default:
62 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
63 Opd1PropInfo, Opd2PropInfo);
64 case ISD::MUL:
65 case ISD::SDIV:
66 case ISD::UDIV:
67 case ISD::UREM:
68 // This increases the cost associated with multiplication and division
69 // to 64 times what the baseline arithmetic cost is. The arithmetic
70 // instruction cost was arbitrarily chosen to reduce the desirability
71 // of emitting arithmetic instructions that are emulated in software.
72 // TODO: Investigate the performance impact given specialized lowerings.
73 return 64 * BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
74 Opd1PropInfo, Opd2PropInfo);
75 }
76 }
77 };
78
79 } // end namespace llvm
80
81 #endif // LLVM_LIB_TARGET_LANAI_LANAITARGETTRANSFORMINFO_H