blob: b9e52914d2ad5e596f5ffb53c21dd1c440945132 [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;
Chandler Carruthc340ca82015-02-01 14:01:15 +000031 friend BaseT;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000032
Chandler Carruthc340ca82015-02-01 14:01:15 +000033 const ARMBaseTargetMachine *TM;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000034 const ARMSubtarget *ST;
35 const ARMTargetLowering *TLI;
36
37 /// Estimate the overhead of scalarizing an instruction. Insert and Extract
38 /// are set if the result needs to be inserted and/or extracted from vectors.
39 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
40
Chandler Carruthc340ca82015-02-01 14:01:15 +000041 const ARMBaseTargetMachine *getTM() const { return TM; }
42 const ARMTargetLowering *getTLI() const { return TLI; }
43
Chandler Carruth93dcdc42015-01-31 11:17:59 +000044public:
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000045 explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, Function &F)
Chandler Carruthc340ca82015-02-01 14:01:15 +000046 : BaseT(TM), TM(TM), ST(TM->getSubtargetImpl(F)),
47 TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000048
49 // Provide value semantics. MSVC requires that we spell all of these out.
50 ARMTTIImpl(const ARMTTIImpl &Arg)
Chandler Carruthc340ca82015-02-01 14:01:15 +000051 : BaseT(static_cast<const BaseT &>(Arg)), TM(Arg.TM), ST(Arg.ST), TLI(Arg.TLI) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000052 ARMTTIImpl(ARMTTIImpl &&Arg)
Chandler Carruthc340ca82015-02-01 14:01:15 +000053 : BaseT(std::move(static_cast<BaseT &>(Arg))), TM(std::move(Arg.TM)),
54 ST(std::move(Arg.ST)), TLI(std::move(Arg.TLI)) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000055 ARMTTIImpl &operator=(const ARMTTIImpl &RHS) {
56 BaseT::operator=(static_cast<const BaseT &>(RHS));
Chandler Carruthc340ca82015-02-01 14:01:15 +000057 TM = RHS.TM;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000058 ST = RHS.ST;
59 TLI = RHS.TLI;
60 return *this;
61 }
62 ARMTTIImpl &operator=(ARMTTIImpl &&RHS) {
63 BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
Chandler Carruthc340ca82015-02-01 14:01:15 +000064 TM = std::move(RHS.TM);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000065 ST = std::move(RHS.ST);
66 TLI = std::move(RHS.TLI);
67 return *this;
68 }
69
70 /// \name Scalar TTI Implementations
71 /// @{
72
73 using BaseT::getIntImmCost;
74 unsigned getIntImmCost(const APInt &Imm, Type *Ty);
75
76 /// @}
77
78 /// \name Vector TTI Implementations
79 /// @{
80
81 unsigned getNumberOfRegisters(bool Vector) {
82 if (Vector) {
83 if (ST->hasNEON())
84 return 16;
85 return 0;
86 }
87
88 if (ST->isThumb1Only())
89 return 8;
90 return 13;
91 }
92
93 unsigned getRegisterBitWidth(bool Vector) {
94 if (Vector) {
95 if (ST->hasNEON())
96 return 128;
97 return 0;
98 }
99
100 return 32;
101 }
102
103 unsigned getMaxInterleaveFactor() {
104 // These are out of order CPUs:
105 if (ST->isCortexA15() || ST->isSwift())
106 return 2;
107 return 1;
108 }
109
110 unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
111 Type *SubTp);
112
113 unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
114
115 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
116
117 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
118
119 unsigned getAddressComputationCost(Type *Val, bool IsComplex);
120
121 unsigned getArithmeticInstrCost(
122 unsigned Opcode, Type *Ty,
123 TTI::OperandValueKind Op1Info = TTI::OK_AnyValue,
124 TTI::OperandValueKind Op2Info = TTI::OK_AnyValue,
125 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
126 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
127
128 unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
129 unsigned AddressSpace);
130
131 /// @}
132};
133
134} // end namespace llvm
135
136#endif