blob: 8fd9fbf8196777b893a2ffb667f6eb8883a1e878 [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
Elena Demikhovsky20662e32015-10-19 07:43:38 +0000116bool TargetTransformInfo::isLegalMaskedStore(Type *DataType) const {
117 return TTIImpl->isLegalMaskedStore(DataType);
Chandler Carruth705b1852015-01-31 03:43:40 +0000118}
119
Elena Demikhovsky20662e32015-10-19 07:43:38 +0000120bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType) const {
121 return TTIImpl->isLegalMaskedLoad(DataType);
Chandler Carruth705b1852015-01-31 03:43:40 +0000122}
123
Elena Demikhovsky09285852015-10-25 15:37:55 +0000124bool TargetTransformInfo::isLegalMaskedGather(Type *DataType) const {
125 return TTIImpl->isLegalMaskedGather(DataType);
126}
127
128bool TargetTransformInfo::isLegalMaskedScatter(Type *DataType) const {
129 return TTIImpl->isLegalMaskedGather(DataType);
130}
131
Quentin Colombetbf490d42013-05-31 21:29:03 +0000132int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
133 int64_t BaseOffset,
134 bool HasBaseReg,
Matt Arsenaulte83379e2015-06-07 20:12:03 +0000135 int64_t Scale,
136 unsigned AddrSpace) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000137 int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
138 Scale, AddrSpace);
139 assert(Cost >= 0 && "TTI should not produce negative costs!");
140 return Cost;
Quentin Colombetbf490d42013-05-31 21:29:03 +0000141}
142
Chandler Carruth539edf42013-01-05 11:43:11 +0000143bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000144 return TTIImpl->isTruncateFree(Ty1, Ty2);
Chandler Carruth539edf42013-01-05 11:43:11 +0000145}
146
Chad Rosier54390052015-02-23 19:15:16 +0000147bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
148 return TTIImpl->isProfitableToHoist(I);
149}
150
Chandler Carruth539edf42013-01-05 11:43:11 +0000151bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000152 return TTIImpl->isTypeLegal(Ty);
Chandler Carruth539edf42013-01-05 11:43:11 +0000153}
154
155unsigned TargetTransformInfo::getJumpBufAlignment() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000156 return TTIImpl->getJumpBufAlignment();
Chandler Carruth539edf42013-01-05 11:43:11 +0000157}
158
159unsigned TargetTransformInfo::getJumpBufSize() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000160 return TTIImpl->getJumpBufSize();
Chandler Carruth539edf42013-01-05 11:43:11 +0000161}
162
163bool TargetTransformInfo::shouldBuildLookupTables() const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000164 return TTIImpl->shouldBuildLookupTables();
Chandler Carruth539edf42013-01-05 11:43:11 +0000165}
166
Olivier Sallenave049d8032015-03-06 23:12:04 +0000167bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
168 return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
169}
170
Silviu Baranga61bdc512015-08-10 14:50:54 +0000171bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
172 return TTIImpl->enableInterleavedAccessVectorization();
173}
174
Chandler Carruth50a36cd2013-01-07 03:16:03 +0000175TargetTransformInfo::PopcntSupportKind
176TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000177 return TTIImpl->getPopcntSupport(IntTyWidthInBit);
Chandler Carruth539edf42013-01-05 11:43:11 +0000178}
179
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000180bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000181 return TTIImpl->haveFastSqrt(Ty);
Richard Sandiford37cd6cf2013-08-23 10:27:02 +0000182}
183
Chandler Carruth93205eb2015-08-05 18:08:10 +0000184int TargetTransformInfo::getFPOpCost(Type *Ty) const {
185 int Cost = TTIImpl->getFPOpCost(Ty);
186 assert(Cost >= 0 && "TTI should not produce negative costs!");
187 return Cost;
Cameron Esfahani17177d12015-02-05 02:09:33 +0000188}
189
Chandler Carruth93205eb2015-08-05 18:08:10 +0000190int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
191 int Cost = TTIImpl->getIntImmCost(Imm, Ty);
192 assert(Cost >= 0 && "TTI should not produce negative costs!");
193 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000194}
195
Chandler Carruth93205eb2015-08-05 18:08:10 +0000196int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
197 const APInt &Imm, Type *Ty) const {
198 int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
199 assert(Cost >= 0 && "TTI should not produce negative costs!");
200 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000201}
202
Chandler Carruth93205eb2015-08-05 18:08:10 +0000203int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
204 const APInt &Imm, Type *Ty) const {
205 int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
206 assert(Cost >= 0 && "TTI should not produce negative costs!");
207 return Cost;
Juergen Ributzkaf26beda2014-01-25 02:02:55 +0000208}
209
Chandler Carruth539edf42013-01-05 11:43:11 +0000210unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000211 return TTIImpl->getNumberOfRegisters(Vector);
Chandler Carruth539edf42013-01-05 11:43:11 +0000212}
213
Nadav Rotemb1791a72013-01-09 22:29:00 +0000214unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000215 return TTIImpl->getRegisterBitWidth(Vector);
Nadav Rotemb1791a72013-01-09 22:29:00 +0000216}
217
Adam Nemetaf761102016-01-21 18:28:36 +0000218unsigned TargetTransformInfo::getCacheLineSize() const {
219 return TTIImpl->getCacheLineSize();
220}
221
Adam Nemetdadfbb52016-01-27 22:21:25 +0000222unsigned TargetTransformInfo::getPrefetchDistance() const {
223 return TTIImpl->getPrefetchDistance();
224}
225
Adam Nemet6d8beec2016-03-18 00:27:38 +0000226unsigned TargetTransformInfo::getMinPrefetchStride() const {
227 return TTIImpl->getMinPrefetchStride();
228}
229
Wei Mi062c7442015-05-06 17:12:25 +0000230unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
231 return TTIImpl->getMaxInterleaveFactor(VF);
Nadav Rotemb696c362013-01-09 01:15:42 +0000232}
233
Chandler Carruth93205eb2015-08-05 18:08:10 +0000234int TargetTransformInfo::getArithmeticInstrCost(
Chandler Carruth705b1852015-01-31 03:43:40 +0000235 unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
236 OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
Karthik Bhat7f33ff72014-08-25 04:56:54 +0000237 OperandValueProperties Opd2PropInfo) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000238 int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
239 Opd1PropInfo, Opd2PropInfo);
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::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
245 Type *SubTp) const {
246 int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
247 assert(Cost >= 0 && "TTI should not produce negative costs!");
248 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000249}
250
Chandler Carruth93205eb2015-08-05 18:08:10 +0000251int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
252 Type *Src) const {
253 int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src);
254 assert(Cost >= 0 && "TTI should not produce negative costs!");
255 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000256}
257
Chandler Carruth93205eb2015-08-05 18:08:10 +0000258int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
259 int Cost = TTIImpl->getCFInstrCost(Opcode);
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::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
265 Type *CondTy) const {
266 int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy);
267 assert(Cost >= 0 && "TTI should not produce negative costs!");
268 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000269}
270
Chandler Carruth93205eb2015-08-05 18:08:10 +0000271int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
272 unsigned Index) const {
273 int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
274 assert(Cost >= 0 && "TTI should not produce negative costs!");
275 return Cost;
Chandler Carruth539edf42013-01-05 11:43:11 +0000276}
277
Chandler Carruth93205eb2015-08-05 18:08:10 +0000278int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
279 unsigned Alignment,
280 unsigned AddressSpace) const {
281 int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
282 assert(Cost >= 0 && "TTI should not produce negative costs!");
283 return Cost;
Elena Demikhovskya3232f72015-01-25 08:44:46 +0000284}
285
Chandler Carruth93205eb2015-08-05 18:08:10 +0000286int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
287 unsigned Alignment,
288 unsigned AddressSpace) const {
289 int Cost =
290 TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
291 assert(Cost >= 0 && "TTI should not produce negative costs!");
292 return Cost;
Chandler Carruth705b1852015-01-31 03:43:40 +0000293}
294
Elena Demikhovsky54946982015-12-28 20:10:59 +0000295int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
296 Value *Ptr, bool VariableMask,
297 unsigned Alignment) const {
298 int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
299 Alignment);
300 assert(Cost >= 0 && "TTI should not produce negative costs!");
301 return Cost;
302}
303
Chandler Carruth93205eb2015-08-05 18:08:10 +0000304int TargetTransformInfo::getInterleavedMemoryOpCost(
Hao Liu32c05392015-06-08 06:39:56 +0000305 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
306 unsigned Alignment, unsigned AddressSpace) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000307 int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
308 Alignment, AddressSpace);
309 assert(Cost >= 0 && "TTI should not produce negative costs!");
310 return Cost;
Hao Liu32c05392015-06-08 06:39:56 +0000311}
312
Chandler Carruth93205eb2015-08-05 18:08:10 +0000313int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
Michael Zolotukhin7ed84a82015-03-17 19:26:23 +0000314 ArrayRef<Type *> Tys) const {
Chandler Carruth93205eb2015-08-05 18:08:10 +0000315 int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys);
316 assert(Cost >= 0 && "TTI should not produce negative costs!");
317 return Cost;
318}
319
Elena Demikhovsky54946982015-12-28 20:10:59 +0000320int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
321 ArrayRef<Value *> Args) const {
322 int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args);
323 assert(Cost >= 0 && "TTI should not produce negative costs!");
324 return Cost;
325}
326
Chandler Carruth93205eb2015-08-05 18:08:10 +0000327int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
328 ArrayRef<Type *> Tys) const {
329 int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
330 assert(Cost >= 0 && "TTI should not produce negative costs!");
331 return Cost;
Michael Zolotukhin7ed84a82015-03-17 19:26:23 +0000332}
333
Chandler Carruth539edf42013-01-05 11:43:11 +0000334unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000335 return TTIImpl->getNumberOfParts(Tp);
Chandler Carruth539edf42013-01-05 11:43:11 +0000336}
337
Chandler Carruth93205eb2015-08-05 18:08:10 +0000338int TargetTransformInfo::getAddressComputationCost(Type *Tp,
339 bool IsComplex) const {
340 int Cost = TTIImpl->getAddressComputationCost(Tp, IsComplex);
341 assert(Cost >= 0 && "TTI should not produce negative costs!");
342 return Cost;
Arnold Schwaighofer594fa2d2013-02-08 14:50:48 +0000343}
Chandler Carruth539edf42013-01-05 11:43:11 +0000344
Chandler Carruth93205eb2015-08-05 18:08:10 +0000345int TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
346 bool IsPairwiseForm) const {
347 int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
348 assert(Cost >= 0 && "TTI should not produce negative costs!");
349 return Cost;
Arnold Schwaighofercae87352013-09-17 18:06:50 +0000350}
351
Chandler Carruth705b1852015-01-31 03:43:40 +0000352unsigned
353TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
354 return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
Chad Rosierf9327d62015-01-26 22:51:15 +0000355}
356
357bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
358 MemIntrinsicInfo &Info) const {
Chandler Carruth705b1852015-01-31 03:43:40 +0000359 return TTIImpl->getTgtMemIntrinsic(Inst, Info);
Chad Rosierf9327d62015-01-26 22:51:15 +0000360}
361
Chandler Carruth705b1852015-01-31 03:43:40 +0000362Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
363 IntrinsicInst *Inst, Type *ExpectedType) const {
364 return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
365}
366
Eric Christopherd566fb12015-07-29 22:09:48 +0000367bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
368 const Function *Callee) const {
369 return TTIImpl->areInlineCompatible(Caller, Callee);
Eric Christopher4371b132015-07-02 01:11:47 +0000370}
371
Chandler Carruth705b1852015-01-31 03:43:40 +0000372TargetTransformInfo::Concept::~Concept() {}
373
Chandler Carruthe0385522015-02-01 10:11:22 +0000374TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
375
376TargetIRAnalysis::TargetIRAnalysis(
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000377 std::function<Result(const Function &)> TTICallback)
Chandler Carruthe0385522015-02-01 10:11:22 +0000378 : TTICallback(TTICallback) {}
379
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000380TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
Chandler Carruthe0385522015-02-01 10:11:22 +0000381 return TTICallback(F);
382}
383
Chandler Carruthb4faf132016-03-11 10:22:49 +0000384char TargetIRAnalysis::PassID;
NAKAMURA Takumidf0cd722016-02-28 17:17:00 +0000385
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000386TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
Mehdi Amini5010ebf2015-07-09 02:08:42 +0000387 return Result(F.getParent()->getDataLayout());
Chandler Carruthe0385522015-02-01 10:11:22 +0000388}
389
Chandler Carruth705b1852015-01-31 03:43:40 +0000390// Register the basic pass.
391INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
392 "Target Transform Information", false, true)
393char TargetTransformInfoWrapperPass::ID = 0;
Chandler Carruth539edf42013-01-05 11:43:11 +0000394
Chandler Carruth705b1852015-01-31 03:43:40 +0000395void TargetTransformInfoWrapperPass::anchor() {}
Chandler Carruth539edf42013-01-05 11:43:11 +0000396
Chandler Carruth705b1852015-01-31 03:43:40 +0000397TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000398 : ImmutablePass(ID) {
Chandler Carruth705b1852015-01-31 03:43:40 +0000399 initializeTargetTransformInfoWrapperPassPass(
400 *PassRegistry::getPassRegistry());
401}
402
403TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000404 TargetIRAnalysis TIRA)
405 : ImmutablePass(ID), TIRA(std::move(TIRA)) {
Chandler Carruth705b1852015-01-31 03:43:40 +0000406 initializeTargetTransformInfoWrapperPassPass(
407 *PassRegistry::getPassRegistry());
408}
409
Eric Christophera4e5d3c2015-09-16 23:38:13 +0000410TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000411 TTI = TIRA.run(F);
412 return *TTI;
413}
414
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000415ImmutablePass *
Chandler Carruth5ec2b1d2015-02-01 12:26:09 +0000416llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
417 return new TargetTransformInfoWrapperPass(std::move(TIRA));
Chandler Carruth539edf42013-01-05 11:43:11 +0000418}