TargetTransformInfo.cpp revision e4ba75f43e2ab1480d119d2d4eb878256274e0fb
1be04929f7fd76a921540e9901f24563e51dc1219Chandler Carruth//===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
2cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem//
3cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem//                     The LLVM Compiler Infrastructure
4cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem//
5cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem// This file is distributed under the University of Illinois Open Source
6cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem// License. See LICENSE.TXT for details.
7cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem//
8cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem//===----------------------------------------------------------------------===//
9cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem
10aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth#define DEBUG_TYPE "tti"
11be04929f7fd76a921540e9901f24563e51dc1219Chandler Carruth#include "llvm/Analysis/TargetTransformInfo.h"
12cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem#include "llvm/Support/ErrorHandling.h"
13cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem
14cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotemusing namespace llvm;
15cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem
167bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth// Setup the analysis group to manage the TargetTransformInfo passes.
177bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler CarruthINITIALIZE_ANALYSIS_GROUP(TargetTransformInfo, "Target Information", NoTTI)
18cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotemchar TargetTransformInfo::ID = 0;
19cbd9a19b5d6ff93efa82c467508ede78b8af3bacNadav Rotem
207bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler CarruthTargetTransformInfo::~TargetTransformInfo() {
217bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
227bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
23aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruthvoid TargetTransformInfo::pushTTIStack(Pass *P) {
24aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  TopTTI = this;
25aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  PrevTTI = &P->getAnalysis<TargetTransformInfo>();
26aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth
27aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  // Walk up the chain and update the top TTI pointer.
28aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI)
29aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    PTTI->TopTTI = this;
30aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth}
31aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth
32aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruthvoid TargetTransformInfo::popTTIStack() {
33aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  TopTTI = 0;
34aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth
35aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  // Walk up the chain and update the top TTI pointer.
36aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  for (TargetTransformInfo *PTTI = PrevTTI; PTTI; PTTI = PTTI->PrevTTI)
37aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    PTTI->TopTTI = PrevTTI;
38aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth
39aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  PrevTTI = 0;
40aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth}
41aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth
427bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthvoid TargetTransformInfo::getAnalysisUsage(AnalysisUsage &AU) const {
437bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  AU.addRequired<TargetTransformInfo>();
447bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
457bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
467bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
477bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->isLegalAddImmediate(Imm);
487bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
497bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
507bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
517bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->isLegalICmpImmediate(Imm);
527bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
537bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
547bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
557bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                int64_t BaseOffset,
567bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                bool HasBaseReg,
577bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                int64_t Scale) const {
587bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
597bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                        Scale);
607bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
617bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
627bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
637bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->isTruncateFree(Ty1, Ty2);
647bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
657bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
667bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::isTypeLegal(Type *Ty) const {
677bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->isTypeLegal(Ty);
687bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
697bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
707bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getJumpBufAlignment() const {
717bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getJumpBufAlignment();
727bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
737bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
747bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getJumpBufSize() const {
757bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getJumpBufSize();
767bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
777bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
787bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthbool TargetTransformInfo::shouldBuildLookupTables() const {
797bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->shouldBuildLookupTables();
807bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
817bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
82d1b8ef97c47d347f2a2261a0d6de4872f248321fChandler CarruthTargetTransformInfo::PopcntSupportKind
83d1b8ef97c47d347f2a2261a0d6de4872f248321fChandler CarruthTargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
84d1b8ef97c47d347f2a2261a0d6de4872f248321fChandler Carruth  return PrevTTI->getPopcntSupport(IntTyWidthInBit);
857bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
867bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
877bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
887bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getIntImmCost(Imm, Ty);
897bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
907bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
917bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
927bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getNumberOfRegisters(Vector);
937bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
947bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
957bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getArithmeticInstrCost(unsigned Opcode,
967bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                     Type *Ty) const {
977bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getArithmeticInstrCost(Opcode, Ty);
987bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
997bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1007bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp,
1017bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                             int Index, Type *SubTp) const {
1027bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getShuffleCost(Kind, Tp, Index, SubTp);
1037bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1047bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1057bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
1067bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                               Type *Src) const {
1077bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getCastInstrCost(Opcode, Dst, Src);
1087bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1097bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1107bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
1117bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getCFInstrCost(Opcode);
1127bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1137bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1147bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
1157bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                 Type *CondTy) const {
1167bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getCmpSelInstrCost(Opcode, ValTy, CondTy);
1177bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1187bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1197bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
1207bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                                 unsigned Index) const {
1217bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getVectorInstrCost(Opcode, Val, Index);
1227bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1237bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1247bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
1257bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                              unsigned Alignment,
1267bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                              unsigned AddressSpace) const {
1277bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
1287bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  ;
1297bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1307bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1317bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned
1327bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler CarruthTargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID,
1337bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                           Type *RetTy,
1347bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                           ArrayRef<Type *> Tys) const {
1357bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getIntrinsicInstrCost(ID, RetTy, Tys);
1367bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1377bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1387bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthunsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
1397bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  return PrevTTI->getNumberOfParts(Tp);
1407bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
1417bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1427bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1437bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthnamespace {
1447bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
145aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruthstruct NoTTI : ImmutablePass, TargetTransformInfo {
146aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  NoTTI() : ImmutablePass(ID) {
147aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    initializeNoTTIPass(*PassRegistry::getPassRegistry());
1487bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1497bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
150aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  virtual void initializePass() {
151aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    // Note that this subclass is special, and must *not* call initializeTTI as
152aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    // it does not chain.
153aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    PrevTTI = 0;
1547bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1557bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
156aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
1577bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth    // Note that this subclass is special, and must *not* call
1587bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth    // TTI::getAnalysisUsage as it breaks the recursion.
1597bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1607bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1617bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  /// Pass identification.
1627bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  static char ID;
1637bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1647bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  /// Provide necessary pointer adjustments for the two base classes.
1657bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  virtual void *getAdjustedAnalysisPointer(const void *ID) {
1667bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth    if (ID == &TargetTransformInfo::ID)
1677bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth      return (TargetTransformInfo*)this;
1687bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth    return this;
1697bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1707bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1717bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1727bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool isLegalAddImmediate(int64_t Imm) const {
173aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return false;
1747bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1757bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1767bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool isLegalICmpImmediate(int64_t Imm) const {
177aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return false;
1787bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1797bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1807bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
1817bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                             bool HasBaseReg, int64_t Scale) const {
182e4ba75f43e2ab1480d119d2d4eb878256274e0fbChandler Carruth    // Guess that reg+reg addressing is allowed. This heuristic is taken from
183e4ba75f43e2ab1480d119d2d4eb878256274e0fbChandler Carruth    // the implementation of LSR.
184e4ba75f43e2ab1480d119d2d4eb878256274e0fbChandler Carruth    return !BaseGV && BaseOffset == 0 && Scale <= 1;
1857bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1867bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1877bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool isTruncateFree(Type *Ty1, Type *Ty2) const {
188aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return false;
1897bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1907bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1917bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool isTypeLegal(Type *Ty) const {
192aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return false;
1937bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1947bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1957bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getJumpBufAlignment() const {
196aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 0;
1977bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
1987bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
1997bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getJumpBufSize() const {
200aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 0;
2017bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2027bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2037bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  bool shouldBuildLookupTables() const {
204aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return true;
2057bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2067bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
207d1b8ef97c47d347f2a2261a0d6de4872f248321fChandler Carruth  PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const {
208d1b8ef97c47d347f2a2261a0d6de4872f248321fChandler Carruth    return PSK_Software;
2097bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2107bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2117bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getIntImmCost(const APInt &Imm, Type *Ty) const {
212aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2137bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2147bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2157bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getNumberOfRegisters(bool Vector) const {
216aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 8;
2177bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2187bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2197bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const {
220aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2217bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2227bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2237bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getShuffleCost(ShuffleKind Kind, Type *Tp,
2247bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                          int Index = 0, Type *SubTp = 0) const {
225aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2267bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2277bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2287bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
2297bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                            Type *Src) const {
230aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2317bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2327bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2337bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getCFInstrCost(unsigned Opcode) const {
234aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2357bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2367bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2377bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
2387bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                              Type *CondTy = 0) const {
239aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2407bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2417bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2427bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getVectorInstrCost(unsigned Opcode, Type *Val,
2437bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                              unsigned Index = -1) const {
244aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2457bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2467bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2477bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
2487bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                           unsigned Alignment,
2497bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                           unsigned AddressSpace) const {
250aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2517bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2527bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2537bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getIntrinsicInstrCost(Intrinsic::ID ID,
2547bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                 Type *RetTy,
2557bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                                 ArrayRef<Type*> Tys) const {
256aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 1;
2577bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2587bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2597bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  unsigned getNumberOfParts(Type *Tp) const {
260aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth    return 0;
2617bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth  }
2627bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth};
2637bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
2647bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth} // end anonymous namespace
2657bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
266aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler CarruthINITIALIZE_AG_PASS(NoTTI, TargetTransformInfo, "notti",
2677bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth                   "No target information", true, true, true)
2687bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruthchar NoTTI::ID = 0;
2697bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth
270aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler CarruthImmutablePass *llvm::createNoTargetTransformInfoPass() {
271aeef83c6afa1e18d1cf9d359cc678ca0ad556175Chandler Carruth  return new NoTTI();
2727bdf6b00e04c177f22133b5d4be10cb246cb1e76Chandler Carruth}
273