Chandler Carruth | be04929 | 2013-01-07 03:08:10 +0000 | [diff] [blame] | 1 | //===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===// |
Nadav Rotem | cbd9a19 | 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 | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 10 | #define DEBUG_TYPE "tti" |
Chandler Carruth | be04929 | 2013-01-07 03:08:10 +0000 | [diff] [blame] | 11 | #include "llvm/Analysis/TargetTransformInfo.h" |
Chandler Carruth | 1e05bd9 | 2013-01-21 01:27:39 +0000 | [diff] [blame^] | 12 | #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" |
Nadav Rotem | cbd9a19 | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 17 | #include "llvm/Support/ErrorHandling.h" |
| 18 | |
| 19 | using namespace llvm; |
| 20 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 21 | // Setup the analysis group to manage the TargetTransformInfo passes. |
| 22 | INITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI) |
Nadav Rotem | cbd9a19 | 2012-10-18 23:22:48 +0000 | [diff] [blame] | 23 | char TargetTransformInfo::ID = 0; |
| 24 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 25 | TargetTransformInfo::~TargetTransformInfo() { |
| 26 | } |
| 27 | |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 28 | void TargetTransformInfo::pushTTIStack(Pass *P) { |
| 29 | TopTTI = this; |
| 30 | PrevTTI = &P->getAnalysis<TargetTransformInfo>(); |
| 31 | |
| 32 | // Walk up the chain and update the top TTI pointer. |
| 33 | for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI) |
| 34 | PTTI->TopTTI = this; |
| 35 | } |
| 36 | |
| 37 | void TargetTransformInfo::popTTIStack() { |
| 38 | TopTTI = 0; |
| 39 | |
| 40 | // Walk up the chain and update the top TTI pointer. |
| 41 | for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI) |
| 42 | PTTI->TopTTI = PrevTTI; |
| 43 | |
| 44 | PrevTTI = 0; |
| 45 | } |
| 46 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 47 | void TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const { |
| 48 | AU.addRequired<TargetTransformInfo>(); |
| 49 | } |
| 50 | |
Chandler Carruth | 1e05bd9 | 2013-01-21 01:27:39 +0000 | [diff] [blame^] | 51 | unsigned TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty, |
| 52 | Type *OpTy) const { |
| 53 | return PrevTTI->getOperationCost(Opcode, Ty, OpTy); |
| 54 | } |
| 55 | |
| 56 | unsigned TargetTransformInfo::getGEPCost( |
| 57 | const Value *Ptr, ArrayRef<const Value *> Operands) const { |
| 58 | return PrevTTI->getGEPCost(Ptr, Operands); |
| 59 | } |
| 60 | |
| 61 | unsigned TargetTransformInfo::getUserCost(const User *U) const { |
| 62 | return PrevTTI->getUserCost(U); |
| 63 | } |
| 64 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 65 | bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const { |
| 66 | return PrevTTI->isLegalAddImmediate(Imm); |
| 67 | } |
| 68 | |
| 69 | bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const { |
| 70 | return PrevTTI->isLegalICmpImmediate(Imm); |
| 71 | } |
| 72 | |
| 73 | bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, |
| 74 | int64_t BaseOffset, |
| 75 | bool HasBaseReg, |
| 76 | int64_t Scale) const { |
| 77 | return PrevTTI->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg, |
| 78 | Scale); |
| 79 | } |
| 80 | |
| 81 | bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const { |
| 82 | return PrevTTI->isTruncateFree(Ty1, Ty2); |
| 83 | } |
| 84 | |
| 85 | bool TargetTransformInfo::isTypeLegal(Type *Ty) const { |
| 86 | return PrevTTI->isTypeLegal(Ty); |
| 87 | } |
| 88 | |
| 89 | unsigned TargetTransformInfo::getJumpBufAlignment() const { |
| 90 | return PrevTTI->getJumpBufAlignment(); |
| 91 | } |
| 92 | |
| 93 | unsigned TargetTransformInfo::getJumpBufSize() const { |
| 94 | return PrevTTI->getJumpBufSize(); |
| 95 | } |
| 96 | |
| 97 | bool TargetTransformInfo::shouldBuildLookupTables() const { |
| 98 | return PrevTTI->shouldBuildLookupTables(); |
| 99 | } |
| 100 | |
Chandler Carruth | d1b8ef9 | 2013-01-07 03:16:03 +0000 | [diff] [blame] | 101 | TargetTransformInfo::PopcntSupportKind |
| 102 | TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const { |
| 103 | return PrevTTI->getPopcntSupport(IntTyWidthInBit); |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | unsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const { |
| 107 | return PrevTTI->getIntImmCost(Imm, Ty); |
| 108 | } |
| 109 | |
| 110 | unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const { |
| 111 | return PrevTTI->getNumberOfRegisters(Vector); |
| 112 | } |
| 113 | |
Nadav Rotem | 14925e6 | 2013-01-09 22:29:00 +0000 | [diff] [blame] | 114 | unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const { |
| 115 | return PrevTTI->getRegisterBitWidth(Vector); |
| 116 | } |
| 117 | |
Nadav Rotem | 83be7b0 | 2013-01-09 01:15:42 +0000 | [diff] [blame] | 118 | unsigned TargetTransformInfo::getMaximumUnrollFactor() const { |
| 119 | return PrevTTI->getMaximumUnrollFactor(); |
| 120 | } |
| 121 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 122 | unsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode, |
| 123 | Type *Ty) const { |
| 124 | return PrevTTI->getArithmeticInstrCost(Opcode, Ty); |
| 125 | } |
| 126 | |
| 127 | unsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp, |
| 128 | int Index, Type *SubTp) const { |
| 129 | return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp); |
| 130 | } |
| 131 | |
| 132 | unsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst, |
| 133 | Type *Src) const { |
| 134 | return PrevTTI->getCastInstrCost(Opcode, Dst, Src); |
| 135 | } |
| 136 | |
| 137 | unsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const { |
| 138 | return PrevTTI->getCFInstrCost(Opcode); |
| 139 | } |
| 140 | |
| 141 | unsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, |
| 142 | Type *CondTy) const { |
| 143 | return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy); |
| 144 | } |
| 145 | |
| 146 | unsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val, |
| 147 | unsigned Index) const { |
| 148 | return PrevTTI->getVectorInstrCost(Opcode, Val, Index); |
| 149 | } |
| 150 | |
| 151 | unsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src, |
| 152 | unsigned Alignment, |
| 153 | unsigned AddressSpace) const { |
| 154 | return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace); |
| 155 | ; |
| 156 | } |
| 157 | |
| 158 | unsigned |
| 159 | TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, |
| 160 | Type *RetTy, |
| 161 | ArrayRef<Type *> Tys) const { |
| 162 | return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys); |
| 163 | } |
| 164 | |
| 165 | unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const { |
| 166 | return PrevTTI->getNumberOfParts(Tp); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | namespace { |
| 171 | |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 172 | struct NoTTI : ImmutablePass, TargetTransformInfo { |
Chandler Carruth | 1e05bd9 | 2013-01-21 01:27:39 +0000 | [diff] [blame^] | 173 | const DataLayout *DL; |
| 174 | |
| 175 | NoTTI() : ImmutablePass(ID), DL(0) { |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 176 | initializeNoTTIPass(*PassRegistry::getPassRegistry()); |
| 177 | } |
| 178 | |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 179 | virtual void initializePass() { |
| 180 | // Note that this subclass is special, and must *not* call initializeTTI as |
| 181 | // it does not chain. |
| 182 | PrevTTI = 0; |
Chandler Carruth | 1e05bd9 | 2013-01-21 01:27:39 +0000 | [diff] [blame^] | 183 | DL = getAnalysisIfAvailable<DataLayout>(); |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 187 | // Note that this subclass is special, and must *not* call |
| 188 | // TTI::getAnalysisUsage as it breaks the recursion. |
| 189 | } |
| 190 | |
| 191 | /// Pass identification. |
| 192 | static char ID; |
| 193 | |
| 194 | /// Provide necessary pointer adjustments for the two base classes. |
| 195 | virtual void *getAdjustedAnalysisPointer(const void *ID) { |
| 196 | if (ID == &TargetTransformInfo::ID) |
| 197 | return (TargetTransformInfo*)this; |
| 198 | return this; |
| 199 | } |
| 200 | |
Chandler Carruth | 1e05bd9 | 2013-01-21 01:27:39 +0000 | [diff] [blame^] | 201 | unsigned getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) const { |
| 202 | switch (Opcode) { |
| 203 | default: |
| 204 | // By default, just classify everything as 'basic'. |
| 205 | return TCC_Basic; |
| 206 | |
| 207 | case Instruction::GetElementPtr: |
| 208 | llvm_unreachable("Use getGEPCost for GEP operations!"); |
| 209 | |
| 210 | case Instruction::BitCast: |
| 211 | assert(OpTy && "Cast instructions must provide the operand type"); |
| 212 | if (Ty == OpTy || (Ty->isPointerTy() && OpTy->isPointerTy())) |
| 213 | // Identity and pointer-to-pointer casts are free. |
| 214 | return TCC_Free; |
| 215 | |
| 216 | // Otherwise, the default basic cost is used. |
| 217 | return TCC_Basic; |
| 218 | |
| 219 | case Instruction::IntToPtr: |
| 220 | // An inttoptr cast is free so long as the input is a legal integer type |
| 221 | // which doesn't contain values outside the range of a pointer. |
| 222 | if (DL && DL->isLegalInteger(OpTy->getScalarSizeInBits()) && |
| 223 | OpTy->getScalarSizeInBits() <= DL->getPointerSizeInBits()) |
| 224 | return TCC_Free; |
| 225 | |
| 226 | // Otherwise it's not a no-op. |
| 227 | return TCC_Basic; |
| 228 | |
| 229 | case Instruction::PtrToInt: |
| 230 | // A ptrtoint cast is free so long as the result is large enough to store |
| 231 | // the pointer, and a legal integer type. |
| 232 | if (DL && DL->isLegalInteger(OpTy->getScalarSizeInBits()) && |
| 233 | OpTy->getScalarSizeInBits() >= DL->getPointerSizeInBits()) |
| 234 | return TCC_Free; |
| 235 | |
| 236 | // Otherwise it's not a no-op. |
| 237 | return TCC_Basic; |
| 238 | |
| 239 | case Instruction::Trunc: |
| 240 | // trunc to a native type is free (assuming the target has compare and |
| 241 | // shift-right of the same width). |
| 242 | if (DL && DL->isLegalInteger(DL->getTypeSizeInBits(Ty))) |
| 243 | return TCC_Free; |
| 244 | |
| 245 | return TCC_Basic; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | unsigned getGEPCost(const Value *Ptr, |
| 250 | ArrayRef<const Value *> Operands) const { |
| 251 | // In the basic model, we just assume that all-constant GEPs will be folded |
| 252 | // into their uses via addressing modes. |
| 253 | for (unsigned Idx = 0, Size = Operands.size(); Idx != Size; ++Idx) |
| 254 | if (!isa<Constant>(Operands[Idx])) |
| 255 | return TCC_Basic; |
| 256 | |
| 257 | return TCC_Free; |
| 258 | } |
| 259 | |
| 260 | unsigned getUserCost(const User *U) const { |
| 261 | if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) |
| 262 | // In the basic model we just assume that all-constant GEPs will be |
| 263 | // folded into their uses via addressing modes. |
| 264 | return GEP->hasAllConstantIndices() ? TCC_Free : TCC_Basic; |
| 265 | |
| 266 | // If we have a call of an intrinsic we can provide more detailed analysis |
| 267 | // by inspecting the particular intrinsic called. |
| 268 | // FIXME: Hoist this out into a getIntrinsicCost routine. |
| 269 | if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(U)) { |
| 270 | switch (II->getIntrinsicID()) { |
| 271 | default: |
| 272 | return TCC_Basic; |
| 273 | case Intrinsic::dbg_declare: |
| 274 | case Intrinsic::dbg_value: |
| 275 | case Intrinsic::invariant_start: |
| 276 | case Intrinsic::invariant_end: |
| 277 | case Intrinsic::lifetime_start: |
| 278 | case Intrinsic::lifetime_end: |
| 279 | case Intrinsic::objectsize: |
| 280 | case Intrinsic::ptr_annotation: |
| 281 | case Intrinsic::var_annotation: |
| 282 | // These intrinsics don't count as size. |
| 283 | return TCC_Free; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | if (const CastInst *CI = dyn_cast<CastInst>(U)) { |
| 288 | // Result of a cmp instruction is often extended (to be used by other |
| 289 | // cmp instructions, logical or return instructions). These are usually |
| 290 | // nop on most sane targets. |
| 291 | if (isa<CmpInst>(CI->getOperand(0))) |
| 292 | return TCC_Free; |
| 293 | } |
| 294 | |
| 295 | // Otherwise delegate to the fully generic implementations. |
| 296 | return getOperationCost(Operator::getOpcode(U), U->getType(), |
| 297 | U->getNumOperands() == 1 ? |
| 298 | U->getOperand(0)->getType() : 0); |
| 299 | } |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 300 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 301 | bool isLegalAddImmediate(int64_t Imm) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 302 | return false; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | bool isLegalICmpImmediate(int64_t Imm) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 306 | return false; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, |
| 310 | bool HasBaseReg, int64_t Scale) const { |
Chandler Carruth | e4ba75f | 2013-01-07 14:41:08 +0000 | [diff] [blame] | 311 | // Guess that reg+reg addressing is allowed. This heuristic is taken from |
| 312 | // the implementation of LSR. |
| 313 | return !BaseGV && BaseOffset == 0 && Scale <= 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | bool isTruncateFree(Type *Ty1, Type *Ty2) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 317 | return false; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | bool isTypeLegal(Type *Ty) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 321 | return false; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | unsigned getJumpBufAlignment() const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 325 | return 0; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | unsigned getJumpBufSize() const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 329 | return 0; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | bool shouldBuildLookupTables() const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 333 | return true; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Chandler Carruth | d1b8ef9 | 2013-01-07 03:16:03 +0000 | [diff] [blame] | 336 | PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const { |
| 337 | return PSK_Software; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | unsigned getIntImmCost(const APInt &Imm, Type *Ty) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 341 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | unsigned getNumberOfRegisters(bool Vector) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 345 | return 8; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Nadav Rotem | 14925e6 | 2013-01-09 22:29:00 +0000 | [diff] [blame] | 348 | unsigned getRegisterBitWidth(bool Vector) const { |
| 349 | return 32; |
| 350 | } |
| 351 | |
Nadav Rotem | 83be7b0 | 2013-01-09 01:15:42 +0000 | [diff] [blame] | 352 | unsigned getMaximumUnrollFactor() const { |
| 353 | return 1; |
| 354 | } |
| 355 | |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 356 | unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 357 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | unsigned getShuffleCost(ShuffleKind Kind, Type *Tp, |
| 361 | int Index = 0, Type *SubTp = 0) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 362 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | unsigned getCastInstrCost(unsigned Opcode, Type *Dst, |
| 366 | Type *Src) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 367 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | unsigned getCFInstrCost(unsigned Opcode) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 371 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, |
| 375 | Type *CondTy = 0) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 376 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | unsigned getVectorInstrCost(unsigned Opcode, Type *Val, |
| 380 | unsigned Index = -1) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 381 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | unsigned getMemoryOpCost(unsigned Opcode, Type *Src, |
| 385 | unsigned Alignment, |
| 386 | unsigned AddressSpace) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 387 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | unsigned getIntrinsicInstrCost(Intrinsic::ID ID, |
| 391 | Type *RetTy, |
| 392 | ArrayRef<Type*> Tys) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 393 | return 1; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | unsigned getNumberOfParts(Type *Tp) const { |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 397 | return 0; |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 398 | } |
| 399 | }; |
| 400 | |
| 401 | } // end anonymous namespace |
| 402 | |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 403 | INITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti", |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 404 | "No target information", true, true, true) |
| 405 | char NoTTI::ID = 0; |
| 406 | |
Chandler Carruth | aeef83c | 2013-01-07 01:37:14 +0000 | [diff] [blame] | 407 | ImmutablePass *llvm::createNoTargetTransformInfoPass() { |
| 408 | return new NoTTI(); |
Chandler Carruth | 7bdf6b0 | 2013-01-05 11:43:11 +0000 | [diff] [blame] | 409 | } |