]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AArch64/AArch64Subtarget.h
Merge ^/head r317971 through r318379.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AArch64 / AArch64Subtarget.h
1 //===--- 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
14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
15 #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
16
17 #include "AArch64FrameLowering.h"
18 #include "AArch64ISelLowering.h"
19 #include "AArch64InstrInfo.h"
20 #include "AArch64RegisterInfo.h"
21 #include "AArch64SelectionDAGInfo.h"
22 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
23 #include "llvm/IR/DataLayout.h"
24 #include "llvm/Target/TargetSubtargetInfo.h"
25 #include <string>
26
27 #define GET_SUBTARGETINFO_HEADER
28 #include "AArch64GenSubtargetInfo.inc"
29
30 namespace llvm {
31 class GlobalValue;
32 class StringRef;
33 class Triple;
34
35 class AArch64Subtarget final : public AArch64GenSubtargetInfo {
36 public:
37   enum ARMProcFamilyEnum : uint8_t {
38     Others,
39     CortexA35,
40     CortexA53,
41     CortexA57,
42     CortexA72,
43     CortexA73,
44     Cyclone,
45     ExynosM1,
46     Falkor,
47     Kryo,
48     ThunderX2T99,
49     ThunderX,
50     ThunderXT81,
51     ThunderXT83,
52     ThunderXT88
53   };
54
55 protected:
56   /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
57   ARMProcFamilyEnum ARMProcFamily = Others;
58
59   bool HasV8_1aOps = false;
60   bool HasV8_2aOps = false;
61
62   bool HasFPARMv8 = false;
63   bool HasNEON = false;
64   bool HasCrypto = false;
65   bool HasCRC = false;
66   bool HasLSE = false;
67   bool HasRAS = false;
68   bool HasRDM = false;
69   bool HasPerfMon = false;
70   bool HasFullFP16 = false;
71   bool HasSPE = false;
72   bool HasLSLFast = false;
73
74   // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
75   bool HasZeroCycleRegMove = false;
76
77   // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
78   bool HasZeroCycleZeroing = false;
79
80   // StrictAlign - Disallow unaligned memory accesses.
81   bool StrictAlign = false;
82
83   // NegativeImmediates - transform instructions with negative immediates
84   bool NegativeImmediates = true;
85
86   bool UseAA = false;
87   bool PredictableSelectIsExpensive = false;
88   bool BalanceFPOps = false;
89   bool CustomAsCheapAsMove = false;
90   bool UsePostRAScheduler = false;
91   bool Misaligned128StoreIsSlow = false;
92   bool Paired128IsSlow = false;
93   bool UseAlternateSExtLoadCVTF32Pattern = false;
94   bool HasArithmeticBccFusion = false;
95   bool HasArithmeticCbzFusion = false;
96   bool HasFuseAES = false;
97   bool HasFuseLiterals = false;
98   bool DisableLatencySchedHeuristic = false;
99   bool UseRSqrt = false;
100   uint8_t MaxInterleaveFactor = 2;
101   uint8_t VectorInsertExtractBaseCost = 3;
102   uint16_t CacheLineSize = 0;
103   uint16_t PrefetchDistance = 0;
104   uint16_t MinPrefetchStride = 1;
105   unsigned MaxPrefetchIterationsAhead = UINT_MAX;
106   unsigned PrefFunctionAlignment = 0;
107   unsigned PrefLoopAlignment = 0;
108   unsigned MaxJumpTableSize = 0;
109
110   // ReserveX18 - X18 is not available as a general purpose register.
111   bool ReserveX18;
112
113   bool IsLittle;
114
115   /// TargetTriple - What processor and OS we're targeting.
116   Triple TargetTriple;
117
118   AArch64FrameLowering FrameLowering;
119   AArch64InstrInfo InstrInfo;
120   AArch64SelectionDAGInfo TSInfo;
121   AArch64TargetLowering TLInfo;
122   /// Gather the accessor points to GlobalISel-related APIs.
123   /// This is used to avoid ifndefs spreading around while GISel is
124   /// an optional library.
125   std::unique_ptr<GISelAccessor> GISel;
126
127   bool ForCodeSize;
128
129 private:
130   /// initializeSubtargetDependencies - Initializes using CPUString and the
131   /// passed in feature string so that we can use initializer lists for
132   /// subtarget initialization.
133   AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
134                                                     StringRef CPUString);
135
136   /// Initialize properties based on the selected processor family.
137   void initializeProperties();
138
139 public:
140   /// This constructor initializes the data members to match that
141   /// of the specified triple.
142   AArch64Subtarget(const Triple &TT, const std::string &CPU,
143                    const std::string &FS, const TargetMachine &TM,
144                    bool LittleEndian, bool ForCodeSize);
145
146   /// This object will take onwership of \p GISelAccessor.
147   void setGISelAccessor(GISelAccessor &GISel) {
148     this->GISel.reset(&GISel);
149   }
150
151   const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
152     return &TSInfo;
153   }
154   const AArch64FrameLowering *getFrameLowering() const override {
155     return &FrameLowering;
156   }
157   const AArch64TargetLowering *getTargetLowering() const override {
158     return &TLInfo;
159   }
160   const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
161   const AArch64RegisterInfo *getRegisterInfo() const override {
162     return &getInstrInfo()->getRegisterInfo();
163   }
164   const CallLowering *getCallLowering() const override;
165   const InstructionSelector *getInstructionSelector() const override;
166   const LegalizerInfo *getLegalizerInfo() const override;
167   const RegisterBankInfo *getRegBankInfo() const override;
168   const Triple &getTargetTriple() const { return TargetTriple; }
169   bool enableMachineScheduler() const override { return true; }
170   bool enablePostRAScheduler() const override {
171     return UsePostRAScheduler;
172   }
173
174   /// Returns ARM processor family.
175   /// Avoid this function! CPU specifics should be kept local to this class
176   /// and preferably modeled with SubtargetFeatures or properties in
177   /// initializeProperties().
178   ARMProcFamilyEnum getProcFamily() const {
179     return ARMProcFamily;
180   }
181
182   bool hasV8_1aOps() const { return HasV8_1aOps; }
183   bool hasV8_2aOps() const { return HasV8_2aOps; }
184
185   bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
186
187   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
188
189   bool requiresStrictAlign() const { return StrictAlign; }
190
191   bool isXRaySupported() const override { return true; }
192
193   bool isX18Reserved() const { return ReserveX18; }
194   bool hasFPARMv8() const { return HasFPARMv8; }
195   bool hasNEON() const { return HasNEON; }
196   bool hasCrypto() const { return HasCrypto; }
197   bool hasCRC() const { return HasCRC; }
198   bool hasLSE() const { return HasLSE; }
199   bool hasRAS() const { return HasRAS; }
200   bool hasRDM() const { return HasRDM; }
201   bool balanceFPOps() const { return BalanceFPOps; }
202   bool predictableSelectIsExpensive() const {
203     return PredictableSelectIsExpensive;
204   }
205   bool hasCustomCheapAsMoveHandling() const { return CustomAsCheapAsMove; }
206   bool isMisaligned128StoreSlow() const { return Misaligned128StoreIsSlow; }
207   bool isPaired128Slow() const { return Paired128IsSlow; }
208   bool useAlternateSExtLoadCVTF32Pattern() const {
209     return UseAlternateSExtLoadCVTF32Pattern;
210   }
211   bool hasArithmeticBccFusion() const { return HasArithmeticBccFusion; }
212   bool hasArithmeticCbzFusion() const { return HasArithmeticCbzFusion; }
213   bool hasFuseAES() const { return HasFuseAES; }
214   bool hasFuseLiterals() const { return HasFuseLiterals; }
215   bool useRSqrt() const { return UseRSqrt; }
216   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
217   unsigned getVectorInsertExtractBaseCost() const {
218     return VectorInsertExtractBaseCost;
219   }
220   unsigned getCacheLineSize() const { return CacheLineSize; }
221   unsigned getPrefetchDistance() const { return PrefetchDistance; }
222   unsigned getMinPrefetchStride() const { return MinPrefetchStride; }
223   unsigned getMaxPrefetchIterationsAhead() const {
224     return MaxPrefetchIterationsAhead;
225   }
226   unsigned getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
227   unsigned getPrefLoopAlignment() const { return PrefLoopAlignment; }
228
229   unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
230
231   /// CPU has TBI (top byte of addresses is ignored during HW address
232   /// translation) and OS enables it.
233   bool supportsAddressTopByteIgnored() const;
234
235   bool hasPerfMon() const { return HasPerfMon; }
236   bool hasFullFP16() const { return HasFullFP16; }
237   bool hasSPE() const { return HasSPE; }
238   bool hasLSLFast() const { return HasLSLFast; }
239
240   bool isLittleEndian() const { return IsLittle; }
241
242   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
243   bool isTargetIOS() const { return TargetTriple.isiOS(); }
244   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
245   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
246   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
247   bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
248
249   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
250   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
251   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
252
253   bool useAA() const override { return UseAA; }
254
255   bool useSmallAddressing() const {
256     switch (TLInfo.getTargetMachine().getCodeModel()) {
257       case CodeModel::Kernel:
258         // Kernel is currently allowed only for Fuchsia targets,
259         // where it is the same as Small for almost all purposes.
260       case CodeModel::Small:
261         return true;
262       default:
263         return false;
264     }
265   }
266
267   bool getForCodeSize() const { return ForCodeSize; }
268
269   /// ParseSubtargetFeatures - Parses features string setting specified
270   /// subtarget options.  Definition of function is auto generated by tblgen.
271   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
272
273   /// ClassifyGlobalReference - Find the target operand flags that describe
274   /// how a global value should be referenced for the current subtarget.
275   unsigned char ClassifyGlobalReference(const GlobalValue *GV,
276                                         const TargetMachine &TM) const;
277
278   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
279                                                 const TargetMachine &TM) const;
280
281   /// This function returns the name of a function which has an interface
282   /// like the non-standard bzero function, if such a function exists on
283   /// the current subtarget and it is considered prefereable over
284   /// memset with zero passed as the second argument. Otherwise it
285   /// returns null.
286   const char *getBZeroEntry() const;
287
288   void overrideSchedPolicy(MachineSchedPolicy &Policy,
289                            unsigned NumRegionInstrs) const override;
290
291   bool enableEarlyIfConversion() const override;
292
293   std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
294 };
295 } // End llvm namespace
296
297 #endif