LLVM  5.0.0
ARMTargetTransformInfo.h
Go to the documentation of this file.
1 //===-- ARMTargetTransformInfo.h - ARM specific TTI -------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This file a TargetTransformInfo::Concept conforming object specific to the
11 /// ARM target machine. It uses the target's detailed information to
12 /// provide more precise answers to certain TTI queries, while letting the
13 /// target independent and default TTI implementations handle the rest.
14 ///
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H
19 
20 #include "ARM.h"
21 #include "ARMTargetMachine.h"
25 
26 namespace llvm {
27 
28 class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
30  typedef TargetTransformInfo TTI;
31  friend BaseT;
32 
33  const ARMSubtarget *ST;
34  const ARMTargetLowering *TLI;
35 
36  // Currently the following features are excluded from InlineFeatureWhitelist.
37  // ModeThumb, FeatureNoARM, ModeSoftFloat, FeatureVFPOnlySP, FeatureD16
38  // Depending on whether they are set or unset, different
39  // instructions/registers are available. For example, inlining a callee with
40  // -thumb-mode in a caller with +thumb-mode, may cause the assembler to
41  // fail if the callee uses ARM only instructions, e.g. in inline asm.
42  const FeatureBitset InlineFeatureWhitelist = {
43  ARM::FeatureVFP2, ARM::FeatureVFP3, ARM::FeatureNEON, ARM::FeatureThumb2,
44  ARM::FeatureFP16, ARM::FeatureVFP4, ARM::FeatureFPARMv8,
45  ARM::FeatureFullFP16, ARM::FeatureHWDivThumb,
46  ARM::FeatureHWDivARM, ARM::FeatureDB, ARM::FeatureV7Clrex,
47  ARM::FeatureAcquireRelease, ARM::FeatureSlowFPBrcc,
48  ARM::FeaturePerfMon, ARM::FeatureTrustZone, ARM::Feature8MSecExt,
49  ARM::FeatureCrypto, ARM::FeatureCRC, ARM::FeatureRAS,
50  ARM::FeatureFPAO, ARM::FeatureFuseAES, ARM::FeatureZCZeroing,
51  ARM::FeatureProfUnpredicate, ARM::FeatureSlowVGETLNi32,
52  ARM::FeatureSlowVDUP32, ARM::FeaturePreferVMOVSR,
53  ARM::FeaturePrefISHSTBarrier, ARM::FeatureMuxedUnits,
54  ARM::FeatureSlowOddRegister, ARM::FeatureSlowLoadDSubreg,
55  ARM::FeatureDontWidenVMOVS, ARM::FeatureExpandMLx,
56  ARM::FeatureHasVMLxHazards, ARM::FeatureNEONForFPMovs,
57  ARM::FeatureNEONForFP, ARM::FeatureCheckVLDnAlign,
58  ARM::FeatureHasSlowFPVMLx, ARM::FeatureVMLxForwarding,
59  ARM::FeaturePref32BitThumb, ARM::FeatureAvoidPartialCPSR,
60  ARM::FeatureCheapPredicableCPSR, ARM::FeatureAvoidMOVsShOp,
61  ARM::FeatureHasRetAddrStack, ARM::FeatureHasNoBranchPredictor,
62  ARM::FeatureDSP, ARM::FeatureMP, ARM::FeatureVirtualization,
63  ARM::FeatureMClass, ARM::FeatureRClass, ARM::FeatureAClass,
64  ARM::FeatureNaClTrap, ARM::FeatureStrictAlign, ARM::FeatureLongCalls,
65  ARM::FeatureExecuteOnly, ARM::FeatureReserveR9, ARM::FeatureNoMovt,
66  ARM::FeatureNoNegativeImmediates
67  };
68 
69  const ARMSubtarget *getST() const { return ST; }
70  const ARMTargetLowering *getTLI() const { return TLI; }
71 
72 public:
73  explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
74  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
75  TLI(ST->getTargetLowering()) {}
76 
77  bool areInlineCompatible(const Function *Caller,
78  const Function *Callee) const;
79 
80  bool enableInterleavedAccessVectorization() { return true; }
81 
82  /// Floating-point computation using ARMv8 AArch32 Advanced
83  /// SIMD instructions remains unchanged from ARMv7. Only AArch64 SIMD
84  /// is IEEE-754 compliant, but it's not covered in this target.
86  return !ST->isTargetDarwin();
87  }
88 
89  /// \name Scalar TTI Implementations
90  /// @{
91 
92  int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
93  Type *Ty);
94 
96  int getIntImmCost(const APInt &Imm, Type *Ty);
97 
98  int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
99 
100  /// @}
101 
102  /// \name Vector TTI Implementations
103  /// @{
104 
105  unsigned getNumberOfRegisters(bool Vector) {
106  if (Vector) {
107  if (ST->hasNEON())
108  return 16;
109  return 0;
110  }
111 
112  if (ST->isThumb1Only())
113  return 8;
114  return 13;
115  }
116 
117  unsigned getRegisterBitWidth(bool Vector) const {
118  if (Vector) {
119  if (ST->hasNEON())
120  return 128;
121  return 0;
122  }
123 
124  return 32;
125  }
126 
127  unsigned getMaxInterleaveFactor(unsigned VF) {
128  return ST->getMaxInterleaveFactor();
129  }
130 
131  int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
132 
133  int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
134  const Instruction *I = nullptr);
135 
136  int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
137  const Instruction *I = nullptr);
138 
139  int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
140 
142  const SCEV *Ptr);
143 
144  int getFPOpCost(Type *Ty);
145 
147  unsigned Opcode, Type *Ty,
153 
154  int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
155  unsigned AddressSpace, const Instruction *I = nullptr);
156 
157  int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
158  ArrayRef<unsigned> Indices, unsigned Alignment,
159  unsigned AddressSpace);
160 
162  // In the ROPI and RWPI relocation models we can't have pointers to global
163  // variables or functions in constant data, so don't convert switches to
164  // lookup tables if any of the values would need relocation.
165  if (ST->isROPI() || ST->isRWPI())
166  return !C->needsRelocation();
167 
168  return true;
169  }
170  /// @}
171 };
172 
173 } // end namespace llvm
174 
175 #endif
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I=nullptr)
bool enableInterleavedAccessVectorization()
bool shouldBuildLookupTablesForConstant(Constant *C) const
unsigned getMaxInterleaveFactor(unsigned VF)
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
The main scalar evolution driver.
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
bool isROPI() const
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:40
bool isThumb1Only() const
Definition: ARMSubtarget.h:650
unsigned getIntImmCost(const APInt &Imm, Type *Ty)
bool isTargetDarwin() const
Definition: ARMSubtarget.h:580
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
#define F(x, y, z)
Definition: MD5.cpp:55
unsigned getNumberOfRegisters(bool Vector)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
bool hasNEON() const
Definition: ARMSubtarget.h:513
ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F)
Container class for subtarget features.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
Definition: Constants.cpp:427
unsigned getRegisterBitWidth(bool Vector) const
bool isRWPI() const
OperandValueProperties
Additional properties of an operand's values.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
AddressSpace
Definition: NVPTXBaseInfo.h:22
int getAddressComputationCost(Type *Val, ScalarEvolution *SE, const SCEV *Ptr)
Class for arbitrary precision integers.
Definition: APInt.h:69
const DataLayout & getDataLayout() const
bool isFPVectorizationPotentiallyUnsafe()
Floating-point computation using ARMv8 AArch32 Advanced SIMD instructions remains unchanged from ARMv...
This class represents an analyzed expression in the program.
#define C
Definition: LargeTest.cpp:25
unsigned getMaxInterleaveFactor() const
Definition: ARMSubtarget.h:715
int getIntImmCost(const APInt &Imm, Type *Ty)
#define I(x, y, z)
Definition: MD5.cpp:58
const unsigned Kind
int getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Op1Info=TTI::OK_AnyValue, TTI::OperandValueKind Op2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >())
static const Function * getParent(const Value *V)
int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty)
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
OperandValueKind
Additional information about an operand's possible values.
This pass exposes codegen information to IR-level passes.
int * Ptr
This file describes how to lower LLVM code to machine code.
ShuffleKind
The various kinds of shuffle patterns for vector queries.