2015-01-31 19:17:59 +08:00
|
|
|
//===-- AMDGPUTargetTransformInfo.h - AMDGPU specific TTI -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
/// This file a TargetTransformInfo::Concept conforming object specific to the
|
|
|
|
/// AMDGPU target machine. It uses the target's detailed information to
|
|
|
|
/// provide more precise answers to certain TTI queries, while letting the
|
|
|
|
/// target independent and default TTI implementations handle the rest.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETTRANSFORMINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUTARGETTRANSFORMINFO_H
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
#include "AMDGPU.h"
|
|
|
|
#include "AMDGPUTargetMachine.h"
|
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
|
|
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2016-03-25 09:00:32 +08:00
|
|
|
class AMDGPUTargetLowering;
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
class AMDGPUTTIImpl final : public BasicTTIImplBase<AMDGPUTTIImpl> {
|
2015-01-31 19:17:59 +08:00
|
|
|
typedef BasicTTIImplBase<AMDGPUTTIImpl> BaseT;
|
|
|
|
typedef TargetTransformInfo TTI;
|
2015-02-01 22:01:15 +08:00
|
|
|
friend BaseT;
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
const AMDGPUSubtarget *ST;
|
2015-02-01 22:01:15 +08:00
|
|
|
const AMDGPUTargetLowering *TLI;
|
2017-01-31 09:20:54 +08:00
|
|
|
bool IsGraphicsShader;
|
2015-02-01 22:01:15 +08:00
|
|
|
|
2015-02-01 22:22:17 +08:00
|
|
|
const AMDGPUSubtarget *getST() const { return ST; }
|
2015-02-01 22:01:15 +08:00
|
|
|
const AMDGPUTargetLowering *getTLI() const { return TLI; }
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2016-03-25 09:00:32 +08:00
|
|
|
|
|
|
|
static inline int getFullRateInstrCost() {
|
|
|
|
return TargetTransformInfo::TCC_Basic;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int getHalfRateInstrCost() {
|
|
|
|
return 2 * TargetTransformInfo::TCC_Basic;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: The size is usually 8 bytes, but takes 4x as many cycles. Maybe
|
|
|
|
// should be 2 or 4.
|
|
|
|
static inline int getQuarterRateInstrCost() {
|
|
|
|
return 3 * TargetTransformInfo::TCC_Basic;
|
|
|
|
}
|
|
|
|
|
|
|
|
// On some parts, normal fp64 operations are half rate, and others
|
|
|
|
// quarter. This also applies to some integer operations.
|
|
|
|
inline int get64BitInstrCost() const {
|
|
|
|
return ST->hasHalfRate64Ops() ?
|
|
|
|
getHalfRateInstrCost() : getQuarterRateInstrCost();
|
|
|
|
}
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
public:
|
2016-06-28 04:48:03 +08:00
|
|
|
explicit AMDGPUTTIImpl(const AMDGPUTargetMachine *TM, const Function &F)
|
|
|
|
: BaseT(TM, F.getParent()->getDataLayout()),
|
|
|
|
ST(TM->getSubtargetImpl(F)),
|
2017-01-31 09:20:54 +08:00
|
|
|
TLI(ST->getTargetLowering()),
|
|
|
|
IsGraphicsShader(AMDGPU::isShader(F.getCallingConv())) {}
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
bool hasBranchDivergence() { return true; }
|
|
|
|
|
2015-02-01 22:31:23 +08:00
|
|
|
void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) {
|
|
|
|
assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
|
2016-05-19 00:10:19 +08:00
|
|
|
return TTI::PSK_FastHardware;
|
2015-01-31 19:17:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getNumberOfRegisters(bool Vector);
|
Const correctness for TTI::getRegisterBitWidth
Summary: The method TargetTransformInfo::getRegisterBitWidth() is declared const, but the type erasing implementation classes (TargetTransformInfo::Concept & TargetTransformInfo::Model) that were introduced by Chandler in https://reviews.llvm.org/D7293 do not have the method declared const. This is an NFC to tidy up the const consistency between TTI and its implementation.
Reviewers: chandlerc, rnk, reames
Reviewed By: reames
Subscribers: reames, jfb, arsenm, dschuff, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, llvm-commits
Differential Revision: https://reviews.llvm.org/D33903
llvm-svn: 305189
2017-06-12 22:22:21 +08:00
|
|
|
unsigned getRegisterBitWidth(bool Vector) const;
|
2016-10-03 18:31:34 +08:00
|
|
|
unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const;
|
2017-02-23 11:58:53 +08:00
|
|
|
|
|
|
|
bool isLegalToVectorizeMemChain(unsigned ChainSizeInBytes,
|
|
|
|
unsigned Alignment,
|
|
|
|
unsigned AddrSpace) const;
|
|
|
|
bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes,
|
|
|
|
unsigned Alignment,
|
|
|
|
unsigned AddrSpace) const;
|
|
|
|
bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
|
|
|
|
unsigned Alignment,
|
|
|
|
unsigned AddrSpace) const;
|
|
|
|
|
2015-05-07 01:12:25 +08:00
|
|
|
unsigned getMaxInterleaveFactor(unsigned VF);
|
2015-12-02 03:08:39 +08:00
|
|
|
|
2016-03-25 09:00:32 +08:00
|
|
|
int getArithmeticInstrCost(
|
|
|
|
unsigned Opcode, Type *Ty,
|
|
|
|
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
|
|
|
TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
|
|
|
|
TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
|
[X86] updating TTI costs for arithmetic instructions on X86\SLM arch.
updated instructions:
pmulld, pmullw, pmulhw, mulsd, mulps, mulpd, divss, divps, divsd, divpd, addpd and subpd.
special optimization case which replaces pmulld with pmullw\pmulhw\pshuf seq.
In case if the real operands bitwidth <= 16.
Differential Revision: https://reviews.llvm.org/D28104
llvm-svn: 291657
2017-01-11 16:23:37 +08:00
|
|
|
TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
|
|
|
|
ArrayRef<const Value *> Args = ArrayRef<const Value *>());
|
2016-03-25 09:00:32 +08:00
|
|
|
|
2015-12-17 02:37:19 +08:00
|
|
|
unsigned getCFInstrCost(unsigned Opcode);
|
|
|
|
|
2015-12-02 03:08:39 +08:00
|
|
|
int getVectorInstrCost(unsigned Opcode, Type *ValTy, unsigned Index);
|
2015-12-16 02:04:38 +08:00
|
|
|
bool isSourceOfDivergence(const Value *V) const;
|
2017-06-16 03:33:10 +08:00
|
|
|
bool isAlwaysUniform(const Value *V) const;
|
2016-07-07 01:30:56 +08:00
|
|
|
|
2017-01-31 09:20:54 +08:00
|
|
|
unsigned getFlatAddressSpace() const {
|
|
|
|
// Don't bother running InferAddressSpaces pass on graphics shaders which
|
|
|
|
// don't use flat addressing.
|
|
|
|
if (IsGraphicsShader)
|
|
|
|
return -1;
|
2017-02-01 07:48:37 +08:00
|
|
|
return ST->hasFlatAddressSpace() ?
|
2017-03-27 22:04:01 +08:00
|
|
|
ST->getAMDGPUAS().FLAT_ADDRESS : ST->getAMDGPUAS().UNKNOWN_ADDRESS_SPACE;
|
2017-01-31 09:20:54 +08:00
|
|
|
}
|
|
|
|
|
2016-07-07 01:30:56 +08:00
|
|
|
unsigned getVectorSplitCost() { return 0; }
|
2017-05-11 05:29:33 +08:00
|
|
|
|
|
|
|
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
|
|
|
|
Type *SubTp);
|
2015-01-31 19:17:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|