blob: 75e940c74dd874e35a742d1c006d46a0072fab0d [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 Carruthd3e73552013-01-07 03:08:10 +000010#include "llvm/Analysis/TargetTransformInfo.h"
Chandler Carruth705b1852015-01-31 03:43:40 +000011#include "llvm/Analysis/TargetTransformInfoImpl.h"
Chandler Carruth219b89b2014-03-04 11:01:28 +000012#include "llvm/IR/CallSite.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000013#include "llvm/IR/DataLayout.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000014#include "llvm/IR/Instruction.h"
Chandler Carruth511aa762013-01-21 01:27:39 +000015#include "llvm/IR/Instructions.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000016#include "llvm/IR/IntrinsicInst.h"
Chandler Carruthe0385522015-02-01 10:11:22 +000017#include "llvm/IR/Module.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000018#include "llvm/IR/Operator.h"
Nadav Rotem5dc203e2012-10-18 23:22:48 +000019#include "llvm/Support/ErrorHandling.h"
20
21using namespace llvm;
22
Chandler Carruthf1221bd2014-04-22 02:48:03 +000023#define DEBUG_TYPE "tti"
24
Chandler Carruth93dcdc42015-01-31 11:17:59 +000025namespace {
26/// \brief No-op implementation of the TTI interface using the utility base
27/// classes.
28///
29/// This is used when no target specific information is available.
30struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
Mehdi Amini5010ebf2015-07-09 02:08:42 +000031 explicit NoTTIImpl(const DataLayout &DL)
Chandler Carruth93dcdc42015-01-31 11:17:59 +000032 : TargetTransformInfoImplCRTPBase<NoTTIImpl>(DL) {}
33};
34}
35
Mehdi Amini5010ebf2015-07-09 02:08:42 +000036TargetTransformInfo::TargetTransformInfo(const DataLayout &DL)
Chandler Carruth93dcdc42015-01-31 11:17:59 +000037 : TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
38
Chandler Carruth705b1852015-01-31 03:43:40 +000039TargetTransformInfo::~TargetTransformInfo() {}
Nadav Rotem5dc203e2012-10-18 23:22:48 +000040
Chandler Carruth705b1852015-01-31 03:43:40 +000041TargetTransformInfo::TargetTransformInfo(TargetTransformInfo &&Arg)
42 : TTIImpl(std::move(Arg.TTIImpl)) {}
Chandler Carruth539edf42013-01-05 11:43:11 +000043
Chandler Carruth705b1852015-01-31 03:43:40 +000044TargetTransformInfo &TargetTransformInfo::operator=(TargetTransformInfo &&RHS) {
45 TTIImpl = std::move(RHS.TTIImpl);
46 return *this;
Chandler Carruth539edf42013-01-05 11:43:11 +000047}
48
Chandler Carruth93205eb2015-08-05 18:08:10 +000049int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
50 Type *OpTy) const {
51 int Cost = TTIImpl->getOperationCost(Opcode, Ty, OpTy);
52 assert(Cost >= 0 && "TTI should not produce negative costs!");
53 return Cost;
Chandler Carruth511aa762013-01-21 01:27:39 +000054}
55
Chandler Carruth93205eb2015-08-05 18:08:10 +000056int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs) const {
57 int Cost = TTIImpl->getCallCost(FTy, NumArgs);
58 assert(Cost >= 0 && "TTI should not produce negative costs!");
59 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000060}
61
Chandler Carruth93205eb2015-08-05 18:08:10 +000062int TargetTransformInfo::getCallCost(const Function *F,
63 ArrayRef<const Value *> Arguments) const {
64 int Cost = TTIImpl->getCallCost(F, Arguments);
65 assert(Cost >= 0 && "TTI should not produce negative costs!");
66 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000067}
68
Chandler Carruth93205eb2015-08-05 18:08:10 +000069int TargetTransformInfo::getIntrinsicCost(
70 Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
71 int Cost = TTIImpl->getIntrinsicCost(IID, RetTy, Arguments);
72 assert(Cost >= 0 && "TTI should not produce negative costs!");
73 return Cost;
Chandler Carruth0ba8db42013-01-22 11:26:02 +000074}
75
Chandler Carruth93205eb2015-08-05 18:08:10 +000076int TargetTransformInfo::getUserCost(const User *U) const {
77 int Cost = TTIImpl->getUserCost(U);
78 assert(Cost >= 0 && "TTI should not produce negative costs!");
79 return Cost;
Chandler Carruth511aa762013-01-21 01:27:39 +000080}
81
Tom Stellard8b1e0212013-07-27 00:01:07 +000082bool TargetTransformInfo::hasBranchDivergence() const {
Chandler Carruth705b1852015-01-31 03:43:40 +000083 return TTIImpl->hasBranchDivergence();
Tom Stellard8b1e0212013-07-27 00:01:07 +000084}
85
Jingyue Wu5da831c2015-04-10 05:03:50 +000086bool TargetTransformInfo::isSourceOfDivergence(const Value *V) const {
87 return TTIImpl->isSourceOfDivergence(V);
88}
89
Chandler Carruth0ba8db42013-01-22 11:26:02 +000090bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
Chandler Carruth705b1852015-01-31 03:43:40 +000091 return TTIImpl->isLoweredToCall(F);
Chandler Carruth0ba8db42013-01-22 11:26:02 +000092}
93
Chandler Carruth705b1852015-01-31 03:43:40 +000094void TargetTransformInfo::getUnrollingPreferences(
Chandler Carruthab5cb362015-02-01 14:31:23 +000095 Loop *L, UnrollingPreferences &UP) const {
96 return TTIImpl->getUnrollingPreferences(L, UP);
Hal Finkel8f2e7002013-09-11 19:25:43 +000097}
98
Chandler Carruth539edf42013-01-05 11:43:11 +000099bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000100 return TTIImpl->isLegalAddImmediate(Imm);
Chandler Carruth539edf42013-01-05 11:43:11 +0000101}
102
103bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000104 return TTIImpl->isLegalICmpImmediate(Imm);
Chandler Carruth539edf42013-01-05 11:43:11 +0000105}
106
107bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
108 int64_t BaseOffset,
109 bool HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000110 int64_t Scale,
111 unsigned AddrSpace) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000112 return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000113 Scale, AddrSpace);
Chandler Carruth539edf42013-01-05 11:43:11 +0000114}
115
Chandler Carruth705b1852015-01-31 03:43:40 +0000116bool TargetTransformInfo::isLegalMaskedStore(Type *DataType,
117 int Consecutive) const {
118 return TTIImpl->isLegalMaskedStore(DataType, Consecutive);
119}
120
121bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType,
122 int Consecutive) const {
123 return TTIImpl->isLegalMaskedLoad(DataType, Consecutive);
124}
125
Quentin Colombetbf490d42013-05-31 21:29:03 +0000126int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
127 int64_t BaseOffset,
128 bool HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000129 int64_t Scale,
130 unsigned AddrSpace) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000131 int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
132 Scale, AddrSpace);
133 assert(Cost >= 0 && "TTI should not produce negative costs!");
134 return Cost;
Quentin Colombetbf490d42013-05-31 21:29:03 +0000135}
136
Chandler Carruth539edf42013-01-05 11:43:11 +0000137bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000138 return TTIImpl->isTruncateFree(Ty1, Ty2);
Chandler Carruth539edf42013-01-05 11:43:11 +0000139}
140
Sanjoy Dasc3182d82015-07-27 23:27:43 +0000141bool TargetTransformInfo::isZExtFree(Type *Ty1, Type *Ty2) const {
142 return TTIImpl->isZExtFree(Ty1, Ty2);
143}
144
Chad Rosier54390052015-02-23 19:15:16 +0000145bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
146 return TTIImpl->isProfitableToHoist(I);
147}
148
Chandler Carruth539edf42013-01-05 11:43:11 +0000149bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000150 return TTIImpl->isTypeLegal(Ty);
Chandler Carruth539edf42013-01-05 11:43:11 +0000151}
152
153unsigned TargetTransformInfo::getJumpBufAlignment() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000154 return TTIImpl->getJumpBufAlignment();
Chandler Carruth539edf42013-01-05 11:43:11 +0000155}
156
157unsigned TargetTransformInfo::getJumpBufSize() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000158 return TTIImpl->getJumpBufSize();
Chandler Carruth539edf42013-01-05 11:43:11 +0000159}
160
161bool TargetTransformInfo::shouldBuildLookupTables() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000162 return TTIImpl->shouldBuildLookupTables();
Chandler Carruth539edf42013-01-05 11:43:11 +0000163}
164
Olivier Sallenave049d8032015-03-06 23:12:04 +0000165bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
166 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
167}
168
Silviu Baranga61bdc512015-08-10 14:50:54 +0000169bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
170 return TTIImpl->enableInterleavedAccessVectorization();
171}
172
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000173TargetTransformInfo::PopcntSupportKind
174TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000175 return TTIImpl->getPopcntSupport(IntTyWidthInBit);
Chandler Carruth539edf42013-01-05 11:43:11 +0000176}
177
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000178bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000179 return TTIImpl->haveFastSqrt(Ty);
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000180}
181
Chandler Carruth93205eb2015-08-05 18:08:10 +0000182int TargetTransformInfo::getFPOpCost(Type *Ty) const {
183 int Cost = TTIImpl->getFPOpCost(Ty);
184 assert(Cost >= 0 && "TTI should not produce negative costs!");
185 return Cost;
Cameron Esfahani17177d12015-02-05 02:09:33 +0000186}
187
Chandler Carruth93205eb2015-08-05 18:08:10 +0000188int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
189 int Cost = TTIImpl->getIntImmCost(Imm, Ty);
190 assert(Cost >= 0 && "TTI should not produce negative costs!");
191 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000192}
193
Chandler Carruth93205eb2015-08-05 18:08:10 +0000194int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
195 const APInt &Imm, Type *Ty) const {
196 int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
197 assert(Cost >= 0 && "TTI should not produce negative costs!");
198 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000199}
200
Chandler Carruth93205eb2015-08-05 18:08:10 +0000201int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
202 const APInt &Imm, Type *Ty) const {
203 int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
204 assert(Cost >= 0 && "TTI should not produce negative costs!");
205 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000206}
207
Chandler Carruth539edf42013-01-05 11:43:11 +0000208unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000209 return TTIImpl->getNumberOfRegisters(Vector);
Chandler Carruth539edf42013-01-05 11:43:11 +0000210}
211
Nadav Rotemb1791a72013-01-09 22:29:00 +0000212unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000213 return TTIImpl->getRegisterBitWidth(Vector);
Nadav Rotemb1791a72013-01-09 22:29:00 +0000214}
215
Wei Mi062c7442015-05-06 17:12:25 +0000216unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
217 return TTIImpl->getMaxInterleaveFactor(VF);
Nadav Rotemb696c362013-01-09 01:15:42 +0000218}
219
Chandler Carruth93205eb2015-08-05 18:08:10 +0000220int TargetTransformInfo::getArithmeticInstrCost(
Chandler Carruth705b1852015-01-31 03:43:40 +0000221 unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
222 OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
Karthik Bhat7f33ff72014-08-25 04:56:54 +0000223 OperandValueProperties Opd2PropInfo) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000224 int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
225 Opd1PropInfo, Opd2PropInfo);
226 assert(Cost >= 0 && "TTI should not produce negative costs!");
227 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000228}
229
Chandler Carruth93205eb2015-08-05 18:08:10 +0000230int TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
231 Type *SubTp) const {
232 int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
233 assert(Cost >= 0 && "TTI should not produce negative costs!");
234 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000235}
236
Chandler Carruth93205eb2015-08-05 18:08:10 +0000237int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
238 Type *Src) const {
239 int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src);
240 assert(Cost >= 0 && "TTI should not produce negative costs!");
241 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000242}
243
Chandler Carruth93205eb2015-08-05 18:08:10 +0000244int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
245 int Cost = TTIImpl->getCFInstrCost(Opcode);
246 assert(Cost >= 0 && "TTI should not produce negative costs!");
247 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000248}
249
Chandler Carruth93205eb2015-08-05 18:08:10 +0000250int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
251 Type *CondTy) const {
252 int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy);
253 assert(Cost >= 0 && "TTI should not produce negative costs!");
254 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000255}
256
Chandler Carruth93205eb2015-08-05 18:08:10 +0000257int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
258 unsigned Index) const {
259 int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
260 assert(Cost >= 0 && "TTI should not produce negative costs!");
261 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000262}
263
Chandler Carruth93205eb2015-08-05 18:08:10 +0000264int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
265 unsigned Alignment,
266 unsigned AddressSpace) const {
267 int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
268 assert(Cost >= 0 && "TTI should not produce negative costs!");
269 return Cost;
Elena Demikhovskya3232f72015-01-25 08:44:46 +0000270}
271
Chandler Carruth93205eb2015-08-05 18:08:10 +0000272int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
273 unsigned Alignment,
274 unsigned AddressSpace) const {
275 int Cost =
276 TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
277 assert(Cost >= 0 && "TTI should not produce negative costs!");
278 return Cost;
Chandler Carruth705b1852015-01-31 03:43:40 +0000279}
280
Chandler Carruth93205eb2015-08-05 18:08:10 +0000281int TargetTransformInfo::getInterleavedMemoryOpCost(
Hao Liu32c05392015-06-08 06:39:56 +0000282 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
283 unsigned Alignment, unsigned AddressSpace) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000284 int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
285 Alignment, AddressSpace);
286 assert(Cost >= 0 && "TTI should not produce negative costs!");
287 return Cost;
Hao Liu32c05392015-06-08 06:39:56 +0000288}
289
Chandler Carruth93205eb2015-08-05 18:08:10 +0000290int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
Michael Zolotukhin7ed84a82015-03-17 19:26:23 +0000291 ArrayRef<Type *> Tys) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000292 int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys);
293 assert(Cost >= 0 && "TTI should not produce negative costs!");
294 return Cost;
295}
296
297int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
298 ArrayRef<Type *> Tys) const {
299 int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
300 assert(Cost >= 0 && "TTI should not produce negative costs!");
301 return Cost;
Michael Zolotukhin7ed84a82015-03-17 19:26:23 +0000302}
303
Chandler Carruth539edf42013-01-05 11:43:11 +0000304unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000305 return TTIImpl->getNumberOfParts(Tp);
Chandler Carruth539edf42013-01-05 11:43:11 +0000306}
307
Chandler Carruth93205eb2015-08-05 18:08:10 +0000308int TargetTransformInfo::getAddressComputationCost(Type *Tp,
309 bool IsComplex) const {
310 int Cost = TTIImpl->getAddressComputationCost(Tp, IsComplex);
311 assert(Cost >= 0 && "TTI should not produce negative costs!");
312 return Cost;
Arnold Schwaighofer594fa2d2013-02-08 14:50:48 +0000313}
Chandler Carruth539edf42013-01-05 11:43:11 +0000314
Chandler Carruth93205eb2015-08-05 18:08:10 +0000315int TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
316 bool IsPairwiseForm) const {
317 int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
318 assert(Cost >= 0 && "TTI should not produce negative costs!");
319 return Cost;
Arnold Schwaighofercae87352013-09-17 18:06:50 +0000320}
321
Chandler Carruth705b1852015-01-31 03:43:40 +0000322unsigned
323TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
324 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
Chad Rosierf9327d62015-01-26 22:51:15 +0000325}
326
327bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
328 MemIntrinsicInfo &Info) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000329 return TTIImpl->getTgtMemIntrinsic(Inst, Info);
Chad Rosierf9327d62015-01-26 22:51:15 +0000330}
331
Chandler Carruth705b1852015-01-31 03:43:40 +0000332Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
333 IntrinsicInst *Inst, Type *ExpectedType) const {
334 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
335}
336
Eric Christopherd566fb12015-07-29 22:09:48 +0000337bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
338 const Function *Callee) const {
339 return TTIImpl->areInlineCompatible(Caller, Callee);
Eric Christopher4371b132015-07-02 01:11:47 +0000340}
341
Chandler Carruth705b1852015-01-31 03:43:40 +0000342TargetTransformInfo::Concept::~Concept() {}
343
Chandler Carruthe0385522015-02-01 10:11:22 +0000344TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
345
346TargetIRAnalysis::TargetIRAnalysis(
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000347 std::function<Result(const Function &)> TTICallback)
Chandler Carruthe0385522015-02-01 10:11:22 +0000348 : TTICallback(TTICallback) {}
349
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000350TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
Chandler Carruthe0385522015-02-01 10:11:22 +0000351 return TTICallback(F);
352}
353
354char TargetIRAnalysis::PassID;
355
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000356TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
Mehdi Amini5010ebf2015-07-09 02:08:42 +0000357 return Result(F.getParent()->getDataLayout());
Chandler Carruthe0385522015-02-01 10:11:22 +0000358}
359
Chandler Carruth705b1852015-01-31 03:43:40 +0000360// Register the basic pass.
361INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
362 "Target Transform Information", false, true)
363char TargetTransformInfoWrapperPass::ID = 0;
Chandler Carruth539edf42013-01-05 11:43:11 +0000364
Chandler Carruth705b1852015-01-31 03:43:40 +0000365void TargetTransformInfoWrapperPass::anchor() {}
Chandler Carruth539edf42013-01-05 11:43:11 +0000366
Chandler Carruth705b1852015-01-31 03:43:40 +0000367TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000368 : ImmutablePass(ID) {
Chandler Carruth705b1852015-01-31 03:43:40 +0000369 initializeTargetTransformInfoWrapperPassPass(
370 *PassRegistry::getPassRegistry());
371}
372
373TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000374 TargetIRAnalysis TIRA)
375 : ImmutablePass(ID), TIRA(std::move(TIRA)) {
Chandler Carruth705b1852015-01-31 03:43:40 +0000376 initializeTargetTransformInfoWrapperPassPass(
377 *PassRegistry::getPassRegistry());
378}
379
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000380TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000381 TTI = TIRA.run(F);
382 return *TTI;
383}
384
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000385ImmutablePass *
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000386llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
387 return new TargetTransformInfoWrapperPass(std::move(TIRA));
Chandler Carruth539edf42013-01-05 11:43:11 +0000388}