LLVM  5.0.0
AArch64Subtarget.h
Go to the documentation of this file.
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"
23 #include "llvm/IR/DataLayout.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 
36 public:
37  enum ARMProcFamilyEnum : uint8_t {
53  };
54 
55 protected:
56  /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and 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  bool HasSVE = false;
74 
75  // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
76  bool HasZeroCycleRegMove = false;
77 
78  // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
79  bool HasZeroCycleZeroing = false;
80 
81  // StrictAlign - Disallow unaligned memory accesses.
82  bool StrictAlign = false;
83 
84  // NegativeImmediates - transform instructions with negative immediates
85  bool NegativeImmediates = true;
86 
87  // Enable 64-bit vectorization in SLP.
89 
90  bool UseAA = false;
92  bool BalanceFPOps = false;
93  bool CustomAsCheapAsMove = false;
94  bool UsePostRAScheduler = false;
96  bool Paired128IsSlow = false;
98  bool HasArithmeticBccFusion = false;
99  bool HasArithmeticCbzFusion = false;
100  bool HasFuseAES = false;
101  bool HasFuseLiterals = false;
103  bool UseRSqrt = false;
104  uint8_t MaxInterleaveFactor = 2;
106  uint16_t CacheLineSize = 0;
107  uint16_t PrefetchDistance = 0;
108  uint16_t MinPrefetchStride = 1;
109  unsigned MaxPrefetchIterationsAhead = UINT_MAX;
110  unsigned PrefFunctionAlignment = 0;
111  unsigned PrefLoopAlignment = 0;
112  unsigned MaxJumpTableSize = 0;
113  unsigned WideningBaseCost = 0;
114 
115  // ReserveX18 - X18 is not available as a general purpose register.
117 
118  bool IsLittle;
119 
120  /// TargetTriple - What processor and OS we're targeting.
122 
127  /// Gather the accessor points to GlobalISel-related APIs.
128  /// This is used to avoid ifndefs spreading around while GISel is
129  /// an optional library.
130  std::unique_ptr<GISelAccessor> GISel;
131 
132 private:
133  /// initializeSubtargetDependencies - Initializes using CPUString and the
134  /// passed in feature string so that we can use initializer lists for
135  /// subtarget initialization.
136  AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
137  StringRef CPUString);
138 
139  /// Initialize properties based on the selected processor family.
140  void initializeProperties();
141 
142 public:
143  /// This constructor initializes the data members to match that
144  /// of the specified triple.
145  AArch64Subtarget(const Triple &TT, const std::string &CPU,
146  const std::string &FS, const TargetMachine &TM,
147  bool LittleEndian);
148 
149  /// This object will take onwership of \p GISelAccessor.
151  this->GISel.reset(&GISel);
152  }
153 
155  return &TSInfo;
156  }
157  const AArch64FrameLowering *getFrameLowering() const override {
158  return &FrameLowering;
159  }
160  const AArch64TargetLowering *getTargetLowering() const override {
161  return &TLInfo;
162  }
163  const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
164  const AArch64RegisterInfo *getRegisterInfo() const override {
165  return &getInstrInfo()->getRegisterInfo();
166  }
167  const CallLowering *getCallLowering() const override;
168  const InstructionSelector *getInstructionSelector() const override;
169  const LegalizerInfo *getLegalizerInfo() const override;
170  const RegisterBankInfo *getRegBankInfo() const override;
171  const Triple &getTargetTriple() const { return TargetTriple; }
172  bool enableMachineScheduler() const override { return true; }
173  bool enablePostRAScheduler() const override {
174  return UsePostRAScheduler;
175  }
176 
177  /// Returns ARM processor family.
178  /// Avoid this function! CPU specifics should be kept local to this class
179  /// and preferably modeled with SubtargetFeatures or properties in
180  /// initializeProperties().
182  return ARMProcFamily;
183  }
184 
185  bool hasV8_1aOps() const { return HasV8_1aOps; }
186  bool hasV8_2aOps() const { return HasV8_2aOps; }
187 
188  bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
189 
190  bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
191 
192  bool requiresStrictAlign() const { return StrictAlign; }
193 
194  bool isXRaySupported() const override { return true; }
195 
196  unsigned getMinVectorRegisterBitWidth() const {
198  }
199 
200  bool isX18Reserved() const { return ReserveX18; }
201  bool hasFPARMv8() const { return HasFPARMv8; }
202  bool hasNEON() const { return HasNEON; }
203  bool hasCrypto() const { return HasCrypto; }
204  bool hasCRC() const { return HasCRC; }
205  bool hasLSE() const { return HasLSE; }
206  bool hasRAS() const { return HasRAS; }
207  bool hasRDM() const { return HasRDM; }
208  bool balanceFPOps() const { return BalanceFPOps; }
211  }
214  bool isPaired128Slow() const { return Paired128IsSlow; }
217  }
220  bool hasFuseAES() const { return HasFuseAES; }
221  bool hasFuseLiterals() const { return HasFuseLiterals; }
222 
223  /// \brief Return true if the CPU supports any kind of instruction fusion.
224  bool hasFusion() const {
227  }
228 
229  bool useRSqrt() const { return UseRSqrt; }
230  unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
233  }
234  unsigned getCacheLineSize() const { return CacheLineSize; }
235  unsigned getPrefetchDistance() const { return PrefetchDistance; }
236  unsigned getMinPrefetchStride() const { return MinPrefetchStride; }
237  unsigned getMaxPrefetchIterationsAhead() const {
239  }
240  unsigned getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
241  unsigned getPrefLoopAlignment() const { return PrefLoopAlignment; }
242 
243  unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
244 
245  unsigned getWideningBaseCost() const { return WideningBaseCost; }
246 
247  /// CPU has TBI (top byte of addresses is ignored during HW address
248  /// translation) and OS enables it.
249  bool supportsAddressTopByteIgnored() const;
250 
251  bool hasPerfMon() const { return HasPerfMon; }
252  bool hasFullFP16() const { return HasFullFP16; }
253  bool hasSPE() const { return HasSPE; }
254  bool hasLSLFast() const { return HasLSLFast; }
255  bool hasSVE() const { return HasSVE; }
256 
257  bool isLittleEndian() const { return IsLittle; }
258 
259  bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
260  bool isTargetIOS() const { return TargetTriple.isiOS(); }
261  bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
262  bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
263  bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
264  bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
265 
266  bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
267  bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
268  bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
269 
270  bool useAA() const override { return UseAA; }
271 
272  bool useSmallAddressing() const {
273  switch (TLInfo.getTargetMachine().getCodeModel()) {
274  case CodeModel::Kernel:
275  // Kernel is currently allowed only for Fuchsia targets,
276  // where it is the same as Small for almost all purposes.
277  case CodeModel::Small:
278  return true;
279  default:
280  return false;
281  }
282  }
283 
284  /// ParseSubtargetFeatures - Parses features string setting specified
285  /// subtarget options. Definition of function is auto generated by tblgen.
287 
288  /// ClassifyGlobalReference - Find the target operand flags that describe
289  /// how a global value should be referenced for the current subtarget.
290  unsigned char ClassifyGlobalReference(const GlobalValue *GV,
291  const TargetMachine &TM) const;
292 
293  unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
294  const TargetMachine &TM) const;
295 
296  /// This function returns the name of a function which has an interface
297  /// like the non-standard bzero function, if such a function exists on
298  /// the current subtarget and it is considered prefereable over
299  /// memset with zero passed as the second argument. Otherwise it
300  /// returns null.
301  const char *getBZeroEntry() const;
302 
304  unsigned NumRegionInstrs) const override;
305 
306  bool enableEarlyIfConversion() const override;
307 
308  std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
309 
311  switch (CC) {
312  case CallingConv::C:
313  return isTargetWindows();
314  case CallingConv::Win64:
315  return true;
316  default:
317  return false;
318  }
319  }
320 };
321 } // End llvm namespace
322 
323 #endif
The goal of this helper class is to gather the accessor to all the APIs related to GlobalISel...
Definition: GISelAccessor.h:29
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
bool isTargetAndroid() const
bool requiresStrictAlign() const
unsigned getVectorInsertExtractBaseCost() const
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:587
const TargetMachine & getTargetMachine() const
bool hasZeroCycleRegMove() const
const InstructionSelector * getInstructionSelector() const override
bool hasZeroCycleZeroing() const
bool hasCustomCheapAsMoveHandling() const
AArch64SelectionDAGInfo TSInfo
const AArch64FrameLowering * getFrameLowering() const override
const CallLowering * getCallLowering() const override
bool isAndroid() const
Tests whether the target is Android.
Definition: Triple.h:610
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:551
void overrideSchedPolicy(MachineSchedPolicy &Policy, unsigned NumRegionInstrs) const override
bool isPaired128Slow() const
Holds all the information related to register banks.
unsigned getMaximumJumpTableSize() const
bool useAlternateSExtLoadCVTF32Pattern() const
bool hasFuseLiterals() const
ARMProcFamilyEnum getProcFamily() const
Returns ARM processor family.
unsigned getMinPrefetchStride() const
bool isOSLinux() const
Tests whether the OS is Linux.
Definition: Triple.h:561
bool isTargetFuchsia() const
const AArch64RegisterInfo * getRegisterInfo() const override
bool useAA() const override
unsigned getPrefetchDistance() const
bool enableMachineScheduler() const override
const Triple & getTargetTriple() const
bool enableEarlyIfConversion() const override
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:447
const AArch64TargetLowering * getTargetLowering() const override
unsigned char classifyGlobalFunctionReference(const GlobalValue *GV, const TargetMachine &TM) const
CodeModel::Model getCodeModel() const
Returns the code model.
bool isXRaySupported() const override
unsigned getMaxPrefetchIterationsAhead() const
bool isLittleEndian() const
bool isOSFuchsia() const
Definition: Triple.h:482
void setGISelAccessor(GISelAccessor &GISel)
This object will take onwership of GISelAccessor.
bool isCallingConvWin64(CallingConv::ID CC) const
bool isMisaligned128StoreSlow() const
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:582
bool predictableSelectIsExpensive() const
unsigned char ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
ClassifyGlobalReference - Find the target operand flags that describe how a global value should be re...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:466
const AArch64SelectionDAGInfo * getSelectionDAGInfo() const override
AArch64InstrInfo InstrInfo
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
unsigned getMaxInterleaveFactor() const
const char * getBZeroEntry() const
This function returns the name of a function which has an interface like the non-standard bzero funct...
unsigned getCacheLineSize() const
bool enablePostRAScheduler() const override
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:35
bool hasArithmeticBccFusion() const
bool isTargetDarwin() const
The C convention as implemented on Windows/x86-64 and AArch64.
Definition: CallingConv.h:154
Provides the logic to select generic machine instructions.
Define a generic scheduling policy for targets that don'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
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:577
bool isTargetWindows() const
bool hasArithmeticCbzFusion() const
AArch64FrameLowering FrameLowering
unsigned getMinVectorRegisterBitWidth() const
bool supportsAddressTopByteIgnored() const
CPU has TBI (top byte of addresses is ignored during HW address translation) and OS enables it...
unsigned getWideningBaseCost() const
Triple TargetTriple
TargetTriple - What processor and OS we're targeting.
ARMProcFamilyEnum ARMProcFamily
ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
bool useSmallAddressing() const
const AArch64InstrInfo * getInstrInfo() const override
const RegisterBankInfo * getRegBankInfo() const override
unsigned getPrefFunctionAlignment() const
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
unsigned getPrefLoopAlignment() const
AArch64TargetLowering TLInfo
std::unique_ptr< GISelAccessor > GISel
Gather the accessor points to GlobalISel-related APIs.
bool hasFusion() const
Return true if the CPU supports any kind of instruction fusion.