LLVM  10.0.0
AArch64Subtarget.h
Go to the documentation of this file.
1 //===--- AArch64Subtarget.h - Define Subtarget for the AArch64 -*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the AArch64 specific subclass of TargetSubtarget.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
14 #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
15 
16 #include "AArch64FrameLowering.h"
17 #include "AArch64ISelLowering.h"
18 #include "AArch64InstrInfo.h"
19 #include "AArch64RegisterInfo.h"
26 #include "llvm/IR/DataLayout.h"
27 #include <string>
28 
29 #define GET_SUBTARGETINFO_HEADER
30 #include "AArch64GenSubtargetInfo.inc"
31 
32 namespace llvm {
33 class GlobalValue;
34 class StringRef;
35 class Triple;
36 
38 public:
39  enum ARMProcFamilyEnum : uint8_t {
67  };
68 
69 protected:
70  /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
72 
73  bool HasV8_1aOps = false;
74  bool HasV8_2aOps = false;
75  bool HasV8_3aOps = false;
76  bool HasV8_4aOps = false;
77  bool HasV8_5aOps = false;
78 
79  bool HasFPARMv8 = false;
80  bool HasNEON = false;
81  bool HasCrypto = false;
82  bool HasDotProd = false;
83  bool HasCRC = false;
84  bool HasLSE = false;
85  bool HasRAS = false;
86  bool HasRDM = false;
87  bool HasPerfMon = false;
88  bool HasFullFP16 = false;
89  bool HasFP16FML = false;
90  bool HasSPE = false;
91 
92  // ARMv8.1 extensions
93  bool HasVH = false;
94  bool HasPAN = false;
95  bool HasLOR = false;
96 
97  // ARMv8.2 extensions
98  bool HasPsUAO = false;
99  bool HasPAN_RWV = false;
100  bool HasCCPP = false;
101 
102  // Armv8.2 Crypto extensions
103  bool HasSM4 = false;
104  bool HasSHA3 = false;
105  bool HasSHA2 = false;
106  bool HasAES = false;
107 
108  // ARMv8.3 extensions
109  bool HasPA = false;
110  bool HasJS = false;
111  bool HasCCIDX = false;
112  bool HasComplxNum = false;
113 
114  // ARMv8.4 extensions
115  bool HasNV = false;
116  bool HasRASv8_4 = false;
117  bool HasMPAM = false;
118  bool HasDIT = false;
119  bool HasTRACEV8_4 = false;
120  bool HasAM = false;
121  bool HasSEL2 = false;
122  bool HasPMU = false;
123  bool HasTLB_RMI = false;
124  bool HasFMI = false;
125  bool HasRCPC_IMMO = false;
126 
127  bool HasLSLFast = false;
128  bool HasSVE = false;
129  bool HasSVE2 = false;
130  bool HasRCPC = false;
131  bool HasAggressiveFMA = false;
132 
133  // Armv8.5-A Extensions
134  bool HasAlternativeNZCV = false;
135  bool HasFRInt3264 = false;
136  bool HasSpecRestrict = false;
137  bool HasSSBS = false;
138  bool HasSB = false;
139  bool HasPredRes = false;
140  bool HasCCDP = false;
141  bool HasBTI = false;
142  bool HasRandGen = false;
143  bool HasMTE = false;
144  bool HasTME = false;
145 
146  // Arm SVE2 extensions
147  bool HasSVE2AES = false;
148  bool HasSVE2SM4 = false;
149  bool HasSVE2SHA3 = false;
150  bool HasSVE2BitPerm = false;
151 
152  // Future architecture extensions.
153  bool HasETE = false;
154  bool HasTRBE = false;
155 
156  // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
157  bool HasZeroCycleRegMove = false;
158 
159  // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
160  bool HasZeroCycleZeroing = false;
161  bool HasZeroCycleZeroingGP = false;
162  bool HasZeroCycleZeroingFP = false;
164 
165  // StrictAlign - Disallow unaligned memory accesses.
166  bool StrictAlign = false;
167 
168  // NegativeImmediates - transform instructions with negative immediates
169  bool NegativeImmediates = true;
170 
171  // Enable 64-bit vectorization in SLP.
173 
174  bool UseAA = false;
176  bool BalanceFPOps = false;
177  bool CustomAsCheapAsMove = false;
178  bool ExynosAsCheapAsMove = false;
179  bool UsePostRAScheduler = false;
181  bool Paired128IsSlow = false;
182  bool STRQroIsSlow = false;
186  bool HasFuseAddress = false;
187  bool HasFuseAES = false;
189  bool HasFuseCCSelect = false;
190  bool HasFuseCryptoEOR = false;
191  bool HasFuseLiterals = false;
193  bool UseRSqrt = false;
194  bool Force32BitJumpTables = false;
195  bool UseEL1ForTP = false;
196  bool UseEL2ForTP = false;
197  bool UseEL3ForTP = false;
198  bool AllowTaggedGlobals = false;
199  uint8_t MaxInterleaveFactor = 2;
204  unsigned MaxPrefetchIterationsAhead = UINT_MAX;
206  unsigned PrefLoopLogAlignment = 0;
207  unsigned MaxJumpTableSize = 0;
208  unsigned WideningBaseCost = 0;
209 
210  // ReserveXRegister[i] - X#i is not available as a general purpose register.
212 
213  // CustomCallUsedXRegister[i] - X#i call saved.
215 
216  bool IsLittle;
217 
218  /// TargetTriple - What processor and OS we're targeting.
220 
225 
226  /// GlobalISel related APIs.
227  std::unique_ptr<CallLowering> CallLoweringInfo;
228  std::unique_ptr<InstructionSelector> InstSelector;
229  std::unique_ptr<LegalizerInfo> Legalizer;
230  std::unique_ptr<RegisterBankInfo> RegBankInfo;
231 
232 private:
233  /// initializeSubtargetDependencies - Initializes using CPUString and the
234  /// passed in feature string so that we can use initializer lists for
235  /// subtarget initialization.
236  AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
237  StringRef CPUString);
238 
239  /// Initialize properties based on the selected processor family.
240  void initializeProperties();
241 
242 public:
243  /// This constructor initializes the data members to match that
244  /// of the specified triple.
245  AArch64Subtarget(const Triple &TT, const std::string &CPU,
246  const std::string &FS, const TargetMachine &TM,
247  bool LittleEndian);
248 
250  return &TSInfo;
251  }
252  const AArch64FrameLowering *getFrameLowering() const override {
253  return &FrameLowering;
254  }
255  const AArch64TargetLowering *getTargetLowering() const override {
256  return &TLInfo;
257  }
258  const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
259  const AArch64RegisterInfo *getRegisterInfo() const override {
260  return &getInstrInfo()->getRegisterInfo();
261  }
262  const CallLowering *getCallLowering() const override;
264  const LegalizerInfo *getLegalizerInfo() const override;
265  const RegisterBankInfo *getRegBankInfo() const override;
266  const Triple &getTargetTriple() const { return TargetTriple; }
267  bool enableMachineScheduler() const override { return true; }
268  bool enablePostRAScheduler() const override {
269  return UsePostRAScheduler;
270  }
271 
272  /// Returns ARM processor family.
273  /// Avoid this function! CPU specifics should be kept local to this class
274  /// and preferably modeled with SubtargetFeatures or properties in
275  /// initializeProperties().
277  return ARMProcFamily;
278  }
279 
280  bool hasV8_1aOps() const { return HasV8_1aOps; }
281  bool hasV8_2aOps() const { return HasV8_2aOps; }
282  bool hasV8_3aOps() const { return HasV8_3aOps; }
283  bool hasV8_4aOps() const { return HasV8_4aOps; }
284  bool hasV8_5aOps() const { return HasV8_5aOps; }
285 
286  bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
287 
289 
291 
294  }
295 
296  bool requiresStrictAlign() const { return StrictAlign; }
297 
298  bool isXRaySupported() const override { return true; }
299 
300  unsigned getMinVectorRegisterBitWidth() const {
302  }
303 
304  bool isXRegisterReserved(size_t i) const { return ReserveXRegister[i]; }
305  unsigned getNumXRegisterReserved() const { return ReserveXRegister.count(); }
306  bool isXRegCustomCalleeSaved(size_t i) const {
307  return CustomCallSavedXRegs[i];
308  }
309  bool hasCustomCallingConv() const { return CustomCallSavedXRegs.any(); }
310  bool hasFPARMv8() const { return HasFPARMv8; }
311  bool hasNEON() const { return HasNEON; }
312  bool hasCrypto() const { return HasCrypto; }
313  bool hasDotProd() const { return HasDotProd; }
314  bool hasCRC() const { return HasCRC; }
315  bool hasLSE() const { return HasLSE; }
316  bool hasRAS() const { return HasRAS; }
317  bool hasRDM() const { return HasRDM; }
318  bool hasSM4() const { return HasSM4; }
319  bool hasSHA3() const { return HasSHA3; }
320  bool hasSHA2() const { return HasSHA2; }
321  bool hasAES() const { return HasAES; }
322  bool balanceFPOps() const { return BalanceFPOps; }
325  }
329  bool isPaired128Slow() const { return Paired128IsSlow; }
330  bool isSTRQroSlow() const { return STRQroIsSlow; }
333  }
336  bool hasFuseAddress() const { return HasFuseAddress; }
337  bool hasFuseAES() const { return HasFuseAES; }
339  bool hasFuseCCSelect() const { return HasFuseCCSelect; }
340  bool hasFuseCryptoEOR() const { return HasFuseCryptoEOR; }
341  bool hasFuseLiterals() const { return HasFuseLiterals; }
342 
343  /// Return true if the CPU supports any kind of instruction fusion.
344  bool hasFusion() const {
348  }
349 
350  bool useEL1ForTP() const { return UseEL1ForTP; }
351  bool useEL2ForTP() const { return UseEL2ForTP; }
352  bool useEL3ForTP() const { return UseEL3ForTP; }
353 
354  bool useRSqrt() const { return UseRSqrt; }
356  unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
359  }
360  unsigned getCacheLineSize() const override { return CacheLineSize; }
361  unsigned getPrefetchDistance() const override { return PrefetchDistance; }
362  unsigned getMinPrefetchStride() const override { return MinPrefetchStride; }
363  unsigned getMaxPrefetchIterationsAhead() const override {
365  }
366  unsigned getPrefFunctionLogAlignment() const {
368  }
369  unsigned getPrefLoopLogAlignment() const { return PrefLoopLogAlignment; }
370 
371  unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
372 
373  unsigned getWideningBaseCost() const { return WideningBaseCost; }
374 
375  /// CPU has TBI (top byte of addresses is ignored during HW address
376  /// translation) and OS enables it.
377  bool supportsAddressTopByteIgnored() const;
378 
379  bool hasPerfMon() const { return HasPerfMon; }
380  bool hasFullFP16() const { return HasFullFP16; }
381  bool hasFP16FML() const { return HasFP16FML; }
382  bool hasSPE() const { return HasSPE; }
383  bool hasLSLFast() const { return HasLSLFast; }
384  bool hasSVE() const { return HasSVE; }
385  bool hasSVE2() const { return HasSVE2; }
386  bool hasRCPC() const { return HasRCPC; }
387  bool hasAggressiveFMA() const { return HasAggressiveFMA; }
388  bool hasAlternativeNZCV() const { return HasAlternativeNZCV; }
389  bool hasFRInt3264() const { return HasFRInt3264; }
390  bool hasSpecRestrict() const { return HasSpecRestrict; }
391  bool hasSSBS() const { return HasSSBS; }
392  bool hasSB() const { return HasSB; }
393  bool hasPredRes() const { return HasPredRes; }
394  bool hasCCDP() const { return HasCCDP; }
395  bool hasBTI() const { return HasBTI; }
396  bool hasRandGen() const { return HasRandGen; }
397  bool hasMTE() const { return HasMTE; }
398  bool hasTME() const { return HasTME; }
399  // Arm SVE2 extensions
400  bool hasSVE2AES() const { return HasSVE2AES; }
401  bool hasSVE2SM4() const { return HasSVE2SM4; }
402  bool hasSVE2SHA3() const { return HasSVE2SHA3; }
403  bool hasSVE2BitPerm() const { return HasSVE2BitPerm; }
404 
405  bool isLittleEndian() const { return IsLittle; }
406 
407  bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
408  bool isTargetIOS() const { return TargetTriple.isiOS(); }
409  bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
410  bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
411  bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
412  bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
413 
414  bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
415  bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
416  bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
417 
418  bool isTargetILP32() const { return TargetTriple.isArch32Bit(); }
419 
420  bool useAA() const override { return UseAA; }
421 
422  bool hasVH() const { return HasVH; }
423  bool hasPAN() const { return HasPAN; }
424  bool hasLOR() const { return HasLOR; }
425 
426  bool hasPsUAO() const { return HasPsUAO; }
427  bool hasPAN_RWV() const { return HasPAN_RWV; }
428  bool hasCCPP() const { return HasCCPP; }
429 
430  bool hasPA() const { return HasPA; }
431  bool hasJS() const { return HasJS; }
432  bool hasCCIDX() const { return HasCCIDX; }
433  bool hasComplxNum() const { return HasComplxNum; }
434 
435  bool hasNV() const { return HasNV; }
436  bool hasRASv8_4() const { return HasRASv8_4; }
437  bool hasMPAM() const { return HasMPAM; }
438  bool hasDIT() const { return HasDIT; }
439  bool hasTRACEV8_4() const { return HasTRACEV8_4; }
440  bool hasAM() const { return HasAM; }
441  bool hasSEL2() const { return HasSEL2; }
442  bool hasPMU() const { return HasPMU; }
443  bool hasTLB_RMI() const { return HasTLB_RMI; }
444  bool hasFMI() const { return HasFMI; }
445  bool hasRCPC_IMMO() const { return HasRCPC_IMMO; }
446 
447  bool addrSinkUsingGEPs() const override {
448  // Keeping GEPs inbounds is important for exploiting AArch64
449  // addressing-modes in ILP32 mode.
450  return useAA() || isTargetILP32();
451  }
452 
453  bool useSmallAddressing() const {
454  switch (TLInfo.getTargetMachine().getCodeModel()) {
455  case CodeModel::Kernel:
456  // Kernel is currently allowed only for Fuchsia targets,
457  // where it is the same as Small for almost all purposes.
458  case CodeModel::Small:
459  return true;
460  default:
461  return false;
462  }
463  }
464 
465  /// ParseSubtargetFeatures - Parses features string setting specified
466  /// subtarget options. Definition of function is auto generated by tblgen.
468 
469  /// ClassifyGlobalReference - Find the target operand flags that describe
470  /// how a global value should be referenced for the current subtarget.
471  unsigned ClassifyGlobalReference(const GlobalValue *GV,
472  const TargetMachine &TM) const;
473 
474  unsigned classifyGlobalFunctionReference(const GlobalValue *GV,
475  const TargetMachine &TM) const;
476 
478  unsigned NumRegionInstrs) const override;
479 
480  bool enableEarlyIfConversion() const override;
481 
482  bool enableAdvancedRASplitCost() const override { return true; }
483 
484  std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
485 
487  switch (CC) {
488  case CallingConv::C:
489  case CallingConv::Fast:
490  case CallingConv::Swift:
491  return isTargetWindows();
492  case CallingConv::Win64:
493  return true;
494  default:
495  return false;
496  }
497  }
498 
499  void mirFileLoaded(MachineFunction &MF) const override;
500 };
501 } // End llvm namespace
502 
503 #endif
const Triple & getTargetTriple() const
unsigned getMinPrefetchStride() const override
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
Definition: Triple.h:482
bool hasAlternativeNZCV() const
unsigned ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
ClassifyGlobalReference - Find the target operand flags that describe how a global value should be re...
bool isMisaligned128StoreSlow() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool hasCustomCallingConv() const
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:624
bool predictableSelectIsExpensive() const
InstructionSelector * getInstructionSelector() const override
AArch64SelectionDAGInfo TSInfo
const AArch64FrameLowering * getFrameLowering() const override
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
bool isOSFuchsia() const
Definition: Triple.h:506
const CallLowering * getCallLowering() const override
bool isCallingConvWin64(CallingConv::ID CC) const
bool hasCustomCheapAsMoveHandling() const
void mirFileLoaded(MachineFunction &MF) const override
void overrideSchedPolicy(MachineSchedPolicy &Policy, unsigned NumRegionInstrs) const override
bool enableAdvancedRASplitCost() const override
unsigned classifyGlobalFunctionReference(const GlobalValue *GV, const TargetMachine &TM) const
bool hasFuseArithmeticLogic() const
Holds all the information related to register banks.
bool hasFusion() const
Return true if the CPU supports any kind of instruction fusion.
bool hasArithmeticBccFusion() const
bool hasZeroCycleRegMove() const
bool force32BitJumpTables() const
std::unique_ptr< InstructionSelector > InstSelector
bool useAlternateSExtLoadCVTF32Pattern() const
const AArch64RegisterInfo * getRegisterInfo() const override
std::unique_ptr< LegalizerInfo > Legalizer
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1302
bool useAA() const override
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:463
unsigned getWideningBaseCost() const
bool enableMachineScheduler() const override
bool isXRegisterReserved(size_t i) const
unsigned getPrefFunctionLogAlignment() const
bool supportsAddressTopByteIgnored() const
CPU has TBI (top byte of addresses is ignored during HW address translation) and OS enables it...
bool enableEarlyIfConversion() const override
unsigned getMinVectorRegisterBitWidth() const
The C convention as implemented on Windows/x86-64 and AArch64.
Definition: CallingConv.h:164
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:539
const AArch64TargetLowering * getTargetLowering() const override
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
bool requiresStrictAlign() const
unsigned getPrefLoopLogAlignment() const
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:629
bool hasExynosCheapAsMoveHandling() const
bool addrSinkUsingGEPs() const override
bool isXRaySupported() const override
bool any() const
any - Returns true if any bit is set.
Definition: BitVector.h:180
bool useSmallAddressing() const
std::unique_ptr< CallLowering > CallLoweringInfo
GlobalISel related APIs.
unsigned getMaxPrefetchIterationsAhead() const override
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:634
const TargetMachine & getTargetMachine() const
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
const AArch64SelectionDAGInfo * getSelectionDAGInfo() const override
bool hasArithmeticCbzFusion() const
size_type count() const
count - Returns the number of bits which are set.
Definition: BitVector.h:172
AArch64InstrInfo InstrInfo
unsigned getMaximumJumpTableSize() const
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:587
unsigned getCacheLineSize() const override
bool enablePostRAScheduler() const override
CodeModel::Model getCodeModel() const
Returns the code model.
unsigned getMaxInterleaveFactor() const
unsigned getNumXRegisterReserved() const
std::unique_ptr< RegisterBankInfo > RegBankInfo
Provides the logic to select generic machine instructions.
Define a generic scheduling policy for targets that don&#39;t provide their own MachineSchedStrategy.
std::unique_ptr< PBQPRAConstraint > getCustomPBQPConstraints() const override
AArch64Subtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM, bool LittleEndian)
This constructor initializes the data members to match that of the specified triple.
const LegalizerInfo * getLegalizerInfo() const override
unsigned getPrefetchDistance() const override
AArch64FrameLowering FrameLowering
ARMProcFamilyEnum getProcFamily() const
Returns ARM processor family.
bool hasZeroCycleZeroingFPWorkaround() const
Triple TargetTriple
TargetTriple - What processor and OS we&#39;re targeting.
ARMProcFamilyEnum ARMProcFamily
ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
bool hasZeroCycleZeroingFP() const
bool hasZeroCycleZeroingGP() const
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
bool isXRegCustomCalleeSaved(size_t i) const
const AArch64InstrInfo * getInstrInfo() const override
This file describes how to lower LLVM calls to machine code calls.
const RegisterBankInfo * getRegBankInfo() const override
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:662
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
AArch64TargetLowering TLInfo
unsigned getVectorInsertExtractBaseCost() const