]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/ARM/ARMSubtarget.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304659, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / ARM / ARMSubtarget.h
1 //===-- ARMSubtarget.h - Define Subtarget for the ARM ----------*- 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 ARM specific subclass of TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
15 #define LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
16
17 #include "ARMBaseInstrInfo.h"
18 #include "ARMBaseRegisterInfo.h"
19 #include "ARMFrameLowering.h"
20 #include "ARMISelLowering.h"
21 #include "ARMSelectionDAGInfo.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
24 #include "llvm/CodeGen/MachineFunction.h"
25 #include "llvm/MC/MCInstrItineraries.h"
26 #include "llvm/MC/MCSchedule.h"
27 #include "llvm/Target/TargetOptions.h"
28 #include "llvm/Target/TargetSubtargetInfo.h"
29 #include <memory>
30 #include <string>
31
32 #define GET_SUBTARGETINFO_HEADER
33 #include "ARMGenSubtargetInfo.inc"
34
35 namespace llvm {
36
37 class ARMBaseTargetMachine;
38 class GlobalValue;
39 class StringRef;
40
41 class ARMSubtarget : public ARMGenSubtargetInfo {
42 protected:
43   enum ARMProcFamilyEnum {
44     Others,
45
46     CortexA12,
47     CortexA15,
48     CortexA17,
49     CortexA32,
50     CortexA35,
51     CortexA5,
52     CortexA53,
53     CortexA57,
54     CortexA7,
55     CortexA72,
56     CortexA73,
57     CortexA8,
58     CortexA9,
59     CortexM3,
60     CortexR4,
61     CortexR4F,
62     CortexR5,
63     CortexR52,
64     CortexR7,
65     ExynosM1,
66     Krait,
67     Kryo,
68     Swift
69   };
70   enum ARMProcClassEnum {
71     None,
72
73     AClass,
74     MClass,
75     RClass
76   };
77   enum ARMArchEnum {
78     ARMv2,
79     ARMv2a,
80     ARMv3,
81     ARMv3m,
82     ARMv4,
83     ARMv4t,
84     ARMv5,
85     ARMv5t,
86     ARMv5te,
87     ARMv5tej,
88     ARMv6,
89     ARMv6k,
90     ARMv6kz,
91     ARMv6m,
92     ARMv6sm,
93     ARMv6t2,
94     ARMv7a,
95     ARMv7em,
96     ARMv7m,
97     ARMv7r,
98     ARMv7ve,
99     ARMv81a,
100     ARMv82a,
101     ARMv8a,
102     ARMv8mBaseline,
103     ARMv8mMainline,
104     ARMv8r
105   };
106
107 public:
108   /// What kind of timing do load multiple/store multiple instructions have.
109   enum ARMLdStMultipleTiming {
110     /// Can load/store 2 registers/cycle.
111     DoubleIssue,
112     /// Can load/store 2 registers/cycle, but needs an extra cycle if the access
113     /// is not 64-bit aligned.
114     DoubleIssueCheckUnalignedAccess,
115     /// Can load/store 1 register/cycle.
116     SingleIssue,
117     /// Can load/store 1 register/cycle, but needs an extra cycle for address
118     /// computation and potentially also for register writeback.
119     SingleIssuePlusExtras,
120   };
121
122 protected:
123   /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
124   ARMProcFamilyEnum ARMProcFamily = Others;
125
126   /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass.
127   ARMProcClassEnum ARMProcClass = None;
128
129   /// ARMArch - ARM architecture
130   ARMArchEnum ARMArch = ARMv4t;
131
132   /// HasV4TOps, HasV5TOps, HasV5TEOps,
133   /// HasV6Ops, HasV6MOps, HasV6KOps, HasV6T2Ops, HasV7Ops, HasV8Ops -
134   /// Specify whether target support specific ARM ISA variants.
135   bool HasV4TOps = false;
136   bool HasV5TOps = false;
137   bool HasV5TEOps = false;
138   bool HasV6Ops = false;
139   bool HasV6MOps = false;
140   bool HasV6KOps = false;
141   bool HasV6T2Ops = false;
142   bool HasV7Ops = false;
143   bool HasV8Ops = false;
144   bool HasV8_1aOps = false;
145   bool HasV8_2aOps = false;
146   bool HasV8MBaselineOps = false;
147   bool HasV8MMainlineOps = false;
148
149   /// HasVFPv2, HasVFPv3, HasVFPv4, HasFPARMv8, HasNEON - Specify what
150   /// floating point ISAs are supported.
151   bool HasVFPv2 = false;
152   bool HasVFPv3 = false;
153   bool HasVFPv4 = false;
154   bool HasFPARMv8 = false;
155   bool HasNEON = false;
156
157   /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
158   /// specified. Use the method useNEONForSinglePrecisionFP() to
159   /// determine if NEON should actually be used.
160   bool UseNEONForSinglePrecisionFP = false;
161
162   /// UseMulOps - True if non-microcoded fused integer multiply-add and
163   /// multiply-subtract instructions should be used.
164   bool UseMulOps = false;
165
166   /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
167   /// whether the FP VML[AS] instructions are slow (if so, don't use them).
168   bool SlowFPVMLx = false;
169
170   /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
171   /// forwarding to allow mul + mla being issued back to back.
172   bool HasVMLxForwarding = false;
173
174   /// SlowFPBrcc - True if floating point compare + branch is slow.
175   bool SlowFPBrcc = false;
176
177   /// InThumbMode - True if compiling for Thumb, false for ARM.
178   bool InThumbMode = false;
179
180   /// UseSoftFloat - True if we're using software floating point features.
181   bool UseSoftFloat = false;
182
183   /// HasThumb2 - True if Thumb2 instructions are supported.
184   bool HasThumb2 = false;
185
186   /// NoARM - True if subtarget does not support ARM mode execution.
187   bool NoARM = false;
188
189   /// ReserveR9 - True if R9 is not available as a general purpose register.
190   bool ReserveR9 = false;
191
192   /// NoMovt - True if MOVT / MOVW pairs are not used for materialization of
193   /// 32-bit imms (including global addresses).
194   bool NoMovt = false;
195
196   /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
197   /// must be able to synthesize call stubs for interworking between ARM and
198   /// Thumb.
199   bool SupportsTailCall = false;
200
201   /// HasFP16 - True if subtarget supports half-precision FP conversions
202   bool HasFP16 = false;
203
204   /// HasFullFP16 - True if subtarget supports half-precision FP operations
205   bool HasFullFP16 = false;
206
207   /// HasD16 - True if subtarget is limited to 16 double precision
208   /// FP registers for VFPv3.
209   bool HasD16 = false;
210
211   /// HasHardwareDivide - True if subtarget supports [su]div in Thumb mode
212   bool HasHardwareDivideInThumb = false;
213
214   /// HasHardwareDivideInARM - True if subtarget supports [su]div in ARM mode
215   bool HasHardwareDivideInARM = false;
216
217   /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
218   /// instructions.
219   bool HasDataBarrier = false;
220
221   /// HasV7Clrex - True if the subtarget supports CLREX instructions
222   bool HasV7Clrex = false;
223
224   /// HasAcquireRelease - True if the subtarget supports v8 atomics (LDA/LDAEX etc)
225   /// instructions
226   bool HasAcquireRelease = false;
227
228   /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
229   /// over 16-bit ones.
230   bool Pref32BitThumb = false;
231
232   /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
233   /// that partially update CPSR and add false dependency on the previous
234   /// CPSR setting instruction.
235   bool AvoidCPSRPartialUpdate = false;
236
237   /// CheapPredicableCPSRDef - If true, disable +1 predication cost
238   /// for instructions updating CPSR. Enabled for Cortex-A57.
239   bool CheapPredicableCPSRDef = false;
240
241   /// AvoidMOVsShifterOperand - If true, codegen should avoid using flag setting
242   /// movs with shifter operand (i.e. asr, lsl, lsr).
243   bool AvoidMOVsShifterOperand = false;
244
245   /// HasRetAddrStack - Some processors perform return stack prediction. CodeGen should
246   /// avoid issue "normal" call instructions to callees which do not return.
247   bool HasRetAddrStack = false;
248
249   /// HasMPExtension - True if the subtarget supports Multiprocessing
250   /// extension (ARMv7 only).
251   bool HasMPExtension = false;
252
253   /// HasVirtualization - True if the subtarget supports the Virtualization
254   /// extension.
255   bool HasVirtualization = false;
256
257   /// FPOnlySP - If true, the floating point unit only supports single
258   /// precision.
259   bool FPOnlySP = false;
260
261   /// If true, the processor supports the Performance Monitor Extensions. These
262   /// include a generic cycle-counter as well as more fine-grained (often
263   /// implementation-specific) events.
264   bool HasPerfMon = false;
265
266   /// HasTrustZone - if true, processor supports TrustZone security extensions
267   bool HasTrustZone = false;
268
269   /// Has8MSecExt - if true, processor supports ARMv8-M Security Extensions
270   bool Has8MSecExt = false;
271
272   /// HasCrypto - if true, processor supports Cryptography extensions
273   bool HasCrypto = false;
274
275   /// HasCRC - if true, processor supports CRC instructions
276   bool HasCRC = false;
277
278   /// HasRAS - if true, the processor supports RAS extensions
279   bool HasRAS = false;
280
281   /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
282   /// particularly effective at zeroing a VFP register.
283   bool HasZeroCycleZeroing = false;
284
285   /// HasFPAO - if true, processor  does positive address offset computation faster
286   bool HasFPAO = false;
287
288   /// If true, if conversion may decide to leave some instructions unpredicated.
289   bool IsProfitableToUnpredicate = false;
290
291   /// If true, VMOV will be favored over VGETLNi32.
292   bool HasSlowVGETLNi32 = false;
293
294   /// If true, VMOV will be favored over VDUP.
295   bool HasSlowVDUP32 = false;
296
297   /// If true, VMOVSR will be favored over VMOVDRR.
298   bool PreferVMOVSR = false;
299
300   /// If true, ISHST barriers will be used for Release semantics.
301   bool PreferISHST = false;
302
303   /// If true, a VLDM/VSTM starting with an odd register number is considered to
304   /// take more microops than single VLDRS/VSTRS.
305   bool SlowOddRegister = false;
306
307   /// If true, loading into a D subregister will be penalized.
308   bool SlowLoadDSubregister = false;
309
310   /// If true, the AGU and NEON/FPU units are multiplexed.
311   bool HasMuxedUnits = false;
312
313   /// If true, VMOVS will never be widened to VMOVD
314   bool DontWidenVMOVS = false;
315
316   /// If true, run the MLx expansion pass.
317   bool ExpandMLx = false;
318
319   /// If true, VFP/NEON VMLA/VMLS have special RAW hazards.
320   bool HasVMLxHazards = false;
321
322   /// If true, VMOVRS, VMOVSR and VMOVS will be converted from VFP to NEON.
323   bool UseNEONForFPMovs = false;
324
325   /// If true, VLDn instructions take an extra cycle for unaligned accesses.
326   bool CheckVLDnAlign = false;
327
328   /// If true, VFP instructions are not pipelined.
329   bool NonpipelinedVFP = false;
330
331   /// StrictAlign - If true, the subtarget disallows unaligned memory
332   /// accesses for some types.  For details, see
333   /// ARMTargetLowering::allowsMisalignedMemoryAccesses().
334   bool StrictAlign = false;
335
336   /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
337   ///  blocks to conform to ARMv8 rule.
338   bool RestrictIT = false;
339
340   /// HasDSP - If true, the subtarget supports the DSP (saturating arith
341   /// and such) instructions.
342   bool HasDSP = false;
343
344   /// NaCl TRAP instruction is generated instead of the regular TRAP.
345   bool UseNaClTrap = false;
346
347   /// Generate calls via indirect call instructions.
348   bool GenLongCalls = false;
349
350   /// Generate code that does not contain data access to code sections.
351   bool GenExecuteOnly = false;
352
353   /// Target machine allowed unsafe FP math (such as use of NEON fp)
354   bool UnsafeFPMath = false;
355
356   /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS).
357   bool UseSjLjEH = false;
358
359   /// Implicitly convert an instruction to a different one if its immediates
360   /// cannot be encoded. For example, ADD r0, r1, #FFFFFFFF -> SUB r0, r1, #1.
361   bool NegativeImmediates = true;
362
363   /// stackAlignment - The minimum alignment known to hold of the stack frame on
364   /// entry to the function and which must be maintained by every function.
365   unsigned stackAlignment = 4;
366
367   /// CPUString - String name of used CPU.
368   std::string CPUString;
369
370   unsigned MaxInterleaveFactor = 1;
371
372   /// Clearance before partial register updates (in number of instructions)
373   unsigned PartialUpdateClearance = 0;
374
375   /// What kind of timing do load multiple/store multiple have (double issue,
376   /// single issue etc).
377   ARMLdStMultipleTiming LdStMultipleTiming = SingleIssue;
378
379   /// The adjustment that we need to apply to get the operand latency from the
380   /// operand cycle returned by the itinerary data for pre-ISel operands.
381   int PreISelOperandLatencyAdjustment = 2;
382
383   /// IsLittle - The target is Little Endian
384   bool IsLittle;
385
386   /// TargetTriple - What processor and OS we're targeting.
387   Triple TargetTriple;
388
389   /// SchedModel - Processor specific instruction costs.
390   MCSchedModel SchedModel;
391
392   /// Selected instruction itineraries (one entry per itinerary class.)
393   InstrItineraryData InstrItins;
394
395   /// Options passed via command line that could influence the target
396   const TargetOptions &Options;
397
398   const ARMBaseTargetMachine &TM;
399
400 public:
401   /// This constructor initializes the data members to match that
402   /// of the specified triple.
403   ///
404   ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
405                const ARMBaseTargetMachine &TM, bool IsLittle);
406
407   /// This object will take onwership of \p GISelAccessor.
408   void setGISelAccessor(GISelAccessor &GISel) { this->GISel.reset(&GISel); }
409
410   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
411   /// that still makes it profitable to inline the call.
412   unsigned getMaxInlineSizeThreshold() const {
413     return 64;
414   }
415
416   /// ParseSubtargetFeatures - Parses features string setting specified
417   /// subtarget options.  Definition of function is auto generated by tblgen.
418   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
419
420   /// initializeSubtargetDependencies - Initializes using a CPU and feature string
421   /// so that we can use initializer lists for subtarget initialization.
422   ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
423
424   const ARMSelectionDAGInfo *getSelectionDAGInfo() const override {
425     return &TSInfo;
426   }
427
428   const ARMBaseInstrInfo *getInstrInfo() const override {
429     return InstrInfo.get();
430   }
431
432   const ARMTargetLowering *getTargetLowering() const override {
433     return &TLInfo;
434   }
435
436   const ARMFrameLowering *getFrameLowering() const override {
437     return FrameLowering.get();
438   }
439
440   const ARMBaseRegisterInfo *getRegisterInfo() const override {
441     return &InstrInfo->getRegisterInfo();
442   }
443
444   const CallLowering *getCallLowering() const override;
445   const InstructionSelector *getInstructionSelector() const override;
446   const LegalizerInfo *getLegalizerInfo() const override;
447   const RegisterBankInfo *getRegBankInfo() const override;
448
449 private:
450   ARMSelectionDAGInfo TSInfo;
451   // Either Thumb1FrameLowering or ARMFrameLowering.
452   std::unique_ptr<ARMFrameLowering> FrameLowering;
453   // Either Thumb1InstrInfo or Thumb2InstrInfo.
454   std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
455   ARMTargetLowering   TLInfo;
456
457   /// Gather the accessor points to GlobalISel-related APIs.
458   /// This is used to avoid ifndefs spreading around while GISel is
459   /// an optional library.
460   std::unique_ptr<GISelAccessor> GISel;
461
462   void initializeEnvironment();
463   void initSubtargetFeatures(StringRef CPU, StringRef FS);
464   ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
465
466 public:
467   void computeIssueWidth();
468
469   bool hasV4TOps()  const { return HasV4TOps;  }
470   bool hasV5TOps()  const { return HasV5TOps;  }
471   bool hasV5TEOps() const { return HasV5TEOps; }
472   bool hasV6Ops()   const { return HasV6Ops;   }
473   bool hasV6MOps()  const { return HasV6MOps;  }
474   bool hasV6KOps()  const { return HasV6KOps; }
475   bool hasV6T2Ops() const { return HasV6T2Ops; }
476   bool hasV7Ops()   const { return HasV7Ops;  }
477   bool hasV8Ops()   const { return HasV8Ops;  }
478   bool hasV8_1aOps() const { return HasV8_1aOps; }
479   bool hasV8_2aOps() const { return HasV8_2aOps; }
480   bool hasV8MBaselineOps() const { return HasV8MBaselineOps; }
481   bool hasV8MMainlineOps() const { return HasV8MMainlineOps; }
482
483   /// @{
484   /// These functions are obsolete, please consider adding subtarget features
485   /// or properties instead of calling them.
486   bool isCortexA5() const { return ARMProcFamily == CortexA5; }
487   bool isCortexA7() const { return ARMProcFamily == CortexA7; }
488   bool isCortexA8() const { return ARMProcFamily == CortexA8; }
489   bool isCortexA9() const { return ARMProcFamily == CortexA9; }
490   bool isCortexA15() const { return ARMProcFamily == CortexA15; }
491   bool isSwift()    const { return ARMProcFamily == Swift; }
492   bool isCortexM3() const { return ARMProcFamily == CortexM3; }
493   bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
494   bool isCortexR5() const { return ARMProcFamily == CortexR5; }
495   bool isKrait() const { return ARMProcFamily == Krait; }
496   /// @}
497
498   bool hasARMOps() const { return !NoARM; }
499
500   bool hasVFP2() const { return HasVFPv2; }
501   bool hasVFP3() const { return HasVFPv3; }
502   bool hasVFP4() const { return HasVFPv4; }
503   bool hasFPARMv8() const { return HasFPARMv8; }
504   bool hasNEON() const { return HasNEON;  }
505   bool hasCrypto() const { return HasCrypto; }
506   bool hasCRC() const { return HasCRC; }
507   bool hasRAS() const { return HasRAS; }
508   bool hasVirtualization() const { return HasVirtualization; }
509
510   bool useNEONForSinglePrecisionFP() const {
511     return hasNEON() && UseNEONForSinglePrecisionFP;
512   }
513
514   bool hasDivideInThumbMode() const { return HasHardwareDivideInThumb; }
515   bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
516   bool hasDataBarrier() const { return HasDataBarrier; }
517   bool hasV7Clrex() const { return HasV7Clrex; }
518   bool hasAcquireRelease() const { return HasAcquireRelease; }
519
520   bool hasAnyDataBarrier() const {
521     return HasDataBarrier || (hasV6Ops() && !isThumb());
522   }
523
524   bool useMulOps() const { return UseMulOps; }
525   bool useFPVMLx() const { return !SlowFPVMLx; }
526   bool hasVMLxForwarding() const { return HasVMLxForwarding; }
527   bool isFPBrccSlow() const { return SlowFPBrcc; }
528   bool isFPOnlySP() const { return FPOnlySP; }
529   bool hasPerfMon() const { return HasPerfMon; }
530   bool hasTrustZone() const { return HasTrustZone; }
531   bool has8MSecExt() const { return Has8MSecExt; }
532   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
533   bool hasFPAO() const { return HasFPAO; }
534   bool isProfitableToUnpredicate() const { return IsProfitableToUnpredicate; }
535   bool hasSlowVGETLNi32() const { return HasSlowVGETLNi32; }
536   bool hasSlowVDUP32() const { return HasSlowVDUP32; }
537   bool preferVMOVSR() const { return PreferVMOVSR; }
538   bool preferISHSTBarriers() const { return PreferISHST; }
539   bool expandMLx() const { return ExpandMLx; }
540   bool hasVMLxHazards() const { return HasVMLxHazards; }
541   bool hasSlowOddRegister() const { return SlowOddRegister; }
542   bool hasSlowLoadDSubregister() const { return SlowLoadDSubregister; }
543   bool hasMuxedUnits() const { return HasMuxedUnits; }
544   bool dontWidenVMOVS() const { return DontWidenVMOVS; }
545   bool useNEONForFPMovs() const { return UseNEONForFPMovs; }
546   bool checkVLDnAccessAlignment() const { return CheckVLDnAlign; }
547   bool nonpipelinedVFP() const { return NonpipelinedVFP; }
548   bool prefers32BitThumb() const { return Pref32BitThumb; }
549   bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
550   bool cheapPredicableCPSRDef() const { return CheapPredicableCPSRDef; }
551   bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
552   bool hasRetAddrStack() const { return HasRetAddrStack; }
553   bool hasMPExtension() const { return HasMPExtension; }
554   bool hasDSP() const { return HasDSP; }
555   bool useNaClTrap() const { return UseNaClTrap; }
556   bool useSjLjEH() const { return UseSjLjEH; }
557   bool genLongCalls() const { return GenLongCalls; }
558   bool genExecuteOnly() const { return GenExecuteOnly; }
559
560   bool hasFP16() const { return HasFP16; }
561   bool hasD16() const { return HasD16; }
562   bool hasFullFP16() const { return HasFullFP16; }
563
564   const Triple &getTargetTriple() const { return TargetTriple; }
565
566   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
567   bool isTargetIOS() const { return TargetTriple.isiOS(); }
568   bool isTargetWatchOS() const { return TargetTriple.isWatchOS(); }
569   bool isTargetWatchABI() const { return TargetTriple.isWatchABI(); }
570   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
571   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
572   bool isTargetNetBSD() const { return TargetTriple.isOSNetBSD(); }
573   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
574
575   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
576   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
577   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
578
579   // ARM EABI is the bare-metal EABI described in ARM ABI documents and
580   // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
581   // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
582   // even for GNUEABI, so we can make a distinction here and still conform to
583   // the EABI on GNU (and Android) mode. This requires change in Clang, too.
584   // FIXME: The Darwin exception is temporary, while we move users to
585   // "*-*-*-macho" triples as quickly as possible.
586   bool isTargetAEABI() const {
587     return (TargetTriple.getEnvironment() == Triple::EABI ||
588             TargetTriple.getEnvironment() == Triple::EABIHF) &&
589            !isTargetDarwin() && !isTargetWindows();
590   }
591   bool isTargetGNUAEABI() const {
592     return (TargetTriple.getEnvironment() == Triple::GNUEABI ||
593             TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
594            !isTargetDarwin() && !isTargetWindows();
595   }
596   bool isTargetMuslAEABI() const {
597     return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
598             TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
599            !isTargetDarwin() && !isTargetWindows();
600   }
601
602   // ARM Targets that support EHABI exception handling standard
603   // Darwin uses SjLj. Other targets might need more checks.
604   bool isTargetEHABICompatible() const {
605     return (TargetTriple.getEnvironment() == Triple::EABI ||
606             TargetTriple.getEnvironment() == Triple::GNUEABI ||
607             TargetTriple.getEnvironment() == Triple::MuslEABI ||
608             TargetTriple.getEnvironment() == Triple::EABIHF ||
609             TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
610             TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
611             isTargetAndroid()) &&
612            !isTargetDarwin() && !isTargetWindows();
613   }
614
615   bool isTargetHardFloat() const {
616     // FIXME: this is invalid for WindowsCE
617     return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
618            TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
619            TargetTriple.getEnvironment() == Triple::EABIHF ||
620            isTargetWindows() || isAAPCS16_ABI();
621   }
622
623   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
624
625   bool isXRaySupported() const override;
626
627   bool isAPCS_ABI() const;
628   bool isAAPCS_ABI() const;
629   bool isAAPCS16_ABI() const;
630
631   bool isROPI() const;
632   bool isRWPI() const;
633
634   bool useSoftFloat() const { return UseSoftFloat; }
635   bool isThumb() const { return InThumbMode; }
636   bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
637   bool isThumb2() const { return InThumbMode && HasThumb2; }
638   bool hasThumb2() const { return HasThumb2; }
639   bool isMClass() const { return ARMProcClass == MClass; }
640   bool isRClass() const { return ARMProcClass == RClass; }
641   bool isAClass() const { return ARMProcClass == AClass; }
642
643   bool isR9Reserved() const {
644     return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
645   }
646
647   bool useR7AsFramePointer() const {
648     return isTargetDarwin() || (!isTargetWindows() && isThumb());
649   }
650
651   /// Returns true if the frame setup is split into two separate pushes (first
652   /// r0-r7,lr then r8-r11), principally so that the frame pointer is adjacent
653   /// to lr. This is always required on Thumb1-only targets, as the push and
654   /// pop instructions can't access the high registers.
655   bool splitFramePushPop(const MachineFunction &MF) const {
656     return (useR7AsFramePointer() &&
657             MF.getTarget().Options.DisableFramePointerElim(MF)) ||
658            isThumb1Only();
659   }
660
661   bool useStride4VFPs(const MachineFunction &MF) const;
662
663   bool useMovt(const MachineFunction &MF) const;
664
665   bool supportsTailCall() const { return SupportsTailCall; }
666
667   bool allowsUnalignedMem() const { return !StrictAlign; }
668
669   bool restrictIT() const { return RestrictIT; }
670
671   const std::string & getCPUString() const { return CPUString; }
672
673   bool isLittle() const { return IsLittle; }
674
675   unsigned getMispredictionPenalty() const;
676
677   /// This function returns true if the target has sincos() routine in its
678   /// compiler runtime or math libraries.
679   bool hasSinCos() const;
680
681   /// Returns true if machine scheduler should be enabled.
682   bool enableMachineScheduler() const override;
683
684   /// True for some subtargets at > -O0.
685   bool enablePostRAScheduler() const override;
686
687   // enableAtomicExpand- True if we need to expand our atomics.
688   bool enableAtomicExpand() const override;
689
690   /// getInstrItins - Return the instruction itineraries based on subtarget
691   /// selection.
692   const InstrItineraryData *getInstrItineraryData() const override {
693     return &InstrItins;
694   }
695
696   /// getStackAlignment - Returns the minimum alignment known to hold of the
697   /// stack frame on entry to the function and which must be maintained by every
698   /// function for this subtarget.
699   unsigned getStackAlignment() const { return stackAlignment; }
700
701   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
702
703   unsigned getPartialUpdateClearance() const { return PartialUpdateClearance; }
704
705   ARMLdStMultipleTiming getLdStMultipleTiming() const {
706     return LdStMultipleTiming;
707   }
708
709   int getPreISelOperandLatencyAdjustment() const {
710     return PreISelOperandLatencyAdjustment;
711   }
712
713   /// True if the GV will be accessed via an indirect symbol.
714   bool isGVIndirectSymbol(const GlobalValue *GV) const;
715
716   /// True if fast-isel is used.
717   bool useFastISel() const;
718 };
719
720 } // end namespace llvm
721
722 #endif  // LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H