blob: 35ce794c7f12099c310e7c5614ef4baeabd331b9 [file] [log] [blame]
Chandler Carruthd3e73552013-01-07 03:08:10 +00001//===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
Nadav Rotem5dc203e2012-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 Carruth664e3542013-01-07 01:37:14 +000010#define DEBUG_TYPE "tti"
Chandler Carruthd3e73552013-01-07 03:08:10 +000011#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruth511aa762013-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 Carruth0ba8db42013-01-22 11:26:02 +000017#include "llvm/Support/CallSite.h"
Nadav Rotem5dc203e2012-10-18 23:22:48 +000018#include "llvm/Support/ErrorHandling.h"
19
20using namespace llvm;
21
Chandler Carruth539edf42013-01-05 11:43:11 +000022// Setup the analysis group to manage the TargetTransformInfo passes.
23INITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI)
Nadav Rotem5dc203e2012-10-18 23:22:48 +000024char TargetTransformInfo::ID = 0;
25
Chandler Carruth539edf42013-01-05 11:43:11 +000026TargetTransformInfo::~TargetTransformInfo() {
27}
28
Chandler Carruth664e3542013-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 Carruth539edf42013-01-05 11:43:11 +000048void TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
49 AU.addRequired<TargetTransformInfo>();
50}
51
Chandler Carruth511aa762013-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 Carruth0ba8db42013-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 Carruth511aa762013-01-21 01:27:39 +000087unsigned TargetTransformInfo::getUserCost(const User *U) const {
88 return PrevTTI->getUserCost(U);
89}
90
Chandler Carruth0ba8db42013-01-22 11:26:02 +000091bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
92 return PrevTTI->isLoweredToCall(F);
93}
94
Chandler Carruth539edf42013-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
Quentin Colombetbf490d42013-05-31 21:29:03 +0000111int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
112 int64_t BaseOffset,
113 bool HasBaseReg,
114 int64_t Scale) const {
115 return PrevTTI->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
116 Scale);
117}
118
Chandler Carruth539edf42013-01-05 11:43:11 +0000119bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
120 return PrevTTI->isTruncateFree(Ty1, Ty2);
121}
122
123bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
124 return PrevTTI->isTypeLegal(Ty);
125}
126
127unsigned TargetTransformInfo::getJumpBufAlignment() const {
128 return PrevTTI->getJumpBufAlignment();
129}
130
131unsigned TargetTransformInfo::getJumpBufSize() const {
132 return PrevTTI->getJumpBufSize();
133}
134
135bool TargetTransformInfo::shouldBuildLookupTables() const {
136 return PrevTTI->shouldBuildLookupTables();
137}
138
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000139TargetTransformInfo::PopcntSupportKind
140TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
141 return PrevTTI->getPopcntSupport(IntTyWidthInBit);
Chandler Carruth539edf42013-01-05 11:43:11 +0000142}
143
144unsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
145 return PrevTTI->getIntImmCost(Imm, Ty);
146}
147
148unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
149 return PrevTTI->getNumberOfRegisters(Vector);
150}
151
Nadav Rotemb1791a72013-01-09 22:29:00 +0000152unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
153 return PrevTTI->getRegisterBitWidth(Vector);
154}
155
Nadav Rotemb696c362013-01-09 01:15:42 +0000156unsigned TargetTransformInfo::getMaximumUnrollFactor() const {
157 return PrevTTI->getMaximumUnrollFactor();
158}
159
Chandler Carruth539edf42013-01-05 11:43:11 +0000160unsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode,
Arnold Schwaighoferb9773872013-04-04 23:26:21 +0000161 Type *Ty,
162 OperandValueKind Op1Info,
163 OperandValueKind Op2Info) const {
164 return PrevTTI->getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info);
Chandler Carruth539edf42013-01-05 11:43:11 +0000165}
166
167unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp,
168 int Index, Type *SubTp) const {
169 return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp);
170}
171
172unsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
173 Type *Src) const {
174 return PrevTTI->getCastInstrCost(Opcode, Dst, Src);
175}
176
177unsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
178 return PrevTTI->getCFInstrCost(Opcode);
179}
180
181unsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
182 Type *CondTy) const {
183 return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy);
184}
185
186unsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
187 unsigned Index) const {
188 return PrevTTI->getVectorInstrCost(Opcode, Val, Index);
189}
190
191unsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
192 unsigned Alignment,
193 unsigned AddressSpace) const {
194 return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
195 ;
196}
197
198unsigned
199TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID,
200 Type *RetTy,
201 ArrayRef<Type *> Tys) const {
202 return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys);
203}
204
205unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
206 return PrevTTI->getNumberOfParts(Tp);
207}
208
Arnold Schwaighofer594fa2d2013-02-08 14:50:48 +0000209unsigned TargetTransformInfo::getAddressComputationCost(Type *Tp) const {
210 return PrevTTI->getAddressComputationCost(Tp);
211}
Chandler Carruth539edf42013-01-05 11:43:11 +0000212
213namespace {
214
Chandler Carruth664e3542013-01-07 01:37:14 +0000215struct NoTTI : ImmutablePass, TargetTransformInfo {
Chandler Carruth511aa762013-01-21 01:27:39 +0000216 const DataLayout *DL;
217
218 NoTTI() : ImmutablePass(ID), DL(0) {
Chandler Carruth539edf42013-01-05 11:43:11 +0000219 initializeNoTTIPass(*PassRegistry::getPassRegistry());
220 }
221
Chandler Carruth664e3542013-01-07 01:37:14 +0000222 virtual void initializePass() {
223 // Note that this subclass is special, and must *not* call initializeTTI as
224 // it does not chain.
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000225 TopTTI = this;
Chandler Carruth664e3542013-01-07 01:37:14 +0000226 PrevTTI = 0;
Chandler Carruth511aa762013-01-21 01:27:39 +0000227 DL = getAnalysisIfAvailable<DataLayout>();
Chandler Carruth664e3542013-01-07 01:37:14 +0000228 }
229
230 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
Chandler Carruth539edf42013-01-05 11:43:11 +0000231 // Note that this subclass is special, and must *not* call
232 // TTI::getAnalysisUsage as it breaks the recursion.
233 }
234
235 /// Pass identification.
236 static char ID;
237
238 /// Provide necessary pointer adjustments for the two base classes.
239 virtual void *getAdjustedAnalysisPointer(const void *ID) {
240 if (ID == &TargetTransformInfo::ID)
241 return (TargetTransformInfo*)this;
242 return this;
243 }
244
Chandler Carruth511aa762013-01-21 01:27:39 +0000245 unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) const {
246 switch (Opcode) {
247 default:
248 // By default, just classify everything as 'basic'.
249 return TCC_Basic;
250
251 case Instruction::GetElementPtr:
252 llvm_unreachable("Use getGEPCost for GEP operations!");
253
254 case Instruction::BitCast:
255 assert(OpTy && "Cast instructions must provide the operand type");
256 if (Ty == OpTy || (Ty->isPointerTy() && OpTy->isPointerTy()))
257 // Identity and pointer-to-pointer casts are free.
258 return TCC_Free;
259
260 // Otherwise, the default basic cost is used.
261 return TCC_Basic;
262
263 case Instruction::IntToPtr:
264 // An inttoptr cast is free so long as the input is a legal integer type
265 // which doesn't contain values outside the range of a pointer.
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::PtrToInt:
274 // A ptrtoint cast is free so long as the result is large enough to store
275 // the pointer, and a legal integer type.
Patrik Hagglund3eaa4b92013-03-12 13:18:30 +0000276 if (DL && DL->isLegalInteger(Ty->getScalarSizeInBits()) &&
277 Ty->getScalarSizeInBits() >= DL->getPointerSizeInBits())
Chandler Carruth511aa762013-01-21 01:27:39 +0000278 return TCC_Free;
279
280 // Otherwise it's not a no-op.
281 return TCC_Basic;
282
283 case Instruction::Trunc:
284 // trunc to a native type is free (assuming the target has compare and
285 // shift-right of the same width).
286 if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty)))
287 return TCC_Free;
288
289 return TCC_Basic;
290 }
291 }
292
293 unsigned getGEPCost(const Value *Ptr,
294 ArrayRef<const Value *> Operands) const {
295 // In the basic model, we just assume that all-constant GEPs will be folded
296 // into their uses via addressing modes.
297 for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx)
298 if (!isa<Constant>(Operands[Idx]))
299 return TCC_Basic;
300
301 return TCC_Free;
302 }
303
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000304 unsigned getCallCost(FunctionType *FTy, int NumArgs = -1) const {
305 assert(FTy && "FunctionType must be provided to this routine.");
306
307 // The target-independent implementation just measures the size of the
308 // function by approximating that each argument will take on average one
309 // instruction to prepare.
310
311 if (NumArgs < 0)
312 // Set the argument number to the number of explicit arguments in the
313 // function.
314 NumArgs = FTy->getNumParams();
315
316 return TCC_Basic * (NumArgs + 1);
317 }
318
319 unsigned getCallCost(const Function *F, int NumArgs = -1) const {
320 assert(F && "A concrete function must be provided to this routine.");
321
322 if (NumArgs < 0)
323 // Set the argument number to the number of explicit arguments in the
324 // function.
325 NumArgs = F->arg_size();
326
327 if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) {
328 FunctionType *FTy = F->getFunctionType();
329 SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end());
330 return TopTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys);
331 }
332
333 if (!TopTTI->isLoweredToCall(F))
334 return TCC_Basic; // Give a basic cost if it will be lowered directly.
335
336 return TopTTI->getCallCost(F->getFunctionType(), NumArgs);
337 }
338
339 unsigned getCallCost(const Function *F,
340 ArrayRef<const Value *> Arguments) const {
341 // Simply delegate to generic handling of the call.
342 // FIXME: We should use instsimplify or something else to catch calls which
343 // will constant fold with these arguments.
344 return TopTTI->getCallCost(F, Arguments.size());
345 }
346
347 unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
348 ArrayRef<Type *> ParamTys) const {
349 switch (IID) {
350 default:
351 // Intrinsics rarely (if ever) have normal argument setup constraints.
352 // Model them as having a basic instruction cost.
353 // FIXME: This is wrong for libc intrinsics.
354 return TCC_Basic;
355
356 case Intrinsic::dbg_declare:
357 case Intrinsic::dbg_value:
358 case Intrinsic::invariant_start:
359 case Intrinsic::invariant_end:
360 case Intrinsic::lifetime_start:
361 case Intrinsic::lifetime_end:
362 case Intrinsic::objectsize:
363 case Intrinsic::ptr_annotation:
364 case Intrinsic::var_annotation:
365 // These intrinsics don't actually represent code after lowering.
366 return TCC_Free;
367 }
368 }
369
370 unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
371 ArrayRef<const Value *> Arguments) const {
372 // Delegate to the generic intrinsic handling code. This mostly provides an
373 // opportunity for targets to (for example) special case the cost of
374 // certain intrinsics based on constants used as arguments.
375 SmallVector<Type *, 8> ParamTys;
376 ParamTys.reserve(Arguments.size());
377 for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; ++Idx)
378 ParamTys.push_back(Arguments[Idx]->getType());
379 return TopTTI->getIntrinsicCost(IID, RetTy, ParamTys);
380 }
381
Chandler Carruth511aa762013-01-21 01:27:39 +0000382 unsigned getUserCost(const User *U) const {
Chandler Carruthbb9caa92013-01-21 13:04:33 +0000383 if (isa<PHINode>(U))
384 return TCC_Free; // Model all PHI nodes as free.
385
Chandler Carruth511aa762013-01-21 01:27:39 +0000386 if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U))
387 // In the basic model we just assume that all-constant GEPs will be
388 // folded into their uses via addressing modes.
389 return GEP->hasAllConstantIndices() ? TCC_Free : TCC_Basic;
390
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000391 if (ImmutableCallSite CS = U) {
392 const Function *F = CS.getCalledFunction();
393 if (!F) {
394 // Just use the called value type.
395 Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
396 return TopTTI->getCallCost(cast<FunctionType>(FTy), CS.arg_size());
Chandler Carruth511aa762013-01-21 01:27:39 +0000397 }
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000398
399 SmallVector<const Value *, 8> Arguments;
400 for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(),
401 AE = CS.arg_end();
402 AI != AE; ++AI)
403 Arguments.push_back(*AI);
404
405 return TopTTI->getCallCost(F, Arguments);
Chandler Carruth511aa762013-01-21 01:27:39 +0000406 }
407
408 if (const CastInst *CI = dyn_cast<CastInst>(U)) {
409 // Result of a cmp instruction is often extended (to be used by other
410 // cmp instructions, logical or return instructions). These are usually
411 // nop on most sane targets.
412 if (isa<CmpInst>(CI->getOperand(0)))
413 return TCC_Free;
414 }
415
416 // Otherwise delegate to the fully generic implementations.
417 return getOperationCost(Operator::getOpcode(U), U->getType(),
418 U->getNumOperands() == 1 ?
419 U->getOperand(0)->getType() : 0);
420 }
Chandler Carruth539edf42013-01-05 11:43:11 +0000421
Chandler Carruth0ba8db42013-01-22 11:26:02 +0000422 bool isLoweredToCall(const Function *F) const {
423 // FIXME: These should almost certainly not be handled here, and instead
424 // handled with the help of TLI or the target itself. This was largely
425 // ported from existing analysis heuristics here so that such refactorings
426 // can take place in the future.
427
428 if (F->isIntrinsic())
429 return false;
430
431 if (F->hasLocalLinkage() || !F->hasName())
432 return true;
433
434 StringRef Name = F->getName();
435
436 // These will all likely lower to a single selection DAG node.
437 if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
438 Name == "fabs" || Name == "fabsf" || Name == "fabsl" || Name == "sin" ||
439 Name == "sinf" || Name == "sinl" || Name == "cos" || Name == "cosf" ||
440 Name == "cosl" || Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl")
441 return false;
442
443 // These are all likely to be optimized into something smaller.
444 if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
445 Name == "exp2l" || Name == "exp2f" || Name == "floor" || Name ==
446 "floorf" || Name == "ceil" || Name == "round" || Name == "ffs" ||
447 Name == "ffsl" || Name == "abs" || Name == "labs" || Name == "llabs")
448 return false;
449
450 return true;
451 }
452
Chandler Carruth539edf42013-01-05 11:43:11 +0000453 bool isLegalAddImmediate(int64_t Imm) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000454 return false;
Chandler Carruth539edf42013-01-05 11:43:11 +0000455 }
456
457 bool isLegalICmpImmediate(int64_t Imm) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000458 return false;
Chandler Carruth539edf42013-01-05 11:43:11 +0000459 }
460
461 bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
462 bool HasBaseReg, int64_t Scale) const {
Chandler Carruth26c59fa2013-01-07 14:41:08 +0000463 // Guess that reg+reg addressing is allowed. This heuristic is taken from
464 // the implementation of LSR.
465 return !BaseGV && BaseOffset == 0 && Scale <= 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000466 }
467
Quentin Colombetbf490d42013-05-31 21:29:03 +0000468 int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
469 bool HasBaseReg, int64_t Scale) const {
470 // Guess that all legal addressing mode are free.
471 if(isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg, Scale))
472 return 0;
473 return -1;
474 }
475
476
Chandler Carruth539edf42013-01-05 11:43:11 +0000477 bool isTruncateFree(Type *Ty1, Type *Ty2) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000478 return false;
Chandler Carruth539edf42013-01-05 11:43:11 +0000479 }
480
481 bool isTypeLegal(Type *Ty) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000482 return false;
Chandler Carruth539edf42013-01-05 11:43:11 +0000483 }
484
485 unsigned getJumpBufAlignment() const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000486 return 0;
Chandler Carruth539edf42013-01-05 11:43:11 +0000487 }
488
489 unsigned getJumpBufSize() const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000490 return 0;
Chandler Carruth539edf42013-01-05 11:43:11 +0000491 }
492
493 bool shouldBuildLookupTables() const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000494 return true;
Chandler Carruth539edf42013-01-05 11:43:11 +0000495 }
496
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000497 PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const {
498 return PSK_Software;
Chandler Carruth539edf42013-01-05 11:43:11 +0000499 }
500
501 unsigned getIntImmCost(const APInt &Imm, Type *Ty) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000502 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000503 }
504
505 unsigned getNumberOfRegisters(bool Vector) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000506 return 8;
Chandler Carruth539edf42013-01-05 11:43:11 +0000507 }
508
Nadav Rotemb1791a72013-01-09 22:29:00 +0000509 unsigned getRegisterBitWidth(bool Vector) const {
510 return 32;
511 }
512
Nadav Rotemb696c362013-01-09 01:15:42 +0000513 unsigned getMaximumUnrollFactor() const {
514 return 1;
515 }
516
Arnold Schwaighoferb9773872013-04-04 23:26:21 +0000517 unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind,
518 OperandValueKind) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000519 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000520 }
521
522 unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
523 int Index = 0, Type *SubTp = 0) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000524 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000525 }
526
527 unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
528 Type *Src) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000529 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000530 }
531
532 unsigned getCFInstrCost(unsigned Opcode) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000533 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000534 }
535
536 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
537 Type *CondTy = 0) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000538 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000539 }
540
541 unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
542 unsigned Index = -1) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000543 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000544 }
545
546 unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
547 unsigned Alignment,
548 unsigned AddressSpace) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000549 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000550 }
551
552 unsigned getIntrinsicInstrCost(Intrinsic::ID ID,
553 Type *RetTy,
554 ArrayRef<Type*> Tys) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000555 return 1;
Chandler Carruth539edf42013-01-05 11:43:11 +0000556 }
557
558 unsigned getNumberOfParts(Type *Tp) const {
Chandler Carruth664e3542013-01-07 01:37:14 +0000559 return 0;
Chandler Carruth539edf42013-01-05 11:43:11 +0000560 }
Arnold Schwaighofer594fa2d2013-02-08 14:50:48 +0000561
562 unsigned getAddressComputationCost(Type *Tp) const {
563 return 0;
564 }
Chandler Carruth539edf42013-01-05 11:43:11 +0000565};
566
567} // end anonymous namespace
568
Chandler Carruth664e3542013-01-07 01:37:14 +0000569INITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti",
Chandler Carruth539edf42013-01-05 11:43:11 +0000570 "No target information", true, true, true)
571char NoTTI::ID = 0;
572
Chandler Carruth664e3542013-01-07 01:37:14 +0000573ImmutablePass *llvm::createNoTargetTransformInfoPass() {
574 return new NoTTI();
Chandler Carruth539edf42013-01-05 11:43:11 +0000575}