2017-09-21 05:35:51 +08:00
|
|
|
//===- ARMTargetTransformInfo.h - ARM specific TTI --------------*- C++ -*-===//
|
2015-01-31 19:17:59 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2017-09-21 05:35:51 +08:00
|
|
|
//
|
2015-01-31 19:17:59 +08:00
|
|
|
/// \file
|
|
|
|
/// This file a TargetTransformInfo::Concept conforming object specific to the
|
|
|
|
/// ARM 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.
|
2017-09-21 05:35:51 +08:00
|
|
|
//
|
2015-01-31 19:17:59 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
|
|
|
|
|
|
|
|
#include "ARM.h"
|
2017-09-21 05:35:51 +08:00
|
|
|
#include "ARMSubtarget.h"
|
2015-01-31 19:17:59 +08:00
|
|
|
#include "ARMTargetMachine.h"
|
2017-09-21 05:35:51 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2015-01-31 19:17:59 +08:00
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
|
|
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
2017-09-21 05:35:51 +08:00
|
|
|
#include "llvm/IR/Constant.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/MC/SubtargetFeature.h"
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2017-09-21 05:35:51 +08:00
|
|
|
class APInt;
|
|
|
|
class ARMTargetLowering;
|
|
|
|
class Instruction;
|
|
|
|
class Loop;
|
|
|
|
class SCEV;
|
|
|
|
class ScalarEvolution;
|
|
|
|
class Type;
|
|
|
|
class Value;
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
|
2017-09-21 05:35:51 +08:00
|
|
|
using BaseT = BasicTTIImplBase<ARMTTIImpl>;
|
|
|
|
using TTI = TargetTransformInfo;
|
|
|
|
|
2015-02-01 22:01:15 +08:00
|
|
|
friend BaseT;
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
const ARMSubtarget *ST;
|
|
|
|
const ARMTargetLowering *TLI;
|
|
|
|
|
[ARM] Inline callee if its target-features are a subset of the caller
Summary:
Similar to X86, it should be safe to inline callees if their
target-features are a subset of the caller. As some subtarget features
provide different instructions depending on whether they are set or
unset (e.g. ThumbMode and ModeSoftFloat), we use a whitelist of
target-features describing hardware capabilities only.
Reviewers: kristof.beyls, rengolin, t.p.northover, SjoerdMeijer, peter.smith, silviu.baranga, efriedma
Reviewed By: SjoerdMeijer, efriedma
Subscribers: dschuff, efriedma, aemerson, sdardis, javed.absar, arichardson, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D34697
llvm-svn: 307889
2017-07-13 16:26:17 +08:00
|
|
|
// Currently the following features are excluded from InlineFeatureWhitelist.
|
|
|
|
// ModeThumb, FeatureNoARM, ModeSoftFloat, FeatureVFPOnlySP, FeatureD16
|
|
|
|
// Depending on whether they are set or unset, different
|
|
|
|
// instructions/registers are available. For example, inlining a callee with
|
|
|
|
// -thumb-mode in a caller with +thumb-mode, may cause the assembler to
|
|
|
|
// fail if the callee uses ARM only instructions, e.g. in inline asm.
|
|
|
|
const FeatureBitset InlineFeatureWhitelist = {
|
|
|
|
ARM::FeatureVFP2, ARM::FeatureVFP3, ARM::FeatureNEON, ARM::FeatureThumb2,
|
|
|
|
ARM::FeatureFP16, ARM::FeatureVFP4, ARM::FeatureFPARMv8,
|
|
|
|
ARM::FeatureFullFP16, ARM::FeatureHWDivThumb,
|
|
|
|
ARM::FeatureHWDivARM, ARM::FeatureDB, ARM::FeatureV7Clrex,
|
|
|
|
ARM::FeatureAcquireRelease, ARM::FeatureSlowFPBrcc,
|
|
|
|
ARM::FeaturePerfMon, ARM::FeatureTrustZone, ARM::Feature8MSecExt,
|
|
|
|
ARM::FeatureCrypto, ARM::FeatureCRC, ARM::FeatureRAS,
|
|
|
|
ARM::FeatureFPAO, ARM::FeatureFuseAES, ARM::FeatureZCZeroing,
|
|
|
|
ARM::FeatureProfUnpredicate, ARM::FeatureSlowVGETLNi32,
|
|
|
|
ARM::FeatureSlowVDUP32, ARM::FeaturePreferVMOVSR,
|
|
|
|
ARM::FeaturePrefISHSTBarrier, ARM::FeatureMuxedUnits,
|
|
|
|
ARM::FeatureSlowOddRegister, ARM::FeatureSlowLoadDSubreg,
|
|
|
|
ARM::FeatureDontWidenVMOVS, ARM::FeatureExpandMLx,
|
|
|
|
ARM::FeatureHasVMLxHazards, ARM::FeatureNEONForFPMovs,
|
|
|
|
ARM::FeatureNEONForFP, ARM::FeatureCheckVLDnAlign,
|
|
|
|
ARM::FeatureHasSlowFPVMLx, ARM::FeatureVMLxForwarding,
|
|
|
|
ARM::FeaturePref32BitThumb, ARM::FeatureAvoidPartialCPSR,
|
|
|
|
ARM::FeatureCheapPredicableCPSR, ARM::FeatureAvoidMOVsShOp,
|
|
|
|
ARM::FeatureHasRetAddrStack, ARM::FeatureHasNoBranchPredictor,
|
|
|
|
ARM::FeatureDSP, ARM::FeatureMP, ARM::FeatureVirtualization,
|
|
|
|
ARM::FeatureMClass, ARM::FeatureRClass, ARM::FeatureAClass,
|
|
|
|
ARM::FeatureNaClTrap, ARM::FeatureStrictAlign, ARM::FeatureLongCalls,
|
|
|
|
ARM::FeatureExecuteOnly, ARM::FeatureReserveR9, ARM::FeatureNoMovt,
|
|
|
|
ARM::FeatureNoNegativeImmediates
|
|
|
|
};
|
|
|
|
|
2015-02-01 22:22:17 +08:00
|
|
|
const ARMSubtarget *getST() const { return ST; }
|
2015-02-01 22:01:15 +08:00
|
|
|
const ARMTargetLowering *getTLI() const { return TLI; }
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
public:
|
2015-09-17 07:38:13 +08:00
|
|
|
explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
|
2015-07-09 10:08:42 +08:00
|
|
|
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
|
|
|
TLI(ST->getTargetLowering()) {}
|
2015-01-31 19:17:59 +08:00
|
|
|
|
[ARM] Inline callee if its target-features are a subset of the caller
Summary:
Similar to X86, it should be safe to inline callees if their
target-features are a subset of the caller. As some subtarget features
provide different instructions depending on whether they are set or
unset (e.g. ThumbMode and ModeSoftFloat), we use a whitelist of
target-features describing hardware capabilities only.
Reviewers: kristof.beyls, rengolin, t.p.northover, SjoerdMeijer, peter.smith, silviu.baranga, efriedma
Reviewed By: SjoerdMeijer, efriedma
Subscribers: dschuff, efriedma, aemerson, sdardis, javed.absar, arichardson, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D34697
llvm-svn: 307889
2017-07-13 16:26:17 +08:00
|
|
|
bool areInlineCompatible(const Function *Caller,
|
|
|
|
const Function *Callee) const;
|
|
|
|
|
2015-09-01 19:19:15 +08:00
|
|
|
bool enableInterleavedAccessVectorization() { return true; }
|
|
|
|
|
2016-04-18 20:06:47 +08:00
|
|
|
/// Floating-point computation using ARMv8 AArch32 Advanced
|
|
|
|
/// SIMD instructions remains unchanged from ARMv7. Only AArch64 SIMD
|
|
|
|
/// is IEEE-754 compliant, but it's not covered in this target.
|
2016-04-15 04:42:18 +08:00
|
|
|
bool isFPVectorizationPotentiallyUnsafe() {
|
2016-04-18 20:06:47 +08:00
|
|
|
return !ST->isTargetDarwin();
|
2016-04-15 04:42:18 +08:00
|
|
|
}
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
/// \name Scalar TTI Implementations
|
|
|
|
/// @{
|
|
|
|
|
2016-07-14 15:44:20 +08:00
|
|
|
int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
|
|
|
|
Type *Ty);
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
using BaseT::getIntImmCost;
|
2015-08-06 02:08:10 +08:00
|
|
|
int getIntImmCost(const APInt &Imm, Type *Ty);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2016-04-16 02:17:18 +08:00
|
|
|
int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
|
2016-04-14 07:08:27 +08:00
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
/// \name Vector TTI Implementations
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
unsigned getNumberOfRegisters(bool Vector) {
|
|
|
|
if (Vector) {
|
|
|
|
if (ST->hasNEON())
|
|
|
|
return 16;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ST->isThumb1Only())
|
|
|
|
return 8;
|
|
|
|
return 13;
|
|
|
|
}
|
|
|
|
|
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 {
|
2015-01-31 19:17:59 +08:00
|
|
|
if (Vector) {
|
|
|
|
if (ST->hasNEON())
|
|
|
|
return 128;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
2015-05-07 01:12:25 +08:00
|
|
|
unsigned getMaxInterleaveFactor(unsigned VF) {
|
2016-06-27 17:08:23 +08:00
|
|
|
return ST->getMaxInterleaveFactor();
|
2015-01-31 19:17:59 +08:00
|
|
|
}
|
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-04-12 19:49:08 +08:00
|
|
|
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
|
|
|
|
const Instruction *I = nullptr);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-04-12 19:49:08 +08:00
|
|
|
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
|
|
|
|
const Instruction *I = nullptr);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-01-05 22:03:41 +08:00
|
|
|
int getAddressComputationCost(Type *Val, ScalarEvolution *SE,
|
|
|
|
const SCEV *Ptr);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getArithmeticInstrCost(
|
2015-01-31 19:17:59 +08:00
|
|
|
unsigned Opcode, Type *Ty,
|
|
|
|
TTI::OperandValueKind Op1Info = TTI::OK_AnyValue,
|
|
|
|
TTI::OperandValueKind Op2Info = 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 *>());
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
2017-04-12 19:49:08 +08:00
|
|
|
unsigned AddressSpace, const Instruction *I = nullptr);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
|
|
|
|
ArrayRef<unsigned> Indices, unsigned Alignment,
|
|
|
|
unsigned AddressSpace);
|
2016-10-07 16:48:24 +08:00
|
|
|
|
2017-07-25 16:51:30 +08:00
|
|
|
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
|
|
|
|
TTI::UnrollingPreferences &UP);
|
|
|
|
|
2016-10-07 16:48:24 +08:00
|
|
|
bool shouldBuildLookupTablesForConstant(Constant *C) const {
|
|
|
|
// In the ROPI and RWPI relocation models we can't have pointers to global
|
|
|
|
// variables or functions in constant data, so don't convert switches to
|
|
|
|
// lookup tables if any of the values would need relocation.
|
|
|
|
if (ST->isROPI() || ST->isRWPI())
|
|
|
|
return !C->needsRelocation();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-01-31 19:17:59 +08:00
|
|
|
/// @}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2017-09-21 05:35:51 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
|