blob: 8dcba8dca8544d69fad7609ba157ea0a30a3c117 [file] [log] [blame]
Chandler Carruth93dcdc42015-01-31 11:17:59 +00001//===-- 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"
22#include "llvm/Analysis/TargetTransformInfo.h"
23#include "llvm/CodeGen/BasicTTIImpl.h"
24#include "llvm/Target/TargetLowering.h"
25
26namespace llvm {
27
28class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
29 typedef BasicTTIImplBase<ARMTTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
31
32 const ARMSubtarget *ST;
33 const ARMTargetLowering *TLI;
34
35 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
36 /// are set if the result needs to be inserted and/or extracted from vectors.
37 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
38
39public:
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000040 explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, Function &F)
41 : BaseT(TM), ST(TM->getSubtargetImpl(F)), TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000042
43 // Provide value semantics. MSVC requires that we spell all of these out.
44 ARMTTIImpl(const ARMTTIImpl &Arg)
45 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
46 ARMTTIImpl(ARMTTIImpl &&Arg)
47 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
48 TLI(std::move(Arg.TLI)) {}
49 ARMTTIImpl &operator=(const ARMTTIImpl &RHS) {
50 BaseT::operator=(static_cast<const BaseT &>(RHS));
51 ST = RHS.ST;
52 TLI = RHS.TLI;
53 return *this;
54 }
55 ARMTTIImpl &operator=(ARMTTIImpl &&RHS) {
56 BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
57 ST = std::move(RHS.ST);
58 TLI = std::move(RHS.TLI);
59 return *this;
60 }
61
62 /// \name Scalar TTI Implementations
63 /// @{
64
65 using BaseT::getIntImmCost;
66 unsigned getIntImmCost(const APInt &Imm, Type *Ty);
67
68 /// @}
69
70 /// \name Vector TTI Implementations
71 /// @{
72
73 unsigned getNumberOfRegisters(bool Vector) {
74 if (Vector) {
75 if (ST->hasNEON())
76 return 16;
77 return 0;
78 }
79
80 if (ST->isThumb1Only())
81 return 8;
82 return 13;
83 }
84
85 unsigned getRegisterBitWidth(bool Vector) {
86 if (Vector) {
87 if (ST->hasNEON())
88 return 128;
89 return 0;
90 }
91
92 return 32;
93 }
94
95 unsigned getMaxInterleaveFactor() {
96 // These are out of order CPUs:
97 if (ST->isCortexA15() || ST->isSwift())
98 return 2;
99 return 1;
100 }
101
102 unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
103 Type *SubTp);
104
105 unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
106
107 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
108
109 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
110
111 unsigned getAddressComputationCost(Type *Val, bool IsComplex);
112
113 unsigned getArithmeticInstrCost(
114 unsigned Opcode, Type *Ty,
115 TTI::OperandValueKind Op1Info = TTI::OK_AnyValue,
116 TTI::OperandValueKind Op2Info = TTI::OK_AnyValue,
117 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
118 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
119
120 unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
121 unsigned AddressSpace);
122
123 /// @}
124};
125
126} // end namespace llvm
127
128#endif