Mercurial > hg > CbC > CbC_llvm
diff lib/Target/Hexagon/HexagonTargetTransformInfo.cpp @ 120:1172e4bd9c6f
update 4.0.0
author | mir3636 |
---|---|
date | Fri, 25 Nov 2016 19:14:25 +0900 |
parents | afa8332a0e37 |
children | 803732b1fca8 |
line wrap: on
line diff
--- a/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp Tue Jan 26 22:56:36 2016 +0900 +++ b/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp Fri Nov 25 19:14:25 2016 +0900 @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "HexagonTargetTransformInfo.h" +#include "llvm/IR/Instructions.h" #include "llvm/Support/Debug.h" using namespace llvm; @@ -36,3 +37,35 @@ unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const { return vector ? 0 : 32; } + +unsigned HexagonTTIImpl::getPrefetchDistance() const { + return getST()->getL1PrefetchDistance(); +} + +unsigned HexagonTTIImpl::getCacheLineSize() const { + return getST()->getL1CacheLineSize(); +} + +int HexagonTTIImpl::getUserCost(const User *U) { + auto isCastFoldedIntoLoad = [] (const CastInst *CI) -> bool { + if (!CI->isIntegerCast()) + return false; + const LoadInst *LI = dyn_cast<const LoadInst>(CI->getOperand(0)); + // Technically, this code could allow multiple uses of the load, and + // check if all the uses are the same extension operation, but this + // should be sufficient for most cases. + if (!LI || !LI->hasOneUse()) + return false; + + // Only extensions from an integer type shorter than 32-bit to i32 + // can be folded into the load. + unsigned SBW = CI->getSrcTy()->getIntegerBitWidth(); + unsigned DBW = CI->getDestTy()->getIntegerBitWidth(); + return DBW == 32 && (SBW < DBW); + }; + + if (const CastInst *CI = dyn_cast<const CastInst>(U)) + if (isCastFoldedIntoLoad(CI)) + return TargetTransformInfo::TCC_Free; + return BaseT::getUserCost(U); +}