blob: fa5297071e91350013a4cf6569f75d2f72c02163 [file] [log] [blame]
Chandler Carruthaeef83c2013-01-07 01:37:14 +00001//===- BasicTargetTransformInfo.cpp - Basic target-independent TTI impl ---===//
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/// \file
10/// This file provides the implementation of a basic TargetTransformInfo pass
11/// predicated on the target abstractions present in the target independent
12/// code generator. It uses these (primarily TargetLowering) to model as much
13/// of the TTI query interface as possible. It is included by most targets so
14/// that they can specialize only a small subset of the query space.
15///
16//===----------------------------------------------------------------------===//
17
18#define DEBUG_TYPE "basictti"
19#include "llvm/CodeGen/Passes.h"
Chandler Carruthbe049292013-01-07 03:08:10 +000020#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruthaeef83c2013-01-07 01:37:14 +000021#include "llvm/Target/TargetLowering.h"
Chandler Carruthaeef83c2013-01-07 01:37:14 +000022#include <utility>
23
24using namespace llvm;
25
26namespace {
27
28class BasicTTI : public ImmutablePass, public TargetTransformInfo {
Bill Wendlingea442812013-06-19 20:51:24 +000029 const TargetMachine *TM;
Chandler Carruthaeef83c2013-01-07 01:37:14 +000030
31 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
32 /// are set if the result needs to be inserted and/or extracted from vectors.
33 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract) const;
34
Bill Wendlingea442812013-06-19 20:51:24 +000035 const TargetLoweringBase *getTLI() const { return TM->getTargetLowering(); }
36
Chandler Carruthaeef83c2013-01-07 01:37:14 +000037public:
Bill Wendlingea442812013-06-19 20:51:24 +000038 BasicTTI() : ImmutablePass(ID), TM(0) {
Chandler Carruthaeef83c2013-01-07 01:37:14 +000039 llvm_unreachable("This pass cannot be directly constructed");
40 }
41
Bill Wendlingea442812013-06-19 20:51:24 +000042 BasicTTI(const TargetMachine *TM) : ImmutablePass(ID), TM(TM) {
Chandler Carruthaeef83c2013-01-07 01:37:14 +000043 initializeBasicTTIPass(*PassRegistry::getPassRegistry());
44 }
45
46 virtual void initializePass() {
47 pushTTIStack(this);
48 }
49
50 virtual void finalizePass() {
51 popTTIStack();
52 }
53
54 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
55 TargetTransformInfo::getAnalysisUsage(AU);
56 }
57
58 /// Pass identification.
59 static char ID;
60
61 /// Provide necessary pointer adjustments for the two base classes.
62 virtual void *getAdjustedAnalysisPointer(const void *ID) {
63 if (ID == &TargetTransformInfo::ID)
64 return (TargetTransformInfo*)this;
65 return this;
66 }
67
68 /// \name Scalar TTI Implementations
69 /// @{
70
71 virtual bool isLegalAddImmediate(int64_t imm) const;
72 virtual bool isLegalICmpImmediate(int64_t imm) const;
73 virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
74 int64_t BaseOffset, bool HasBaseReg,
75 int64_t Scale) const;
Quentin Colombet06f5ebc2013-05-31 21:29:03 +000076 virtual int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
77 int64_t BaseOffset, bool HasBaseReg,
78 int64_t Scale) const;
Chandler Carruthaeef83c2013-01-07 01:37:14 +000079 virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const;
80 virtual bool isTypeLegal(Type *Ty) const;
81 virtual unsigned getJumpBufAlignment() const;
82 virtual unsigned getJumpBufSize() const;
83 virtual bool shouldBuildLookupTables() const;
84
85 /// @}
86
87 /// \name Vector TTI Implementations
88 /// @{
89
90 virtual unsigned getNumberOfRegisters(bool Vector) const;
Nadav Rotem83be7b02013-01-09 01:15:42 +000091 virtual unsigned getMaximumUnrollFactor() const;
Nadav Rotem14925e62013-01-09 22:29:00 +000092 virtual unsigned getRegisterBitWidth(bool Vector) const;
Arnold Schwaighofer6bf4f672013-04-04 23:26:21 +000093 virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
94 OperandValueKind,
95 OperandValueKind) const;
Chandler Carruthaeef83c2013-01-07 01:37:14 +000096 virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
97 int Index, Type *SubTp) const;
98 virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
99 Type *Src) const;
100 virtual unsigned getCFInstrCost(unsigned Opcode) const;
101 virtual unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
102 Type *CondTy) const;
103 virtual unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
104 unsigned Index) const;
105 virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
106 unsigned Alignment,
107 unsigned AddressSpace) const;
108 virtual unsigned getIntrinsicInstrCost(Intrinsic::ID, Type *RetTy,
109 ArrayRef<Type*> Tys) const;
110 virtual unsigned getNumberOfParts(Type *Tp) const;
Arnold Schwaighoferfb55a8f2013-02-08 14:50:48 +0000111 virtual unsigned getAddressComputationCost(Type *Ty) const;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000112
113 /// @}
114};
115
116}
117
118INITIALIZE_AG_PASS(BasicTTI, TargetTransformInfo, "basictti",
119 "Target independent code generator's TTI", true, true, false)
120char BasicTTI::ID = 0;
121
122ImmutablePass *
Bill Wendlingea442812013-06-19 20:51:24 +0000123llvm::createBasicTargetTransformInfoPass(const TargetMachine *TM) {
124 return new BasicTTI(TM);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000125}
126
127
128bool BasicTTI::isLegalAddImmediate(int64_t imm) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000129 return getTLI()->isLegalAddImmediate(imm);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000130}
131
132bool BasicTTI::isLegalICmpImmediate(int64_t imm) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000133 return getTLI()->isLegalICmpImmediate(imm);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000134}
135
136bool BasicTTI::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
137 int64_t BaseOffset, bool HasBaseReg,
138 int64_t Scale) const {
Benjamin Kramer69e42db2013-01-11 20:05:37 +0000139 TargetLoweringBase::AddrMode AM;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000140 AM.BaseGV = BaseGV;
141 AM.BaseOffs = BaseOffset;
142 AM.HasBaseReg = HasBaseReg;
143 AM.Scale = Scale;
Bill Wendlingea442812013-06-19 20:51:24 +0000144 return getTLI()->isLegalAddressingMode(AM, Ty);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000145}
146
Quentin Colombet06f5ebc2013-05-31 21:29:03 +0000147int BasicTTI::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
148 int64_t BaseOffset, bool HasBaseReg,
149 int64_t Scale) const {
150 TargetLoweringBase::AddrMode AM;
151 AM.BaseGV = BaseGV;
152 AM.BaseOffs = BaseOffset;
153 AM.HasBaseReg = HasBaseReg;
154 AM.Scale = Scale;
Bill Wendlingea442812013-06-19 20:51:24 +0000155 return getTLI()->getScalingFactorCost(AM, Ty);
Quentin Colombet06f5ebc2013-05-31 21:29:03 +0000156}
157
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000158bool BasicTTI::isTruncateFree(Type *Ty1, Type *Ty2) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000159 return getTLI()->isTruncateFree(Ty1, Ty2);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000160}
161
162bool BasicTTI::isTypeLegal(Type *Ty) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000163 EVT T = getTLI()->getValueType(Ty);
164 return getTLI()->isTypeLegal(T);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000165}
166
167unsigned BasicTTI::getJumpBufAlignment() const {
Bill Wendlingea442812013-06-19 20:51:24 +0000168 return getTLI()->getJumpBufAlignment();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000169}
170
171unsigned BasicTTI::getJumpBufSize() const {
Bill Wendlingea442812013-06-19 20:51:24 +0000172 return getTLI()->getJumpBufSize();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000173}
174
175bool BasicTTI::shouldBuildLookupTables() const {
Bill Wendlingea442812013-06-19 20:51:24 +0000176 const TargetLoweringBase *TLI = getTLI();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000177 return TLI->supportJumpTables() &&
178 (TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
179 TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other));
180}
181
182//===----------------------------------------------------------------------===//
183//
184// Calls used by the vectorizers.
185//
186//===----------------------------------------------------------------------===//
187
188unsigned BasicTTI::getScalarizationOverhead(Type *Ty, bool Insert,
189 bool Extract) const {
190 assert (Ty->isVectorTy() && "Can only scalarize vectors");
191 unsigned Cost = 0;
192
193 for (int i = 0, e = Ty->getVectorNumElements(); i < e; ++i) {
194 if (Insert)
195 Cost += TopTTI->getVectorInstrCost(Instruction::InsertElement, Ty, i);
196 if (Extract)
197 Cost += TopTTI->getVectorInstrCost(Instruction::ExtractElement, Ty, i);
198 }
199
200 return Cost;
201}
202
203unsigned BasicTTI::getNumberOfRegisters(bool Vector) const {
204 return 1;
205}
206
Nadav Rotem14925e62013-01-09 22:29:00 +0000207unsigned BasicTTI::getRegisterBitWidth(bool Vector) const {
208 return 32;
209}
210
Nadav Rotem83be7b02013-01-09 01:15:42 +0000211unsigned BasicTTI::getMaximumUnrollFactor() const {
212 return 1;
213}
214
Arnold Schwaighofer6bf4f672013-04-04 23:26:21 +0000215unsigned BasicTTI::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
216 OperandValueKind,
217 OperandValueKind) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000218 // Check if any of the operands are vector operands.
Bill Wendlingea442812013-06-19 20:51:24 +0000219 const TargetLoweringBase *TLI = getTLI();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000220 int ISD = TLI->InstructionOpcodeToISD(Opcode);
221 assert(ISD && "Invalid opcode");
222
223 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty);
224
Nadav Rotem9eb366a2013-04-12 21:15:03 +0000225 bool IsFloat = Ty->getScalarType()->isFloatingPointTy();
Nadav Rotem42082002013-04-14 05:55:18 +0000226 // Assume that floating point arithmetic operations cost twice as much as
227 // integer operations.
Nadav Rotem9eb366a2013-04-12 21:15:03 +0000228 unsigned OpCost = (IsFloat ? 2 : 1);
229
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000230 if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
231 // The operation is legal. Assume it costs 1.
Nadav Rotem42082002013-04-14 05:55:18 +0000232 // If the type is split to multiple registers, assume that there is some
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000233 // overhead to this.
234 // TODO: Once we have extract/insert subvector cost we need to use them.
235 if (LT.first > 1)
Nadav Rotem9eb366a2013-04-12 21:15:03 +0000236 return LT.first * 2 * OpCost;
237 return LT.first * 1 * OpCost;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000238 }
239
240 if (!TLI->isOperationExpand(ISD, LT.second)) {
241 // If the operation is custom lowered then assume
242 // thare the code is twice as expensive.
Nadav Rotem9eb366a2013-04-12 21:15:03 +0000243 return LT.first * 2 * OpCost;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000244 }
245
246 // Else, assume that we need to scalarize this op.
247 if (Ty->isVectorTy()) {
248 unsigned Num = Ty->getVectorNumElements();
249 unsigned Cost = TopTTI->getArithmeticInstrCost(Opcode, Ty->getScalarType());
250 // return the cost of multiple scalar invocation plus the cost of inserting
251 // and extracting the values.
252 return getScalarizationOverhead(Ty, true, true) + Num * Cost;
253 }
254
255 // We don't know anything about this scalar instruction.
Nadav Rotem9eb366a2013-04-12 21:15:03 +0000256 return OpCost;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000257}
258
259unsigned BasicTTI::getShuffleCost(ShuffleKind Kind, Type *Tp, int Index,
260 Type *SubTp) const {
261 return 1;
262}
263
264unsigned BasicTTI::getCastInstrCost(unsigned Opcode, Type *Dst,
265 Type *Src) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000266 const TargetLoweringBase *TLI = getTLI();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000267 int ISD = TLI->InstructionOpcodeToISD(Opcode);
268 assert(ISD && "Invalid opcode");
269
270 std::pair<unsigned, MVT> SrcLT = TLI->getTypeLegalizationCost(Src);
271 std::pair<unsigned, MVT> DstLT = TLI->getTypeLegalizationCost(Dst);
272
Nadav Rotem3e40d922013-01-11 19:54:13 +0000273 // Check for NOOP conversions.
274 if (SrcLT.first == DstLT.first &&
275 SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {
276
277 // Bitcast between types that are legalized to the same type are free.
278 if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
279 return 0;
280 }
281
282 if (Opcode == Instruction::Trunc &&
283 TLI->isTruncateFree(SrcLT.second, DstLT.second))
284 return 0;
285
286 if (Opcode == Instruction::ZExt &&
287 TLI->isZExtFree(SrcLT.second, DstLT.second))
288 return 0;
289
290 // If the cast is marked as legal (or promote) then assume low cost.
291 if (TLI->isOperationLegalOrPromote(ISD, DstLT.second))
292 return 1;
293
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000294 // Handle scalar conversions.
295 if (!Src->isVectorTy() && !Dst->isVectorTy()) {
296
297 // Scalar bitcasts are usually free.
298 if (Opcode == Instruction::BitCast)
299 return 0;
300
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000301 // Just check the op cost. If the operation is legal then assume it costs 1.
302 if (!TLI->isOperationExpand(ISD, DstLT.second))
303 return 1;
304
305 // Assume that illegal scalar instruction are expensive.
306 return 4;
307 }
308
309 // Check vector-to-vector casts.
310 if (Dst->isVectorTy() && Src->isVectorTy()) {
311
312 // If the cast is between same-sized registers, then the check is simple.
313 if (SrcLT.first == DstLT.first &&
314 SrcLT.second.getSizeInBits() == DstLT.second.getSizeInBits()) {
315
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000316 // Assume that Zext is done using AND.
317 if (Opcode == Instruction::ZExt)
318 return 1;
319
320 // Assume that sext is done using SHL and SRA.
321 if (Opcode == Instruction::SExt)
322 return 2;
323
324 // Just check the op cost. If the operation is legal then assume it costs
325 // 1 and multiply by the type-legalization overhead.
326 if (!TLI->isOperationExpand(ISD, DstLT.second))
327 return SrcLT.first * 1;
328 }
329
330 // If we are converting vectors and the operation is illegal, or
331 // if the vectors are legalized to different types, estimate the
332 // scalarization costs.
333 unsigned Num = Dst->getVectorNumElements();
334 unsigned Cost = TopTTI->getCastInstrCost(Opcode, Dst->getScalarType(),
335 Src->getScalarType());
336
337 // Return the cost of multiple scalar invocation plus the cost of
338 // inserting and extracting the values.
339 return getScalarizationOverhead(Dst, true, true) + Num * Cost;
340 }
341
342 // We already handled vector-to-vector and scalar-to-scalar conversions. This
343 // is where we handle bitcast between vectors and scalars. We need to assume
344 // that the conversion is scalarized in one way or another.
345 if (Opcode == Instruction::BitCast)
346 // Illegal bitcasts are done by storing and loading from a stack slot.
347 return (Src->isVectorTy()? getScalarizationOverhead(Src, false, true):0) +
348 (Dst->isVectorTy()? getScalarizationOverhead(Dst, true, false):0);
349
350 llvm_unreachable("Unhandled cast");
351 }
352
353unsigned BasicTTI::getCFInstrCost(unsigned Opcode) const {
354 // Branches are assumed to be predicted.
355 return 0;
356}
357
358unsigned BasicTTI::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
359 Type *CondTy) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000360 const TargetLoweringBase *TLI = getTLI();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000361 int ISD = TLI->InstructionOpcodeToISD(Opcode);
362 assert(ISD && "Invalid opcode");
363
364 // Selects on vectors are actually vector selects.
365 if (ISD == ISD::SELECT) {
366 assert(CondTy && "CondTy must exist");
367 if (CondTy->isVectorTy())
368 ISD = ISD::VSELECT;
369 }
370
371 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(ValTy);
372
373 if (!TLI->isOperationExpand(ISD, LT.second)) {
374 // The operation is legal. Assume it costs 1. Multiply
375 // by the type-legalization overhead.
376 return LT.first * 1;
377 }
378
379 // Otherwise, assume that the cast is scalarized.
380 if (ValTy->isVectorTy()) {
381 unsigned Num = ValTy->getVectorNumElements();
382 if (CondTy)
383 CondTy = CondTy->getScalarType();
384 unsigned Cost = TopTTI->getCmpSelInstrCost(Opcode, ValTy->getScalarType(),
385 CondTy);
386
387 // Return the cost of multiple scalar invocation plus the cost of inserting
388 // and extracting the values.
389 return getScalarizationOverhead(ValTy, true, false) + Num * Cost;
390 }
391
392 // Unknown scalar opcode.
393 return 1;
394}
395
396unsigned BasicTTI::getVectorInstrCost(unsigned Opcode, Type *Val,
397 unsigned Index) const {
398 return 1;
399}
400
401unsigned BasicTTI::getMemoryOpCost(unsigned Opcode, Type *Src,
402 unsigned Alignment,
403 unsigned AddressSpace) const {
404 assert(!Src->isVoidTy() && "Invalid type");
Bill Wendlingea442812013-06-19 20:51:24 +0000405 std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(Src);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000406
407 // Assume that all loads of legal types cost 1.
408 return LT.first;
409}
410
Benjamin Kramer8611d442013-02-28 19:09:33 +0000411unsigned BasicTTI::getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000412 ArrayRef<Type *> Tys) const {
Benjamin Kramer8611d442013-02-28 19:09:33 +0000413 unsigned ISD = 0;
414 switch (IID) {
415 default: {
416 // Assume that we need to scalarize this intrinsic.
417 unsigned ScalarizationCost = 0;
418 unsigned ScalarCalls = 1;
419 if (RetTy->isVectorTy()) {
420 ScalarizationCost = getScalarizationOverhead(RetTy, true, false);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000421 ScalarCalls = std::max(ScalarCalls, RetTy->getVectorNumElements());
422 }
Benjamin Kramer8611d442013-02-28 19:09:33 +0000423 for (unsigned i = 0, ie = Tys.size(); i != ie; ++i) {
424 if (Tys[i]->isVectorTy()) {
425 ScalarizationCost += getScalarizationOverhead(Tys[i], false, true);
426 ScalarCalls = std::max(ScalarCalls, RetTy->getVectorNumElements());
427 }
428 }
429
430 return ScalarCalls + ScalarizationCost;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000431 }
Benjamin Kramer8611d442013-02-28 19:09:33 +0000432 // Look for intrinsics that can be lowered directly or turned into a scalar
433 // intrinsic call.
434 case Intrinsic::sqrt: ISD = ISD::FSQRT; break;
435 case Intrinsic::sin: ISD = ISD::FSIN; break;
436 case Intrinsic::cos: ISD = ISD::FCOS; break;
437 case Intrinsic::exp: ISD = ISD::FEXP; break;
438 case Intrinsic::exp2: ISD = ISD::FEXP2; break;
439 case Intrinsic::log: ISD = ISD::FLOG; break;
440 case Intrinsic::log10: ISD = ISD::FLOG10; break;
441 case Intrinsic::log2: ISD = ISD::FLOG2; break;
442 case Intrinsic::fabs: ISD = ISD::FABS; break;
443 case Intrinsic::floor: ISD = ISD::FFLOOR; break;
444 case Intrinsic::ceil: ISD = ISD::FCEIL; break;
445 case Intrinsic::trunc: ISD = ISD::FTRUNC; break;
446 case Intrinsic::rint: ISD = ISD::FRINT; break;
447 case Intrinsic::pow: ISD = ISD::FPOW; break;
448 case Intrinsic::fma: ISD = ISD::FMA; break;
449 case Intrinsic::fmuladd: ISD = ISD::FMA; break; // FIXME: mul + add?
450 }
451
Bill Wendlingea442812013-06-19 20:51:24 +0000452 const TargetLoweringBase *TLI = getTLI();
Benjamin Kramer8611d442013-02-28 19:09:33 +0000453 std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(RetTy);
454
455 if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
456 // The operation is legal. Assume it costs 1.
457 // If the type is split to multiple registers, assume that thre is some
458 // overhead to this.
459 // TODO: Once we have extract/insert subvector cost we need to use them.
460 if (LT.first > 1)
461 return LT.first * 2;
462 return LT.first * 1;
463 }
464
465 if (!TLI->isOperationExpand(ISD, LT.second)) {
466 // If the operation is custom lowered then assume
467 // thare the code is twice as expensive.
468 return LT.first * 2;
469 }
470
471 // Else, assume that we need to scalarize this intrinsic. For math builtins
472 // this will emit a costly libcall, adding call overhead and spills. Make it
473 // very expensive.
474 if (RetTy->isVectorTy()) {
475 unsigned Num = RetTy->getVectorNumElements();
476 unsigned Cost = TopTTI->getIntrinsicInstrCost(IID, RetTy->getScalarType(),
477 Tys);
478 return 10 * Cost * Num;
479 }
480
481 // This is going to be turned into a library call, make it expensive.
482 return 10;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000483}
484
485unsigned BasicTTI::getNumberOfParts(Type *Tp) const {
Bill Wendlingea442812013-06-19 20:51:24 +0000486 std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(Tp);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000487 return LT.first;
488}
Arnold Schwaighoferfb55a8f2013-02-08 14:50:48 +0000489
490unsigned BasicTTI::getAddressComputationCost(Type *Ty) const {
491 return 0;
492}