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 AArch64SUBTARGET_H 15 #define AArch64SUBTARGET_H 16 17 #include "AArch64InstrInfo.h" 18 #include "AArch64FrameLowering.h" 19 #include "AArch64ISelLowering.h" 20 #include "AArch64RegisterInfo.h" 21 #include "AArch64SelectionDAGInfo.h" 22 #include "llvm/IR/DataLayout.h" 23 #include "llvm/Target/TargetSubtargetInfo.h" 24 #include <string> 25 26 #define GET_SUBTARGETINFO_HEADER 27 #include "AArch64GenSubtargetInfo.inc" 28 29 namespace llvm { 30 class GlobalValue; 31 class StringRef; 32 33 class AArch64Subtarget : public AArch64GenSubtargetInfo { 34 protected: 35 enum ARMProcFamilyEnum {Others, CortexA53, CortexA57, Cyclone}; 36 37 /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others. 38 ARMProcFamilyEnum ARMProcFamily; 39 40 bool HasFPARMv8; 41 bool HasNEON; 42 bool HasCrypto; 43 bool HasCRC; 44 45 // HasZeroCycleRegMove - Has zero-cycle register mov instructions. 46 bool HasZeroCycleRegMove; 47 48 // HasZeroCycleZeroing - Has zero-cycle zeroing instructions. 49 bool HasZeroCycleZeroing; 50 51 /// CPUString - String name of used CPU. 52 std::string CPUString; 53 54 /// TargetTriple - What processor and OS we're targeting. 55 Triple TargetTriple; 56 57 const DataLayout DL; 58 AArch64FrameLowering FrameLowering; 59 AArch64InstrInfo InstrInfo; 60 AArch64SelectionDAGInfo TSInfo; 61 AArch64TargetLowering TLInfo; 62 private: 63 /// initializeSubtargetDependencies - Initializes using CPUString and the 64 /// passed in feature string so that we can use initializer lists for 65 /// subtarget initialization. 66 AArch64Subtarget &initializeSubtargetDependencies(StringRef FS); 67 68 public: 69 /// This constructor initializes the data members to match that 70 /// of the specified triple. 71 AArch64Subtarget(const std::string &TT, const std::string &CPU, 72 const std::string &FS, TargetMachine &TM, bool LittleEndian); 73 getSelectionDAGInfo()74 const AArch64SelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; } getFrameLowering()75 const AArch64FrameLowering *getFrameLowering() const { 76 return &FrameLowering; 77 } getTargetLowering()78 const AArch64TargetLowering *getTargetLowering() const { 79 return &TLInfo; 80 } getInstrInfo()81 const AArch64InstrInfo *getInstrInfo() const { return &InstrInfo; } getDataLayout()82 const DataLayout *getDataLayout() const { return &DL; } enableMachineScheduler()83 bool enableMachineScheduler() const override { return true; } 84 hasZeroCycleRegMove()85 bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; } 86 hasZeroCycleZeroing()87 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; } 88 hasFPARMv8()89 bool hasFPARMv8() const { return HasFPARMv8; } hasNEON()90 bool hasNEON() const { return HasNEON; } hasCrypto()91 bool hasCrypto() const { return HasCrypto; } hasCRC()92 bool hasCRC() const { return HasCRC; } 93 isLittleEndian()94 bool isLittleEndian() const { return DL.isLittleEndian(); } 95 isTargetDarwin()96 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); } 97 isTargetELF()98 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } 99 isTargetMachO()100 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); } 101 isCyclone()102 bool isCyclone() const { return CPUString == "cyclone"; } 103 104 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size 105 /// that still makes it profitable to inline the call. getMaxInlineSizeThreshold()106 unsigned getMaxInlineSizeThreshold() const { return 64; } 107 108 /// ParseSubtargetFeatures - Parses features string setting specified 109 /// subtarget options. Definition of function is auto generated by tblgen. 110 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 111 112 /// ClassifyGlobalReference - Find the target operand flags that describe 113 /// how a global value should be referenced for the current subtarget. 114 unsigned char ClassifyGlobalReference(const GlobalValue *GV, 115 const TargetMachine &TM) const; 116 117 /// This function returns the name of a function which has an interface 118 /// like the non-standard bzero function, if such a function exists on 119 /// the current subtarget and it is considered prefereable over 120 /// memset with zero passed as the second argument. Otherwise it 121 /// returns null. 122 const char *getBZeroEntry() const; 123 124 void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin, 125 MachineInstr *end, 126 unsigned NumRegionInstrs) const override; 127 128 bool enableEarlyIfConversion() const override; 129 }; 130 } // End llvm namespace 131 132 #endif // AArch64SUBTARGET_H 133