]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/ARM/ARMSubtarget.h
Merge ACPICA 20170831.
[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   /// HasBranchPredictor - True if the subtarget has a branch predictor. Having
250   /// a branch predictor or not changes the expected cost of taking a branch
251   /// which affects the choice of whether to use predicated instructions.
252   bool HasBranchPredictor = true;
253
254   /// HasMPExtension - True if the subtarget supports Multiprocessing
255   /// extension (ARMv7 only).
256   bool HasMPExtension = false;
257
258   /// HasVirtualization - True if the subtarget supports the Virtualization
259   /// extension.
260   bool HasVirtualization = false;
261
262   /// FPOnlySP - If true, the floating point unit only supports single
263   /// precision.
264   bool FPOnlySP = false;
265
266   /// If true, the processor supports the Performance Monitor Extensions. These
267   /// include a generic cycle-counter as well as more fine-grained (often
268   /// implementation-specific) events.
269   bool HasPerfMon = false;
270
271   /// HasTrustZone - if true, processor supports TrustZone security extensions
272   bool HasTrustZone = false;
273
274   /// Has8MSecExt - if true, processor supports ARMv8-M Security Extensions
275   bool Has8MSecExt = false;
276
277   /// HasCrypto - if true, processor supports Cryptography extensions
278   bool HasCrypto = false;
279
280   /// HasCRC - if true, processor supports CRC instructions
281   bool HasCRC = false;
282
283   /// HasRAS - if true, the processor supports RAS extensions
284   bool HasRAS = false;
285
286   /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
287   /// particularly effective at zeroing a VFP register.
288   bool HasZeroCycleZeroing = false;
289
290   /// HasFPAO - if true, processor  does positive address offset computation faster
291   bool HasFPAO = false;
292
293   /// HasFuseAES - if true, processor executes back to back AES instruction
294   /// pairs faster.
295   bool HasFuseAES = false;
296
297   /// If true, if conversion may decide to leave some instructions unpredicated.
298   bool IsProfitableToUnpredicate = false;
299
300   /// If true, VMOV will be favored over VGETLNi32.
301   bool HasSlowVGETLNi32 = false;
302
303   /// If true, VMOV will be favored over VDUP.
304   bool HasSlowVDUP32 = false;
305
306   /// If true, VMOVSR will be favored over VMOVDRR.
307   bool PreferVMOVSR = false;
308
309   /// If true, ISHST barriers will be used for Release semantics.
310   bool PreferISHST = false;
311
312   /// If true, a VLDM/VSTM starting with an odd register number is considered to
313   /// take more microops than single VLDRS/VSTRS.
314   bool SlowOddRegister = false;
315
316   /// If true, loading into a D subregister will be penalized.
317   bool SlowLoadDSubregister = false;
318
319   /// If true, the AGU and NEON/FPU units are multiplexed.
320   bool HasMuxedUnits = false;
321
322   /// If true, VMOVS will never be widened to VMOVD
323   bool DontWidenVMOVS = false;
324
325   /// If true, run the MLx expansion pass.
326   bool ExpandMLx = false;
327
328   /// If true, VFP/NEON VMLA/VMLS have special RAW hazards.
329   bool HasVMLxHazards = false;
330
331   /// If true, VMOVRS, VMOVSR and VMOVS will be converted from VFP to NEON.
332   bool UseNEONForFPMovs = false;
333
334   /// If true, VLDn instructions take an extra cycle for unaligned accesses.
335   bool CheckVLDnAlign = false;
336
337   /// If true, VFP instructions are not pipelined.
338   bool NonpipelinedVFP = false;
339
340   /// StrictAlign - If true, the subtarget disallows unaligned memory
341   /// accesses for some types.  For details, see
342   /// ARMTargetLowering::allowsMisalignedMemoryAccesses().
343   bool StrictAlign = false;
344
345   /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
346   ///  blocks to conform to ARMv8 rule.
347   bool RestrictIT = false;
348
349   /// HasDSP - If true, the subtarget supports the DSP (saturating arith
350   /// and such) instructions.
351   bool HasDSP = false;
352
353   /// NaCl TRAP instruction is generated instead of the regular TRAP.
354   bool UseNaClTrap = false;
355
356   /// Generate calls via indirect call instructions.
357   bool GenLongCalls = false;
358
359   /// Generate code that does not contain data access to code sections.
360   bool GenExecuteOnly = false;
361
362   /// Target machine allowed unsafe FP math (such as use of NEON fp)
363   bool UnsafeFPMath = false;
364
365   /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS).
366   bool UseSjLjEH = false;
367
368   /// Implicitly convert an instruction to a different one if its immediates
369   /// cannot be encoded. For example, ADD r0, r1, #FFFFFFFF -> SUB r0, r1, #1.
370   bool NegativeImmediates = true;
371
372   /// stackAlignment - The minimum alignment known to hold of the stack frame on
373   /// entry to the function and which must be maintained by every function.
374   unsigned stackAlignment = 4;
375
376   /// CPUString - String name of used CPU.
377   std::string CPUString;
378
379   unsigned MaxInterleaveFactor = 1;
380
381   /// Clearance before partial register updates (in number of instructions)
382   unsigned PartialUpdateClearance = 0;
383
384   /// What kind of timing do load multiple/store multiple have (double issue,
385   /// single issue etc).
386   ARMLdStMultipleTiming LdStMultipleTiming = SingleIssue;
387
388   /// The adjustment that we need to apply to get the operand latency from the
389   /// operand cycle returned by the itinerary data for pre-ISel operands.
390   int PreISelOperandLatencyAdjustment = 2;
391
392   /// IsLittle - The target is Little Endian
393   bool IsLittle;
394
395   /// TargetTriple - What processor and OS we're targeting.
396   Triple TargetTriple;
397
398   /// SchedModel - Processor specific instruction costs.
399   MCSchedModel SchedModel;
400
401   /// Selected instruction itineraries (one entry per itinerary class.)
402   InstrItineraryData InstrItins;
403
404   /// Options passed via command line that could influence the target
405   const TargetOptions &Options;
406
407   const ARMBaseTargetMachine &TM;
408
409 public:
410   /// This constructor initializes the data members to match that
411   /// of the specified triple.
412   ///
413   ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
414                const ARMBaseTargetMachine &TM, bool IsLittle);
415
416   /// This object will take onwership of \p GISelAccessor.
417   void setGISelAccessor(GISelAccessor &GISel) { this->GISel.reset(&GISel); }
418
419   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
420   /// that still makes it profitable to inline the call.
421   unsigned getMaxInlineSizeThreshold() const {
422     return 64;
423   }
424
425   /// ParseSubtargetFeatures - Parses features string setting specified
426   /// subtarget options.  Definition of function is auto generated by tblgen.
427   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
428
429   /// initializeSubtargetDependencies - Initializes using a CPU and feature string
430   /// so that we can use initializer lists for subtarget initialization.
431   ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
432
433   const ARMSelectionDAGInfo *getSelectionDAGInfo() const override {
434     return &TSInfo;
435   }
436
437   const ARMBaseInstrInfo *getInstrInfo() const override {
438     return InstrInfo.get();
439   }
440
441   const ARMTargetLowering *getTargetLowering() const override {
442     return &TLInfo;
443   }
444
445   const ARMFrameLowering *getFrameLowering() const override {
446     return FrameLowering.get();
447   }
448
449   const ARMBaseRegisterInfo *getRegisterInfo() const override {
450     return &InstrInfo->getRegisterInfo();
451   }
452
453   const CallLowering *getCallLowering() const override;
454   const InstructionSelector *getInstructionSelector() const override;
455   const LegalizerInfo *getLegalizerInfo() const override;
456   const RegisterBankInfo *getRegBankInfo() const override;
457
458 private:
459   ARMSelectionDAGInfo TSInfo;
460   // Either Thumb1FrameLowering or ARMFrameLowering.
461   std::unique_ptr<ARMFrameLowering> FrameLowering;
462   // Either Thumb1InstrInfo or Thumb2InstrInfo.
463   std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
464   ARMTargetLowering   TLInfo;
465
466   /// Gather the accessor points to GlobalISel-related APIs.
467   /// This is used to avoid ifndefs spreading around while GISel is
468   /// an optional library.
469   std::unique_ptr<GISelAccessor> GISel;
470
471   void initializeEnvironment();
472   void initSubtargetFeatures(StringRef CPU, StringRef FS);
473   ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
474
475 public:
476   void computeIssueWidth();
477
478   bool hasV4TOps()  const { return HasV4TOps;  }
479   bool hasV5TOps()  const { return HasV5TOps;  }
480   bool hasV5TEOps() const { return HasV5TEOps; }
481   bool hasV6Ops()   const { return HasV6Ops;   }
482   bool hasV6MOps()  const { return HasV6MOps;  }
483   bool hasV6KOps()  const { return HasV6KOps; }
484   bool hasV6T2Ops() const { return HasV6T2Ops; }
485   bool hasV7Ops()   const { return HasV7Ops;  }
486   bool hasV8Ops()   const { return HasV8Ops;  }
487   bool hasV8_1aOps() const { return HasV8_1aOps; }
488   bool hasV8_2aOps() const { return HasV8_2aOps; }
489   bool hasV8MBaselineOps() const { return HasV8MBaselineOps; }
490   bool hasV8MMainlineOps() const { return HasV8MMainlineOps; }
491
492   /// @{
493   /// These functions are obsolete, please consider adding subtarget features
494   /// or properties instead of calling them.
495   bool isCortexA5() const { return ARMProcFamily == CortexA5; }
496   bool isCortexA7() const { return ARMProcFamily == CortexA7; }
497   bool isCortexA8() const { return ARMProcFamily == CortexA8; }
498   bool isCortexA9() const { return ARMProcFamily == CortexA9; }
499   bool isCortexA15() const { return ARMProcFamily == CortexA15; }
500   bool isSwift()    const { return ARMProcFamily == Swift; }
501   bool isCortexM3() const { return ARMProcFamily == CortexM3; }
502   bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
503   bool isCortexR5() const { return ARMProcFamily == CortexR5; }
504   bool isKrait() const { return ARMProcFamily == Krait; }
505   /// @}
506
507   bool hasARMOps() const { return !NoARM; }
508
509   bool hasVFP2() const { return HasVFPv2; }
510   bool hasVFP3() const { return HasVFPv3; }
511   bool hasVFP4() const { return HasVFPv4; }
512   bool hasFPARMv8() const { return HasFPARMv8; }
513   bool hasNEON() const { return HasNEON;  }
514   bool hasCrypto() const { return HasCrypto; }
515   bool hasCRC() const { return HasCRC; }
516   bool hasRAS() const { return HasRAS; }
517   bool hasVirtualization() const { return HasVirtualization; }
518
519   bool useNEONForSinglePrecisionFP() const {
520     return hasNEON() && UseNEONForSinglePrecisionFP;
521   }
522
523   bool hasDivideInThumbMode() const { return HasHardwareDivideInThumb; }
524   bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
525   bool hasDataBarrier() const { return HasDataBarrier; }
526   bool hasV7Clrex() const { return HasV7Clrex; }
527   bool hasAcquireRelease() const { return HasAcquireRelease; }
528
529   bool hasAnyDataBarrier() const {
530     return HasDataBarrier || (hasV6Ops() && !isThumb());
531   }
532
533   bool useMulOps() const { return UseMulOps; }
534   bool useFPVMLx() const { return !SlowFPVMLx; }
535   bool hasVMLxForwarding() const { return HasVMLxForwarding; }
536   bool isFPBrccSlow() const { return SlowFPBrcc; }
537   bool isFPOnlySP() const { return FPOnlySP; }
538   bool hasPerfMon() const { return HasPerfMon; }
539   bool hasTrustZone() const { return HasTrustZone; }
540   bool has8MSecExt() const { return Has8MSecExt; }
541   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
542   bool hasFPAO() const { return HasFPAO; }
543   bool isProfitableToUnpredicate() const { return IsProfitableToUnpredicate; }
544   bool hasSlowVGETLNi32() const { return HasSlowVGETLNi32; }
545   bool hasSlowVDUP32() const { return HasSlowVDUP32; }
546   bool preferVMOVSR() const { return PreferVMOVSR; }
547   bool preferISHSTBarriers() const { return PreferISHST; }
548   bool expandMLx() const { return ExpandMLx; }
549   bool hasVMLxHazards() const { return HasVMLxHazards; }
550   bool hasSlowOddRegister() const { return SlowOddRegister; }
551   bool hasSlowLoadDSubregister() const { return SlowLoadDSubregister; }
552   bool hasMuxedUnits() const { return HasMuxedUnits; }
553   bool dontWidenVMOVS() const { return DontWidenVMOVS; }
554   bool useNEONForFPMovs() const { return UseNEONForFPMovs; }
555   bool checkVLDnAccessAlignment() const { return CheckVLDnAlign; }
556   bool nonpipelinedVFP() const { return NonpipelinedVFP; }
557   bool prefers32BitThumb() const { return Pref32BitThumb; }
558   bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
559   bool cheapPredicableCPSRDef() const { return CheapPredicableCPSRDef; }
560   bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
561   bool hasRetAddrStack() const { return HasRetAddrStack; }
562   bool hasBranchPredictor() const { return HasBranchPredictor; }
563   bool hasMPExtension() const { return HasMPExtension; }
564   bool hasDSP() const { return HasDSP; }
565   bool useNaClTrap() const { return UseNaClTrap; }
566   bool useSjLjEH() const { return UseSjLjEH; }
567   bool genLongCalls() const { return GenLongCalls; }
568   bool genExecuteOnly() const { return GenExecuteOnly; }
569
570   bool hasFP16() const { return HasFP16; }
571   bool hasD16() const { return HasD16; }
572   bool hasFullFP16() const { return HasFullFP16; }
573
574   bool hasFuseAES() const { return HasFuseAES; }
575   /// \brief Return true if the CPU supports any kind of instruction fusion.
576   bool hasFusion() const { return hasFuseAES(); }
577
578   const Triple &getTargetTriple() const { return TargetTriple; }
579
580   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
581   bool isTargetIOS() const { return TargetTriple.isiOS(); }
582   bool isTargetWatchOS() const { return TargetTriple.isWatchOS(); }
583   bool isTargetWatchABI() const { return TargetTriple.isWatchABI(); }
584   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
585   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
586   bool isTargetNetBSD() const { return TargetTriple.isOSNetBSD(); }
587   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
588
589   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
590   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
591   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
592
593   // ARM EABI is the bare-metal EABI described in ARM ABI documents and
594   // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
595   // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
596   // even for GNUEABI, so we can make a distinction here and still conform to
597   // the EABI on GNU (and Android) mode. This requires change in Clang, too.
598   // FIXME: The Darwin exception is temporary, while we move users to
599   // "*-*-*-macho" triples as quickly as possible.
600   bool isTargetAEABI() const {
601     return (TargetTriple.getEnvironment() == Triple::EABI ||
602             TargetTriple.getEnvironment() == Triple::EABIHF) &&
603            !isTargetDarwin() && !isTargetWindows();
604   }
605   bool isTargetGNUAEABI() const {
606     return (TargetTriple.getEnvironment() == Triple::GNUEABI ||
607             TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
608            !isTargetDarwin() && !isTargetWindows();
609   }
610   bool isTargetMuslAEABI() const {
611     return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
612             TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
613            !isTargetDarwin() && !isTargetWindows();
614   }
615
616   // ARM Targets that support EHABI exception handling standard
617   // Darwin uses SjLj. Other targets might need more checks.
618   bool isTargetEHABICompatible() const {
619     return (TargetTriple.getEnvironment() == Triple::EABI ||
620             TargetTriple.getEnvironment() == Triple::GNUEABI ||
621             TargetTriple.getEnvironment() == Triple::MuslEABI ||
622             TargetTriple.getEnvironment() == Triple::EABIHF ||
623             TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
624             TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
625             isTargetAndroid()) &&
626            !isTargetDarwin() && !isTargetWindows();
627   }
628
629   bool isTargetHardFloat() const {
630     // FIXME: this is invalid for WindowsCE
631     return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
632            TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
633            TargetTriple.getEnvironment() == Triple::EABIHF ||
634            isTargetWindows() || isAAPCS16_ABI();
635   }
636
637   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
638
639   bool isXRaySupported() const override;
640
641   bool isAPCS_ABI() const;
642   bool isAAPCS_ABI() const;
643   bool isAAPCS16_ABI() const;
644
645   bool isROPI() const;
646   bool isRWPI() const;
647
648   bool useSoftFloat() const { return UseSoftFloat; }
649   bool isThumb() const { return InThumbMode; }
650   bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
651   bool isThumb2() const { return InThumbMode && HasThumb2; }
652   bool hasThumb2() const { return HasThumb2; }
653   bool isMClass() const { return ARMProcClass == MClass; }
654   bool isRClass() const { return ARMProcClass == RClass; }
655   bool isAClass() const { return ARMProcClass == AClass; }
656
657   bool isR9Reserved() const {
658     return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
659   }
660
661   bool useR7AsFramePointer() const {
662     return isTargetDarwin() || (!isTargetWindows() && isThumb());
663   }
664
665   /// Returns true if the frame setup is split into two separate pushes (first
666   /// r0-r7,lr then r8-r11), principally so that the frame pointer is adjacent
667   /// to lr. This is always required on Thumb1-only targets, as the push and
668   /// pop instructions can't access the high registers.
669   bool splitFramePushPop(const MachineFunction &MF) const {
670     return (useR7AsFramePointer() &&
671             MF.getTarget().Options.DisableFramePointerElim(MF)) ||
672            isThumb1Only();
673   }
674
675   bool useStride4VFPs(const MachineFunction &MF) const;
676
677   bool useMovt(const MachineFunction &MF) const;
678
679   bool supportsTailCall() const { return SupportsTailCall; }
680
681   bool allowsUnalignedMem() const { return !StrictAlign; }
682
683   bool restrictIT() const { return RestrictIT; }
684
685   const std::string & getCPUString() const { return CPUString; }
686
687   bool isLittle() const { return IsLittle; }
688
689   unsigned getMispredictionPenalty() const;
690
691   /// This function returns true if the target has sincos() routine in its
692   /// compiler runtime or math libraries.
693   bool hasSinCos() const;
694
695   /// Returns true if machine scheduler should be enabled.
696   bool enableMachineScheduler() const override;
697
698   /// True for some subtargets at > -O0.
699   bool enablePostRAScheduler() const override;
700
701   // enableAtomicExpand- True if we need to expand our atomics.
702   bool enableAtomicExpand() const override;
703
704   /// getInstrItins - Return the instruction itineraries based on subtarget
705   /// selection.
706   const InstrItineraryData *getInstrItineraryData() const override {
707     return &InstrItins;
708   }
709
710   /// getStackAlignment - Returns the minimum alignment known to hold of the
711   /// stack frame on entry to the function and which must be maintained by every
712   /// function for this subtarget.
713   unsigned getStackAlignment() const { return stackAlignment; }
714
715   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
716
717   unsigned getPartialUpdateClearance() const { return PartialUpdateClearance; }
718
719   ARMLdStMultipleTiming getLdStMultipleTiming() const {
720     return LdStMultipleTiming;
721   }
722
723   int getPreISelOperandLatencyAdjustment() const {
724     return PreISelOperandLatencyAdjustment;
725   }
726
727   /// True if the GV will be accessed via an indirect symbol.
728   bool isGVIndirectSymbol(const GlobalValue *GV) const;
729
730   /// True if fast-isel is used.
731   bool useFastISel() const;
732 };
733
734 } // end namespace llvm
735
736 #endif  // LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H