blob: 73f63b8b9f67900620f129974a7d968d33a7105b [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===--- AArch64Subtarget.h - Define Subtarget for the AArch64 -*- 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//
10// This file declares the AArch64 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
15#define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
Tim Northover3b0846e2014-05-24 12:50:23 +000016
Eric Christopher29aab7b2014-06-10 17:44:12 +000017#include "AArch64FrameLowering.h"
Eric Christopher841da852014-06-10 23:26:45 +000018#include "AArch64ISelLowering.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000019#include "AArch64InstrInfo.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000020#include "AArch64RegisterInfo.h"
Eric Christopherfcb06ca2014-06-10 18:21:53 +000021#include "AArch64SelectionDAGInfo.h"
Tom Stellardcef0fe42016-04-14 17:45:38 +000022#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
Eric Christopher6f2a2032014-06-10 18:06:23 +000023#include "llvm/IR/DataLayout.h"
Eric Christopher29aab7b2014-06-10 17:44:12 +000024#include "llvm/Target/TargetSubtargetInfo.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000025#include <string>
26
27#define GET_SUBTARGETINFO_HEADER
28#include "AArch64GenSubtargetInfo.inc"
29
30namespace llvm {
31class GlobalValue;
32class StringRef;
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000033class Triple;
Tim Northover3b0846e2014-05-24 12:50:23 +000034
Ahmed Bougacha5e402ee2016-07-27 14:31:46 +000035class AArch64Subtarget final : public AArch64GenSubtargetInfo {
Matthias Braun651cff42016-06-02 18:03:53 +000036public:
37 enum ARMProcFamilyEnum : uint8_t {
MinSeong Kima7385eb2016-01-05 12:51:59 +000038 Others,
39 CortexA35,
40 CortexA53,
41 CortexA57,
Silviu Barangaaee40fc2016-06-21 15:53:54 +000042 CortexA72,
43 CortexA73,
MinSeong Kima7385eb2016-01-05 12:51:59 +000044 Cyclone,
Chad Rosiercd2be7f2016-02-12 15:51:51 +000045 ExynosM1,
Chad Rosier201fc1e2016-11-15 21:34:12 +000046 Falkor,
Pankaj Gode0aab2e32016-06-20 11:13:31 +000047 Kryo,
48 Vulcan
MinSeong Kima7385eb2016-01-05 12:51:59 +000049 };
Tim Northover3b0846e2014-05-24 12:50:23 +000050
Matthias Braun651cff42016-06-02 18:03:53 +000051protected:
Tim Northover3b0846e2014-05-24 12:50:23 +000052 /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
Matthias Braun27b66922016-05-27 22:14:09 +000053 ARMProcFamilyEnum ARMProcFamily = Others;
Tim Northover3b0846e2014-05-24 12:50:23 +000054
Matthias Braun27b66922016-05-27 22:14:09 +000055 bool HasV8_1aOps = false;
56 bool HasV8_2aOps = false;
Vladimir Sukharev439328e2015-04-01 14:49:29 +000057
Matthias Braun27b66922016-05-27 22:14:09 +000058 bool HasFPARMv8 = false;
59 bool HasNEON = false;
60 bool HasCrypto = false;
61 bool HasCRC = false;
Joel Jones75818bc2016-11-30 22:25:24 +000062 bool HasLSE = false;
Sjoerd Meijerd906bf12016-06-03 14:03:27 +000063 bool HasRAS = false;
Matthias Braun27b66922016-05-27 22:14:09 +000064 bool HasPerfMon = false;
65 bool HasFullFP16 = false;
66 bool HasSPE = false;
Tim Northover3b0846e2014-05-24 12:50:23 +000067
68 // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
Matthias Braun27b66922016-05-27 22:14:09 +000069 bool HasZeroCycleRegMove = false;
Tim Northover3b0846e2014-05-24 12:50:23 +000070
71 // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
Matthias Braun27b66922016-05-27 22:14:09 +000072 bool HasZeroCycleZeroing = false;
Tim Northover3b0846e2014-05-24 12:50:23 +000073
Akira Hatanakaf53b0402015-07-29 14:17:26 +000074 // StrictAlign - Disallow unaligned memory accesses.
Matthias Braun27b66922016-05-27 22:14:09 +000075 bool StrictAlign = false;
Matthias Braun651cff42016-06-02 18:03:53 +000076 bool UseAA = false;
77 bool PredictableSelectIsExpensive = false;
78 bool BalanceFPOps = false;
79 bool CustomAsCheapAsMove = false;
80 bool UsePostRAScheduler = false;
81 bool Misaligned128StoreIsSlow = false;
82 bool AvoidQuadLdStPairs = false;
83 bool UseAlternateSExtLoadCVTF32Pattern = false;
Matthias Braun46a52382016-10-04 19:28:21 +000084 bool HasArithmeticBccFusion = false;
85 bool HasArithmeticCbzFusion = false;
Matthias Braun651cff42016-06-02 18:03:53 +000086 bool DisableLatencySchedHeuristic = false;
Evandro Menezeseff2bd92016-10-24 16:14:58 +000087 bool UseRSqrt = false;
Matthias Braun651cff42016-06-02 18:03:53 +000088 uint8_t MaxInterleaveFactor = 2;
89 uint8_t VectorInsertExtractBaseCost = 3;
90 uint16_t CacheLineSize = 0;
91 uint16_t PrefetchDistance = 0;
92 uint16_t MinPrefetchStride = 1;
93 unsigned MaxPrefetchIterationsAhead = UINT_MAX;
Evandro Menezesa3a0a602016-06-10 16:00:18 +000094 unsigned PrefFunctionAlignment = 0;
95 unsigned PrefLoopAlignment = 0;
Evandro Menezese45de8a2016-09-26 15:32:33 +000096 unsigned MaxJumpTableSize = 0;
Akira Hatanakaf53b0402015-07-29 14:17:26 +000097
Akira Hatanaka0d4c9ea2015-07-25 00:18:31 +000098 // ReserveX18 - X18 is not available as a general purpose register.
99 bool ReserveX18;
100
Eric Christopher8b770652015-01-26 19:03:15 +0000101 bool IsLittle;
102
Tim Northover3b0846e2014-05-24 12:50:23 +0000103 /// TargetTriple - What processor and OS we're targeting.
104 Triple TargetTriple;
105
Eric Christopher29aab7b2014-06-10 17:44:12 +0000106 AArch64FrameLowering FrameLowering;
Eric Christopherf63bc642014-06-10 22:57:25 +0000107 AArch64InstrInfo InstrInfo;
Eric Christopherfcb06ca2014-06-10 18:21:53 +0000108 AArch64SelectionDAGInfo TSInfo;
Eric Christopher7c9d4e02014-06-11 00:46:34 +0000109 AArch64TargetLowering TLInfo;
Quentin Colombetc17f7442016-04-06 17:26:03 +0000110 /// Gather the accessor points to GlobalISel-related APIs.
111 /// This is used to avoid ifndefs spreading around while GISel is
112 /// an optional library.
Tom Stellardcef0fe42016-04-14 17:45:38 +0000113 std::unique_ptr<GISelAccessor> GISel;
Quentin Colombetba2a0162016-02-16 19:26:02 +0000114
Eric Christopher7c9d4e02014-06-11 00:46:34 +0000115private:
116 /// initializeSubtargetDependencies - Initializes using CPUString and the
117 /// passed in feature string so that we can use initializer lists for
118 /// subtarget initialization.
Matthias Brauna827ed82016-10-03 20:17:02 +0000119 AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
120 StringRef CPUString);
Eric Christopher29aab7b2014-06-10 17:44:12 +0000121
Matthias Braun651cff42016-06-02 18:03:53 +0000122 /// Initialize properties based on the selected processor family.
123 void initializeProperties();
124
Tim Northover3b0846e2014-05-24 12:50:23 +0000125public:
126 /// This constructor initializes the data members to match that
127 /// of the specified triple.
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000128 AArch64Subtarget(const Triple &TT, const std::string &CPU,
Eric Christophera0de2532015-03-18 20:37:30 +0000129 const std::string &FS, const TargetMachine &TM,
Eric Christopherf12e1ab2014-10-03 00:42:41 +0000130 bool LittleEndian);
Tim Northover3b0846e2014-05-24 12:50:23 +0000131
Quentin Colombetc17f7442016-04-06 17:26:03 +0000132 /// This object will take onwership of \p GISelAccessor.
Tom Stellardcef0fe42016-04-14 17:45:38 +0000133 void setGISelAccessor(GISelAccessor &GISel) {
134 this->GISel.reset(&GISel);
Quentin Colombetc17f7442016-04-06 17:26:03 +0000135 }
136
Eric Christopherd9134482014-08-04 21:25:23 +0000137 const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
138 return &TSInfo;
139 }
140 const AArch64FrameLowering *getFrameLowering() const override {
Eric Christopher29aab7b2014-06-10 17:44:12 +0000141 return &FrameLowering;
142 }
Eric Christopherd9134482014-08-04 21:25:23 +0000143 const AArch64TargetLowering *getTargetLowering() const override {
Eric Christopher7c9d4e02014-06-11 00:46:34 +0000144 return &TLInfo;
Eric Christopher841da852014-06-10 23:26:45 +0000145 }
Eric Christopherd9134482014-08-04 21:25:23 +0000146 const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
Eric Christophera0de2532015-03-18 20:37:30 +0000147 const AArch64RegisterInfo *getRegisterInfo() const override {
148 return &getInstrInfo()->getRegisterInfo();
149 }
Quentin Colombetba2a0162016-02-16 19:26:02 +0000150 const CallLowering *getCallLowering() const override;
Ahmed Bougacha6756a2c2016-07-27 14:31:55 +0000151 const InstructionSelector *getInstructionSelector() const override;
Tim Northover69fa84a2016-10-14 22:18:18 +0000152 const LegalizerInfo *getLegalizerInfo() const override;
Quentin Colombetc17f7442016-04-06 17:26:03 +0000153 const RegisterBankInfo *getRegBankInfo() const override;
Eric Christopher09696d32015-03-12 02:04:46 +0000154 const Triple &getTargetTriple() const { return TargetTriple; }
Tim Northover3b0846e2014-05-24 12:50:23 +0000155 bool enableMachineScheduler() const override { return true; }
Matthias Braun39a2afc2015-06-13 03:42:16 +0000156 bool enablePostRAScheduler() const override {
Matthias Braun651cff42016-06-02 18:03:53 +0000157 return UsePostRAScheduler;
158 }
159
160 /// Returns ARM processor family.
161 /// Avoid this function! CPU specifics should be kept local to this class
162 /// and preferably modeled with SubtargetFeatures or properties in
163 /// initializeProperties().
164 ARMProcFamilyEnum getProcFamily() const {
165 return ARMProcFamily;
Chad Rosier486e0872014-09-12 17:40:39 +0000166 }
Tim Northover3b0846e2014-05-24 12:50:23 +0000167
Vladimir Sukharev439328e2015-04-01 14:49:29 +0000168 bool hasV8_1aOps() const { return HasV8_1aOps; }
Oliver Stannard7cc0c4e2015-11-26 15:23:32 +0000169 bool hasV8_2aOps() const { return HasV8_2aOps; }
Vladimir Sukharev439328e2015-04-01 14:49:29 +0000170
Tim Northover3b0846e2014-05-24 12:50:23 +0000171 bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
172
173 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
174
Akira Hatanakaf53b0402015-07-29 14:17:26 +0000175 bool requiresStrictAlign() const { return StrictAlign; }
176
Dean Michael Berris3234d3a2016-11-17 05:15:37 +0000177 bool isXRaySupported() const override { return true; }
178
Akira Hatanaka0d4c9ea2015-07-25 00:18:31 +0000179 bool isX18Reserved() const { return ReserveX18; }
Tim Northover3b0846e2014-05-24 12:50:23 +0000180 bool hasFPARMv8() const { return HasFPARMv8; }
181 bool hasNEON() const { return HasNEON; }
182 bool hasCrypto() const { return HasCrypto; }
183 bool hasCRC() const { return HasCRC; }
Joel Jones75818bc2016-11-30 22:25:24 +0000184 bool hasLSE() const { return HasLSE; }
Sjoerd Meijerd906bf12016-06-03 14:03:27 +0000185 bool hasRAS() const { return HasRAS; }
Matthias Braun651cff42016-06-02 18:03:53 +0000186 bool balanceFPOps() const { return BalanceFPOps; }
187 bool predictableSelectIsExpensive() const {
188 return PredictableSelectIsExpensive;
189 }
190 bool hasCustomCheapAsMoveHandling() const { return CustomAsCheapAsMove; }
191 bool isMisaligned128StoreSlow() const { return Misaligned128StoreIsSlow; }
192 bool avoidQuadLdStPairs() const { return AvoidQuadLdStPairs; }
193 bool useAlternateSExtLoadCVTF32Pattern() const {
194 return UseAlternateSExtLoadCVTF32Pattern;
195 }
Matthias Braun46a52382016-10-04 19:28:21 +0000196 bool hasArithmeticBccFusion() const { return HasArithmeticBccFusion; }
197 bool hasArithmeticCbzFusion() const { return HasArithmeticCbzFusion; }
Evandro Menezeseff2bd92016-10-24 16:14:58 +0000198 bool useRSqrt() const { return UseRSqrt; }
Matthias Braun651cff42016-06-02 18:03:53 +0000199 unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
200 unsigned getVectorInsertExtractBaseCost() const {
201 return VectorInsertExtractBaseCost;
202 }
203 unsigned getCacheLineSize() const { return CacheLineSize; }
204 unsigned getPrefetchDistance() const { return PrefetchDistance; }
205 unsigned getMinPrefetchStride() const { return MinPrefetchStride; }
206 unsigned getMaxPrefetchIterationsAhead() const {
207 return MaxPrefetchIterationsAhead;
208 }
Evandro Menezesa3a0a602016-06-10 16:00:18 +0000209 unsigned getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
210 unsigned getPrefLoopAlignment() const { return PrefLoopAlignment; }
Matthias Braun651cff42016-06-02 18:03:53 +0000211
Evandro Menezese45de8a2016-09-26 15:32:33 +0000212 unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
213
Tim Northover339c83e2015-11-10 00:44:23 +0000214 /// CPU has TBI (top byte of addresses is ignored during HW address
215 /// translation) and OS enables it.
216 bool supportsAddressTopByteIgnored() const;
217
Ahmed Bougachab0ff6432015-09-01 16:23:45 +0000218 bool hasPerfMon() const { return HasPerfMon; }
Oliver Stannard7cc0c4e2015-11-26 15:23:32 +0000219 bool hasFullFP16() const { return HasFullFP16; }
Oliver Stannarda34e4702015-12-01 10:48:51 +0000220 bool hasSPE() const { return HasSPE; }
Tim Northover3b0846e2014-05-24 12:50:23 +0000221
Eric Christopher8b770652015-01-26 19:03:15 +0000222 bool isLittleEndian() const { return IsLittle; }
Tim Northover3b0846e2014-05-24 12:50:23 +0000223
224 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
Chad Rosierb481bdf2014-08-06 16:56:58 +0000225 bool isTargetIOS() const { return TargetTriple.isiOS(); }
226 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
227 bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
Evgeniy Stepanov5fe279e2015-10-08 21:21:24 +0000228 bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
Tim Northover3b0846e2014-05-24 12:50:23 +0000229
Chad Rosierb481bdf2014-08-06 16:56:58 +0000230 bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
Tim Northover3b0846e2014-05-24 12:50:23 +0000231 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
Tim Northover3b0846e2014-05-24 12:50:23 +0000232 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
233
Matthias Braun651cff42016-06-02 18:03:53 +0000234 bool useAA() const override { return UseAA; }
Chad Rosierc9f94772014-09-08 14:31:49 +0000235
Tim Northover3b0846e2014-05-24 12:50:23 +0000236 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
237 /// that still makes it profitable to inline the call.
238 unsigned getMaxInlineSizeThreshold() const { return 64; }
239
240 /// ParseSubtargetFeatures - Parses features string setting specified
241 /// subtarget options. Definition of function is auto generated by tblgen.
242 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
243
244 /// ClassifyGlobalReference - Find the target operand flags that describe
245 /// how a global value should be referenced for the current subtarget.
246 unsigned char ClassifyGlobalReference(const GlobalValue *GV,
247 const TargetMachine &TM) const;
248
249 /// This function returns the name of a function which has an interface
250 /// like the non-standard bzero function, if such a function exists on
251 /// the current subtarget and it is considered prefereable over
252 /// memset with zero passed as the second argument. Otherwise it
253 /// returns null.
254 const char *getBZeroEntry() const;
255
Duncan P. N. Exon Smith63298722016-07-01 00:23:27 +0000256 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tim Northover3b0846e2014-05-24 12:50:23 +0000257 unsigned NumRegionInstrs) const override;
258
259 bool enableEarlyIfConversion() const override;
Lang Hames8f31f442014-10-09 18:20:51 +0000260
261 std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
Tim Northover3b0846e2014-05-24 12:50:23 +0000262};
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000263} // End llvm namespace
Tim Northover3b0846e2014-05-24 12:50:23 +0000264
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000265#endif