blob: 72421a00c767061f19e47029cf8cabffe0895160 [file] [log] [blame]
Chandler Carruthbe049292013-01-07 03:08:10 +00001//===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
Nadav Rotemcbd9a192012-10-18 23:22:48 +00002//
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
Chandler Carruthaeef83c2013-01-07 01:37:14 +000010#define DEBUG_TYPE "tti"
Chandler Carruthbe049292013-01-07 03:08:10 +000011#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruth1e05bd92013-01-21 01:27:39 +000012#include "llvm/IR/DataLayout.h"
13#include "llvm/IR/Operator.h"
14#include "llvm/IR/Instruction.h"
15#include "llvm/IR/IntrinsicInst.h"
16#include "llvm/IR/Instructions.h"
Chandler Carruth13086a62013-01-22 11:26:02 +000017#include "llvm/Support/CallSite.h"
Nadav Rotemcbd9a192012-10-18 23:22:48 +000018#include "llvm/Support/ErrorHandling.h"
19
20using namespace llvm;
21
Chandler Carruth7bdf6b02013-01-05 11:43:11 +000022// Setup the analysis group to manage the TargetTransformInfo passes.
23INITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI)
Nadav Rotemcbd9a192012-10-18 23:22:48 +000024char TargetTransformInfo::ID = 0;
25
Chandler Carruth7bdf6b02013-01-05 11:43:11 +000026TargetTransformInfo::~TargetTransformInfo() {
27}
28
Chandler Carruthaeef83c2013-01-07 01:37:14 +000029void TargetTransformInfo::pushTTIStack(Pass *P) {
30 TopTTI = this;
31 PrevTTI = &P->getAnalysis<TargetTransformInfo>();
32
33 // Walk up the chain and update the top TTI pointer.
34 for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI)
35 PTTI->TopTTI = this;
36}
37
38void TargetTransformInfo::popTTIStack() {
39 TopTTI = 0;
40
41 // Walk up the chain and update the top TTI pointer.
42 for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI)
43 PTTI->TopTTI = PrevTTI;
44
45 PrevTTI = 0;
46}
47
Chandler Carruth7bdf6b02013-01-05 11:43:11 +000048void TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
49 AU.addRequired<TargetTransformInfo>();
50}
51
Chandler Carruth1e05bd92013-01-21 01:27:39 +000052unsigned TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
53 Type *OpTy) const {
54 return PrevTTI->getOperationCost(Opcode, Ty, OpTy);
55}
56
57unsigned TargetTransformInfo::getGEPCost(
58 const Value *Ptr, ArrayRef<const Value *> Operands) const {
59 return PrevTTI->getGEPCost(Ptr, Operands);
60}
61
Chandler Carruth13086a62013-01-22 11:26:02 +000062unsigned TargetTransformInfo::getCallCost(FunctionType *FTy,
63 int NumArgs) const {
64 return PrevTTI->getCallCost(FTy, NumArgs);
65}
66
67unsigned TargetTransformInfo::getCallCost(const Function *F,
68 int NumArgs) const {
69 return PrevTTI->getCallCost(F, NumArgs);
70}
71
72unsigned TargetTransformInfo::getCallCost(
73 const Function *F, ArrayRef<const Value *> Arguments) const {
74 return PrevTTI->getCallCost(F, Arguments);
75}
76
77unsigned TargetTransformInfo::getIntrinsicCost(
78 Intrinsic::ID IID, Type *RetTy, ArrayRef<Type *> ParamTys) const {
79 return PrevTTI->getIntrinsicCost(IID, RetTy, ParamTys);
80}
81
82unsigned TargetTransformInfo::getIntrinsicCost(
83 Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
84 return PrevTTI->getIntrinsicCost(IID, RetTy, Arguments);
85}
86
Chandler Carruth1e05bd92013-01-21 01:27:39 +000087unsigned TargetTransformInfo::getUserCost(const User *U) const {
88 return PrevTTI->getUserCost(U);
89}
90
Chandler Carruth13086a62013-01-22 11:26:02 +000091bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
92 return PrevTTI->isLoweredToCall(F);
93}
94
Chandler Carruth7bdf6b02013-01-05 11:43:11 +000095bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
96 return PrevTTI->isLegalAddImmediate(Imm);
97}
98
99bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
100 return PrevTTI->isLegalICmpImmediate(Imm);
101}
102
103bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
104 int64_t BaseOffset,
105 bool HasBaseReg,
106 int64_t Scale) const {
107 return PrevTTI->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
108 Scale);
109}
110
111bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
112 return PrevTTI->isTruncateFree(Ty1, Ty2);
113}
114
115bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
116 return PrevTTI->isTypeLegal(Ty);
117}
118
119unsigned TargetTransformInfo::getJumpBufAlignment() const {
120 return PrevTTI->getJumpBufAlignment();
121}
122
123unsigned TargetTransformInfo::getJumpBufSize() const {
124 return PrevTTI->getJumpBufSize();
125}
126
127bool TargetTransformInfo::shouldBuildLookupTables() const {
128 return PrevTTI->shouldBuildLookupTables();
129}
130
Chandler Carruthd1b8ef92013-01-07 03:16:03 +0000131TargetTransformInfo::PopcntSupportKind
132TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
133 return PrevTTI->getPopcntSupport(IntTyWidthInBit);
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000134}
135
136unsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
137 return PrevTTI->getIntImmCost(Imm, Ty);
138}
139
140unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
141 return PrevTTI->getNumberOfRegisters(Vector);
142}
143
Nadav Rotem14925e62013-01-09 22:29:00 +0000144unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
145 return PrevTTI->getRegisterBitWidth(Vector);
146}
147
Nadav Rotem83be7b02013-01-09 01:15:42 +0000148unsigned TargetTransformInfo::getMaximumUnrollFactor() const {
149 return PrevTTI->getMaximumUnrollFactor();
150}
151
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000152unsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode,
153 Type *Ty) const {
154 return PrevTTI->getArithmeticInstrCost(Opcode, Ty);
155}
156
157unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp,
158 int Index, Type *SubTp) const {
159 return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp);
160}
161
162unsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
163 Type *Src) const {
164 return PrevTTI->getCastInstrCost(Opcode, Dst, Src);
165}
166
167unsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
168 return PrevTTI->getCFInstrCost(Opcode);
169}
170
171unsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
172 Type *CondTy) const {
173 return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy);
174}
175
176unsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
177 unsigned Index) const {
178 return PrevTTI->getVectorInstrCost(Opcode, Val, Index);
179}
180
181unsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
182 unsigned Alignment,
183 unsigned AddressSpace) const {
184 return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
185 ;
186}
187
188unsigned
189TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID,
190 Type *RetTy,
191 ArrayRef<Type *> Tys) const {
192 return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys);
193}
194
195unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
196 return PrevTTI->getNumberOfParts(Tp);
197}
198
Arnold Schwaighoferfb55a8f2013-02-08 14:50:48 +0000199unsigned TargetTransformInfo::getAddressComputationCost(Type *Tp) const {
200 return PrevTTI->getAddressComputationCost(Tp);
201}
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000202
203namespace {
204
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000205struct NoTTI : ImmutablePass, TargetTransformInfo {
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000206 const DataLayout *DL;
207
208 NoTTI() : ImmutablePass(ID), DL(0) {
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000209 initializeNoTTIPass(*PassRegistry::getPassRegistry());
210 }
211
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000212 virtual void initializePass() {
213 // Note that this subclass is special, and must *not* call initializeTTI as
214 // it does not chain.
Chandler Carruth13086a62013-01-22 11:26:02 +0000215 TopTTI = this;
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000216 PrevTTI = 0;
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000217 DL = getAnalysisIfAvailable<DataLayout>();
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000218 }
219
220 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000221 // Note that this subclass is special, and must *not* call
222 // TTI::getAnalysisUsage as it breaks the recursion.
223 }
224
225 /// Pass identification.
226 static char ID;
227
228 /// Provide necessary pointer adjustments for the two base classes.
229 virtual void *getAdjustedAnalysisPointer(const void *ID) {
230 if (ID == &TargetTransformInfo::ID)
231 return (TargetTransformInfo*)this;
232 return this;
233 }
234
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000235 unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) const {
236 switch (Opcode) {
237 default:
238 // By default, just classify everything as 'basic'.
239 return TCC_Basic;
240
241 case Instruction::GetElementPtr:
242 llvm_unreachable("Use getGEPCost for GEP operations!");
243
244 case Instruction::BitCast:
245 assert(OpTy && "Cast instructions must provide the operand type");
246 if (Ty == OpTy || (Ty->isPointerTy() && OpTy->isPointerTy()))
247 // Identity and pointer-to-pointer casts are free.
248 return TCC_Free;
249
250 // Otherwise, the default basic cost is used.
251 return TCC_Basic;
252
253 case Instruction::IntToPtr:
254 // An inttoptr cast is free so long as the input is a legal integer type
255 // which doesn't contain values outside the range of a pointer.
256 if (DL && DL->isLegalInteger(OpTy->getScalarSizeInBits()) &&
257 OpTy->getScalarSizeInBits() <= DL->getPointerSizeInBits())
258 return TCC_Free;
259
260 // Otherwise it's not a no-op.
261 return TCC_Basic;
262
263 case Instruction::PtrToInt:
264 // A ptrtoint cast is free so long as the result is large enough to store
265 // the pointer, and a legal integer type.
266 if (DL && DL->isLegalInteger(OpTy->getScalarSizeInBits()) &&
267 OpTy->getScalarSizeInBits() >= DL->getPointerSizeInBits())
268 return TCC_Free;
269
270 // Otherwise it's not a no-op.
271 return TCC_Basic;
272
273 case Instruction::Trunc:
274 // trunc to a native type is free (assuming the target has compare and
275 // shift-right of the same width).
276 if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty)))
277 return TCC_Free;
278
279 return TCC_Basic;
280 }
281 }
282
283 unsigned getGEPCost(const Value *Ptr,
284 ArrayRef<const Value *> Operands) const {
285 // In the basic model, we just assume that all-constant GEPs will be folded
286 // into their uses via addressing modes.
287 for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
288 if (!isa<Constant>(Operands[Idx]))
289 return TCC_Basic;
290
291 return TCC_Free;
292 }
293
Chandler Carruth13086a62013-01-22 11:26:02 +0000294 unsigned getCallCost(FunctionType *FTy, int NumArgs = -1) const {
295 assert(FTy && "FunctionType must be provided to this routine.");
296
297 // The target-independent implementation just measures the size of the
298 // function by approximating that each argument will take on average one
299 // instruction to prepare.
300
301 if (NumArgs < 0)
302 // Set the argument number to the number of explicit arguments in the
303 // function.
304 NumArgs = FTy->getNumParams();
305
306 return TCC_Basic * (NumArgs + 1);
307 }
308
309 unsigned getCallCost(const Function *F, int NumArgs = -1) const {
310 assert(F && "A concrete function must be provided to this routine.");
311
312 if (NumArgs < 0)
313 // Set the argument number to the number of explicit arguments in the
314 // function.
315 NumArgs = F->arg_size();
316
317 if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) {
318 FunctionType *FTy = F->getFunctionType();
319 SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
320 return TopTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
321 }
322
323 if (!TopTTI->isLoweredToCall(F))
324 return TCC_Basic; // Give a basic cost if it will be lowered directly.
325
326 return TopTTI->getCallCost(F->getFunctionType(), NumArgs);
327 }
328
329 unsigned getCallCost(const Function *F,
330 ArrayRef<const Value *> Arguments) const {
331 // Simply delegate to generic handling of the call.
332 // FIXME: We should use instsimplify or something else to catch calls which
333 // will constant fold with these arguments.
334 return TopTTI->getCallCost(F, Arguments.size());
335 }
336
337 unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
338 ArrayRef<Type *> ParamTys) const {
339 switch (IID) {
340 default:
341 // Intrinsics rarely (if ever) have normal argument setup constraints.
342 // Model them as having a basic instruction cost.
343 // FIXME: This is wrong for libc intrinsics.
344 return TCC_Basic;
345
346 case Intrinsic::dbg_declare:
347 case Intrinsic::dbg_value:
348 case Intrinsic::invariant_start:
349 case Intrinsic::invariant_end:
350 case Intrinsic::lifetime_start:
351 case Intrinsic::lifetime_end:
352 case Intrinsic::objectsize:
353 case Intrinsic::ptr_annotation:
354 case Intrinsic::var_annotation:
355 // These intrinsics don't actually represent code after lowering.
356 return TCC_Free;
357 }
358 }
359
360 unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
361 ArrayRef<const Value *> Arguments) const {
362 // Delegate to the generic intrinsic handling code. This mostly provides an
363 // opportunity for targets to (for example) special case the cost of
364 // certain intrinsics based on constants used as arguments.
365 SmallVector<Type *, 8> ParamTys;
366 ParamTys.reserve(Arguments.size());
367 for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; ++Idx)
368 ParamTys.push_back(Arguments[Idx]->getType());
369 return TopTTI->getIntrinsicCost(IID, RetTy, ParamTys);
370 }
371
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000372 unsigned getUserCost(const User *U) const {
Chandler Carrutha5157e62013-01-21 13:04:33 +0000373 if (isa<PHINode>(U))
374 return TCC_Free; // Model all PHI nodes as free.
375
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000376 if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U))
377 // In the basic model we just assume that all-constant GEPs will be
378 // folded into their uses via addressing modes.
379 return GEP->hasAllConstantIndices() ? TCC_Free : TCC_Basic;
380
Chandler Carruth13086a62013-01-22 11:26:02 +0000381 if (ImmutableCallSite CS = U) {
382 const Function *F = CS.getCalledFunction();
383 if (!F) {
384 // Just use the called value type.
385 Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
386 return TopTTI->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000387 }
Chandler Carruth13086a62013-01-22 11:26:02 +0000388
389 SmallVector<const Value *, 8> Arguments;
390 for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(),
391 AE = CS.arg_end();
392 AI != AE; ++AI)
393 Arguments.push_back(*AI);
394
395 return TopTTI->getCallCost(F, Arguments);
Chandler Carruth1e05bd92013-01-21 01:27:39 +0000396 }
397
398 if (const CastInst *CI = dyn_cast<CastInst>(U)) {
399 // Result of a cmp instruction is often extended (to be used by other
400 // cmp instructions, logical or return instructions). These are usually
401 // nop on most sane targets.
402 if (isa<CmpInst>(CI->getOperand(0)))
403 return TCC_Free;
404 }
405
406 // Otherwise delegate to the fully generic implementations.
407 return getOperationCost(Operator::getOpcode(U), U->getType(),
408 U->getNumOperands() == 1 ?
409 U->getOperand(0)->getType() : 0);
410 }
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000411
Chandler Carruth13086a62013-01-22 11:26:02 +0000412 bool isLoweredToCall(const Function *F) const {
413 // FIXME: These should almost certainly not be handled here, and instead
414 // handled with the help of TLI or the target itself. This was largely
415 // ported from existing analysis heuristics here so that such refactorings
416 // can take place in the future.
417
418 if (F->isIntrinsic())
419 return false;
420
421 if (F->hasLocalLinkage() || !F->hasName())
422 return true;
423
424 StringRef Name = F->getName();
425
426 // These will all likely lower to a single selection DAG node.
427 if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
428 Name == "fabs" || Name == "fabsf" || Name == "fabsl" || Name == "sin" ||
429 Name == "sinf" || Name == "sinl" || Name == "cos" || Name == "cosf" ||
430 Name == "cosl" || Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl")
431 return false;
432
433 // These are all likely to be optimized into something smaller.
434 if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
435 Name == "exp2l" || Name == "exp2f" || Name == "floor" || Name ==
436 "floorf" || Name == "ceil" || Name == "round" || Name == "ffs" ||
437 Name == "ffsl" || Name == "abs" || Name == "labs" || Name == "llabs")
438 return false;
439
440 return true;
441 }
442
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000443 bool isLegalAddImmediate(int64_t Imm) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000444 return false;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000445 }
446
447 bool isLegalICmpImmediate(int64_t Imm) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000448 return false;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000449 }
450
451 bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
452 bool HasBaseReg, int64_t Scale) const {
Chandler Carruthe4ba75f2013-01-07 14:41:08 +0000453 // Guess that reg+reg addressing is allowed. This heuristic is taken from
454 // the implementation of LSR.
455 return !BaseGV && BaseOffset == 0 && Scale <= 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000456 }
457
458 bool isTruncateFree(Type *Ty1, Type *Ty2) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000459 return false;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000460 }
461
462 bool isTypeLegal(Type *Ty) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000463 return false;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000464 }
465
466 unsigned getJumpBufAlignment() const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000467 return 0;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000468 }
469
470 unsigned getJumpBufSize() const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000471 return 0;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000472 }
473
474 bool shouldBuildLookupTables() const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000475 return true;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000476 }
477
Chandler Carruthd1b8ef92013-01-07 03:16:03 +0000478 PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const {
479 return PSK_Software;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000480 }
481
482 unsigned getIntImmCost(const APInt &Imm, Type *Ty) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000483 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000484 }
485
486 unsigned getNumberOfRegisters(bool Vector) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000487 return 8;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000488 }
489
Nadav Rotem14925e62013-01-09 22:29:00 +0000490 unsigned getRegisterBitWidth(bool Vector) const {
491 return 32;
492 }
493
Nadav Rotem83be7b02013-01-09 01:15:42 +0000494 unsigned getMaximumUnrollFactor() const {
495 return 1;
496 }
497
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000498 unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000499 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000500 }
501
502 unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
503 int Index = 0, Type *SubTp = 0) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000504 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000505 }
506
507 unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
508 Type *Src) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000509 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000510 }
511
512 unsigned getCFInstrCost(unsigned Opcode) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000513 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000514 }
515
516 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
517 Type *CondTy = 0) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000518 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000519 }
520
521 unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
522 unsigned Index = -1) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000523 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000524 }
525
526 unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
527 unsigned Alignment,
528 unsigned AddressSpace) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000529 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000530 }
531
532 unsigned getIntrinsicInstrCost(Intrinsic::ID ID,
533 Type *RetTy,
534 ArrayRef<Type*> Tys) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000535 return 1;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000536 }
537
538 unsigned getNumberOfParts(Type *Tp) const {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000539 return 0;
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000540 }
Arnold Schwaighoferfb55a8f2013-02-08 14:50:48 +0000541
542 unsigned getAddressComputationCost(Type *Tp) const {
543 return 0;
544 }
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000545};
546
547} // end anonymous namespace
548
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000549INITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti",
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000550 "No target information", true, true, true)
551char NoTTI::ID = 0;
552
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000553ImmutablePass *llvm::createNoTargetTransformInfoPass() {
554 return new NoTTI();
Chandler Carruth7bdf6b02013-01-05 11:43:11 +0000555}