2013-04-08 18:41:23 +00:00
|
|
|
//===- llvm/Analysis/TargetTransformInfo.cpp ------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
2015-05-27 18:44:32 +00:00
|
|
|
#include "llvm/Analysis/TargetTransformInfoImpl.h"
|
2014-11-24 09:08:18 +00:00
|
|
|
#include "llvm/IR/CallSite.h"
|
2013-04-08 18:41:23 +00:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
|
|
|
#include "llvm/IR/Instruction.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
2014-11-24 09:08:18 +00:00
|
|
|
#include "llvm/IR/IntrinsicInst.h"
|
2015-05-27 18:44:32 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
2014-11-24 09:08:18 +00:00
|
|
|
#include "llvm/IR/Operator.h"
|
2013-04-08 18:41:23 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2016-07-23 20:41:05 +00:00
|
|
|
#include <utility>
|
2013-04-08 18:41:23 +00:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-11-24 09:08:18 +00:00
|
|
|
#define DEBUG_TYPE "tti"
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
namespace {
|
|
|
|
/// \brief No-op implementation of the TTI interface using the utility base
|
|
|
|
/// classes.
|
|
|
|
///
|
|
|
|
/// This is used when no target specific information is available.
|
|
|
|
struct NoTTIImpl : TargetTransformInfoImplCRTPBase<NoTTIImpl> {
|
2015-08-07 23:01:33 +00:00
|
|
|
explicit NoTTIImpl(const DataLayout &DL)
|
2015-05-27 18:44:32 +00:00
|
|
|
: TargetTransformInfoImplCRTPBase<NoTTIImpl>(DL) {}
|
|
|
|
};
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 23:01:33 +00:00
|
|
|
TargetTransformInfo::TargetTransformInfo(const DataLayout &DL)
|
2015-05-27 18:44:32 +00:00
|
|
|
: TTIImpl(new Model<NoTTIImpl>(NoTTIImpl(DL))) {}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
TargetTransformInfo::~TargetTransformInfo() {}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
TargetTransformInfo::TargetTransformInfo(TargetTransformInfo &&Arg)
|
|
|
|
: TTIImpl(std::move(Arg.TTIImpl)) {}
|
|
|
|
|
|
|
|
TargetTransformInfo &TargetTransformInfo::operator=(TargetTransformInfo &&RHS) {
|
|
|
|
TTIImpl = std::move(RHS.TTIImpl);
|
|
|
|
return *this;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getOperationCost(unsigned Opcode, Type *Ty,
|
|
|
|
Type *OpTy) const {
|
|
|
|
int Cost = TTIImpl->getOperationCost(Opcode, Ty, OpTy);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getCallCost(FunctionType *FTy, int NumArgs) const {
|
|
|
|
int Cost = TTIImpl->getCallCost(FTy, NumArgs);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getCallCost(const Function *F,
|
|
|
|
ArrayRef<const Value *> Arguments) const {
|
|
|
|
int Cost = TTIImpl->getCallCost(F, Arguments);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
unsigned TargetTransformInfo::getInliningThresholdMultiplier() const {
|
|
|
|
return TTIImpl->getInliningThresholdMultiplier();
|
|
|
|
}
|
|
|
|
|
|
|
|
int TargetTransformInfo::getGEPCost(Type *PointeeType, const Value *Ptr,
|
|
|
|
ArrayRef<const Value *> Operands) const {
|
|
|
|
return TTIImpl->getGEPCost(PointeeType, Ptr, Operands);
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntrinsicCost(
|
|
|
|
Intrinsic::ID IID, Type *RetTy, ArrayRef<const Value *> Arguments) const {
|
|
|
|
int Cost = TTIImpl->getIntrinsicCost(IID, RetTy, Arguments);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getUserCost(const User *U) const {
|
|
|
|
int Cost = TTIImpl->getUserCost(U);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-22 00:04:03 +00:00
|
|
|
bool TargetTransformInfo::hasBranchDivergence() const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->hasBranchDivergence();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isSourceOfDivergence(const Value *V) const {
|
|
|
|
return TTIImpl->isSourceOfDivergence(V);
|
2013-12-22 00:04:03 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
bool TargetTransformInfo::isLoweredToCall(const Function *F) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isLoweredToCall(F);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
void TargetTransformInfo::getUnrollingPreferences(
|
|
|
|
Loop *L, UnrollingPreferences &UP) const {
|
|
|
|
return TTIImpl->getUnrollingPreferences(L, UP);
|
2013-12-22 00:04:03 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
bool TargetTransformInfo::isLegalAddImmediate(int64_t Imm) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isLegalAddImmediate(Imm);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalICmpImmediate(int64_t Imm) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isLegalICmpImmediate(Imm);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
bool TargetTransformInfo::isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
|
|
|
|
int64_t BaseOffset,
|
|
|
|
bool HasBaseReg,
|
2015-06-09 19:06:30 +00:00
|
|
|
int64_t Scale,
|
|
|
|
unsigned AddrSpace) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
|
2015-06-09 19:06:30 +00:00
|
|
|
Scale, AddrSpace);
|
2015-01-18 16:17:27 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
bool TargetTransformInfo::isLegalMaskedStore(Type *DataType) const {
|
|
|
|
return TTIImpl->isLegalMaskedStore(DataType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType) const {
|
|
|
|
return TTIImpl->isLegalMaskedLoad(DataType);
|
2015-01-18 16:17:27 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
bool TargetTransformInfo::isLegalMaskedGather(Type *DataType) const {
|
|
|
|
return TTIImpl->isLegalMaskedGather(DataType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalMaskedScatter(Type *DataType) const {
|
|
|
|
return TTIImpl->isLegalMaskedGather(DataType);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-22 00:04:03 +00:00
|
|
|
int TargetTransformInfo::getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
|
|
|
|
int64_t BaseOffset,
|
|
|
|
bool HasBaseReg,
|
2015-06-09 19:06:30 +00:00
|
|
|
int64_t Scale,
|
|
|
|
unsigned AddrSpace) const {
|
2015-12-30 11:46:15 +00:00
|
|
|
int Cost = TTIImpl->getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg,
|
|
|
|
Scale, AddrSpace);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-12-22 00:04:03 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
bool TargetTransformInfo::isFoldableMemAccessOffset(Instruction *I,
|
|
|
|
int64_t Offset) const {
|
|
|
|
return TTIImpl->isFoldableMemAccessOffset(I, Offset);
|
|
|
|
}
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
bool TargetTransformInfo::isTruncateFree(Type *Ty1, Type *Ty2) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isTruncateFree(Ty1, Ty2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isProfitableToHoist(Instruction *I) const {
|
|
|
|
return TTIImpl->isProfitableToHoist(I);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->isTypeLegal(Ty);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getJumpBufAlignment() const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getJumpBufAlignment();
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getJumpBufSize() const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getJumpBufSize();
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::shouldBuildLookupTables() const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->shouldBuildLookupTables();
|
|
|
|
}
|
2017-01-02 19:17:04 +00:00
|
|
|
bool TargetTransformInfo::shouldBuildLookupTablesForConstant(Constant *C) const {
|
|
|
|
return TTIImpl->shouldBuildLookupTablesForConstant(C);
|
|
|
|
}
|
2015-05-27 18:44:32 +00:00
|
|
|
|
|
|
|
bool TargetTransformInfo::enableAggressiveInterleaving(bool LoopHasReductions) const {
|
|
|
|
return TTIImpl->enableAggressiveInterleaving(LoopHasReductions);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
bool TargetTransformInfo::enableInterleavedAccessVectorization() const {
|
|
|
|
return TTIImpl->enableInterleavedAccessVectorization();
|
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
bool TargetTransformInfo::isFPVectorizationPotentiallyUnsafe() const {
|
|
|
|
return TTIImpl->isFPVectorizationPotentiallyUnsafe();
|
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
bool TargetTransformInfo::allowsMisalignedMemoryAccesses(LLVMContext &Context,
|
|
|
|
unsigned BitWidth,
|
2016-07-23 20:41:05 +00:00
|
|
|
unsigned AddressSpace,
|
|
|
|
unsigned Alignment,
|
|
|
|
bool *Fast) const {
|
2017-01-02 19:17:04 +00:00
|
|
|
return TTIImpl->allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
|
2016-07-23 20:41:05 +00:00
|
|
|
Alignment, Fast);
|
|
|
|
}
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
TargetTransformInfo::PopcntSupportKind
|
|
|
|
TargetTransformInfo::getPopcntSupport(unsigned IntTyWidthInBit) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getPopcntSupport(IntTyWidthInBit);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2013-12-22 00:04:03 +00:00
|
|
|
bool TargetTransformInfo::haveFastSqrt(Type *Ty) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->haveFastSqrt(Ty);
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getFPOpCost(Type *Ty) const {
|
|
|
|
int Cost = TTIImpl->getFPOpCost(Ty);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-12-22 00:04:03 +00:00
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
int TargetTransformInfo::getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
|
|
|
|
const APInt &Imm,
|
|
|
|
Type *Ty) const {
|
|
|
|
int Cost = TTIImpl->getIntImmCodeSizeCost(Opcode, Idx, Imm, Ty);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntImmCost(const APInt &Imm, Type *Ty) const {
|
|
|
|
int Cost = TTIImpl->getIntImmCost(Imm, Ty);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntImmCost(unsigned Opcode, unsigned Idx,
|
|
|
|
const APInt &Imm, Type *Ty) const {
|
|
|
|
int Cost = TTIImpl->getIntImmCost(Opcode, Idx, Imm, Ty);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2014-11-24 09:08:18 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntImmCost(Intrinsic::ID IID, unsigned Idx,
|
|
|
|
const APInt &Imm, Type *Ty) const {
|
|
|
|
int Cost = TTIImpl->getIntImmCost(IID, Idx, Imm, Ty);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2014-11-24 09:08:18 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 18:41:23 +00:00
|
|
|
unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getNumberOfRegisters(Vector);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getRegisterBitWidth(Vector);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
unsigned TargetTransformInfo::getCacheLineSize() const {
|
|
|
|
return TTIImpl->getCacheLineSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getPrefetchDistance() const {
|
|
|
|
return TTIImpl->getPrefetchDistance();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getMinPrefetchStride() const {
|
|
|
|
return TTIImpl->getMinPrefetchStride();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getMaxPrefetchIterationsAhead() const {
|
|
|
|
return TTIImpl->getMaxPrefetchIterationsAhead();
|
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
|
|
|
|
return TTIImpl->getMaxInterleaveFactor(VF);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getArithmeticInstrCost(
|
2015-05-27 18:44:32 +00:00
|
|
|
unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
|
|
|
|
OperandValueKind Opd2Info, OperandValueProperties Opd1PropInfo,
|
2015-01-18 16:17:27 +00:00
|
|
|
OperandValueProperties Opd2PropInfo) const {
|
2015-12-30 11:46:15 +00:00
|
|
|
int Cost = TTIImpl->getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
|
|
|
|
Opd1PropInfo, Opd2PropInfo);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Ty, int Index,
|
|
|
|
Type *SubTp) const {
|
|
|
|
int Cost = TTIImpl->getShuffleCost(Kind, Ty, Index, SubTp);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getCastInstrCost(unsigned Opcode, Type *Dst,
|
|
|
|
Type *Src) const {
|
|
|
|
int Cost = TTIImpl->getCastInstrCost(Opcode, Dst, Src);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
int TargetTransformInfo::getExtractWithExtendCost(unsigned Opcode, Type *Dst,
|
|
|
|
VectorType *VecTy,
|
|
|
|
unsigned Index) const {
|
|
|
|
int Cost = TTIImpl->getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getCFInstrCost(unsigned Opcode) const {
|
|
|
|
int Cost = TTIImpl->getCFInstrCost(Opcode);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
|
|
|
|
Type *CondTy) const {
|
|
|
|
int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
|
|
|
|
unsigned Index) const {
|
|
|
|
int Cost = TTIImpl->getVectorInstrCost(Opcode, Val, Index);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
|
|
|
|
unsigned Alignment,
|
|
|
|
unsigned AddressSpace) const {
|
|
|
|
int Cost = TTIImpl->getMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
|
|
|
|
unsigned Alignment,
|
|
|
|
unsigned AddressSpace) const {
|
|
|
|
int Cost =
|
|
|
|
TTIImpl->getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
|
|
|
|
Value *Ptr, bool VariableMask,
|
|
|
|
unsigned Alignment) const {
|
|
|
|
int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
|
|
|
|
Alignment);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2015-05-27 18:44:32 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getInterleavedMemoryOpCost(
|
2015-06-09 19:06:30 +00:00
|
|
|
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
|
|
|
|
unsigned Alignment, unsigned AddressSpace) const {
|
2015-12-30 11:46:15 +00:00
|
|
|
int Cost = TTIImpl->getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
|
|
|
|
Alignment, AddressSpace);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2015-06-09 19:06:30 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
|
2016-07-23 20:41:05 +00:00
|
|
|
ArrayRef<Type *> Tys,
|
|
|
|
FastMathFlags FMF) const {
|
|
|
|
int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Tys, FMF);
|
2015-12-30 11:46:15 +00:00
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2015-05-27 18:44:32 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy,
|
2016-07-23 20:41:05 +00:00
|
|
|
ArrayRef<Value *> Args,
|
|
|
|
FastMathFlags FMF) const {
|
|
|
|
int Cost = TTIImpl->getIntrinsicInstrCost(ID, RetTy, Args, FMF);
|
2015-12-30 11:46:15 +00:00
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TargetTransformInfo::getCallInstrCost(Function *F, Type *RetTy,
|
|
|
|
ArrayRef<Type *> Tys) const {
|
|
|
|
int Cost = TTIImpl->getCallInstrCost(F, RetTy, Tys);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTIImpl->getNumberOfParts(Tp);
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getAddressComputationCost(Type *Tp,
|
2017-01-06 20:13:21 +00:00
|
|
|
ScalarEvolution *SE,
|
|
|
|
const SCEV *Ptr) const {
|
|
|
|
int Cost = TTIImpl->getAddressComputationCost(Tp, SE, Ptr);
|
2015-12-30 11:46:15 +00:00
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-12-22 00:04:03 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
int TargetTransformInfo::getReductionCost(unsigned Opcode, Type *Ty,
|
|
|
|
bool IsPairwiseForm) const {
|
|
|
|
int Cost = TTIImpl->getReductionCost(Opcode, Ty, IsPairwiseForm);
|
|
|
|
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
|
|
|
return Cost;
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
unsigned
|
|
|
|
TargetTransformInfo::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
|
|
|
|
return TTIImpl->getCostOfKeepingLiveOverCall(Tys);
|
2015-01-18 16:17:27 +00:00
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
|
|
|
|
MemIntrinsicInfo &Info) const {
|
|
|
|
return TTIImpl->getTgtMemIntrinsic(Inst, Info);
|
|
|
|
}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
Value *TargetTransformInfo::getOrCreateResultFromMemIntrinsic(
|
|
|
|
IntrinsicInst *Inst, Type *ExpectedType) const {
|
|
|
|
return TTIImpl->getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
|
|
|
|
}
|
2015-01-18 16:17:27 +00:00
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
bool TargetTransformInfo::areInlineCompatible(const Function *Caller,
|
|
|
|
const Function *Callee) const {
|
|
|
|
return TTIImpl->areInlineCompatible(Caller, Callee);
|
2015-07-05 14:21:36 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
unsigned TargetTransformInfo::getLoadStoreVecRegBitWidth(unsigned AS) const {
|
|
|
|
return TTIImpl->getLoadStoreVecRegBitWidth(AS);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalToVectorizeLoad(LoadInst *LI) const {
|
|
|
|
return TTIImpl->isLegalToVectorizeLoad(LI);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalToVectorizeStore(StoreInst *SI) const {
|
|
|
|
return TTIImpl->isLegalToVectorizeStore(SI);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalToVectorizeLoadChain(
|
|
|
|
unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
|
|
|
|
return TTIImpl->isLegalToVectorizeLoadChain(ChainSizeInBytes, Alignment,
|
|
|
|
AddrSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TargetTransformInfo::isLegalToVectorizeStoreChain(
|
|
|
|
unsigned ChainSizeInBytes, unsigned Alignment, unsigned AddrSpace) const {
|
|
|
|
return TTIImpl->isLegalToVectorizeStoreChain(ChainSizeInBytes, Alignment,
|
|
|
|
AddrSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getLoadVectorFactor(unsigned VF,
|
|
|
|
unsigned LoadSize,
|
|
|
|
unsigned ChainSizeInBytes,
|
|
|
|
VectorType *VecTy) const {
|
|
|
|
return TTIImpl->getLoadVectorFactor(VF, LoadSize, ChainSizeInBytes, VecTy);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned TargetTransformInfo::getStoreVectorFactor(unsigned VF,
|
|
|
|
unsigned StoreSize,
|
|
|
|
unsigned ChainSizeInBytes,
|
|
|
|
VectorType *VecTy) const {
|
|
|
|
return TTIImpl->getStoreVectorFactor(VF, StoreSize, ChainSizeInBytes, VecTy);
|
|
|
|
}
|
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
TargetTransformInfo::Concept::~Concept() {}
|
|
|
|
|
|
|
|
TargetIRAnalysis::TargetIRAnalysis() : TTICallback(&getDefaultTTI) {}
|
|
|
|
|
|
|
|
TargetIRAnalysis::TargetIRAnalysis(
|
2015-12-30 11:46:15 +00:00
|
|
|
std::function<Result(const Function &)> TTICallback)
|
2016-07-23 20:41:05 +00:00
|
|
|
: TTICallback(std::move(TTICallback)) {}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2016-07-23 20:41:05 +00:00
|
|
|
TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
|
2017-01-02 19:17:04 +00:00
|
|
|
FunctionAnalysisManager &) {
|
2015-05-27 18:44:32 +00:00
|
|
|
return TTICallback(F);
|
|
|
|
}
|
|
|
|
|
2017-01-02 19:17:04 +00:00
|
|
|
AnalysisKey TargetIRAnalysis::Key;
|
2015-05-27 18:44:32 +00:00
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
TargetIRAnalysis::Result TargetIRAnalysis::getDefaultTTI(const Function &F) {
|
2015-08-07 23:01:33 +00:00
|
|
|
return Result(F.getParent()->getDataLayout());
|
2015-05-27 18:44:32 +00:00
|
|
|
}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
// Register the basic pass.
|
|
|
|
INITIALIZE_PASS(TargetTransformInfoWrapperPass, "tti",
|
|
|
|
"Target Transform Information", false, true)
|
|
|
|
char TargetTransformInfoWrapperPass::ID = 0;
|
|
|
|
|
|
|
|
void TargetTransformInfoWrapperPass::anchor() {}
|
|
|
|
|
|
|
|
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
|
|
|
|
: ImmutablePass(ID) {
|
|
|
|
initializeTargetTransformInfoWrapperPassPass(
|
|
|
|
*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
|
|
|
|
TargetIRAnalysis TIRA)
|
|
|
|
: ImmutablePass(ID), TIRA(std::move(TIRA)) {
|
|
|
|
initializeTargetTransformInfoWrapperPassPass(
|
|
|
|
*PassRegistry::getPassRegistry());
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
|
2017-01-02 19:17:04 +00:00
|
|
|
FunctionAnalysisManager DummyFAM;
|
2016-07-23 20:41:05 +00:00
|
|
|
TTI = TIRA.run(F, DummyFAM);
|
2015-05-27 18:44:32 +00:00
|
|
|
return *TTI;
|
|
|
|
}
|
2013-04-08 18:41:23 +00:00
|
|
|
|
2015-05-27 18:44:32 +00:00
|
|
|
ImmutablePass *
|
|
|
|
llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
|
|
|
|
return new TargetTransformInfoWrapperPass(std::move(TIRA));
|
2013-04-08 18:41:23 +00:00
|
|
|
}
|