Chandler Carruth | d3e7355 | 2013-01-07 03:08:10 +0000 | [diff] [blame] | 1 | //===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===// |
Nadav Rotem | 5dc203e | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 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 | |
Chandler Carruth | d3e7355 | 2013-01-07 03:08:10 +0000 | [diff] [blame] | 10 | #include "llvm/Analysis/TargetTransformInfo.h" |
Chandler Carruth | 219b89b | 2014-03-04 11:01:28 +0000 | [diff] [blame] | 11 | #include "llvm/IR/CallSite.h" |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 12 | #include "llvm/IR/DataLayout.h" |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 13 | #include "llvm/IR/Instruction.h" |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 14 | #include "llvm/IR/Instructions.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 15 | #include "llvm/IR/IntrinsicInst.h" |
| 16 | #include "llvm/IR/Operator.h" |
Nadav Rotem | 5dc203e | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 17 | #include "llvm/Support/ErrorHandling.h" |
| 18 | |
| 19 | using namespace llvm; |
| 20 | |
Chandler Carruth | f1221bd | 2014-04-22 02:48:03 +0000 | [diff] [blame] | 21 | #define DEBUG_TYPE "tti" |
| 22 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 23 | // Setup the analysis group to manage the TargetTransformInfo passes. |
| 24 | INITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI) |
Nadav Rotem | 5dc203e | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 25 | char TargetTransformInfo::ID = 0; |
| 26 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 27 | TargetTransformInfo::~TargetTransformInfo() { |
| 28 | } |
| 29 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 30 | void TargetTransformInfo::pushTTIStack(Pass *P) { |
| 31 | TopTTI = this; |
| 32 | PrevTTI = &P->getAnalysis<TargetTransformInfo>(); |
| 33 | |
| 34 | // Walk up the chain and update the top TTI pointer. |
| 35 | for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI) |
| 36 | PTTI->TopTTI = this; |
| 37 | } |
| 38 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 39 | void TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const { |
| 40 | AU.addRequired<TargetTransformInfo>(); |
| 41 | } |
| 42 | |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 43 | unsigned TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty, |
| 44 | Type *OpTy) const { |
| 45 | return PrevTTI->getOperationCost(Opcode, Ty, OpTy); |
| 46 | } |
| 47 | |
| 48 | unsigned TargetTransformInfo::getGEPCost( |
| 49 | const Value *Ptr, ArrayRef<const Value *> Operands) const { |
| 50 | return PrevTTI->getGEPCost(Ptr, Operands); |
| 51 | } |
| 52 | |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 53 | unsigned TargetTransformInfo::getCallCost(FunctionType *FTy, |
| 54 | int NumArgs) const { |
| 55 | return PrevTTI->getCallCost(FTy, NumArgs); |
| 56 | } |
| 57 | |
| 58 | unsigned TargetTransformInfo::getCallCost(const Function *F, |
| 59 | int NumArgs) const { |
| 60 | return PrevTTI->getCallCost(F, NumArgs); |
| 61 | } |
| 62 | |
| 63 | unsigned TargetTransformInfo::getCallCost( |
| 64 | const Function *F, ArrayRef<const Value *> Arguments) const { |
| 65 | return PrevTTI->getCallCost(F, Arguments); |
| 66 | } |
| 67 | |
| 68 | unsigned TargetTransformInfo::getIntrinsicCost( |
| 69 | Intrinsic::ID IID, Type *RetTy, ArrayRef<Type *> ParamTys) const { |
| 70 | return PrevTTI->getIntrinsicCost(IID, RetTy, ParamTys); |
| 71 | } |
| 72 | |
| 73 | unsigned TargetTransformInfo::getIntrinsicCost( |
| 74 | Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const { |
| 75 | return PrevTTI->getIntrinsicCost(IID, RetTy, Arguments); |
| 76 | } |
| 77 | |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 78 | unsigned TargetTransformInfo::getUserCost(const User *U) const { |
| 79 | return PrevTTI->getUserCost(U); |
| 80 | } |
| 81 | |
Tom Stellard | 8b1e021 | 2013-07-27 00:01:07 +0000 | [diff] [blame] | 82 | bool TargetTransformInfo::hasBranchDivergence() const { |
| 83 | return PrevTTI->hasBranchDivergence(); |
| 84 | } |
| 85 | |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 86 | bool TargetTransformInfo::isLoweredToCall(const Function *F) const { |
| 87 | return PrevTTI->isLoweredToCall(F); |
| 88 | } |
| 89 | |
Hal Finkel | 8f2e700 | 2013-09-11 19:25:43 +0000 | [diff] [blame] | 90 | void TargetTransformInfo::getUnrollingPreferences(Loop *L, |
| 91 | UnrollingPreferences &UP) const { |
| 92 | PrevTTI->getUnrollingPreferences(L, UP); |
| 93 | } |
| 94 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 95 | bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const { |
| 96 | return PrevTTI->isLegalAddImmediate(Imm); |
| 97 | } |
| 98 | |
| 99 | bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const { |
| 100 | return PrevTTI->isLegalICmpImmediate(Imm); |
| 101 | } |
| 102 | |
| 103 | bool 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 Colombet | bf490d4 | 2013-05-31 21:29:03 +0000 | [diff] [blame] | 111 | int 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 Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 119 | bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const { |
| 120 | return PrevTTI->isTruncateFree(Ty1, Ty2); |
| 121 | } |
| 122 | |
| 123 | bool TargetTransformInfo::isTypeLegal(Type *Ty) const { |
| 124 | return PrevTTI->isTypeLegal(Ty); |
| 125 | } |
| 126 | |
| 127 | unsigned TargetTransformInfo::getJumpBufAlignment() const { |
| 128 | return PrevTTI->getJumpBufAlignment(); |
| 129 | } |
| 130 | |
| 131 | unsigned TargetTransformInfo::getJumpBufSize() const { |
| 132 | return PrevTTI->getJumpBufSize(); |
| 133 | } |
| 134 | |
| 135 | bool TargetTransformInfo::shouldBuildLookupTables() const { |
| 136 | return PrevTTI->shouldBuildLookupTables(); |
| 137 | } |
| 138 | |
Chandler Carruth | 50a36cd | 2013-01-07 03:16:03 +0000 | [diff] [blame] | 139 | TargetTransformInfo::PopcntSupportKind |
| 140 | TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const { |
| 141 | return PrevTTI->getPopcntSupport(IntTyWidthInBit); |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Richard Sandiford | 37cd6cf | 2013-08-23 10:27:02 +0000 | [diff] [blame] | 144 | bool TargetTransformInfo::haveFastSqrt(Type *Ty) const { |
| 145 | return PrevTTI->haveFastSqrt(Ty); |
| 146 | } |
| 147 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 148 | unsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const { |
| 149 | return PrevTTI->getIntImmCost(Imm, Ty); |
| 150 | } |
| 151 | |
Juergen Ributzka | f0dff49 | 2014-03-21 06:04:45 +0000 | [diff] [blame] | 152 | unsigned TargetTransformInfo::getIntImmCost(unsigned Opc, unsigned Idx, |
| 153 | const APInt &Imm, Type *Ty) const { |
| 154 | return PrevTTI->getIntImmCost(Opc, Idx, Imm, Ty); |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Juergen Ributzka | f0dff49 | 2014-03-21 06:04:45 +0000 | [diff] [blame] | 157 | unsigned TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx, |
| 158 | const APInt &Imm, Type *Ty) const { |
| 159 | return PrevTTI->getIntImmCost(IID, Idx, Imm, Ty); |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 162 | unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const { |
| 163 | return PrevTTI->getNumberOfRegisters(Vector); |
| 164 | } |
| 165 | |
Nadav Rotem | b1791a7 | 2013-01-09 22:29:00 +0000 | [diff] [blame] | 166 | unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const { |
| 167 | return PrevTTI->getRegisterBitWidth(Vector); |
| 168 | } |
| 169 | |
Nadav Rotem | b696c36 | 2013-01-09 01:15:42 +0000 | [diff] [blame] | 170 | unsigned TargetTransformInfo::getMaximumUnrollFactor() const { |
| 171 | return PrevTTI->getMaximumUnrollFactor(); |
| 172 | } |
| 173 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 174 | unsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode, |
Arnold Schwaighofer | b977387 | 2013-04-04 23:26:21 +0000 | [diff] [blame] | 175 | Type *Ty, |
| 176 | OperandValueKind Op1Info, |
| 177 | OperandValueKind Op2Info) const { |
| 178 | return PrevTTI->getArithmeticInstrCost(Opcode, Ty, Op1Info, Op2Info); |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp, |
| 182 | int Index, Type *SubTp) const { |
| 183 | return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp); |
| 184 | } |
| 185 | |
| 186 | unsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst, |
| 187 | Type *Src) const { |
| 188 | return PrevTTI->getCastInstrCost(Opcode, Dst, Src); |
| 189 | } |
| 190 | |
| 191 | unsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const { |
| 192 | return PrevTTI->getCFInstrCost(Opcode); |
| 193 | } |
| 194 | |
| 195 | unsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, |
| 196 | Type *CondTy) const { |
| 197 | return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy); |
| 198 | } |
| 199 | |
| 200 | unsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val, |
| 201 | unsigned Index) const { |
| 202 | return PrevTTI->getVectorInstrCost(Opcode, Val, Index); |
| 203 | } |
| 204 | |
| 205 | unsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src, |
| 206 | unsigned Alignment, |
| 207 | unsigned AddressSpace) const { |
| 208 | return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace); |
| 209 | ; |
| 210 | } |
| 211 | |
| 212 | unsigned |
| 213 | TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, |
| 214 | Type *RetTy, |
| 215 | ArrayRef<Type *> Tys) const { |
| 216 | return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys); |
| 217 | } |
| 218 | |
| 219 | unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const { |
| 220 | return PrevTTI->getNumberOfParts(Tp); |
| 221 | } |
| 222 | |
Arnold Schwaighofer | 9da9a43 | 2013-07-12 19:16:02 +0000 | [diff] [blame] | 223 | unsigned TargetTransformInfo::getAddressComputationCost(Type *Tp, |
| 224 | bool IsComplex) const { |
| 225 | return PrevTTI->getAddressComputationCost(Tp, IsComplex); |
Arnold Schwaighofer | 594fa2d | 2013-02-08 14:50:48 +0000 | [diff] [blame] | 226 | } |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 227 | |
Arnold Schwaighofer | cae8735 | 2013-09-17 18:06:50 +0000 | [diff] [blame] | 228 | unsigned TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty, |
| 229 | bool IsPairwise) const { |
| 230 | return PrevTTI->getReductionCost(Opcode, Ty, IsPairwise); |
| 231 | } |
| 232 | |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame^] | 233 | unsigned TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type*> Tys) |
| 234 | const { |
| 235 | return PrevTTI->getCostOfKeepingLiveOverCall(Tys); |
| 236 | } |
| 237 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 238 | namespace { |
| 239 | |
Craig Topper | 77dfe45 | 2014-03-02 08:08:51 +0000 | [diff] [blame] | 240 | struct NoTTI final : ImmutablePass, TargetTransformInfo { |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 241 | const DataLayout *DL; |
| 242 | |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 243 | NoTTI() : ImmutablePass(ID), DL(nullptr) { |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 244 | initializeNoTTIPass(*PassRegistry::getPassRegistry()); |
| 245 | } |
| 246 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 247 | virtual void initializePass() override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 248 | // Note that this subclass is special, and must *not* call initializeTTI as |
| 249 | // it does not chain. |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 250 | TopTTI = this; |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 251 | PrevTTI = nullptr; |
Rafael Espindola | 9351251 | 2014-02-25 17:30:31 +0000 | [diff] [blame] | 252 | DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 253 | DL = DLP ? &DLP->getDataLayout() : nullptr; |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 256 | virtual void getAnalysisUsage(AnalysisUsage &AU) const override { |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 257 | // Note that this subclass is special, and must *not* call |
| 258 | // TTI::getAnalysisUsage as it breaks the recursion. |
| 259 | } |
| 260 | |
| 261 | /// Pass identification. |
| 262 | static char ID; |
| 263 | |
| 264 | /// Provide necessary pointer adjustments for the two base classes. |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 265 | virtual void *getAdjustedAnalysisPointer(const void *ID) override { |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 266 | if (ID == &TargetTransformInfo::ID) |
| 267 | return (TargetTransformInfo*)this; |
| 268 | return this; |
| 269 | } |
| 270 | |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 271 | unsigned getOperationCost(unsigned Opcode, Type *Ty, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 272 | Type *OpTy) const override { |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 273 | switch (Opcode) { |
| 274 | default: |
| 275 | // By default, just classify everything as 'basic'. |
| 276 | return TCC_Basic; |
| 277 | |
| 278 | case Instruction::GetElementPtr: |
| 279 | llvm_unreachable("Use getGEPCost for GEP operations!"); |
| 280 | |
| 281 | case Instruction::BitCast: |
| 282 | assert(OpTy && "Cast instructions must provide the operand type"); |
| 283 | if (Ty == OpTy || (Ty->isPointerTy() && OpTy->isPointerTy())) |
| 284 | // Identity and pointer-to-pointer casts are free. |
| 285 | return TCC_Free; |
| 286 | |
| 287 | // Otherwise, the default basic cost is used. |
| 288 | return TCC_Basic; |
| 289 | |
Matt Arsenault | 54c3cbc | 2013-08-28 22:41:57 +0000 | [diff] [blame] | 290 | case Instruction::IntToPtr: { |
| 291 | if (!DL) |
| 292 | return TCC_Basic; |
| 293 | |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 294 | // An inttoptr cast is free so long as the input is a legal integer type |
| 295 | // which doesn't contain values outside the range of a pointer. |
Matt Arsenault | 54c3cbc | 2013-08-28 22:41:57 +0000 | [diff] [blame] | 296 | unsigned OpSize = OpTy->getScalarSizeInBits(); |
| 297 | if (DL->isLegalInteger(OpSize) && |
| 298 | OpSize <= DL->getPointerTypeSizeInBits(Ty)) |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 299 | return TCC_Free; |
| 300 | |
| 301 | // Otherwise it's not a no-op. |
| 302 | return TCC_Basic; |
Matt Arsenault | 54c3cbc | 2013-08-28 22:41:57 +0000 | [diff] [blame] | 303 | } |
| 304 | case Instruction::PtrToInt: { |
| 305 | if (!DL) |
| 306 | return TCC_Basic; |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 307 | |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 308 | // A ptrtoint cast is free so long as the result is large enough to store |
| 309 | // the pointer, and a legal integer type. |
Matt Arsenault | 54c3cbc | 2013-08-28 22:41:57 +0000 | [diff] [blame] | 310 | unsigned DestSize = Ty->getScalarSizeInBits(); |
| 311 | if (DL->isLegalInteger(DestSize) && |
| 312 | DestSize >= DL->getPointerTypeSizeInBits(OpTy)) |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 313 | return TCC_Free; |
| 314 | |
| 315 | // Otherwise it's not a no-op. |
| 316 | return TCC_Basic; |
Matt Arsenault | 54c3cbc | 2013-08-28 22:41:57 +0000 | [diff] [blame] | 317 | } |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 318 | case Instruction::Trunc: |
| 319 | // trunc to a native type is free (assuming the target has compare and |
| 320 | // shift-right of the same width). |
| 321 | if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty))) |
| 322 | return TCC_Free; |
| 323 | |
| 324 | return TCC_Basic; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | unsigned getGEPCost(const Value *Ptr, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 329 | ArrayRef<const Value *> Operands) const override { |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 330 | // In the basic model, we just assume that all-constant GEPs will be folded |
| 331 | // into their uses via addressing modes. |
| 332 | for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx) |
| 333 | if (!isa<Constant>(Operands[Idx])) |
| 334 | return TCC_Basic; |
| 335 | |
| 336 | return TCC_Free; |
| 337 | } |
| 338 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 339 | unsigned getCallCost(FunctionType *FTy, int NumArgs = -1) const override |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 340 | { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 341 | assert(FTy && "FunctionType must be provided to this routine."); |
| 342 | |
| 343 | // The target-independent implementation just measures the size of the |
| 344 | // function by approximating that each argument will take on average one |
| 345 | // instruction to prepare. |
| 346 | |
| 347 | if (NumArgs < 0) |
| 348 | // Set the argument number to the number of explicit arguments in the |
| 349 | // function. |
| 350 | NumArgs = FTy->getNumParams(); |
| 351 | |
| 352 | return TCC_Basic * (NumArgs + 1); |
| 353 | } |
| 354 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 355 | unsigned getCallCost(const Function *F, int NumArgs = -1) const override |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 356 | { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 357 | assert(F && "A concrete function must be provided to this routine."); |
| 358 | |
| 359 | if (NumArgs < 0) |
| 360 | // Set the argument number to the number of explicit arguments in the |
| 361 | // function. |
| 362 | NumArgs = F->arg_size(); |
| 363 | |
| 364 | if (Intrinsic::ID IID = (Intrinsic::ID)F->getIntrinsicID()) { |
| 365 | FunctionType *FTy = F->getFunctionType(); |
| 366 | SmallVector<Type *, 8> ParamTys(FTy->param_begin(), FTy->param_end()); |
| 367 | return TopTTI->getIntrinsicCost(IID, FTy->getReturnType(), ParamTys); |
| 368 | } |
| 369 | |
| 370 | if (!TopTTI->isLoweredToCall(F)) |
| 371 | return TCC_Basic; // Give a basic cost if it will be lowered directly. |
| 372 | |
| 373 | return TopTTI->getCallCost(F->getFunctionType(), NumArgs); |
| 374 | } |
| 375 | |
| 376 | unsigned getCallCost(const Function *F, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 377 | ArrayRef<const Value *> Arguments) const override { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 378 | // Simply delegate to generic handling of the call. |
| 379 | // FIXME: We should use instsimplify or something else to catch calls which |
| 380 | // will constant fold with these arguments. |
| 381 | return TopTTI->getCallCost(F, Arguments.size()); |
| 382 | } |
| 383 | |
| 384 | unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 385 | ArrayRef<Type *> ParamTys) const override { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 386 | switch (IID) { |
| 387 | default: |
| 388 | // Intrinsics rarely (if ever) have normal argument setup constraints. |
| 389 | // Model them as having a basic instruction cost. |
| 390 | // FIXME: This is wrong for libc intrinsics. |
| 391 | return TCC_Basic; |
| 392 | |
Hal Finkel | 9304691 | 2014-07-25 21:13:35 +0000 | [diff] [blame] | 393 | case Intrinsic::assume: |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 394 | case Intrinsic::dbg_declare: |
| 395 | case Intrinsic::dbg_value: |
| 396 | case Intrinsic::invariant_start: |
| 397 | case Intrinsic::invariant_end: |
| 398 | case Intrinsic::lifetime_start: |
| 399 | case Intrinsic::lifetime_end: |
| 400 | case Intrinsic::objectsize: |
| 401 | case Intrinsic::ptr_annotation: |
| 402 | case Intrinsic::var_annotation: |
| 403 | // These intrinsics don't actually represent code after lowering. |
| 404 | return TCC_Free; |
| 405 | } |
| 406 | } |
| 407 | |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 408 | unsigned |
| 409 | getIntrinsicCost(Intrinsic::ID IID, Type *RetTy, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 410 | ArrayRef<const Value *> Arguments) const override { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 411 | // Delegate to the generic intrinsic handling code. This mostly provides an |
| 412 | // opportunity for targets to (for example) special case the cost of |
| 413 | // certain intrinsics based on constants used as arguments. |
| 414 | SmallVector<Type *, 8> ParamTys; |
| 415 | ParamTys.reserve(Arguments.size()); |
| 416 | for (unsigned Idx = 0, Size = Arguments.size(); Idx != Size; ++Idx) |
| 417 | ParamTys.push_back(Arguments[Idx]->getType()); |
| 418 | return TopTTI->getIntrinsicCost(IID, RetTy, ParamTys); |
| 419 | } |
| 420 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 421 | unsigned getUserCost(const User *U) const override { |
Chandler Carruth | bb9caa9 | 2013-01-21 13:04:33 +0000 | [diff] [blame] | 422 | if (isa<PHINode>(U)) |
| 423 | return TCC_Free; // Model all PHI nodes as free. |
| 424 | |
Hal Finkel | b4e001c | 2014-04-01 18:50:06 +0000 | [diff] [blame] | 425 | if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) { |
| 426 | SmallVector<const Value *, 4> Indices(GEP->idx_begin(), GEP->idx_end()); |
| 427 | return TopTTI->getGEPCost(GEP->getPointerOperand(), Indices); |
| 428 | } |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 429 | |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 430 | if (ImmutableCallSite CS = U) { |
| 431 | const Function *F = CS.getCalledFunction(); |
| 432 | if (!F) { |
| 433 | // Just use the called value type. |
| 434 | Type *FTy = CS.getCalledValue()->getType()->getPointerElementType(); |
| 435 | return TopTTI->getCallCost(cast<FunctionType>(FTy), CS.arg_size()); |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 436 | } |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 437 | |
Benjamin Kramer | 3c29c07 | 2014-02-10 14:17:42 +0000 | [diff] [blame] | 438 | SmallVector<const Value *, 8> Arguments(CS.arg_begin(), CS.arg_end()); |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 439 | return TopTTI->getCallCost(F, Arguments); |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | if (const CastInst *CI = dyn_cast<CastInst>(U)) { |
| 443 | // Result of a cmp instruction is often extended (to be used by other |
| 444 | // cmp instructions, logical or return instructions). These are usually |
| 445 | // nop on most sane targets. |
| 446 | if (isa<CmpInst>(CI->getOperand(0))) |
| 447 | return TCC_Free; |
| 448 | } |
| 449 | |
| 450 | // Otherwise delegate to the fully generic implementations. |
| 451 | return getOperationCost(Operator::getOpcode(U), U->getType(), |
| 452 | U->getNumOperands() == 1 ? |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 453 | U->getOperand(0)->getType() : nullptr); |
Chandler Carruth | 511aa76 | 2013-01-21 01:27:39 +0000 | [diff] [blame] | 454 | } |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 455 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 456 | bool hasBranchDivergence() const override { return false; } |
Tom Stellard | 8b1e021 | 2013-07-27 00:01:07 +0000 | [diff] [blame] | 457 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 458 | bool isLoweredToCall(const Function *F) const override { |
Chandler Carruth | 0ba8db4 | 2013-01-22 11:26:02 +0000 | [diff] [blame] | 459 | // FIXME: These should almost certainly not be handled here, and instead |
| 460 | // handled with the help of TLI or the target itself. This was largely |
| 461 | // ported from existing analysis heuristics here so that such refactorings |
| 462 | // can take place in the future. |
| 463 | |
| 464 | if (F->isIntrinsic()) |
| 465 | return false; |
| 466 | |
| 467 | if (F->hasLocalLinkage() || !F->hasName()) |
| 468 | return true; |
| 469 | |
| 470 | StringRef Name = F->getName(); |
| 471 | |
| 472 | // These will all likely lower to a single selection DAG node. |
| 473 | if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" || |
| 474 | Name == "fabs" || Name == "fabsf" || Name == "fabsl" || Name == "sin" || |
| 475 | Name == "sinf" || Name == "sinl" || Name == "cos" || Name == "cosf" || |
| 476 | Name == "cosl" || Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl") |
| 477 | return false; |
| 478 | |
| 479 | // These are all likely to be optimized into something smaller. |
| 480 | if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" || |
| 481 | Name == "exp2l" || Name == "exp2f" || Name == "floor" || Name == |
| 482 | "floorf" || Name == "ceil" || Name == "round" || Name == "ffs" || |
| 483 | Name == "ffsl" || Name == "abs" || Name == "labs" || Name == "llabs") |
| 484 | return false; |
| 485 | |
| 486 | return true; |
| 487 | } |
| 488 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 489 | void getUnrollingPreferences(Loop *, UnrollingPreferences &) const override { |
| 490 | } |
Hal Finkel | 8f2e700 | 2013-09-11 19:25:43 +0000 | [diff] [blame] | 491 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 492 | bool isLegalAddImmediate(int64_t Imm) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 493 | return false; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 496 | bool isLegalICmpImmediate(int64_t Imm) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 497 | return false; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 501 | bool HasBaseReg, int64_t Scale) const override |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 502 | { |
Chandler Carruth | 26c59fa | 2013-01-07 14:41:08 +0000 | [diff] [blame] | 503 | // Guess that reg+reg addressing is allowed. This heuristic is taken from |
| 504 | // the implementation of LSR. |
| 505 | return !BaseGV && BaseOffset == 0 && Scale <= 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 506 | } |
| 507 | |
Quentin Colombet | bf490d4 | 2013-05-31 21:29:03 +0000 | [diff] [blame] | 508 | int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 509 | bool HasBaseReg, int64_t Scale) const override { |
Quentin Colombet | bf490d4 | 2013-05-31 21:29:03 +0000 | [diff] [blame] | 510 | // Guess that all legal addressing mode are free. |
| 511 | if(isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg, Scale)) |
| 512 | return 0; |
| 513 | return -1; |
| 514 | } |
| 515 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 516 | bool isTruncateFree(Type *Ty1, Type *Ty2) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 517 | return false; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 518 | } |
| 519 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 520 | bool isTypeLegal(Type *Ty) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 521 | return false; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 522 | } |
| 523 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 524 | unsigned getJumpBufAlignment() const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 525 | return 0; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 526 | } |
| 527 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 528 | unsigned getJumpBufSize() const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 529 | return 0; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 530 | } |
| 531 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 532 | bool shouldBuildLookupTables() const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 533 | return true; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 534 | } |
| 535 | |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 536 | PopcntSupportKind |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 537 | getPopcntSupport(unsigned IntTyWidthInBit) const override { |
Chandler Carruth | 50a36cd | 2013-01-07 03:16:03 +0000 | [diff] [blame] | 538 | return PSK_Software; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 541 | bool haveFastSqrt(Type *Ty) const override { |
Richard Sandiford | 37cd6cf | 2013-08-23 10:27:02 +0000 | [diff] [blame] | 542 | return false; |
| 543 | } |
| 544 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 545 | unsigned getIntImmCost(const APInt &Imm, Type *Ty) const override { |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 546 | return TCC_Basic; |
| 547 | } |
| 548 | |
Juergen Ributzka | f0dff49 | 2014-03-21 06:04:45 +0000 | [diff] [blame] | 549 | unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 550 | Type *Ty) const override { |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 551 | return TCC_Free; |
| 552 | } |
| 553 | |
Juergen Ributzka | f0dff49 | 2014-03-21 06:04:45 +0000 | [diff] [blame] | 554 | unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 555 | Type *Ty) const override { |
Juergen Ributzka | f26beda | 2014-01-25 02:02:55 +0000 | [diff] [blame] | 556 | return TCC_Free; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 559 | unsigned getNumberOfRegisters(bool Vector) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 560 | return 8; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 563 | unsigned getRegisterBitWidth(bool Vector) const override { |
Nadav Rotem | b1791a7 | 2013-01-09 22:29:00 +0000 | [diff] [blame] | 564 | return 32; |
| 565 | } |
| 566 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 567 | unsigned getMaximumUnrollFactor() const override { |
Nadav Rotem | b696c36 | 2013-01-09 01:15:42 +0000 | [diff] [blame] | 568 | return 1; |
| 569 | } |
| 570 | |
Arnold Schwaighofer | b977387 | 2013-04-04 23:26:21 +0000 | [diff] [blame] | 571 | unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 572 | OperandValueKind) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 573 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Juergen Ributzka | 3e752e7 | 2014-01-24 18:22:59 +0000 | [diff] [blame] | 576 | unsigned getShuffleCost(ShuffleKind Kind, Type *Ty, |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 577 | int Index = 0, Type *SubTp = nullptr) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 578 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | unsigned getCastInstrCost(unsigned Opcode, Type *Dst, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 582 | Type *Src) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 583 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 586 | unsigned getCFInstrCost(unsigned Opcode) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 587 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, |
Craig Topper | 9f00886 | 2014-04-15 04:59:12 +0000 | [diff] [blame] | 591 | Type *CondTy = nullptr) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 592 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | unsigned getVectorInstrCost(unsigned Opcode, Type *Val, |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 596 | unsigned Index = -1) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 597 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 600 | unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
| 601 | unsigned AddressSpace) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 602 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 603 | } |
| 604 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 605 | unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, |
| 606 | ArrayRef<Type*> Tys) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 607 | return 1; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 608 | } |
| 609 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 610 | unsigned getNumberOfParts(Type *Tp) const override { |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 611 | return 0; |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 612 | } |
Arnold Schwaighofer | 594fa2d | 2013-02-08 14:50:48 +0000 | [diff] [blame] | 613 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 614 | unsigned getAddressComputationCost(Type *Tp, bool) const override { |
Arnold Schwaighofer | 594fa2d | 2013-02-08 14:50:48 +0000 | [diff] [blame] | 615 | return 0; |
| 616 | } |
Arnold Schwaighofer | cae8735 | 2013-09-17 18:06:50 +0000 | [diff] [blame] | 617 | |
Craig Topper | 7315602 | 2014-03-02 09:09:27 +0000 | [diff] [blame] | 618 | unsigned getReductionCost(unsigned, Type *, bool) const override { |
Arnold Schwaighofer | cae8735 | 2013-09-17 18:06:50 +0000 | [diff] [blame] | 619 | return 1; |
| 620 | } |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame^] | 621 | |
| 622 | unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type*> Tys) const override { |
| 623 | return 0; |
| 624 | } |
| 625 | |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 626 | }; |
| 627 | |
| 628 | } // end anonymous namespace |
| 629 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 630 | INITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti", |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 631 | "No target information", true, true, true) |
| 632 | char NoTTI::ID = 0; |
| 633 | |
Chandler Carruth | 664e354 | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 634 | ImmutablePass *llvm::createNoTargetTransformInfoPass() { |
| 635 | return new NoTTI(); |
Chandler Carruth | 539edf4 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 636 | } |