Mercurial > hg > CbC > CbC_llvm
comparison lib/Target/Lanai/LanaiTargetTransformInfo.h @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | 1172e4bd9c6f |
children | 3a76565eade5 |
comparison
equal
deleted
inserted
replaced
120:1172e4bd9c6f | 121:803732b1fca8 |
---|---|
20 #include "Lanai.h" | 20 #include "Lanai.h" |
21 #include "LanaiSubtarget.h" | 21 #include "LanaiSubtarget.h" |
22 #include "LanaiTargetMachine.h" | 22 #include "LanaiTargetMachine.h" |
23 #include "llvm/Analysis/TargetTransformInfo.h" | 23 #include "llvm/Analysis/TargetTransformInfo.h" |
24 #include "llvm/CodeGen/BasicTTIImpl.h" | 24 #include "llvm/CodeGen/BasicTTIImpl.h" |
25 #include "llvm/Support/MathExtras.h" | |
25 #include "llvm/Target/TargetLowering.h" | 26 #include "llvm/Target/TargetLowering.h" |
26 | 27 |
27 namespace llvm { | 28 namespace llvm { |
28 class LanaiTTIImpl : public BasicTTIImplBase<LanaiTTIImpl> { | 29 class LanaiTTIImpl : public BasicTTIImplBase<LanaiTTIImpl> { |
29 typedef BasicTTIImplBase<LanaiTTIImpl> BaseT; | 30 typedef BasicTTIImplBase<LanaiTTIImpl> BaseT; |
47 if (TyWidth == 32) | 48 if (TyWidth == 32) |
48 return TTI::PSK_FastHardware; | 49 return TTI::PSK_FastHardware; |
49 return TTI::PSK_Software; | 50 return TTI::PSK_Software; |
50 } | 51 } |
51 | 52 |
53 int getIntImmCost(const APInt &Imm, Type *Ty) { | |
54 assert(Ty->isIntegerTy()); | |
55 if (Imm == 0) | |
56 return TTI::TCC_Free; | |
57 if (isInt<16>(Imm.getSExtValue())) | |
58 return TTI::TCC_Basic; | |
59 if (isInt<21>(Imm.getZExtValue())) | |
60 return TTI::TCC_Basic; | |
61 if (isInt<32>(Imm.getSExtValue())) { | |
62 if ((Imm.getSExtValue() & 0xFFFF) == 0) | |
63 return TTI::TCC_Basic; | |
64 return 2 * TTI::TCC_Basic; | |
65 } | |
66 | |
67 return 4 * TTI::TCC_Basic; | |
68 } | |
69 | |
70 int getIntImmCost(unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty) { | |
71 return getIntImmCost(Imm, Ty); | |
72 } | |
73 | |
74 int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, | |
75 Type *Ty) { | |
76 return getIntImmCost(Imm, Ty); | |
77 } | |
78 | |
52 unsigned getArithmeticInstrCost( | 79 unsigned getArithmeticInstrCost( |
53 unsigned Opcode, Type *Ty, | 80 unsigned Opcode, Type *Ty, |
54 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, | 81 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
55 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, | 82 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
56 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, | 83 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
57 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None) { | 84 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, |
85 ArrayRef<const Value *> Args = ArrayRef<const Value *>()) { | |
58 int ISD = TLI->InstructionOpcodeToISD(Opcode); | 86 int ISD = TLI->InstructionOpcodeToISD(Opcode); |
59 | 87 |
60 switch (ISD) { | 88 switch (ISD) { |
61 default: | 89 default: |
62 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info, | 90 return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info, |