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" 23fe6060f1SDimitry Andric #include "llvm/Analysis/TargetTransformInfo.h" 240b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/CallLowering.h" 250b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/InstructionSelector.h" 260b57cec5SDimitry Andric #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" 270b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 2881ad6265SDimitry Andric #include "llvm/CodeGen/RegisterBankInfo.h" 290b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 300b57cec5SDimitry Andric #include "llvm/MC/MCInstrItineraries.h" 310b57cec5SDimitry Andric #include "llvm/MC/MCSchedule.h" 325ffd83dbSDimitry Andric #include "llvm/Target/TargetMachine.h" 330b57cec5SDimitry Andric #include "llvm/Target/TargetOptions.h" 3406c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h" 35*5f757f3fSDimitry Andric #include <bitset> 360b57cec5SDimitry Andric #include <memory> 370b57cec5SDimitry Andric #include <string> 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric #define GET_SUBTARGETINFO_HEADER 400b57cec5SDimitry Andric #include "ARMGenSubtargetInfo.inc" 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric namespace llvm { 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric class ARMBaseTargetMachine; 450b57cec5SDimitry Andric class GlobalValue; 460b57cec5SDimitry Andric class StringRef; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric class ARMSubtarget : public ARMGenSubtargetInfo { 490b57cec5SDimitry Andric protected: 500b57cec5SDimitry Andric enum ARMProcFamilyEnum { 510b57cec5SDimitry Andric Others, 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric CortexA12, 540b57cec5SDimitry Andric CortexA15, 550b57cec5SDimitry Andric CortexA17, 560b57cec5SDimitry Andric CortexA32, 570b57cec5SDimitry Andric CortexA35, 580b57cec5SDimitry Andric CortexA5, 590b57cec5SDimitry Andric CortexA53, 600b57cec5SDimitry Andric CortexA55, 610b57cec5SDimitry Andric CortexA57, 620b57cec5SDimitry Andric CortexA7, 630b57cec5SDimitry Andric CortexA72, 640b57cec5SDimitry Andric CortexA73, 650b57cec5SDimitry Andric CortexA75, 660b57cec5SDimitry Andric CortexA76, 675ffd83dbSDimitry Andric CortexA77, 685ffd83dbSDimitry Andric CortexA78, 69e8d8bef9SDimitry Andric CortexA78C, 70349cc55cSDimitry Andric CortexA710, 710b57cec5SDimitry Andric CortexA8, 720b57cec5SDimitry Andric CortexA9, 730b57cec5SDimitry Andric CortexM3, 74e8d8bef9SDimitry Andric CortexM7, 75*5f757f3fSDimitry Andric CortexM52, 760b57cec5SDimitry Andric CortexR4, 770b57cec5SDimitry Andric CortexR4F, 780b57cec5SDimitry Andric CortexR5, 790b57cec5SDimitry Andric CortexR52, 800b57cec5SDimitry Andric CortexR7, 815ffd83dbSDimitry Andric CortexX1, 821fd87a68SDimitry Andric CortexX1C, 830b57cec5SDimitry Andric Exynos, 840b57cec5SDimitry Andric Krait, 850b57cec5SDimitry Andric Kryo, 868bcb0991SDimitry Andric NeoverseN1, 87e8d8bef9SDimitry Andric NeoverseN2, 88e8d8bef9SDimitry Andric NeoverseV1, 890b57cec5SDimitry Andric Swift 900b57cec5SDimitry Andric }; 910b57cec5SDimitry Andric enum ARMProcClassEnum { 920b57cec5SDimitry Andric None, 930b57cec5SDimitry Andric 940b57cec5SDimitry Andric AClass, 950b57cec5SDimitry Andric MClass, 960b57cec5SDimitry Andric RClass 970b57cec5SDimitry Andric }; 980b57cec5SDimitry Andric enum ARMArchEnum { 990b57cec5SDimitry Andric ARMv4, 1000b57cec5SDimitry Andric ARMv4t, 1010b57cec5SDimitry Andric ARMv5, 1020b57cec5SDimitry Andric ARMv5t, 1030b57cec5SDimitry Andric ARMv5te, 1040b57cec5SDimitry Andric ARMv5tej, 1050b57cec5SDimitry Andric ARMv6, 1060b57cec5SDimitry Andric ARMv6k, 1070b57cec5SDimitry Andric ARMv6kz, 1080b57cec5SDimitry Andric ARMv6m, 1090b57cec5SDimitry Andric ARMv6sm, 1100b57cec5SDimitry Andric ARMv6t2, 1110b57cec5SDimitry Andric ARMv7a, 1120b57cec5SDimitry Andric ARMv7em, 1130b57cec5SDimitry Andric ARMv7m, 1140b57cec5SDimitry Andric ARMv7r, 1150b57cec5SDimitry Andric ARMv7ve, 1160b57cec5SDimitry Andric ARMv81a, 1170b57cec5SDimitry Andric ARMv82a, 1180b57cec5SDimitry Andric ARMv83a, 1190b57cec5SDimitry Andric ARMv84a, 1200b57cec5SDimitry Andric ARMv85a, 1215ffd83dbSDimitry Andric ARMv86a, 122fe6060f1SDimitry Andric ARMv87a, 12304eeddc0SDimitry Andric ARMv88a, 124bdd1243dSDimitry Andric ARMv89a, 1250b57cec5SDimitry Andric ARMv8a, 1260b57cec5SDimitry Andric ARMv8mBaseline, 1270b57cec5SDimitry Andric ARMv8mMainline, 1280b57cec5SDimitry Andric ARMv8r, 1290b57cec5SDimitry Andric ARMv81mMainline, 130349cc55cSDimitry Andric ARMv9a, 131349cc55cSDimitry Andric ARMv91a, 132349cc55cSDimitry Andric ARMv92a, 13304eeddc0SDimitry Andric ARMv93a, 134bdd1243dSDimitry Andric ARMv94a, 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: 15381ad6265SDimitry Andric // Bool members corresponding to the SubtargetFeatures defined in tablegen 15481ad6265SDimitry Andric #define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \ 15581ad6265SDimitry Andric bool ATTRIBUTE = DEFAULT; 15681ad6265SDimitry Andric #include "ARMGenSubtargetInfo.inc" 15781ad6265SDimitry Andric 1580b57cec5SDimitry Andric /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others. 1590b57cec5SDimitry Andric ARMProcFamilyEnum ARMProcFamily = Others; 1600b57cec5SDimitry Andric 1610b57cec5SDimitry Andric /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass. 1620b57cec5SDimitry Andric ARMProcClassEnum ARMProcClass = None; 1630b57cec5SDimitry Andric 1640b57cec5SDimitry Andric /// ARMArch - ARM architecture 1650b57cec5SDimitry Andric ARMArchEnum ARMArch = ARMv4t; 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric /// UseMulOps - True if non-microcoded fused integer multiply-add and 1680b57cec5SDimitry Andric /// multiply-subtract instructions should be used. 1690b57cec5SDimitry Andric bool UseMulOps = false; 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric /// SupportsTailCall - True if the OS supports tail call. The dynamic linker 1720b57cec5SDimitry Andric /// must be able to synthesize call stubs for interworking between ARM and 1730b57cec5SDimitry Andric /// Thumb. 1740b57cec5SDimitry Andric bool SupportsTailCall = false; 1750b57cec5SDimitry Andric 17681ad6265SDimitry Andric /// RestrictIT - If true, the subtarget disallows generation of complex IT 17781ad6265SDimitry Andric /// blocks. 1780b57cec5SDimitry Andric bool RestrictIT = false; 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andric /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS). 1810b57cec5SDimitry Andric bool UseSjLjEH = false; 1820b57cec5SDimitry Andric 1830b57cec5SDimitry Andric /// stackAlignment - The minimum alignment known to hold of the stack frame on 1840b57cec5SDimitry Andric /// entry to the function and which must be maintained by every function. 1858bcb0991SDimitry Andric Align stackAlignment = Align(4); 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andric /// CPUString - String name of used CPU. 1880b57cec5SDimitry Andric std::string CPUString; 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric unsigned MaxInterleaveFactor = 1; 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric /// Clearance before partial register updates (in number of instructions) 1930b57cec5SDimitry Andric unsigned PartialUpdateClearance = 0; 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric /// What kind of timing do load multiple/store multiple have (double issue, 1960b57cec5SDimitry Andric /// single issue etc). 1970b57cec5SDimitry Andric ARMLdStMultipleTiming LdStMultipleTiming = SingleIssue; 1980b57cec5SDimitry Andric 1990b57cec5SDimitry Andric /// The adjustment that we need to apply to get the operand latency from the 2000b57cec5SDimitry Andric /// operand cycle returned by the itinerary data for pre-ISel operands. 2010b57cec5SDimitry Andric int PreISelOperandLatencyAdjustment = 2; 2020b57cec5SDimitry Andric 203*5f757f3fSDimitry Andric /// What alignment is preferred for loop bodies and functions, in log2(bytes). 2048bcb0991SDimitry Andric unsigned PrefLoopLogAlignment = 0; 2058bcb0991SDimitry Andric 2068bcb0991SDimitry Andric /// The cost factor for MVE instructions, representing the multiple beats an 2078bcb0991SDimitry Andric // instruction can take. The default is 2, (set in initSubtargetFeatures so 2088bcb0991SDimitry Andric // that we can use subtarget features less than 2). 2098bcb0991SDimitry Andric unsigned MVEVectorCostFactor = 0; 2100b57cec5SDimitry Andric 2110b57cec5SDimitry Andric /// OptMinSize - True if we're optimising for minimum code size, equal to 2120b57cec5SDimitry Andric /// the function attribute. 2130b57cec5SDimitry Andric bool OptMinSize = false; 2140b57cec5SDimitry Andric 2150b57cec5SDimitry Andric /// IsLittle - The target is Little Endian 2160b57cec5SDimitry Andric bool IsLittle; 2170b57cec5SDimitry Andric 2180b57cec5SDimitry Andric /// TargetTriple - What processor and OS we're targeting. 2190b57cec5SDimitry Andric Triple TargetTriple; 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric /// SchedModel - Processor specific instruction costs. 2220b57cec5SDimitry Andric MCSchedModel SchedModel; 2230b57cec5SDimitry Andric 2240b57cec5SDimitry Andric /// Selected instruction itineraries (one entry per itinerary class.) 2250b57cec5SDimitry Andric InstrItineraryData InstrItins; 2260b57cec5SDimitry Andric 2270b57cec5SDimitry Andric /// Options passed via command line that could influence the target 2280b57cec5SDimitry Andric const TargetOptions &Options; 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric const ARMBaseTargetMachine &TM; 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric public: 2330b57cec5SDimitry Andric /// This constructor initializes the data members to match that 2340b57cec5SDimitry Andric /// of the specified triple. 2350b57cec5SDimitry Andric /// 2360b57cec5SDimitry Andric ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, 2370b57cec5SDimitry Andric const ARMBaseTargetMachine &TM, bool IsLittle, 2380b57cec5SDimitry Andric bool MinSize = false); 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andric /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size 2410b57cec5SDimitry Andric /// that still makes it profitable to inline the call. 2420b57cec5SDimitry Andric unsigned getMaxInlineSizeThreshold() const { 2430b57cec5SDimitry Andric return 64; 2440b57cec5SDimitry Andric } 2450b57cec5SDimitry Andric 246fe6060f1SDimitry Andric /// getMaxMemcpyTPInlineSizeThreshold - Returns the maximum size 247fe6060f1SDimitry Andric /// that still makes it profitable to inline a llvm.memcpy as a Tail 248fe6060f1SDimitry Andric /// Predicated loop. 249fe6060f1SDimitry Andric /// This threshold should only be used for constant size inputs. 250fe6060f1SDimitry Andric unsigned getMaxMemcpyTPInlineSizeThreshold() const { return 128; } 251fe6060f1SDimitry Andric 2520b57cec5SDimitry Andric /// ParseSubtargetFeatures - Parses features string setting specified 2530b57cec5SDimitry Andric /// subtarget options. Definition of function is auto generated by tblgen. 254e8d8bef9SDimitry Andric void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 2550b57cec5SDimitry Andric 2560b57cec5SDimitry Andric /// initializeSubtargetDependencies - Initializes using a CPU and feature string 2570b57cec5SDimitry Andric /// so that we can use initializer lists for subtarget initialization. 2580b57cec5SDimitry Andric ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); 2590b57cec5SDimitry Andric 2600b57cec5SDimitry Andric const ARMSelectionDAGInfo *getSelectionDAGInfo() const override { 2610b57cec5SDimitry Andric return &TSInfo; 2620b57cec5SDimitry Andric } 2630b57cec5SDimitry Andric 2640b57cec5SDimitry Andric const ARMBaseInstrInfo *getInstrInfo() const override { 2650b57cec5SDimitry Andric return InstrInfo.get(); 2660b57cec5SDimitry Andric } 2670b57cec5SDimitry Andric 2680b57cec5SDimitry Andric const ARMTargetLowering *getTargetLowering() const override { 2690b57cec5SDimitry Andric return &TLInfo; 2700b57cec5SDimitry Andric } 2710b57cec5SDimitry Andric 2720b57cec5SDimitry Andric const ARMFrameLowering *getFrameLowering() const override { 2730b57cec5SDimitry Andric return FrameLowering.get(); 2740b57cec5SDimitry Andric } 2750b57cec5SDimitry Andric 2760b57cec5SDimitry Andric const ARMBaseRegisterInfo *getRegisterInfo() const override { 2770b57cec5SDimitry Andric return &InstrInfo->getRegisterInfo(); 2780b57cec5SDimitry Andric } 2790b57cec5SDimitry Andric 2800b57cec5SDimitry Andric const CallLowering *getCallLowering() const override; 2818bcb0991SDimitry Andric InstructionSelector *getInstructionSelector() const override; 2820b57cec5SDimitry Andric const LegalizerInfo *getLegalizerInfo() const override; 2830b57cec5SDimitry Andric const RegisterBankInfo *getRegBankInfo() const override; 2840b57cec5SDimitry Andric 2850b57cec5SDimitry Andric private: 2860b57cec5SDimitry Andric ARMSelectionDAGInfo TSInfo; 2870b57cec5SDimitry Andric // Either Thumb1FrameLowering or ARMFrameLowering. 2880b57cec5SDimitry Andric std::unique_ptr<ARMFrameLowering> FrameLowering; 2890b57cec5SDimitry Andric // Either Thumb1InstrInfo or Thumb2InstrInfo. 2900b57cec5SDimitry Andric std::unique_ptr<ARMBaseInstrInfo> InstrInfo; 2910b57cec5SDimitry Andric ARMTargetLowering TLInfo; 2920b57cec5SDimitry Andric 2930b57cec5SDimitry Andric /// GlobalISel related APIs. 2940b57cec5SDimitry Andric std::unique_ptr<CallLowering> CallLoweringInfo; 2950b57cec5SDimitry Andric std::unique_ptr<InstructionSelector> InstSelector; 2960b57cec5SDimitry Andric std::unique_ptr<LegalizerInfo> Legalizer; 2970b57cec5SDimitry Andric std::unique_ptr<RegisterBankInfo> RegBankInfo; 2980b57cec5SDimitry Andric 2990b57cec5SDimitry Andric void initializeEnvironment(); 3000b57cec5SDimitry Andric void initSubtargetFeatures(StringRef CPU, StringRef FS); 3010b57cec5SDimitry Andric ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS); 3020b57cec5SDimitry Andric 3035ffd83dbSDimitry Andric std::bitset<8> CoprocCDE = {}; 3040b57cec5SDimitry Andric public: 30581ad6265SDimitry Andric // Getters for SubtargetFeatures defined in tablegen 30681ad6265SDimitry Andric #define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \ 30781ad6265SDimitry Andric bool GETTER() const { return ATTRIBUTE; } 30881ad6265SDimitry Andric #include "ARMGenSubtargetInfo.inc" 3090b57cec5SDimitry Andric 3100b57cec5SDimitry Andric /// @{ 3110b57cec5SDimitry Andric /// These functions are obsolete, please consider adding subtarget features 3120b57cec5SDimitry Andric /// or properties instead of calling them. 3130b57cec5SDimitry Andric bool isCortexA5() const { return ARMProcFamily == CortexA5; } 3140b57cec5SDimitry Andric bool isCortexA7() const { return ARMProcFamily == CortexA7; } 3150b57cec5SDimitry Andric bool isCortexA8() const { return ARMProcFamily == CortexA8; } 3160b57cec5SDimitry Andric bool isCortexA9() const { return ARMProcFamily == CortexA9; } 3170b57cec5SDimitry Andric bool isCortexA15() const { return ARMProcFamily == CortexA15; } 3180b57cec5SDimitry Andric bool isSwift() const { return ARMProcFamily == Swift; } 3190b57cec5SDimitry Andric bool isCortexM3() const { return ARMProcFamily == CortexM3; } 320e8d8bef9SDimitry Andric bool isCortexM7() const { return ARMProcFamily == CortexM7; } 3210b57cec5SDimitry Andric bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); } 3220b57cec5SDimitry Andric bool isCortexR5() const { return ARMProcFamily == CortexR5; } 3230b57cec5SDimitry Andric bool isKrait() const { return ARMProcFamily == Krait; } 3240b57cec5SDimitry Andric /// @} 3250b57cec5SDimitry Andric 3260b57cec5SDimitry Andric bool hasARMOps() const { return !NoARM; } 3270b57cec5SDimitry Andric 3280b57cec5SDimitry Andric bool useNEONForSinglePrecisionFP() const { 32981ad6265SDimitry Andric return hasNEON() && hasNEONForFP(); 3300b57cec5SDimitry Andric } 3310b57cec5SDimitry Andric 33281ad6265SDimitry Andric bool hasVFP2Base() const { return hasVFPv2SP(); } 33381ad6265SDimitry Andric bool hasVFP3Base() const { return hasVFPv3D16SP(); } 33481ad6265SDimitry Andric bool hasVFP4Base() const { return hasVFPv4D16SP(); } 33581ad6265SDimitry Andric bool hasFPARMv8Base() const { return hasFPARMv8D16SP(); } 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andric bool hasAnyDataBarrier() const { 3380b57cec5SDimitry Andric return HasDataBarrier || (hasV6Ops() && !isThumb()); 3390b57cec5SDimitry Andric } 3400b57cec5SDimitry Andric 3410b57cec5SDimitry Andric bool useMulOps() const { return UseMulOps; } 3420b57cec5SDimitry Andric bool useFPVMLx() const { return !SlowFPVMLx; } 343480093f4SDimitry Andric bool useFPVFMx() const { 344480093f4SDimitry Andric return !isTargetDarwin() && hasVFP4Base() && !SlowFPVFMx; 345480093f4SDimitry Andric } 346480093f4SDimitry Andric bool useFPVFMx16() const { return useFPVFMx() && hasFullFP16(); } 347480093f4SDimitry Andric bool useFPVFMx64() const { return useFPVFMx() && hasFP64(); } 3480b57cec5SDimitry Andric bool useSjLjEH() const { return UseSjLjEH; } 3498bcb0991SDimitry Andric bool hasBaseDSP() const { 3508bcb0991SDimitry Andric if (isThumb()) 35106c3fb27SDimitry Andric return hasThumb2() && hasDSP(); 3528bcb0991SDimitry Andric else 3538bcb0991SDimitry Andric return hasV5TEOps(); 3548bcb0991SDimitry Andric } 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric /// Return true if the CPU supports any kind of instruction fusion. 3570b57cec5SDimitry Andric bool hasFusion() const { return hasFuseAES() || hasFuseLiterals(); } 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andric const Triple &getTargetTriple() const { return TargetTriple; } 3600b57cec5SDimitry Andric 3610b57cec5SDimitry Andric bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); } 3620b57cec5SDimitry Andric bool isTargetIOS() const { return TargetTriple.isiOS(); } 3630b57cec5SDimitry Andric bool isTargetWatchOS() const { return TargetTriple.isWatchOS(); } 3640b57cec5SDimitry Andric bool isTargetWatchABI() const { return TargetTriple.isWatchABI(); } 36581ad6265SDimitry Andric bool isTargetDriverKit() const { return TargetTriple.isDriverKit(); } 3660b57cec5SDimitry Andric bool isTargetLinux() const { return TargetTriple.isOSLinux(); } 3670b57cec5SDimitry Andric bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); } 3680b57cec5SDimitry Andric bool isTargetNetBSD() const { return TargetTriple.isOSNetBSD(); } 3690b57cec5SDimitry Andric bool isTargetWindows() const { return TargetTriple.isOSWindows(); } 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andric bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); } 3720b57cec5SDimitry Andric bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } 3730b57cec5SDimitry Andric bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); } 3740b57cec5SDimitry Andric 3750b57cec5SDimitry Andric // ARM EABI is the bare-metal EABI described in ARM ABI documents and 3760b57cec5SDimitry Andric // can be accessed via -target arm-none-eabi. This is NOT GNUEABI. 3770b57cec5SDimitry Andric // FIXME: Add a flag for bare-metal for that target and set Triple::EABI 3780b57cec5SDimitry Andric // even for GNUEABI, so we can make a distinction here and still conform to 3790b57cec5SDimitry Andric // the EABI on GNU (and Android) mode. This requires change in Clang, too. 3800b57cec5SDimitry Andric // FIXME: The Darwin exception is temporary, while we move users to 3810b57cec5SDimitry Andric // "*-*-*-macho" triples as quickly as possible. 3820b57cec5SDimitry Andric bool isTargetAEABI() const { 3830b57cec5SDimitry Andric return (TargetTriple.getEnvironment() == Triple::EABI || 3840b57cec5SDimitry Andric TargetTriple.getEnvironment() == Triple::EABIHF) && 3850b57cec5SDimitry Andric !isTargetDarwin() && !isTargetWindows(); 3860b57cec5SDimitry Andric } 3870b57cec5SDimitry Andric bool isTargetGNUAEABI() const { 3880b57cec5SDimitry Andric return (TargetTriple.getEnvironment() == Triple::GNUEABI || 3890b57cec5SDimitry Andric TargetTriple.getEnvironment() == Triple::GNUEABIHF) && 3900b57cec5SDimitry Andric !isTargetDarwin() && !isTargetWindows(); 3910b57cec5SDimitry Andric } 3920b57cec5SDimitry Andric bool isTargetMuslAEABI() const { 3930b57cec5SDimitry Andric return (TargetTriple.getEnvironment() == Triple::MuslEABI || 39406c3fb27SDimitry Andric TargetTriple.getEnvironment() == Triple::MuslEABIHF || 39506c3fb27SDimitry Andric TargetTriple.getEnvironment() == Triple::OpenHOS) && 3960b57cec5SDimitry Andric !isTargetDarwin() && !isTargetWindows(); 3970b57cec5SDimitry Andric } 3980b57cec5SDimitry Andric 3990b57cec5SDimitry Andric // ARM Targets that support EHABI exception handling standard 4000b57cec5SDimitry Andric // Darwin uses SjLj. Other targets might need more checks. 4010b57cec5SDimitry Andric bool isTargetEHABICompatible() const { 402349cc55cSDimitry Andric return TargetTriple.isTargetEHABICompatible(); 4030b57cec5SDimitry Andric } 4040b57cec5SDimitry Andric 4050b57cec5SDimitry Andric bool isTargetHardFloat() const; 4060b57cec5SDimitry Andric 40706c3fb27SDimitry Andric bool isReadTPSoft() const { 40806c3fb27SDimitry Andric return !(isReadTPTPIDRURW() || isReadTPTPIDRURO() || isReadTPTPIDRPRW()); 40906c3fb27SDimitry Andric } 41006c3fb27SDimitry Andric 4110b57cec5SDimitry Andric bool isTargetAndroid() const { return TargetTriple.isAndroid(); } 4120b57cec5SDimitry Andric 4130b57cec5SDimitry Andric bool isXRaySupported() const override; 4140b57cec5SDimitry Andric 4150b57cec5SDimitry Andric bool isAPCS_ABI() const; 4160b57cec5SDimitry Andric bool isAAPCS_ABI() const; 4170b57cec5SDimitry Andric bool isAAPCS16_ABI() const; 4180b57cec5SDimitry Andric 4190b57cec5SDimitry Andric bool isROPI() const; 4200b57cec5SDimitry Andric bool isRWPI() const; 4210b57cec5SDimitry Andric 4220b57cec5SDimitry Andric bool useMachineScheduler() const { return UseMISched; } 42381ad6265SDimitry Andric bool useMachinePipeliner() const { return UseMIPipeliner; } 4240b57cec5SDimitry Andric bool hasMinSize() const { return OptMinSize; } 42581ad6265SDimitry Andric bool isThumb1Only() const { return isThumb() && !hasThumb2(); } 42681ad6265SDimitry Andric bool isThumb2() const { return isThumb() && hasThumb2(); } 4270b57cec5SDimitry Andric bool isMClass() const { return ARMProcClass == MClass; } 4280b57cec5SDimitry Andric bool isRClass() const { return ARMProcClass == RClass; } 4290b57cec5SDimitry Andric bool isAClass() const { return ARMProcClass == AClass; } 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andric bool isR9Reserved() const { 4320b57cec5SDimitry Andric return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9; 4330b57cec5SDimitry Andric } 4340b57cec5SDimitry Andric 435fe6060f1SDimitry Andric MCPhysReg getFramePointerReg() const { 43681ad6265SDimitry Andric if (isTargetDarwin() || 43781ad6265SDimitry Andric (!isTargetWindows() && isThumb() && !createAAPCSFrameChain())) 438fe6060f1SDimitry Andric return ARM::R7; 439fe6060f1SDimitry Andric return ARM::R11; 4400b57cec5SDimitry Andric } 4410b57cec5SDimitry Andric 4420b57cec5SDimitry Andric /// Returns true if the frame setup is split into two separate pushes (first 4430b57cec5SDimitry Andric /// r0-r7,lr then r8-r11), principally so that the frame pointer is adjacent 4440b57cec5SDimitry Andric /// to lr. This is always required on Thumb1-only targets, as the push and 4450b57cec5SDimitry Andric /// pop instructions can't access the high registers. 4460b57cec5SDimitry Andric bool splitFramePushPop(const MachineFunction &MF) const { 4470eae32dcSDimitry Andric if (MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress()) 4480eae32dcSDimitry Andric return true; 449fe6060f1SDimitry Andric return (getFramePointerReg() == ARM::R7 && 4500b57cec5SDimitry Andric MF.getTarget().Options.DisableFramePointerElim(MF)) || 4510b57cec5SDimitry Andric isThumb1Only(); 4520b57cec5SDimitry Andric } 4530b57cec5SDimitry Andric 45481ad6265SDimitry Andric bool splitFramePointerPush(const MachineFunction &MF) const; 45581ad6265SDimitry Andric 4560b57cec5SDimitry Andric bool useStride4VFPs() const; 4570b57cec5SDimitry Andric 4580b57cec5SDimitry Andric bool useMovt() const; 4590b57cec5SDimitry Andric 4600b57cec5SDimitry Andric bool supportsTailCall() const { return SupportsTailCall; } 4610b57cec5SDimitry Andric 4620b57cec5SDimitry Andric bool allowsUnalignedMem() const { return !StrictAlign; } 4630b57cec5SDimitry Andric 4640b57cec5SDimitry Andric bool restrictIT() const { return RestrictIT; } 4650b57cec5SDimitry Andric 4660b57cec5SDimitry Andric const std::string & getCPUString() const { return CPUString; } 4670b57cec5SDimitry Andric 4680b57cec5SDimitry Andric bool isLittle() const { return IsLittle; } 4690b57cec5SDimitry Andric 4700b57cec5SDimitry Andric unsigned getMispredictionPenalty() const; 4710b57cec5SDimitry Andric 4720b57cec5SDimitry Andric /// Returns true if machine scheduler should be enabled. 4730b57cec5SDimitry Andric bool enableMachineScheduler() const override; 4740b57cec5SDimitry Andric 47581ad6265SDimitry Andric /// Returns true if machine pipeliner should be enabled. 47681ad6265SDimitry Andric bool enableMachinePipeliner() const override; 47781ad6265SDimitry Andric bool useDFAforSMS() const override; 47881ad6265SDimitry Andric 4790b57cec5SDimitry Andric /// True for some subtargets at > -O0. 4800b57cec5SDimitry Andric bool enablePostRAScheduler() const override; 4810b57cec5SDimitry Andric 482480093f4SDimitry Andric /// True for some subtargets at > -O0. 483480093f4SDimitry Andric bool enablePostRAMachineScheduler() const override; 484480093f4SDimitry Andric 485480093f4SDimitry Andric /// Check whether this subtarget wants to use subregister liveness. 486480093f4SDimitry Andric bool enableSubRegLiveness() const override; 487480093f4SDimitry Andric 4880b57cec5SDimitry Andric /// Enable use of alias analysis during code generation (during MI 4890b57cec5SDimitry Andric /// scheduling, DAGCombine, etc.). 490480093f4SDimitry Andric bool useAA() const override { return true; } 4910b57cec5SDimitry Andric 4920b57cec5SDimitry Andric /// getInstrItins - Return the instruction itineraries based on subtarget 4930b57cec5SDimitry Andric /// selection. 4940b57cec5SDimitry Andric const InstrItineraryData *getInstrItineraryData() const override { 4950b57cec5SDimitry Andric return &InstrItins; 4960b57cec5SDimitry Andric } 4970b57cec5SDimitry Andric 4980b57cec5SDimitry Andric /// getStackAlignment - Returns the minimum alignment known to hold of the 4990b57cec5SDimitry Andric /// stack frame on entry to the function and which must be maintained by every 5000b57cec5SDimitry Andric /// function for this subtarget. 5018bcb0991SDimitry Andric Align getStackAlignment() const { return stackAlignment; } 5020b57cec5SDimitry Andric 50306c3fb27SDimitry Andric // Returns the required alignment for LDRD/STRD instructions 50406c3fb27SDimitry Andric Align getDualLoadStoreAlignment() const { 50506c3fb27SDimitry Andric return Align(hasV7Ops() || allowsUnalignedMem() ? 4 : 8); 50606c3fb27SDimitry Andric } 50706c3fb27SDimitry Andric 5080b57cec5SDimitry Andric unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; } 5090b57cec5SDimitry Andric 5100b57cec5SDimitry Andric unsigned getPartialUpdateClearance() const { return PartialUpdateClearance; } 5110b57cec5SDimitry Andric 5120b57cec5SDimitry Andric ARMLdStMultipleTiming getLdStMultipleTiming() const { 5130b57cec5SDimitry Andric return LdStMultipleTiming; 5140b57cec5SDimitry Andric } 5150b57cec5SDimitry Andric 5160b57cec5SDimitry Andric int getPreISelOperandLatencyAdjustment() const { 5170b57cec5SDimitry Andric return PreISelOperandLatencyAdjustment; 5180b57cec5SDimitry Andric } 5190b57cec5SDimitry Andric 5200b57cec5SDimitry Andric /// True if the GV will be accessed via an indirect symbol. 5210b57cec5SDimitry Andric bool isGVIndirectSymbol(const GlobalValue *GV) const; 5220b57cec5SDimitry Andric 5230b57cec5SDimitry Andric /// Returns the constant pool modifier needed to access the GV. 5240b57cec5SDimitry Andric bool isGVInGOT(const GlobalValue *GV) const; 5250b57cec5SDimitry Andric 5260b57cec5SDimitry Andric /// True if fast-isel is used. 5270b57cec5SDimitry Andric bool useFastISel() const; 5280b57cec5SDimitry Andric 5290b57cec5SDimitry Andric /// Returns the correct return opcode for the current feature set. 5300b57cec5SDimitry Andric /// Use BX if available to allow mixing thumb/arm code, but fall back 5310b57cec5SDimitry Andric /// to plain mov pc,lr on ARMv4. 5320b57cec5SDimitry Andric unsigned getReturnOpcode() const { 5330b57cec5SDimitry Andric if (isThumb()) 5340b57cec5SDimitry Andric return ARM::tBX_RET; 5350b57cec5SDimitry Andric if (hasV4TOps()) 5360b57cec5SDimitry Andric return ARM::BX_RET; 5370b57cec5SDimitry Andric return ARM::MOVPCLR; 5380b57cec5SDimitry Andric } 5390b57cec5SDimitry Andric 5400b57cec5SDimitry Andric /// Allow movt+movw for PIC global address calculation. 5410b57cec5SDimitry Andric /// ELF does not have GOT relocations for movt+movw. 5420b57cec5SDimitry Andric /// ROPI does not use GOT. 5430b57cec5SDimitry Andric bool allowPositionIndependentMovt() const { 5440b57cec5SDimitry Andric return isROPI() || !isTargetELF(); 5450b57cec5SDimitry Andric } 5460b57cec5SDimitry Andric 5478bcb0991SDimitry Andric unsigned getPrefLoopLogAlignment() const { return PrefLoopLogAlignment; } 5488bcb0991SDimitry Andric 549fe6060f1SDimitry Andric unsigned 550fe6060f1SDimitry Andric getMVEVectorCostFactor(TargetTransformInfo::TargetCostKind CostKind) const { 551fe6060f1SDimitry Andric if (CostKind == TargetTransformInfo::TCK_CodeSize) 552fe6060f1SDimitry Andric return 1; 553fe6060f1SDimitry Andric return MVEVectorCostFactor; 554fe6060f1SDimitry Andric } 5550b57cec5SDimitry Andric 5560b57cec5SDimitry Andric bool ignoreCSRForAllocationOrder(const MachineFunction &MF, 5570b57cec5SDimitry Andric unsigned PhysReg) const override; 5580b57cec5SDimitry Andric unsigned getGPRAllocationOrder(const MachineFunction &MF) const; 5590b57cec5SDimitry Andric }; 5600b57cec5SDimitry Andric 5610b57cec5SDimitry Andric } // end namespace llvm 5620b57cec5SDimitry Andric 5630b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_ARM_ARMSUBTARGET_H 564