| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 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 | |
| Eric Christopher | 29aab7b | 2014-06-10 17:44:12 +0000 | [diff] [blame] | 17 | #include "AArch64FrameLowering.h" |
| Eric Christopher | 841da85 | 2014-06-10 23:26:45 +0000 | [diff] [blame] | 18 | #include "AArch64ISelLowering.h" |
| Benjamin Kramer | 1f8930e | 2014-07-25 11:42:14 +0000 | [diff] [blame] | 19 | #include "AArch64InstrInfo.h" |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 20 | #include "AArch64RegisterInfo.h" |
| Eric Christopher | fcb06ca | 2014-06-10 18:21:53 +0000 | [diff] [blame] | 21 | #include "AArch64SelectionDAGInfo.h" |
| Eric Christopher | 6f2a203 | 2014-06-10 18:06:23 +0000 | [diff] [blame] | 22 | #include "llvm/IR/DataLayout.h" |
| Eric Christopher | 29aab7b | 2014-06-10 17:44:12 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetSubtargetInfo.h" |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 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 | |
| Eric Christopher | 6f2a203 | 2014-06-10 18:06:23 +0000 | [diff] [blame] | 57 | const DataLayout DL; |
| Eric Christopher | 29aab7b | 2014-06-10 17:44:12 +0000 | [diff] [blame] | 58 | AArch64FrameLowering FrameLowering; |
| Eric Christopher | f63bc64 | 2014-06-10 22:57:25 +0000 | [diff] [blame] | 59 | AArch64InstrInfo InstrInfo; |
| Eric Christopher | fcb06ca | 2014-06-10 18:21:53 +0000 | [diff] [blame] | 60 | AArch64SelectionDAGInfo TSInfo; |
| Eric Christopher | 7c9d4e0 | 2014-06-11 00:46:34 +0000 | [diff] [blame] | 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); |
| Eric Christopher | 29aab7b | 2014-06-10 17:44:12 +0000 | [diff] [blame] | 67 | |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 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, |
| Eric Christopher | 841da85 | 2014-06-10 23:26:45 +0000 | [diff] [blame] | 72 | const std::string &FS, TargetMachine &TM, bool LittleEndian); |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 73 | |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame^] | 74 | const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override { |
| 75 | return &TSInfo; |
| 76 | } |
| 77 | const AArch64FrameLowering *getFrameLowering() const override { |
| Eric Christopher | 29aab7b | 2014-06-10 17:44:12 +0000 | [diff] [blame] | 78 | return &FrameLowering; |
| 79 | } |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame^] | 80 | const AArch64TargetLowering *getTargetLowering() const override { |
| Eric Christopher | 7c9d4e0 | 2014-06-11 00:46:34 +0000 | [diff] [blame] | 81 | return &TLInfo; |
| Eric Christopher | 841da85 | 2014-06-10 23:26:45 +0000 | [diff] [blame] | 82 | } |
| Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame^] | 83 | const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| 84 | const DataLayout *getDataLayout() const override { return &DL; } |
| 85 | const AArch64RegisterInfo *getRegisterInfo() const override { |
| 86 | return &getInstrInfo()->getRegisterInfo(); |
| 87 | } |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 88 | bool enableMachineScheduler() const override { return true; } |
| 89 | |
| 90 | bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; } |
| 91 | |
| 92 | bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; } |
| 93 | |
| 94 | bool hasFPARMv8() const { return HasFPARMv8; } |
| 95 | bool hasNEON() const { return HasNEON; } |
| 96 | bool hasCrypto() const { return HasCrypto; } |
| 97 | bool hasCRC() const { return HasCRC; } |
| 98 | |
| Eric Christopher | 17254ee | 2014-06-10 18:11:20 +0000 | [diff] [blame] | 99 | bool isLittleEndian() const { return DL.isLittleEndian(); } |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 100 | |
| 101 | bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); } |
| 102 | |
| 103 | bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } |
| 104 | |
| 105 | bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); } |
| 106 | |
| 107 | bool isCyclone() const { return CPUString == "cyclone"; } |
| Jiangning Liu | cd29637 | 2014-07-29 02:09:26 +0000 | [diff] [blame] | 108 | bool isCortexA57() const { return CPUString == "cortex-a57"; } |
| 109 | bool isCortexA53() const { return CPUString == "cortex-a53"; } |
| Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 110 | |
| 111 | /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size |
| 112 | /// that still makes it profitable to inline the call. |
| 113 | unsigned getMaxInlineSizeThreshold() const { return 64; } |
| 114 | |
| 115 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 116 | /// subtarget options. Definition of function is auto generated by tblgen. |
| 117 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
| 118 | |
| 119 | /// ClassifyGlobalReference - Find the target operand flags that describe |
| 120 | /// how a global value should be referenced for the current subtarget. |
| 121 | unsigned char ClassifyGlobalReference(const GlobalValue *GV, |
| 122 | const TargetMachine &TM) const; |
| 123 | |
| 124 | /// This function returns the name of a function which has an interface |
| 125 | /// like the non-standard bzero function, if such a function exists on |
| 126 | /// the current subtarget and it is considered prefereable over |
| 127 | /// memset with zero passed as the second argument. Otherwise it |
| 128 | /// returns null. |
| 129 | const char *getBZeroEntry() const; |
| 130 | |
| 131 | void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin, |
| 132 | MachineInstr *end, |
| 133 | unsigned NumRegionInstrs) const override; |
| 134 | |
| 135 | bool enableEarlyIfConversion() const override; |
| 136 | }; |
| 137 | } // End llvm namespace |
| 138 | |
| 139 | #endif // AArch64SUBTARGET_H |