xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARM/ARMSubtarget.h (revision 1fd87a682ad7442327078e1eeb63edc4258f9815)
10b57cec5SDimitry Andric //===-- ARMSubtarget.h - Define Subtarget for the ARM ----------*- C++ -*--===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file declares the ARM specific subclass of TargetSubtargetInfo.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "ARMBaseInstrInfo.h"
170b57cec5SDimitry Andric #include "ARMBaseRegisterInfo.h"
180b57cec5SDimitry Andric #include "ARMConstantPoolValue.h"
190b57cec5SDimitry Andric #include "ARMFrameLowering.h"
200b57cec5SDimitry Andric #include "ARMISelLowering.h"
210eae32dcSDimitry Andric #include "ARMMachineFunctionInfo.h"
220b57cec5SDimitry Andric #include "ARMSelectionDAGInfo.h"
230b57cec5SDimitry Andric #include "llvm/ADT/Triple.h"
24fe6060f1SDimitry Andric #include "llvm/Analysis/TargetTransformInfo.h"
250b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/CallLowering.h"
260b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
270b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
280b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
290b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
300b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h"
310b57cec5SDimitry Andric #include "llvm/MC/MCInstrItineraries.h"
320b57cec5SDimitry Andric #include "llvm/MC/MCSchedule.h"
335ffd83dbSDimitry Andric #include "llvm/Target/TargetMachine.h"
340b57cec5SDimitry Andric #include "llvm/Target/TargetOptions.h"
350b57cec5SDimitry Andric #include <memory>
360b57cec5SDimitry Andric #include <string>
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric #define GET_SUBTARGETINFO_HEADER
390b57cec5SDimitry Andric #include "ARMGenSubtargetInfo.inc"
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric namespace llvm {
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric class ARMBaseTargetMachine;
440b57cec5SDimitry Andric class GlobalValue;
450b57cec5SDimitry Andric class StringRef;
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric class ARMSubtarget : public ARMGenSubtargetInfo {
480b57cec5SDimitry Andric protected:
490b57cec5SDimitry Andric   enum ARMProcFamilyEnum {
500b57cec5SDimitry Andric     Others,
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric     CortexA12,
530b57cec5SDimitry Andric     CortexA15,
540b57cec5SDimitry Andric     CortexA17,
550b57cec5SDimitry Andric     CortexA32,
560b57cec5SDimitry Andric     CortexA35,
570b57cec5SDimitry Andric     CortexA5,
580b57cec5SDimitry Andric     CortexA53,
590b57cec5SDimitry Andric     CortexA55,
600b57cec5SDimitry Andric     CortexA57,
610b57cec5SDimitry Andric     CortexA7,
620b57cec5SDimitry Andric     CortexA72,
630b57cec5SDimitry Andric     CortexA73,
640b57cec5SDimitry Andric     CortexA75,
650b57cec5SDimitry Andric     CortexA76,
665ffd83dbSDimitry Andric     CortexA77,
675ffd83dbSDimitry Andric     CortexA78,
68e8d8bef9SDimitry Andric     CortexA78C,
69349cc55cSDimitry Andric     CortexA710,
700b57cec5SDimitry Andric     CortexA8,
710b57cec5SDimitry Andric     CortexA9,
720b57cec5SDimitry Andric     CortexM3,
73e8d8bef9SDimitry Andric     CortexM7,
740b57cec5SDimitry Andric     CortexR4,
750b57cec5SDimitry Andric     CortexR4F,
760b57cec5SDimitry Andric     CortexR5,
770b57cec5SDimitry Andric     CortexR52,
780b57cec5SDimitry Andric     CortexR7,
795ffd83dbSDimitry Andric     CortexX1,
80*1fd87a68SDimitry Andric     CortexX1C,
810b57cec5SDimitry Andric     Exynos,
820b57cec5SDimitry Andric     Krait,
830b57cec5SDimitry Andric     Kryo,
848bcb0991SDimitry Andric     NeoverseN1,
85e8d8bef9SDimitry Andric     NeoverseN2,
86e8d8bef9SDimitry Andric     NeoverseV1,
870b57cec5SDimitry Andric     Swift
880b57cec5SDimitry Andric   };
890b57cec5SDimitry Andric   enum ARMProcClassEnum {
900b57cec5SDimitry Andric     None,
910b57cec5SDimitry Andric 
920b57cec5SDimitry Andric     AClass,
930b57cec5SDimitry Andric     MClass,
940b57cec5SDimitry Andric     RClass
950b57cec5SDimitry Andric   };
960b57cec5SDimitry Andric   enum ARMArchEnum {
970b57cec5SDimitry Andric     ARMv2,
980b57cec5SDimitry Andric     ARMv2a,
990b57cec5SDimitry Andric     ARMv3,
1000b57cec5SDimitry Andric     ARMv3m,
1010b57cec5SDimitry Andric     ARMv4,
1020b57cec5SDimitry Andric     ARMv4t,
1030b57cec5SDimitry Andric     ARMv5,
1040b57cec5SDimitry Andric     ARMv5t,
1050b57cec5SDimitry Andric     ARMv5te,
1060b57cec5SDimitry Andric     ARMv5tej,
1070b57cec5SDimitry Andric     ARMv6,
1080b57cec5SDimitry Andric     ARMv6k,
1090b57cec5SDimitry Andric     ARMv6kz,
1100b57cec5SDimitry Andric     ARMv6m,
1110b57cec5SDimitry Andric     ARMv6sm,
1120b57cec5SDimitry Andric     ARMv6t2,
1130b57cec5SDimitry Andric     ARMv7a,
1140b57cec5SDimitry Andric     ARMv7em,
1150b57cec5SDimitry Andric     ARMv7m,
1160b57cec5SDimitry Andric     ARMv7r,
1170b57cec5SDimitry Andric     ARMv7ve,
1180b57cec5SDimitry Andric     ARMv81a,
1190b57cec5SDimitry Andric     ARMv82a,
1200b57cec5SDimitry Andric     ARMv83a,
1210b57cec5SDimitry Andric     ARMv84a,
1220b57cec5SDimitry Andric     ARMv85a,
1235ffd83dbSDimitry Andric     ARMv86a,
124fe6060f1SDimitry Andric     ARMv87a,
12504eeddc0SDimitry Andric     ARMv88a,
1260b57cec5SDimitry Andric     ARMv8a,
1270b57cec5SDimitry Andric     ARMv8mBaseline,
1280b57cec5SDimitry Andric     ARMv8mMainline,
1290b57cec5SDimitry Andric     ARMv8r,
1300b57cec5SDimitry Andric     ARMv81mMainline,
131349cc55cSDimitry Andric     ARMv9a,
132349cc55cSDimitry Andric     ARMv91a,
133349cc55cSDimitry Andric     ARMv92a,
13404eeddc0SDimitry Andric     ARMv93a,
1350b57cec5SDimitry Andric   };
1360b57cec5SDimitry Andric 
1370b57cec5SDimitry Andric public:
1380b57cec5SDimitry Andric   /// What kind of timing do load multiple/store multiple instructions have.
1390b57cec5SDimitry Andric   enum ARMLdStMultipleTiming {
1400b57cec5SDimitry Andric     /// Can load/store 2 registers/cycle.
1410b57cec5SDimitry Andric     DoubleIssue,
1420b57cec5SDimitry Andric     /// Can load/store 2 registers/cycle, but needs an extra cycle if the access
1430b57cec5SDimitry Andric     /// is not 64-bit aligned.
1440b57cec5SDimitry Andric     DoubleIssueCheckUnalignedAccess,
1450b57cec5SDimitry Andric     /// Can load/store 1 register/cycle.
1460b57cec5SDimitry Andric     SingleIssue,
1470b57cec5SDimitry Andric     /// Can load/store 1 register/cycle, but needs an extra cycle for address
1480b57cec5SDimitry Andric     /// computation and potentially also for register writeback.
1490b57cec5SDimitry Andric     SingleIssuePlusExtras,
1500b57cec5SDimitry Andric   };
1510b57cec5SDimitry Andric 
1520b57cec5SDimitry Andric protected:
1530b57cec5SDimitry Andric   /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
1540b57cec5SDimitry Andric   ARMProcFamilyEnum ARMProcFamily = Others;
1550b57cec5SDimitry Andric 
1560b57cec5SDimitry Andric   /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass.
1570b57cec5SDimitry Andric   ARMProcClassEnum ARMProcClass = None;
1580b57cec5SDimitry Andric 
1590b57cec5SDimitry Andric   /// ARMArch - ARM architecture
1600b57cec5SDimitry Andric   ARMArchEnum ARMArch = ARMv4t;
1610b57cec5SDimitry Andric 
1620b57cec5SDimitry Andric   /// HasV4TOps, HasV5TOps, HasV5TEOps,
1630b57cec5SDimitry Andric   /// HasV6Ops, HasV6MOps, HasV6KOps, HasV6T2Ops, HasV7Ops, HasV8Ops -
1640b57cec5SDimitry Andric   /// Specify whether target support specific ARM ISA variants.
1650b57cec5SDimitry Andric   bool HasV4TOps = false;
1660b57cec5SDimitry Andric   bool HasV5TOps = false;
1670b57cec5SDimitry Andric   bool HasV5TEOps = false;
1680b57cec5SDimitry Andric   bool HasV6Ops = false;
1690b57cec5SDimitry Andric   bool HasV6MOps = false;
1700b57cec5SDimitry Andric   bool HasV6KOps = false;
1710b57cec5SDimitry Andric   bool HasV6T2Ops = false;
1720b57cec5SDimitry Andric   bool HasV7Ops = false;
1730b57cec5SDimitry Andric   bool HasV8Ops = false;
1740b57cec5SDimitry Andric   bool HasV8_1aOps = false;
1750b57cec5SDimitry Andric   bool HasV8_2aOps = false;
1760b57cec5SDimitry Andric   bool HasV8_3aOps = false;
1770b57cec5SDimitry Andric   bool HasV8_4aOps = false;
1780b57cec5SDimitry Andric   bool HasV8_5aOps = false;
1795ffd83dbSDimitry Andric   bool HasV8_6aOps = false;
18004eeddc0SDimitry Andric   bool HasV8_8aOps = false;
181e8d8bef9SDimitry Andric   bool HasV8_7aOps = false;
182349cc55cSDimitry Andric   bool HasV9_0aOps = false;
183349cc55cSDimitry Andric   bool HasV9_1aOps = false;
184349cc55cSDimitry Andric   bool HasV9_2aOps = false;
18504eeddc0SDimitry Andric   bool HasV9_3aOps = false;
1860b57cec5SDimitry Andric   bool HasV8MBaselineOps = false;
1870b57cec5SDimitry Andric   bool HasV8MMainlineOps = false;
1880b57cec5SDimitry Andric   bool HasV8_1MMainlineOps = false;
1890b57cec5SDimitry Andric   bool HasMVEIntegerOps = false;
1900b57cec5SDimitry Andric   bool HasMVEFloatOps = false;
1915ffd83dbSDimitry Andric   bool HasCDEOps = false;
1920b57cec5SDimitry Andric 
1930b57cec5SDimitry Andric   /// HasVFPv2, HasVFPv3, HasVFPv4, HasFPARMv8, HasNEON - Specify what
1940b57cec5SDimitry Andric   /// floating point ISAs are supported.
1950b57cec5SDimitry Andric   bool HasVFPv2 = false;
1960b57cec5SDimitry Andric   bool HasVFPv3 = false;
1970b57cec5SDimitry Andric   bool HasVFPv4 = false;
1980b57cec5SDimitry Andric   bool HasFPARMv8 = false;
1990b57cec5SDimitry Andric   bool HasNEON = false;
2000b57cec5SDimitry Andric   bool HasFPRegs = false;
2010b57cec5SDimitry Andric   bool HasFPRegs16 = false;
2020b57cec5SDimitry Andric   bool HasFPRegs64 = false;
2030b57cec5SDimitry Andric 
2040b57cec5SDimitry Andric   /// Versions of the VFP flags restricted to single precision, or to
2050b57cec5SDimitry Andric   /// 16 d-registers, or both.
2060b57cec5SDimitry Andric   bool HasVFPv2SP = false;
2070b57cec5SDimitry Andric   bool HasVFPv3SP = false;
2080b57cec5SDimitry Andric   bool HasVFPv4SP = false;
2090b57cec5SDimitry Andric   bool HasFPARMv8SP = false;
2100b57cec5SDimitry Andric   bool HasVFPv3D16 = false;
2110b57cec5SDimitry Andric   bool HasVFPv4D16 = false;
2120b57cec5SDimitry Andric   bool HasFPARMv8D16 = false;
2130b57cec5SDimitry Andric   bool HasVFPv3D16SP = false;
2140b57cec5SDimitry Andric   bool HasVFPv4D16SP = false;
2150b57cec5SDimitry Andric   bool HasFPARMv8D16SP = false;
2160b57cec5SDimitry Andric 
2170b57cec5SDimitry Andric   /// HasDotProd - True if the ARMv8.2A dot product instructions are supported.
2180b57cec5SDimitry Andric   bool HasDotProd = false;
2190b57cec5SDimitry Andric 
2200b57cec5SDimitry Andric   /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
2210b57cec5SDimitry Andric   /// specified. Use the method useNEONForSinglePrecisionFP() to
2220b57cec5SDimitry Andric   /// determine if NEON should actually be used.
2230b57cec5SDimitry Andric   bool UseNEONForSinglePrecisionFP = false;
2240b57cec5SDimitry Andric 
2250b57cec5SDimitry Andric   /// UseMulOps - True if non-microcoded fused integer multiply-add and
2260b57cec5SDimitry Andric   /// multiply-subtract instructions should be used.
2270b57cec5SDimitry Andric   bool UseMulOps = false;
2280b57cec5SDimitry Andric 
2290b57cec5SDimitry Andric   /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
2300b57cec5SDimitry Andric   /// whether the FP VML[AS] instructions are slow (if so, don't use them).
2310b57cec5SDimitry Andric   bool SlowFPVMLx = false;
2320b57cec5SDimitry Andric 
233480093f4SDimitry Andric   /// SlowFPVFMx - If the VFP4 / NEON instructions are available, indicates
234480093f4SDimitry Andric   /// whether the FP VFM[AS] instructions are slow (if so, don't use them).
235480093f4SDimitry Andric   bool SlowFPVFMx = false;
236480093f4SDimitry Andric 
2370b57cec5SDimitry Andric   /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
2380b57cec5SDimitry Andric   /// forwarding to allow mul + mla being issued back to back.
2390b57cec5SDimitry Andric   bool HasVMLxForwarding = false;
2400b57cec5SDimitry Andric 
2410b57cec5SDimitry Andric   /// SlowFPBrcc - True if floating point compare + branch is slow.
2420b57cec5SDimitry Andric   bool SlowFPBrcc = false;
2430b57cec5SDimitry Andric 
2440b57cec5SDimitry Andric   /// InThumbMode - True if compiling for Thumb, false for ARM.
2450b57cec5SDimitry Andric   bool InThumbMode = false;
2460b57cec5SDimitry Andric 
2470b57cec5SDimitry Andric   /// UseSoftFloat - True if we're using software floating point features.
2480b57cec5SDimitry Andric   bool UseSoftFloat = false;
2490b57cec5SDimitry Andric 
2500b57cec5SDimitry Andric   /// UseMISched - True if MachineScheduler should be used for this subtarget.
2510b57cec5SDimitry Andric   bool UseMISched = false;
2520b57cec5SDimitry Andric 
2530b57cec5SDimitry Andric   /// DisablePostRAScheduler - False if scheduling should happen again after
2540b57cec5SDimitry Andric   /// register allocation.
2550b57cec5SDimitry Andric   bool DisablePostRAScheduler = false;
2560b57cec5SDimitry Andric 
2570b57cec5SDimitry Andric   /// HasThumb2 - True if Thumb2 instructions are supported.
2580b57cec5SDimitry Andric   bool HasThumb2 = false;
2590b57cec5SDimitry Andric 
2600b57cec5SDimitry Andric   /// NoARM - True if subtarget does not support ARM mode execution.
2610b57cec5SDimitry Andric   bool NoARM = false;
2620b57cec5SDimitry Andric 
2630b57cec5SDimitry Andric   /// ReserveR9 - True if R9 is not available as a general purpose register.
2640b57cec5SDimitry Andric   bool ReserveR9 = false;
2650b57cec5SDimitry Andric 
2660b57cec5SDimitry Andric   /// NoMovt - True if MOVT / MOVW pairs are not used for materialization of
2670b57cec5SDimitry Andric   /// 32-bit imms (including global addresses).
2680b57cec5SDimitry Andric   bool NoMovt = false;
2690b57cec5SDimitry Andric 
2700b57cec5SDimitry Andric   /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
2710b57cec5SDimitry Andric   /// must be able to synthesize call stubs for interworking between ARM and
2720b57cec5SDimitry Andric   /// Thumb.
2730b57cec5SDimitry Andric   bool SupportsTailCall = false;
2740b57cec5SDimitry Andric 
2750b57cec5SDimitry Andric   /// HasFP16 - True if subtarget supports half-precision FP conversions
2760b57cec5SDimitry Andric   bool HasFP16 = false;
2770b57cec5SDimitry Andric 
2780b57cec5SDimitry Andric   /// HasFullFP16 - True if subtarget supports half-precision FP operations
2790b57cec5SDimitry Andric   bool HasFullFP16 = false;
2800b57cec5SDimitry Andric 
2810b57cec5SDimitry Andric   /// HasFP16FML - True if subtarget supports half-precision FP fml operations
2820b57cec5SDimitry Andric   bool HasFP16FML = false;
2830b57cec5SDimitry Andric 
2845ffd83dbSDimitry Andric   /// HasBF16 - True if subtarget supports BFloat16 floating point operations
2855ffd83dbSDimitry Andric   bool HasBF16 = false;
2865ffd83dbSDimitry Andric 
2875ffd83dbSDimitry Andric   /// HasMatMulInt8 - True if subtarget supports 8-bit integer matrix multiply
2885ffd83dbSDimitry Andric   bool HasMatMulInt8 = false;
2895ffd83dbSDimitry Andric 
2900b57cec5SDimitry Andric   /// HasD32 - True if subtarget has the full 32 double precision
2910b57cec5SDimitry Andric   /// FP registers for VFPv3.
2920b57cec5SDimitry Andric   bool HasD32 = false;
2930b57cec5SDimitry Andric 
2940b57cec5SDimitry Andric   /// HasHardwareDivide - True if subtarget supports [su]div in Thumb mode
2950b57cec5SDimitry Andric   bool HasHardwareDivideInThumb = false;
2960b57cec5SDimitry Andric 
2970b57cec5SDimitry Andric   /// HasHardwareDivideInARM - True if subtarget supports [su]div in ARM mode
2980b57cec5SDimitry Andric   bool HasHardwareDivideInARM = false;
2990b57cec5SDimitry Andric 
3000b57cec5SDimitry Andric   /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
3010b57cec5SDimitry Andric   /// instructions.
3020b57cec5SDimitry Andric   bool HasDataBarrier = false;
3030b57cec5SDimitry Andric 
3040b57cec5SDimitry Andric   /// HasFullDataBarrier - True if the subtarget supports DFB data barrier
3050b57cec5SDimitry Andric   /// instruction.
3060b57cec5SDimitry Andric   bool HasFullDataBarrier = false;
3070b57cec5SDimitry Andric 
3080b57cec5SDimitry Andric   /// HasV7Clrex - True if the subtarget supports CLREX instructions
3090b57cec5SDimitry Andric   bool HasV7Clrex = false;
3100b57cec5SDimitry Andric 
3110b57cec5SDimitry Andric   /// HasAcquireRelease - True if the subtarget supports v8 atomics (LDA/LDAEX etc)
3120b57cec5SDimitry Andric   /// instructions
3130b57cec5SDimitry Andric   bool HasAcquireRelease = false;
3140b57cec5SDimitry Andric 
3150b57cec5SDimitry Andric   /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
3160b57cec5SDimitry Andric   /// over 16-bit ones.
3170b57cec5SDimitry Andric   bool Pref32BitThumb = false;
3180b57cec5SDimitry Andric 
3190b57cec5SDimitry Andric   /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
3200b57cec5SDimitry Andric   /// that partially update CPSR and add false dependency on the previous
3210b57cec5SDimitry Andric   /// CPSR setting instruction.
3220b57cec5SDimitry Andric   bool AvoidCPSRPartialUpdate = false;
3230b57cec5SDimitry Andric 
3240b57cec5SDimitry Andric   /// CheapPredicableCPSRDef - If true, disable +1 predication cost
3250b57cec5SDimitry Andric   /// for instructions updating CPSR. Enabled for Cortex-A57.
3260b57cec5SDimitry Andric   bool CheapPredicableCPSRDef = false;
3270b57cec5SDimitry Andric 
3280b57cec5SDimitry Andric   /// AvoidMOVsShifterOperand - If true, codegen should avoid using flag setting
3290b57cec5SDimitry Andric   /// movs with shifter operand (i.e. asr, lsl, lsr).
3300b57cec5SDimitry Andric   bool AvoidMOVsShifterOperand = false;
3310b57cec5SDimitry Andric 
3320b57cec5SDimitry Andric   /// HasRetAddrStack - Some processors perform return stack prediction. CodeGen should
3330b57cec5SDimitry Andric   /// avoid issue "normal" call instructions to callees which do not return.
3340b57cec5SDimitry Andric   bool HasRetAddrStack = false;
3350b57cec5SDimitry Andric 
3360b57cec5SDimitry Andric   /// HasBranchPredictor - True if the subtarget has a branch predictor. Having
3370b57cec5SDimitry Andric   /// a branch predictor or not changes the expected cost of taking a branch
3380b57cec5SDimitry Andric   /// which affects the choice of whether to use predicated instructions.
3390b57cec5SDimitry Andric   bool HasBranchPredictor = true;
3400b57cec5SDimitry Andric 
3410b57cec5SDimitry Andric   /// HasMPExtension - True if the subtarget supports Multiprocessing
3420b57cec5SDimitry Andric   /// extension (ARMv7 only).
3430b57cec5SDimitry Andric   bool HasMPExtension = false;
3440b57cec5SDimitry Andric 
3450b57cec5SDimitry Andric   /// HasVirtualization - True if the subtarget supports the Virtualization
3460b57cec5SDimitry Andric   /// extension.
3470b57cec5SDimitry Andric   bool HasVirtualization = false;
3480b57cec5SDimitry Andric 
3490b57cec5SDimitry Andric   /// HasFP64 - If true, the floating point unit supports double
3500b57cec5SDimitry Andric   /// precision.
3510b57cec5SDimitry Andric   bool HasFP64 = false;
3520b57cec5SDimitry Andric 
3530b57cec5SDimitry Andric   /// If true, the processor supports the Performance Monitor Extensions. These
3540b57cec5SDimitry Andric   /// include a generic cycle-counter as well as more fine-grained (often
3550b57cec5SDimitry Andric   /// implementation-specific) events.
3560b57cec5SDimitry Andric   bool HasPerfMon = false;
3570b57cec5SDimitry Andric 
3580b57cec5SDimitry Andric   /// HasTrustZone - if true, processor supports TrustZone security extensions
3590b57cec5SDimitry Andric   bool HasTrustZone = false;
3600b57cec5SDimitry Andric 
3610b57cec5SDimitry Andric   /// Has8MSecExt - if true, processor supports ARMv8-M Security Extensions
3620b57cec5SDimitry Andric   bool Has8MSecExt = false;
3630b57cec5SDimitry Andric 
3640b57cec5SDimitry Andric   /// HasSHA2 - if true, processor supports SHA1 and SHA256
3650b57cec5SDimitry Andric   bool HasSHA2 = false;
3660b57cec5SDimitry Andric 
3670b57cec5SDimitry Andric   /// HasAES - if true, processor supports AES
3680b57cec5SDimitry Andric   bool HasAES = false;
3690b57cec5SDimitry Andric 
3700b57cec5SDimitry Andric   /// HasCrypto - if true, processor supports Cryptography extensions
3710b57cec5SDimitry Andric   bool HasCrypto = false;
3720b57cec5SDimitry Andric 
3730b57cec5SDimitry Andric   /// HasCRC - if true, processor supports CRC instructions
3740b57cec5SDimitry Andric   bool HasCRC = false;
3750b57cec5SDimitry Andric 
3760b57cec5SDimitry Andric   /// HasRAS - if true, the processor supports RAS extensions
3770b57cec5SDimitry Andric   bool HasRAS = false;
3780b57cec5SDimitry Andric 
3790b57cec5SDimitry Andric   /// HasLOB - if true, the processor supports the Low Overhead Branch extension
3800b57cec5SDimitry Andric   bool HasLOB = false;
3810b57cec5SDimitry Andric 
3824824e7fdSDimitry Andric   bool HasPACBTI = false;
3834824e7fdSDimitry Andric 
3840b57cec5SDimitry Andric   /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
3850b57cec5SDimitry Andric   /// particularly effective at zeroing a VFP register.
3860b57cec5SDimitry Andric   bool HasZeroCycleZeroing = false;
3870b57cec5SDimitry Andric 
3880b57cec5SDimitry Andric   /// HasFPAO - if true, processor  does positive address offset computation faster
3890b57cec5SDimitry Andric   bool HasFPAO = false;
3900b57cec5SDimitry Andric 
3910b57cec5SDimitry Andric   /// HasFuseAES - if true, processor executes back to back AES instruction
3920b57cec5SDimitry Andric   /// pairs faster.
3930b57cec5SDimitry Andric   bool HasFuseAES = false;
3940b57cec5SDimitry Andric 
3950b57cec5SDimitry Andric   /// HasFuseLiterals - if true, processor executes back to back
3960b57cec5SDimitry Andric   /// bottom and top halves of literal generation faster.
3970b57cec5SDimitry Andric   bool HasFuseLiterals = false;
3980b57cec5SDimitry Andric 
3990b57cec5SDimitry Andric   /// If true, if conversion may decide to leave some instructions unpredicated.
4000b57cec5SDimitry Andric   bool IsProfitableToUnpredicate = false;
4010b57cec5SDimitry Andric 
4020b57cec5SDimitry Andric   /// If true, VMOV will be favored over VGETLNi32.
4030b57cec5SDimitry Andric   bool HasSlowVGETLNi32 = false;
4040b57cec5SDimitry Andric 
4050b57cec5SDimitry Andric   /// If true, VMOV will be favored over VDUP.
4060b57cec5SDimitry Andric   bool HasSlowVDUP32 = false;
4070b57cec5SDimitry Andric 
4080b57cec5SDimitry Andric   /// If true, VMOVSR will be favored over VMOVDRR.
4090b57cec5SDimitry Andric   bool PreferVMOVSR = false;
4100b57cec5SDimitry Andric 
4110b57cec5SDimitry Andric   /// If true, ISHST barriers will be used for Release semantics.
4120b57cec5SDimitry Andric   bool PreferISHST = false;
4130b57cec5SDimitry Andric 
4140b57cec5SDimitry Andric   /// If true, a VLDM/VSTM starting with an odd register number is considered to
4150b57cec5SDimitry Andric   /// take more microops than single VLDRS/VSTRS.
4160b57cec5SDimitry Andric   bool SlowOddRegister = false;
4170b57cec5SDimitry Andric 
4180b57cec5SDimitry Andric   /// If true, loading into a D subregister will be penalized.
4190b57cec5SDimitry Andric   bool SlowLoadDSubregister = false;
4200b57cec5SDimitry Andric 
4210b57cec5SDimitry Andric   /// If true, use a wider stride when allocating VFP registers.
4220b57cec5SDimitry Andric   bool UseWideStrideVFP = false;
4230b57cec5SDimitry Andric 
4240b57cec5SDimitry Andric   /// If true, the AGU and NEON/FPU units are multiplexed.
4250b57cec5SDimitry Andric   bool HasMuxedUnits = false;
4260b57cec5SDimitry Andric 
4270b57cec5SDimitry Andric   /// If true, VMOVS will never be widened to VMOVD.
4280b57cec5SDimitry Andric   bool DontWidenVMOVS = false;
4290b57cec5SDimitry Andric 
4300b57cec5SDimitry Andric   /// If true, splat a register between VFP and NEON instructions.
4310b57cec5SDimitry Andric   bool SplatVFPToNeon = false;
4320b57cec5SDimitry Andric 
4330b57cec5SDimitry Andric   /// If true, run the MLx expansion pass.
4340b57cec5SDimitry Andric   bool ExpandMLx = false;
4350b57cec5SDimitry Andric 
4360b57cec5SDimitry Andric   /// If true, VFP/NEON VMLA/VMLS have special RAW hazards.
4370b57cec5SDimitry Andric   bool HasVMLxHazards = false;
4380b57cec5SDimitry Andric 
4390b57cec5SDimitry Andric   // If true, read thread pointer from coprocessor register.
4400b57cec5SDimitry Andric   bool ReadTPHard = false;
4410b57cec5SDimitry Andric 
4420b57cec5SDimitry Andric   /// If true, VMOVRS, VMOVSR and VMOVS will be converted from VFP to NEON.
4430b57cec5SDimitry Andric   bool UseNEONForFPMovs = false;
4440b57cec5SDimitry Andric 
4450b57cec5SDimitry Andric   /// If true, VLDn instructions take an extra cycle for unaligned accesses.
4460b57cec5SDimitry Andric   bool CheckVLDnAlign = false;
4470b57cec5SDimitry Andric 
4480b57cec5SDimitry Andric   /// If true, VFP instructions are not pipelined.
4490b57cec5SDimitry Andric   bool NonpipelinedVFP = false;
4500b57cec5SDimitry Andric 
4510b57cec5SDimitry Andric   /// StrictAlign - If true, the subtarget disallows unaligned memory
4520b57cec5SDimitry Andric   /// accesses for some types.  For details, see
4530b57cec5SDimitry Andric   /// ARMTargetLowering::allowsMisalignedMemoryAccesses().
4540b57cec5SDimitry Andric   bool StrictAlign = false;
4550b57cec5SDimitry Andric 
4560b57cec5SDimitry Andric   /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
4570b57cec5SDimitry Andric   ///  blocks to conform to ARMv8 rule.
4580b57cec5SDimitry Andric   bool RestrictIT = false;
4590b57cec5SDimitry Andric 
4600b57cec5SDimitry Andric   /// HasDSP - If true, the subtarget supports the DSP (saturating arith
4610b57cec5SDimitry Andric   /// and such) instructions.
4620b57cec5SDimitry Andric   bool HasDSP = false;
4630b57cec5SDimitry Andric 
4640b57cec5SDimitry Andric   /// NaCl TRAP instruction is generated instead of the regular TRAP.
4650b57cec5SDimitry Andric   bool UseNaClTrap = false;
4660b57cec5SDimitry Andric 
4670b57cec5SDimitry Andric   /// Generate calls via indirect call instructions.
4680b57cec5SDimitry Andric   bool GenLongCalls = false;
4690b57cec5SDimitry Andric 
4700b57cec5SDimitry Andric   /// Generate code that does not contain data access to code sections.
4710b57cec5SDimitry Andric   bool GenExecuteOnly = false;
4720b57cec5SDimitry Andric 
4730b57cec5SDimitry Andric   /// Target machine allowed unsafe FP math (such as use of NEON fp)
4740b57cec5SDimitry Andric   bool UnsafeFPMath = false;
4750b57cec5SDimitry Andric 
4760b57cec5SDimitry Andric   /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS).
4770b57cec5SDimitry Andric   bool UseSjLjEH = false;
4780b57cec5SDimitry Andric 
4790b57cec5SDimitry Andric   /// Has speculation barrier
4800b57cec5SDimitry Andric   bool HasSB = false;
4810b57cec5SDimitry Andric 
4820b57cec5SDimitry Andric   /// Implicitly convert an instruction to a different one if its immediates
4830b57cec5SDimitry Andric   /// cannot be encoded. For example, ADD r0, r1, #FFFFFFFF -> SUB r0, r1, #1.
4840b57cec5SDimitry Andric   bool NegativeImmediates = true;
4850b57cec5SDimitry Andric 
486349cc55cSDimitry Andric   /// Mitigate against the cve-2021-35465 security vulnurability.
487349cc55cSDimitry Andric   bool FixCMSE_CVE_2021_35465 = false;
488349cc55cSDimitry Andric 
489e8d8bef9SDimitry Andric   /// Harden against Straight Line Speculation for Returns and Indirect
490e8d8bef9SDimitry Andric   /// Branches.
491e8d8bef9SDimitry Andric   bool HardenSlsRetBr = false;
492e8d8bef9SDimitry Andric 
493e8d8bef9SDimitry Andric   /// Harden against Straight Line Speculation for indirect calls.
494e8d8bef9SDimitry Andric   bool HardenSlsBlr = false;
495e8d8bef9SDimitry Andric 
496fe6060f1SDimitry Andric   /// Generate thunk code for SLS mitigation in the normal text section.
497fe6060f1SDimitry Andric   bool HardenSlsNoComdat = false;
498fe6060f1SDimitry Andric 
4990b57cec5SDimitry Andric   /// stackAlignment - The minimum alignment known to hold of the stack frame on
5000b57cec5SDimitry Andric   /// entry to the function and which must be maintained by every function.
5018bcb0991SDimitry Andric   Align stackAlignment = Align(4);
5020b57cec5SDimitry Andric 
5030b57cec5SDimitry Andric   /// CPUString - String name of used CPU.
5040b57cec5SDimitry Andric   std::string CPUString;
5050b57cec5SDimitry Andric 
5060b57cec5SDimitry Andric   unsigned MaxInterleaveFactor = 1;
5070b57cec5SDimitry Andric 
5080b57cec5SDimitry Andric   /// Clearance before partial register updates (in number of instructions)
5090b57cec5SDimitry Andric   unsigned PartialUpdateClearance = 0;
5100b57cec5SDimitry Andric 
5110b57cec5SDimitry Andric   /// What kind of timing do load multiple/store multiple have (double issue,
5120b57cec5SDimitry Andric   /// single issue etc).
5130b57cec5SDimitry Andric   ARMLdStMultipleTiming LdStMultipleTiming = SingleIssue;
5140b57cec5SDimitry Andric 
5150b57cec5SDimitry Andric   /// The adjustment that we need to apply to get the operand latency from the
5160b57cec5SDimitry Andric   /// operand cycle returned by the itinerary data for pre-ISel operands.
5170b57cec5SDimitry Andric   int PreISelOperandLatencyAdjustment = 2;
5180b57cec5SDimitry Andric 
5190b57cec5SDimitry Andric   /// What alignment is preferred for loop bodies, in log2(bytes).
5208bcb0991SDimitry Andric   unsigned PrefLoopLogAlignment = 0;
5218bcb0991SDimitry Andric 
5228bcb0991SDimitry Andric   /// The cost factor for MVE instructions, representing the multiple beats an
5238bcb0991SDimitry Andric   // instruction can take. The default is 2, (set in initSubtargetFeatures so
5248bcb0991SDimitry Andric   // that we can use subtarget features less than 2).
5258bcb0991SDimitry Andric   unsigned MVEVectorCostFactor = 0;
5260b57cec5SDimitry Andric 
5270b57cec5SDimitry Andric   /// OptMinSize - True if we're optimising for minimum code size, equal to
5280b57cec5SDimitry Andric   /// the function attribute.
5290b57cec5SDimitry Andric   bool OptMinSize = false;
5300b57cec5SDimitry Andric 
5310b57cec5SDimitry Andric   /// IsLittle - The target is Little Endian
5320b57cec5SDimitry Andric   bool IsLittle;
5330b57cec5SDimitry Andric 
5340b57cec5SDimitry Andric   /// TargetTriple - What processor and OS we're targeting.
5350b57cec5SDimitry Andric   Triple TargetTriple;
5360b57cec5SDimitry Andric 
5370b57cec5SDimitry Andric   /// SchedModel - Processor specific instruction costs.
5380b57cec5SDimitry Andric   MCSchedModel SchedModel;
5390b57cec5SDimitry Andric 
5400b57cec5SDimitry Andric   /// Selected instruction itineraries (one entry per itinerary class.)
5410b57cec5SDimitry Andric   InstrItineraryData InstrItins;
5420b57cec5SDimitry Andric 
5430eae32dcSDimitry Andric   /// NoBTIAtReturnTwice - Don't place a BTI instruction after
5440eae32dcSDimitry Andric   /// return-twice constructs (setjmp)
5450eae32dcSDimitry Andric   bool NoBTIAtReturnTwice = false;
5460eae32dcSDimitry Andric 
5470b57cec5SDimitry Andric   /// Options passed via command line that could influence the target
5480b57cec5SDimitry Andric   const TargetOptions &Options;
5490b57cec5SDimitry Andric 
5500b57cec5SDimitry Andric   const ARMBaseTargetMachine &TM;
5510b57cec5SDimitry Andric 
5520b57cec5SDimitry Andric public:
5530b57cec5SDimitry Andric   /// This constructor initializes the data members to match that
5540b57cec5SDimitry Andric   /// of the specified triple.
5550b57cec5SDimitry Andric   ///
5560b57cec5SDimitry Andric   ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
5570b57cec5SDimitry Andric                const ARMBaseTargetMachine &TM, bool IsLittle,
5580b57cec5SDimitry Andric                bool MinSize = false);
5590b57cec5SDimitry Andric 
5600b57cec5SDimitry Andric   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
5610b57cec5SDimitry Andric   /// that still makes it profitable to inline the call.
5620b57cec5SDimitry Andric   unsigned getMaxInlineSizeThreshold() const {
5630b57cec5SDimitry Andric     return 64;
5640b57cec5SDimitry Andric   }
5650b57cec5SDimitry Andric 
566fe6060f1SDimitry Andric   /// getMaxMemcpyTPInlineSizeThreshold - Returns the maximum size
567fe6060f1SDimitry Andric   /// that still makes it profitable to inline a llvm.memcpy as a Tail
568fe6060f1SDimitry Andric   /// Predicated loop.
569fe6060f1SDimitry Andric   /// This threshold should only be used for constant size inputs.
570fe6060f1SDimitry Andric   unsigned getMaxMemcpyTPInlineSizeThreshold() const { return 128; }
571fe6060f1SDimitry Andric 
5720b57cec5SDimitry Andric   /// ParseSubtargetFeatures - Parses features string setting specified
5730b57cec5SDimitry Andric   /// subtarget options.  Definition of function is auto generated by tblgen.
574e8d8bef9SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
5750b57cec5SDimitry Andric 
5760b57cec5SDimitry Andric   /// initializeSubtargetDependencies - Initializes using a CPU and feature string
5770b57cec5SDimitry Andric   /// so that we can use initializer lists for subtarget initialization.
5780b57cec5SDimitry Andric   ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
5790b57cec5SDimitry Andric 
5800b57cec5SDimitry Andric   const ARMSelectionDAGInfo *getSelectionDAGInfo() const override {
5810b57cec5SDimitry Andric     return &TSInfo;
5820b57cec5SDimitry Andric   }
5830b57cec5SDimitry Andric 
5840b57cec5SDimitry Andric   const ARMBaseInstrInfo *getInstrInfo() const override {
5850b57cec5SDimitry Andric     return InstrInfo.get();
5860b57cec5SDimitry Andric   }
5870b57cec5SDimitry Andric 
5880b57cec5SDimitry Andric   const ARMTargetLowering *getTargetLowering() const override {
5890b57cec5SDimitry Andric     return &TLInfo;
5900b57cec5SDimitry Andric   }
5910b57cec5SDimitry Andric 
5920b57cec5SDimitry Andric   const ARMFrameLowering *getFrameLowering() const override {
5930b57cec5SDimitry Andric     return FrameLowering.get();
5940b57cec5SDimitry Andric   }
5950b57cec5SDimitry Andric 
5960b57cec5SDimitry Andric   const ARMBaseRegisterInfo *getRegisterInfo() const override {
5970b57cec5SDimitry Andric     return &InstrInfo->getRegisterInfo();
5980b57cec5SDimitry Andric   }
5990b57cec5SDimitry Andric 
6000b57cec5SDimitry Andric   const CallLowering *getCallLowering() const override;
6018bcb0991SDimitry Andric   InstructionSelector *getInstructionSelector() const override;
6020b57cec5SDimitry Andric   const LegalizerInfo *getLegalizerInfo() const override;
6030b57cec5SDimitry Andric   const RegisterBankInfo *getRegBankInfo() const override;
6040b57cec5SDimitry Andric 
6050b57cec5SDimitry Andric private:
6060b57cec5SDimitry Andric   ARMSelectionDAGInfo TSInfo;
6070b57cec5SDimitry Andric   // Either Thumb1FrameLowering or ARMFrameLowering.
6080b57cec5SDimitry Andric   std::unique_ptr<ARMFrameLowering> FrameLowering;
6090b57cec5SDimitry Andric   // Either Thumb1InstrInfo or Thumb2InstrInfo.
6100b57cec5SDimitry Andric   std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
6110b57cec5SDimitry Andric   ARMTargetLowering   TLInfo;
6120b57cec5SDimitry Andric 
6130b57cec5SDimitry Andric   /// GlobalISel related APIs.
6140b57cec5SDimitry Andric   std::unique_ptr<CallLowering> CallLoweringInfo;
6150b57cec5SDimitry Andric   std::unique_ptr<InstructionSelector> InstSelector;
6160b57cec5SDimitry Andric   std::unique_ptr<LegalizerInfo> Legalizer;
6170b57cec5SDimitry Andric   std::unique_ptr<RegisterBankInfo> RegBankInfo;
6180b57cec5SDimitry Andric 
6190b57cec5SDimitry Andric   void initializeEnvironment();
6200b57cec5SDimitry Andric   void initSubtargetFeatures(StringRef CPU, StringRef FS);
6210b57cec5SDimitry Andric   ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
6220b57cec5SDimitry Andric 
6235ffd83dbSDimitry Andric   std::bitset<8> CoprocCDE = {};
6240b57cec5SDimitry Andric public:
6250b57cec5SDimitry Andric   void computeIssueWidth();
6260b57cec5SDimitry Andric 
6270b57cec5SDimitry Andric   bool hasV4TOps()  const { return HasV4TOps;  }
6280b57cec5SDimitry Andric   bool hasV5TOps()  const { return HasV5TOps;  }
6290b57cec5SDimitry Andric   bool hasV5TEOps() const { return HasV5TEOps; }
6300b57cec5SDimitry Andric   bool hasV6Ops()   const { return HasV6Ops;   }
6310b57cec5SDimitry Andric   bool hasV6MOps()  const { return HasV6MOps;  }
6320b57cec5SDimitry Andric   bool hasV6KOps()  const { return HasV6KOps; }
6330b57cec5SDimitry Andric   bool hasV6T2Ops() const { return HasV6T2Ops; }
6340b57cec5SDimitry Andric   bool hasV7Ops()   const { return HasV7Ops;  }
6350b57cec5SDimitry Andric   bool hasV8Ops()   const { return HasV8Ops;  }
6360b57cec5SDimitry Andric   bool hasV8_1aOps() const { return HasV8_1aOps; }
6370b57cec5SDimitry Andric   bool hasV8_2aOps() const { return HasV8_2aOps; }
6380b57cec5SDimitry Andric   bool hasV8_3aOps() const { return HasV8_3aOps; }
6390b57cec5SDimitry Andric   bool hasV8_4aOps() const { return HasV8_4aOps; }
6400b57cec5SDimitry Andric   bool hasV8_5aOps() const { return HasV8_5aOps; }
6415ffd83dbSDimitry Andric   bool hasV8_6aOps() const { return HasV8_6aOps; }
642e8d8bef9SDimitry Andric   bool hasV8_7aOps() const { return HasV8_7aOps; }
64304eeddc0SDimitry Andric   bool hasV8_8aOps() const { return HasV8_8aOps; }
644349cc55cSDimitry Andric   bool hasV9_0aOps() const { return HasV9_0aOps; }
645349cc55cSDimitry Andric   bool hasV9_1aOps() const { return HasV9_1aOps; }
646349cc55cSDimitry Andric   bool hasV9_2aOps() const { return HasV9_2aOps; }
64704eeddc0SDimitry Andric   bool hasV9_3aOps() const { return HasV9_3aOps; }
6480b57cec5SDimitry Andric   bool hasV8MBaselineOps() const { return HasV8MBaselineOps; }
6490b57cec5SDimitry Andric   bool hasV8MMainlineOps() const { return HasV8MMainlineOps; }
6500b57cec5SDimitry Andric   bool hasV8_1MMainlineOps() const { return HasV8_1MMainlineOps; }
6510b57cec5SDimitry Andric   bool hasMVEIntegerOps() const { return HasMVEIntegerOps; }
6520b57cec5SDimitry Andric   bool hasMVEFloatOps() const { return HasMVEFloatOps; }
6535ffd83dbSDimitry Andric   bool hasCDEOps() const { return HasCDEOps; }
6540b57cec5SDimitry Andric   bool hasFPRegs() const { return HasFPRegs; }
6550b57cec5SDimitry Andric   bool hasFPRegs16() const { return HasFPRegs16; }
6560b57cec5SDimitry Andric   bool hasFPRegs64() const { return HasFPRegs64; }
6570b57cec5SDimitry Andric 
6580b57cec5SDimitry Andric   /// @{
6590b57cec5SDimitry Andric   /// These functions are obsolete, please consider adding subtarget features
6600b57cec5SDimitry Andric   /// or properties instead of calling them.
6610b57cec5SDimitry Andric   bool isCortexA5() const { return ARMProcFamily == CortexA5; }
6620b57cec5SDimitry Andric   bool isCortexA7() const { return ARMProcFamily == CortexA7; }
6630b57cec5SDimitry Andric   bool isCortexA8() const { return ARMProcFamily == CortexA8; }
6640b57cec5SDimitry Andric   bool isCortexA9() const { return ARMProcFamily == CortexA9; }
6650b57cec5SDimitry Andric   bool isCortexA15() const { return ARMProcFamily == CortexA15; }
6660b57cec5SDimitry Andric   bool isSwift()    const { return ARMProcFamily == Swift; }
6670b57cec5SDimitry Andric   bool isCortexM3() const { return ARMProcFamily == CortexM3; }
668e8d8bef9SDimitry Andric   bool isCortexM7() const { return ARMProcFamily == CortexM7; }
6690b57cec5SDimitry Andric   bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
6700b57cec5SDimitry Andric   bool isCortexR5() const { return ARMProcFamily == CortexR5; }
6710b57cec5SDimitry Andric   bool isKrait() const { return ARMProcFamily == Krait; }
6720b57cec5SDimitry Andric   /// @}
6730b57cec5SDimitry Andric 
6740b57cec5SDimitry Andric   bool hasARMOps() const { return !NoARM; }
6750b57cec5SDimitry Andric 
6768bcb0991SDimitry Andric   bool hasVFP2Base() const { return HasVFPv2SP; }
6770b57cec5SDimitry Andric   bool hasVFP3Base() const { return HasVFPv3D16SP; }
6780b57cec5SDimitry Andric   bool hasVFP4Base() const { return HasVFPv4D16SP; }
6790b57cec5SDimitry Andric   bool hasFPARMv8Base() const { return HasFPARMv8D16SP; }
6800b57cec5SDimitry Andric   bool hasNEON() const { return HasNEON;  }
6810b57cec5SDimitry Andric   bool hasSHA2() const { return HasSHA2; }
6820b57cec5SDimitry Andric   bool hasAES() const { return HasAES; }
6830b57cec5SDimitry Andric   bool hasCrypto() const { return HasCrypto; }
6840b57cec5SDimitry Andric   bool hasDotProd() const { return HasDotProd; }
6850b57cec5SDimitry Andric   bool hasCRC() const { return HasCRC; }
6860b57cec5SDimitry Andric   bool hasRAS() const { return HasRAS; }
6870b57cec5SDimitry Andric   bool hasLOB() const { return HasLOB; }
6884824e7fdSDimitry Andric   bool hasPACBTI() const { return HasPACBTI; }
6890b57cec5SDimitry Andric   bool hasVirtualization() const { return HasVirtualization; }
6900b57cec5SDimitry Andric 
6910b57cec5SDimitry Andric   bool useNEONForSinglePrecisionFP() const {
6920b57cec5SDimitry Andric     return hasNEON() && UseNEONForSinglePrecisionFP;
6930b57cec5SDimitry Andric   }
6940b57cec5SDimitry Andric 
6950b57cec5SDimitry Andric   bool hasDivideInThumbMode() const { return HasHardwareDivideInThumb; }
6960b57cec5SDimitry Andric   bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
6970b57cec5SDimitry Andric   bool hasDataBarrier() const { return HasDataBarrier; }
6980b57cec5SDimitry Andric   bool hasFullDataBarrier() const { return HasFullDataBarrier; }
6990b57cec5SDimitry Andric   bool hasV7Clrex() const { return HasV7Clrex; }
7000b57cec5SDimitry Andric   bool hasAcquireRelease() const { return HasAcquireRelease; }
7010b57cec5SDimitry Andric 
7020b57cec5SDimitry Andric   bool hasAnyDataBarrier() const {
7030b57cec5SDimitry Andric     return HasDataBarrier || (hasV6Ops() && !isThumb());
7040b57cec5SDimitry Andric   }
7050b57cec5SDimitry Andric 
7060b57cec5SDimitry Andric   bool useMulOps() const { return UseMulOps; }
7070b57cec5SDimitry Andric   bool useFPVMLx() const { return !SlowFPVMLx; }
708480093f4SDimitry Andric   bool useFPVFMx() const {
709480093f4SDimitry Andric     return !isTargetDarwin() && hasVFP4Base() && !SlowFPVFMx;
710480093f4SDimitry Andric   }
711480093f4SDimitry Andric   bool useFPVFMx16() const { return useFPVFMx() && hasFullFP16(); }
712480093f4SDimitry Andric   bool useFPVFMx64() const { return useFPVFMx() && hasFP64(); }
7130b57cec5SDimitry Andric   bool hasVMLxForwarding() const { return HasVMLxForwarding; }
7140b57cec5SDimitry Andric   bool isFPBrccSlow() const { return SlowFPBrcc; }
7150b57cec5SDimitry Andric   bool hasFP64() const { return HasFP64; }
7160b57cec5SDimitry Andric   bool hasPerfMon() const { return HasPerfMon; }
7170b57cec5SDimitry Andric   bool hasTrustZone() const { return HasTrustZone; }
7180b57cec5SDimitry Andric   bool has8MSecExt() const { return Has8MSecExt; }
7190b57cec5SDimitry Andric   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
7200b57cec5SDimitry Andric   bool hasFPAO() const { return HasFPAO; }
7210b57cec5SDimitry Andric   bool isProfitableToUnpredicate() const { return IsProfitableToUnpredicate; }
7220b57cec5SDimitry Andric   bool hasSlowVGETLNi32() const { return HasSlowVGETLNi32; }
7230b57cec5SDimitry Andric   bool hasSlowVDUP32() const { return HasSlowVDUP32; }
7240b57cec5SDimitry Andric   bool preferVMOVSR() const { return PreferVMOVSR; }
7250b57cec5SDimitry Andric   bool preferISHSTBarriers() const { return PreferISHST; }
7260b57cec5SDimitry Andric   bool expandMLx() const { return ExpandMLx; }
7270b57cec5SDimitry Andric   bool hasVMLxHazards() const { return HasVMLxHazards; }
7280b57cec5SDimitry Andric   bool hasSlowOddRegister() const { return SlowOddRegister; }
7290b57cec5SDimitry Andric   bool hasSlowLoadDSubregister() const { return SlowLoadDSubregister; }
7300b57cec5SDimitry Andric   bool useWideStrideVFP() const { return UseWideStrideVFP; }
7310b57cec5SDimitry Andric   bool hasMuxedUnits() const { return HasMuxedUnits; }
7320b57cec5SDimitry Andric   bool dontWidenVMOVS() const { return DontWidenVMOVS; }
7330b57cec5SDimitry Andric   bool useSplatVFPToNeon() const { return SplatVFPToNeon; }
7340b57cec5SDimitry Andric   bool useNEONForFPMovs() const { return UseNEONForFPMovs; }
7350b57cec5SDimitry Andric   bool checkVLDnAccessAlignment() const { return CheckVLDnAlign; }
7360b57cec5SDimitry Andric   bool nonpipelinedVFP() const { return NonpipelinedVFP; }
7370b57cec5SDimitry Andric   bool prefers32BitThumb() const { return Pref32BitThumb; }
7380b57cec5SDimitry Andric   bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
7390b57cec5SDimitry Andric   bool cheapPredicableCPSRDef() const { return CheapPredicableCPSRDef; }
7400b57cec5SDimitry Andric   bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
7410b57cec5SDimitry Andric   bool hasRetAddrStack() const { return HasRetAddrStack; }
7420b57cec5SDimitry Andric   bool hasBranchPredictor() const { return HasBranchPredictor; }
7430b57cec5SDimitry Andric   bool hasMPExtension() const { return HasMPExtension; }
7440b57cec5SDimitry Andric   bool hasDSP() const { return HasDSP; }
7450b57cec5SDimitry Andric   bool useNaClTrap() const { return UseNaClTrap; }
7460b57cec5SDimitry Andric   bool useSjLjEH() const { return UseSjLjEH; }
7470b57cec5SDimitry Andric   bool hasSB() const { return HasSB; }
7480b57cec5SDimitry Andric   bool genLongCalls() const { return GenLongCalls; }
7490b57cec5SDimitry Andric   bool genExecuteOnly() const { return GenExecuteOnly; }
7508bcb0991SDimitry Andric   bool hasBaseDSP() const {
7518bcb0991SDimitry Andric     if (isThumb())
7528bcb0991SDimitry Andric       return hasDSP();
7538bcb0991SDimitry Andric     else
7548bcb0991SDimitry Andric       return hasV5TEOps();
7558bcb0991SDimitry Andric   }
7560b57cec5SDimitry Andric 
7570b57cec5SDimitry Andric   bool hasFP16() const { return HasFP16; }
7580b57cec5SDimitry Andric   bool hasD32() const { return HasD32; }
7590b57cec5SDimitry Andric   bool hasFullFP16() const { return HasFullFP16; }
7600b57cec5SDimitry Andric   bool hasFP16FML() const { return HasFP16FML; }
7615ffd83dbSDimitry Andric   bool hasBF16() const { return HasBF16; }
7620b57cec5SDimitry Andric 
7630b57cec5SDimitry Andric   bool hasFuseAES() const { return HasFuseAES; }
7640b57cec5SDimitry Andric   bool hasFuseLiterals() const { return HasFuseLiterals; }
7650b57cec5SDimitry Andric   /// Return true if the CPU supports any kind of instruction fusion.
7660b57cec5SDimitry Andric   bool hasFusion() const { return hasFuseAES() || hasFuseLiterals(); }
7670b57cec5SDimitry Andric 
7685ffd83dbSDimitry Andric   bool hasMatMulInt8() const { return HasMatMulInt8; }
7695ffd83dbSDimitry Andric 
7700b57cec5SDimitry Andric   const Triple &getTargetTriple() const { return TargetTriple; }
7710b57cec5SDimitry Andric 
7720b57cec5SDimitry Andric   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
7730b57cec5SDimitry Andric   bool isTargetIOS() const { return TargetTriple.isiOS(); }
7740b57cec5SDimitry Andric   bool isTargetWatchOS() const { return TargetTriple.isWatchOS(); }
7750b57cec5SDimitry Andric   bool isTargetWatchABI() const { return TargetTriple.isWatchABI(); }
7760b57cec5SDimitry Andric   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
7770b57cec5SDimitry Andric   bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
7780b57cec5SDimitry Andric   bool isTargetNetBSD() const { return TargetTriple.isOSNetBSD(); }
7790b57cec5SDimitry Andric   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
7800b57cec5SDimitry Andric 
7810b57cec5SDimitry Andric   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
7820b57cec5SDimitry Andric   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
7830b57cec5SDimitry Andric   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
7840b57cec5SDimitry Andric 
7850b57cec5SDimitry Andric   // ARM EABI is the bare-metal EABI described in ARM ABI documents and
7860b57cec5SDimitry Andric   // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
7870b57cec5SDimitry Andric   // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
7880b57cec5SDimitry Andric   // even for GNUEABI, so we can make a distinction here and still conform to
7890b57cec5SDimitry Andric   // the EABI on GNU (and Android) mode. This requires change in Clang, too.
7900b57cec5SDimitry Andric   // FIXME: The Darwin exception is temporary, while we move users to
7910b57cec5SDimitry Andric   // "*-*-*-macho" triples as quickly as possible.
7920b57cec5SDimitry Andric   bool isTargetAEABI() const {
7930b57cec5SDimitry Andric     return (TargetTriple.getEnvironment() == Triple::EABI ||
7940b57cec5SDimitry Andric             TargetTriple.getEnvironment() == Triple::EABIHF) &&
7950b57cec5SDimitry Andric            !isTargetDarwin() && !isTargetWindows();
7960b57cec5SDimitry Andric   }
7970b57cec5SDimitry Andric   bool isTargetGNUAEABI() const {
7980b57cec5SDimitry Andric     return (TargetTriple.getEnvironment() == Triple::GNUEABI ||
7990b57cec5SDimitry Andric             TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
8000b57cec5SDimitry Andric            !isTargetDarwin() && !isTargetWindows();
8010b57cec5SDimitry Andric   }
8020b57cec5SDimitry Andric   bool isTargetMuslAEABI() const {
8030b57cec5SDimitry Andric     return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
8040b57cec5SDimitry Andric             TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
8050b57cec5SDimitry Andric            !isTargetDarwin() && !isTargetWindows();
8060b57cec5SDimitry Andric   }
8070b57cec5SDimitry Andric 
8080b57cec5SDimitry Andric   // ARM Targets that support EHABI exception handling standard
8090b57cec5SDimitry Andric   // Darwin uses SjLj. Other targets might need more checks.
8100b57cec5SDimitry Andric   bool isTargetEHABICompatible() const {
811349cc55cSDimitry Andric     return TargetTriple.isTargetEHABICompatible();
8120b57cec5SDimitry Andric   }
8130b57cec5SDimitry Andric 
8140b57cec5SDimitry Andric   bool isTargetHardFloat() const;
8150b57cec5SDimitry Andric 
8160b57cec5SDimitry Andric   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
8170b57cec5SDimitry Andric 
8180b57cec5SDimitry Andric   bool isXRaySupported() const override;
8190b57cec5SDimitry Andric 
8200b57cec5SDimitry Andric   bool isAPCS_ABI() const;
8210b57cec5SDimitry Andric   bool isAAPCS_ABI() const;
8220b57cec5SDimitry Andric   bool isAAPCS16_ABI() const;
8230b57cec5SDimitry Andric 
8240b57cec5SDimitry Andric   bool isROPI() const;
8250b57cec5SDimitry Andric   bool isRWPI() const;
8260b57cec5SDimitry Andric 
8270b57cec5SDimitry Andric   bool useMachineScheduler() const { return UseMISched; }
8280b57cec5SDimitry Andric   bool disablePostRAScheduler() const { return DisablePostRAScheduler; }
8290b57cec5SDimitry Andric   bool useSoftFloat() const { return UseSoftFloat; }
8300b57cec5SDimitry Andric   bool isThumb() const { return InThumbMode; }
8310b57cec5SDimitry Andric   bool hasMinSize() const { return OptMinSize; }
8320b57cec5SDimitry Andric   bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
8330b57cec5SDimitry Andric   bool isThumb2() const { return InThumbMode && HasThumb2; }
8340b57cec5SDimitry Andric   bool hasThumb2() const { return HasThumb2; }
8350b57cec5SDimitry Andric   bool isMClass() const { return ARMProcClass == MClass; }
8360b57cec5SDimitry Andric   bool isRClass() const { return ARMProcClass == RClass; }
8370b57cec5SDimitry Andric   bool isAClass() const { return ARMProcClass == AClass; }
8380b57cec5SDimitry Andric   bool isReadTPHard() const { return ReadTPHard; }
8390b57cec5SDimitry Andric 
8400b57cec5SDimitry Andric   bool isR9Reserved() const {
8410b57cec5SDimitry Andric     return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
8420b57cec5SDimitry Andric   }
8430b57cec5SDimitry Andric 
844fe6060f1SDimitry Andric   MCPhysReg getFramePointerReg() const {
845fe6060f1SDimitry Andric     if (isTargetDarwin() || (!isTargetWindows() && isThumb()))
846fe6060f1SDimitry Andric       return ARM::R7;
847fe6060f1SDimitry Andric     return ARM::R11;
8480b57cec5SDimitry Andric   }
8490b57cec5SDimitry Andric 
8500b57cec5SDimitry Andric   /// Returns true if the frame setup is split into two separate pushes (first
8510b57cec5SDimitry Andric   /// r0-r7,lr then r8-r11), principally so that the frame pointer is adjacent
8520b57cec5SDimitry Andric   /// to lr. This is always required on Thumb1-only targets, as the push and
8530b57cec5SDimitry Andric   /// pop instructions can't access the high registers.
8540b57cec5SDimitry Andric   bool splitFramePushPop(const MachineFunction &MF) const {
8550eae32dcSDimitry Andric     if (MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress())
8560eae32dcSDimitry Andric       return true;
857fe6060f1SDimitry Andric     return (getFramePointerReg() == ARM::R7 &&
8580b57cec5SDimitry Andric             MF.getTarget().Options.DisableFramePointerElim(MF)) ||
8590b57cec5SDimitry Andric            isThumb1Only();
8600b57cec5SDimitry Andric   }
8610b57cec5SDimitry Andric 
8620b57cec5SDimitry Andric   bool useStride4VFPs() const;
8630b57cec5SDimitry Andric 
8640b57cec5SDimitry Andric   bool useMovt() const;
8650b57cec5SDimitry Andric 
8660b57cec5SDimitry Andric   bool supportsTailCall() const { return SupportsTailCall; }
8670b57cec5SDimitry Andric 
8680b57cec5SDimitry Andric   bool allowsUnalignedMem() const { return !StrictAlign; }
8690b57cec5SDimitry Andric 
8700b57cec5SDimitry Andric   bool restrictIT() const { return RestrictIT; }
8710b57cec5SDimitry Andric 
8720b57cec5SDimitry Andric   const std::string & getCPUString() const { return CPUString; }
8730b57cec5SDimitry Andric 
8740b57cec5SDimitry Andric   bool isLittle() const { return IsLittle; }
8750b57cec5SDimitry Andric 
8760b57cec5SDimitry Andric   unsigned getMispredictionPenalty() const;
8770b57cec5SDimitry Andric 
8780b57cec5SDimitry Andric   /// Returns true if machine scheduler should be enabled.
8790b57cec5SDimitry Andric   bool enableMachineScheduler() const override;
8800b57cec5SDimitry Andric 
8810b57cec5SDimitry Andric   /// True for some subtargets at > -O0.
8820b57cec5SDimitry Andric   bool enablePostRAScheduler() const override;
8830b57cec5SDimitry Andric 
884480093f4SDimitry Andric   /// True for some subtargets at > -O0.
885480093f4SDimitry Andric   bool enablePostRAMachineScheduler() const override;
886480093f4SDimitry Andric 
887480093f4SDimitry Andric   /// Check whether this subtarget wants to use subregister liveness.
888480093f4SDimitry Andric   bool enableSubRegLiveness() const override;
889480093f4SDimitry Andric 
8900b57cec5SDimitry Andric   /// Enable use of alias analysis during code generation (during MI
8910b57cec5SDimitry Andric   /// scheduling, DAGCombine, etc.).
892480093f4SDimitry Andric   bool useAA() const override { return true; }
8930b57cec5SDimitry Andric 
8940b57cec5SDimitry Andric   // enableAtomicExpand- True if we need to expand our atomics.
8950b57cec5SDimitry Andric   bool enableAtomicExpand() const override;
8960b57cec5SDimitry Andric 
8970b57cec5SDimitry Andric   /// getInstrItins - Return the instruction itineraries based on subtarget
8980b57cec5SDimitry Andric   /// selection.
8990b57cec5SDimitry Andric   const InstrItineraryData *getInstrItineraryData() const override {
9000b57cec5SDimitry Andric     return &InstrItins;
9010b57cec5SDimitry Andric   }
9020b57cec5SDimitry Andric 
9030b57cec5SDimitry Andric   /// getStackAlignment - Returns the minimum alignment known to hold of the
9040b57cec5SDimitry Andric   /// stack frame on entry to the function and which must be maintained by every
9050b57cec5SDimitry Andric   /// function for this subtarget.
9068bcb0991SDimitry Andric   Align getStackAlignment() const { return stackAlignment; }
9070b57cec5SDimitry Andric 
9080b57cec5SDimitry Andric   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
9090b57cec5SDimitry Andric 
9100b57cec5SDimitry Andric   unsigned getPartialUpdateClearance() const { return PartialUpdateClearance; }
9110b57cec5SDimitry Andric 
9120b57cec5SDimitry Andric   ARMLdStMultipleTiming getLdStMultipleTiming() const {
9130b57cec5SDimitry Andric     return LdStMultipleTiming;
9140b57cec5SDimitry Andric   }
9150b57cec5SDimitry Andric 
9160b57cec5SDimitry Andric   int getPreISelOperandLatencyAdjustment() const {
9170b57cec5SDimitry Andric     return PreISelOperandLatencyAdjustment;
9180b57cec5SDimitry Andric   }
9190b57cec5SDimitry Andric 
9200b57cec5SDimitry Andric   /// True if the GV will be accessed via an indirect symbol.
9210b57cec5SDimitry Andric   bool isGVIndirectSymbol(const GlobalValue *GV) const;
9220b57cec5SDimitry Andric 
9230b57cec5SDimitry Andric   /// Returns the constant pool modifier needed to access the GV.
9240b57cec5SDimitry Andric   bool isGVInGOT(const GlobalValue *GV) const;
9250b57cec5SDimitry Andric 
9260b57cec5SDimitry Andric   /// True if fast-isel is used.
9270b57cec5SDimitry Andric   bool useFastISel() const;
9280b57cec5SDimitry Andric 
9290b57cec5SDimitry Andric   /// Returns the correct return opcode for the current feature set.
9300b57cec5SDimitry Andric   /// Use BX if available to allow mixing thumb/arm code, but fall back
9310b57cec5SDimitry Andric   /// to plain mov pc,lr on ARMv4.
9320b57cec5SDimitry Andric   unsigned getReturnOpcode() const {
9330b57cec5SDimitry Andric     if (isThumb())
9340b57cec5SDimitry Andric       return ARM::tBX_RET;
9350b57cec5SDimitry Andric     if (hasV4TOps())
9360b57cec5SDimitry Andric       return ARM::BX_RET;
9370b57cec5SDimitry Andric     return ARM::MOVPCLR;
9380b57cec5SDimitry Andric   }
9390b57cec5SDimitry Andric 
9400b57cec5SDimitry Andric   /// Allow movt+movw for PIC global address calculation.
9410b57cec5SDimitry Andric   /// ELF does not have GOT relocations for movt+movw.
9420b57cec5SDimitry Andric   /// ROPI does not use GOT.
9430b57cec5SDimitry Andric   bool allowPositionIndependentMovt() const {
9440b57cec5SDimitry Andric     return isROPI() || !isTargetELF();
9450b57cec5SDimitry Andric   }
9460b57cec5SDimitry Andric 
9478bcb0991SDimitry Andric   unsigned getPrefLoopLogAlignment() const { return PrefLoopLogAlignment; }
9488bcb0991SDimitry Andric 
949fe6060f1SDimitry Andric   unsigned
950fe6060f1SDimitry Andric   getMVEVectorCostFactor(TargetTransformInfo::TargetCostKind CostKind) const {
951fe6060f1SDimitry Andric     if (CostKind == TargetTransformInfo::TCK_CodeSize)
952fe6060f1SDimitry Andric       return 1;
953fe6060f1SDimitry Andric     return MVEVectorCostFactor;
954fe6060f1SDimitry Andric   }
9550b57cec5SDimitry Andric 
9560b57cec5SDimitry Andric   bool ignoreCSRForAllocationOrder(const MachineFunction &MF,
9570b57cec5SDimitry Andric                                    unsigned PhysReg) const override;
9580b57cec5SDimitry Andric   unsigned getGPRAllocationOrder(const MachineFunction &MF) const;
959e8d8bef9SDimitry Andric 
960349cc55cSDimitry Andric   bool fixCMSE_CVE_2021_35465() const { return FixCMSE_CVE_2021_35465; }
961349cc55cSDimitry Andric 
962e8d8bef9SDimitry Andric   bool hardenSlsRetBr() const { return HardenSlsRetBr; }
963e8d8bef9SDimitry Andric   bool hardenSlsBlr() const { return HardenSlsBlr; }
964fe6060f1SDimitry Andric   bool hardenSlsNoComdat() const { return HardenSlsNoComdat; }
9650eae32dcSDimitry Andric 
9660eae32dcSDimitry Andric   bool getNoBTIAtReturnTwice() const { return NoBTIAtReturnTwice; }
9670b57cec5SDimitry Andric };
9680b57cec5SDimitry Andric 
9690b57cec5SDimitry Andric } // end namespace llvm
9700b57cec5SDimitry Andric 
9710b57cec5SDimitry Andric #endif  // LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H
972