LCOV - code coverage report
Current view: top level - lib/Target/AArch64 - AArch64Subtarget.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 32 33 97.0 %
Date: 2017-09-14 15:23:50 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===--- AArch64Subtarget.h - Define Subtarget for the AArch64 -*- C++ -*--===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file declares the AArch64 specific subclass of TargetSubtarget.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
      15             : #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
      16             : 
      17             : #include "AArch64FrameLowering.h"
      18             : #include "AArch64ISelLowering.h"
      19             : #include "AArch64InstrInfo.h"
      20             : #include "AArch64RegisterInfo.h"
      21             : #include "AArch64SelectionDAGInfo.h"
      22             : #include "llvm/CodeGen/GlobalISel/CallLowering.h"
      23             : #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
      24             : #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
      25             : #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
      26             : #include "llvm/IR/DataLayout.h"
      27             : #include "llvm/Target/TargetSubtargetInfo.h"
      28             : #include <string>
      29             : 
      30             : #define GET_SUBTARGETINFO_HEADER
      31             : #include "AArch64GenSubtargetInfo.inc"
      32             : 
      33             : namespace llvm {
      34             : class GlobalValue;
      35             : class StringRef;
      36             : class Triple;
      37             : 
      38       14313 : class AArch64Subtarget final : public AArch64GenSubtargetInfo {
      39             : public:
      40             :   enum ARMProcFamilyEnum : uint8_t {
      41             :     Others,
      42             :     CortexA35,
      43             :     CortexA53,
      44             :     CortexA55,
      45             :     CortexA57,
      46             :     CortexA72,
      47             :     CortexA73,
      48             :     CortexA75,
      49             :     Cyclone,
      50             :     ExynosM1,
      51             :     Falkor,
      52             :     Kryo,
      53             :     ThunderX2T99,
      54             :     ThunderX,
      55             :     ThunderXT81,
      56             :     ThunderXT83,
      57             :     ThunderXT88
      58             :   };
      59             : 
      60             : protected:
      61             :   /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
      62             :   ARMProcFamilyEnum ARMProcFamily = Others;
      63             : 
      64             :   bool HasV8_1aOps = false;
      65             :   bool HasV8_2aOps = false;
      66             :   bool HasV8_3aOps = false;
      67             : 
      68             :   bool HasFPARMv8 = false;
      69             :   bool HasNEON = false;
      70             :   bool HasCrypto = false;
      71             :   bool HasDotProd = false;
      72             :   bool HasCRC = false;
      73             :   bool HasLSE = false;
      74             :   bool HasRAS = false;
      75             :   bool HasRDM = false;
      76             :   bool HasPerfMon = false;
      77             :   bool HasFullFP16 = false;
      78             :   bool HasSPE = false;
      79             :   bool HasLSLFast = false;
      80             :   bool HasSVE = false;
      81             :   bool HasRCPC = false;
      82             : 
      83             :   // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
      84             :   bool HasZeroCycleRegMove = false;
      85             : 
      86             :   // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
      87             :   bool HasZeroCycleZeroing = false;
      88             : 
      89             :   // StrictAlign - Disallow unaligned memory accesses.
      90             :   bool StrictAlign = false;
      91             : 
      92             :   // NegativeImmediates - transform instructions with negative immediates
      93             :   bool NegativeImmediates = true;
      94             : 
      95             :   // Enable 64-bit vectorization in SLP.
      96             :   unsigned MinVectorRegisterBitWidth = 64;
      97             : 
      98             :   bool UseAA = false;
      99             :   bool PredictableSelectIsExpensive = false;
     100             :   bool BalanceFPOps = false;
     101             :   bool CustomAsCheapAsMove = false;
     102             :   bool UsePostRAScheduler = false;
     103             :   bool Misaligned128StoreIsSlow = false;
     104             :   bool Paired128IsSlow = false;
     105             :   bool STRQroIsSlow = false;
     106             :   bool UseAlternateSExtLoadCVTF32Pattern = false;
     107             :   bool HasArithmeticBccFusion = false;
     108             :   bool HasArithmeticCbzFusion = false;
     109             :   bool HasFuseAES = false;
     110             :   bool HasFuseLiterals = false;
     111             :   bool DisableLatencySchedHeuristic = false;
     112             :   bool UseRSqrt = false;
     113             :   uint8_t MaxInterleaveFactor = 2;
     114             :   uint8_t VectorInsertExtractBaseCost = 3;
     115             :   uint16_t CacheLineSize = 0;
     116             :   uint16_t PrefetchDistance = 0;
     117             :   uint16_t MinPrefetchStride = 1;
     118             :   unsigned MaxPrefetchIterationsAhead = UINT_MAX;
     119             :   unsigned PrefFunctionAlignment = 0;
     120             :   unsigned PrefLoopAlignment = 0;
     121             :   unsigned MaxJumpTableSize = 0;
     122             :   unsigned WideningBaseCost = 0;
     123             : 
     124             :   // ReserveX18 - X18 is not available as a general purpose register.
     125             :   bool ReserveX18;
     126             : 
     127             :   bool IsLittle;
     128             : 
     129             :   /// TargetTriple - What processor and OS we're targeting.
     130             :   Triple TargetTriple;
     131             : 
     132             :   AArch64FrameLowering FrameLowering;
     133             :   AArch64InstrInfo InstrInfo;
     134             :   AArch64SelectionDAGInfo TSInfo;
     135             :   AArch64TargetLowering TLInfo;
     136             : 
     137             :   /// GlobalISel related APIs.
     138             :   std::unique_ptr<CallLowering> CallLoweringInfo;
     139             :   std::unique_ptr<InstructionSelector> InstSelector;
     140             :   std::unique_ptr<LegalizerInfo> Legalizer;
     141             :   std::unique_ptr<RegisterBankInfo> RegBankInfo;
     142             : 
     143             : private:
     144             :   /// initializeSubtargetDependencies - Initializes using CPUString and the
     145             :   /// passed in feature string so that we can use initializer lists for
     146             :   /// subtarget initialization.
     147             :   AArch64Subtarget &initializeSubtargetDependencies(StringRef FS,
     148             :                                                     StringRef CPUString);
     149             : 
     150             :   /// Initialize properties based on the selected processor family.
     151             :   void initializeProperties();
     152             : 
     153             : public:
     154             :   /// This constructor initializes the data members to match that
     155             :   /// of the specified triple.
     156             :   AArch64Subtarget(const Triple &TT, const std::string &CPU,
     157             :                    const std::string &FS, const TargetMachine &TM,
     158             :                    bool LittleEndian);
     159             : 
     160       12259 :   const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
     161       12259 :     return &TSInfo;
     162             :   }
     163      448944 :   const AArch64FrameLowering *getFrameLowering() const override {
     164      448944 :     return &FrameLowering;
     165             :   }
     166      289894 :   const AArch64TargetLowering *getTargetLowering() const override {
     167      547689 :     return &TLInfo;
     168             :   }
     169      990212 :   const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
     170     2488435 :   const AArch64RegisterInfo *getRegisterInfo() const override {
     171     5065880 :     return &getInstrInfo()->getRegisterInfo();
     172             :   }
     173             :   const CallLowering *getCallLowering() const override;
     174             :   const InstructionSelector *getInstructionSelector() const override;
     175             :   const LegalizerInfo *getLegalizerInfo() const override;
     176             :   const RegisterBankInfo *getRegBankInfo() const override;
     177        1217 :   const Triple &getTargetTriple() const { return TargetTriple; }
     178       34141 :   bool enableMachineScheduler() const override { return true; }
     179        8969 :   bool enablePostRAScheduler() const override {
     180        8969 :     return UsePostRAScheduler;
     181             :   }
     182             : 
     183             :   /// Returns ARM processor family.
     184             :   /// Avoid this function! CPU specifics should be kept local to this class
     185             :   /// and preferably modeled with SubtargetFeatures or properties in
     186             :   /// initializeProperties().
     187             :   ARMProcFamilyEnum getProcFamily() const {
     188             :     return ARMProcFamily;
     189             :   }
     190             : 
     191             :   bool hasV8_1aOps() const { return HasV8_1aOps; }
     192             :   bool hasV8_2aOps() const { return HasV8_2aOps; }
     193             :   bool hasV8_3aOps() const { return HasV8_3aOps; }
     194             : 
     195             :   bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
     196             : 
     197             :   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
     198             : 
     199             :   bool requiresStrictAlign() const { return StrictAlign; }
     200             : 
     201           3 :   bool isXRaySupported() const override { return true; }
     202             : 
     203             :   unsigned getMinVectorRegisterBitWidth() const {
     204             :     return MinVectorRegisterBitWidth;
     205             :   }
     206             : 
     207             :   bool isX18Reserved() const { return ReserveX18; }
     208             :   bool hasFPARMv8() const { return HasFPARMv8; }
     209             :   bool hasNEON() const { return HasNEON; }
     210             :   bool hasCrypto() const { return HasCrypto; }
     211             :   bool hasDotProd() const { return HasDotProd; }
     212             :   bool hasCRC() const { return HasCRC; }
     213             :   bool hasLSE() const { return HasLSE; }
     214             :   bool hasRAS() const { return HasRAS; }
     215             :   bool hasRDM() const { return HasRDM; }
     216             :   bool balanceFPOps() const { return BalanceFPOps; }
     217             :   bool predictableSelectIsExpensive() const {
     218             :     return PredictableSelectIsExpensive;
     219             :   }
     220             :   bool hasCustomCheapAsMoveHandling() const { return CustomAsCheapAsMove; }
     221             :   bool isMisaligned128StoreSlow() const { return Misaligned128StoreIsSlow; }
     222             :   bool isPaired128Slow() const { return Paired128IsSlow; }
     223             :   bool isSTRQroSlow() const { return STRQroIsSlow; }
     224             :   bool useAlternateSExtLoadCVTF32Pattern() const {
     225             :     return UseAlternateSExtLoadCVTF32Pattern;
     226             :   }
     227             :   bool hasArithmeticBccFusion() const { return HasArithmeticBccFusion; }
     228             :   bool hasArithmeticCbzFusion() const { return HasArithmeticCbzFusion; }
     229             :   bool hasFuseAES() const { return HasFuseAES; }
     230             :   bool hasFuseLiterals() const { return HasFuseLiterals; }
     231             : 
     232             :   /// \brief Return true if the CPU supports any kind of instruction fusion.
     233             :   bool hasFusion() const {
     234       18776 :     return hasArithmeticBccFusion() || hasArithmeticCbzFusion() ||
     235       19307 :            hasFuseAES() || hasFuseLiterals();
     236             :   }
     237             : 
     238             :   bool useRSqrt() const { return UseRSqrt; }
     239          31 :   unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }
     240             :   unsigned getVectorInsertExtractBaseCost() const {
     241             :     return VectorInsertExtractBaseCost;
     242             :   }
     243           0 :   unsigned getCacheLineSize() const { return CacheLineSize; }
     244       11102 :   unsigned getPrefetchDistance() const { return PrefetchDistance; }
     245          12 :   unsigned getMinPrefetchStride() const { return MinPrefetchStride; }
     246             :   unsigned getMaxPrefetchIterationsAhead() const {
     247             :     return MaxPrefetchIterationsAhead;
     248             :   }
     249             :   unsigned getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
     250             :   unsigned getPrefLoopAlignment() const { return PrefLoopAlignment; }
     251             : 
     252             :   unsigned getMaximumJumpTableSize() const { return MaxJumpTableSize; }
     253             : 
     254             :   unsigned getWideningBaseCost() const { return WideningBaseCost; }
     255             : 
     256             :   /// CPU has TBI (top byte of addresses is ignored during HW address
     257             :   /// translation) and OS enables it.
     258             :   bool supportsAddressTopByteIgnored() const;
     259             : 
     260             :   bool hasPerfMon() const { return HasPerfMon; }
     261             :   bool hasFullFP16() const { return HasFullFP16; }
     262             :   bool hasSPE() const { return HasSPE; }
     263             :   bool hasLSLFast() const { return HasLSLFast; }
     264             :   bool hasSVE() const { return HasSVE; }
     265             :   bool hasRCPC() const { return HasRCPC; }
     266             : 
     267             :   bool isLittleEndian() const { return IsLittle; }
     268             : 
     269       24680 :   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
     270             :   bool isTargetIOS() const { return TargetTriple.isiOS(); }
     271             :   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
     272      100682 :   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
     273          98 :   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
     274          86 :   bool isTargetFuchsia() const { return TargetTriple.isOSFuchsia(); }
     275             : 
     276             :   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
     277         108 :   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
     278       11368 :   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
     279             : 
     280       36990 :   bool useAA() const override { return UseAA; }
     281             : 
     282             :   bool useSmallAddressing() const {
     283        2340 :     switch (TLInfo.getTargetMachine().getCodeModel()) {
     284             :       case CodeModel::Kernel:
     285             :         // Kernel is currently allowed only for Fuchsia targets,
     286             :         // where it is the same as Small for almost all purposes.
     287             :       case CodeModel::Small:
     288             :         return true;
     289             :       default:
     290             :         return false;
     291             :     }
     292             :   }
     293             : 
     294             :   /// ParseSubtargetFeatures - Parses features string setting specified
     295             :   /// subtarget options.  Definition of function is auto generated by tblgen.
     296             :   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
     297             : 
     298             :   /// ClassifyGlobalReference - Find the target operand flags that describe
     299             :   /// how a global value should be referenced for the current subtarget.
     300             :   unsigned char ClassifyGlobalReference(const GlobalValue *GV,
     301             :                                         const TargetMachine &TM) const;
     302             : 
     303             :   unsigned char classifyGlobalFunctionReference(const GlobalValue *GV,
     304             :                                                 const TargetMachine &TM) const;
     305             : 
     306             :   /// This function returns the name of a function which has an interface
     307             :   /// like the non-standard bzero function, if such a function exists on
     308             :   /// the current subtarget and it is considered prefereable over
     309             :   /// memset with zero passed as the second argument. Otherwise it
     310             :   /// returns null.
     311             :   const char *getBZeroEntry() const;
     312             : 
     313             :   void overrideSchedPolicy(MachineSchedPolicy &Policy,
     314             :                            unsigned NumRegionInstrs) const override;
     315             : 
     316             :   bool enableEarlyIfConversion() const override;
     317             : 
     318             :   std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
     319             : 
     320             :   bool isCallingConvWin64(CallingConv::ID CC) const {
     321       26854 :     switch (CC) {
     322       26175 :     case CallingConv::C:
     323       26175 :       return isTargetWindows();
     324             :     case CallingConv::Win64:
     325             :       return true;
     326          83 :     default:
     327             :       return false;
     328             :     }
     329             :   }
     330             : };
     331             : } // End llvm namespace
     332             : 
     333             : #endif

Generated by: LCOV version 1.13