1 //===--- AArch64Subtarget.h - Define Subtarget for the AArch64 -*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the AArch64 specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
15 #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
17 #include "AArch64FrameLowering.h"
18 #include "AArch64ISelLowering.h"
19 #include "AArch64InstrInfo.h"
20 #include "AArch64RegisterInfo.h"
21 #include "AArch64SelectionDAGInfo.h"
22 #include "llvm/IR/DataLayout.h"
23 #include "llvm/Target/TargetSubtargetInfo.h"
26 #define GET_SUBTARGETINFO_HEADER
27 #include "AArch64GenSubtargetInfo.inc"
34 class AArch64Subtarget : public AArch64GenSubtargetInfo {
36 enum ARMProcFamilyEnum {Others, CortexA53, CortexA57, Cyclone};
38 /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
39 ARMProcFamilyEnum ARMProcFamily;
48 // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
49 bool HasZeroCycleRegMove;
51 // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
52 bool HasZeroCycleZeroing;
56 /// CPUString - String name of used CPU.
57 std::string CPUString;
59 /// TargetTriple - What processor and OS we're targeting.
62 AArch64FrameLowering FrameLowering;
63 AArch64InstrInfo InstrInfo;
64 AArch64SelectionDAGInfo TSInfo;
65 AArch64TargetLowering TLInfo;
67 /// initializeSubtargetDependencies - Initializes using CPUString and the
68 /// passed in feature string so that we can use initializer lists for
69 /// subtarget initialization.
70 AArch64Subtarget &initializeSubtargetDependencies(StringRef FS);
73 /// This constructor initializes the data members to match that
74 /// of the specified triple.
75 AArch64Subtarget(const Triple &TT, const std::string &CPU,
76 const std::string &FS, const TargetMachine &TM,
79 const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
82 const AArch64FrameLowering *getFrameLowering() const override {
83 return &FrameLowering;
85 const AArch64TargetLowering *getTargetLowering() const override {
88 const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
89 const AArch64RegisterInfo *getRegisterInfo() const override {
90 return &getInstrInfo()->getRegisterInfo();
92 const Triple &getTargetTriple() const { return TargetTriple; }
93 bool enableMachineScheduler() const override { return true; }
94 bool enablePostMachineScheduler() const override {
95 return isCortexA53() || isCortexA57();
98 bool hasV8_1aOps() const { return HasV8_1aOps; }
100 bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
102 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
104 bool hasFPARMv8() const { return HasFPARMv8; }
105 bool hasNEON() const { return HasNEON; }
106 bool hasCrypto() const { return HasCrypto; }
107 bool hasCRC() const { return HasCRC; }
109 bool isLittleEndian() const { return IsLittle; }
111 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
112 bool isTargetIOS() const { return TargetTriple.isiOS(); }
113 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
114 bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
116 bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
117 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
118 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
120 bool isCyclone() const { return CPUString == "cyclone"; }
121 bool isCortexA57() const { return CPUString == "cortex-a57"; }
122 bool isCortexA53() const { return CPUString == "cortex-a53"; }
124 bool useAA() const override { return isCortexA53(); }
126 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
127 /// that still makes it profitable to inline the call.
128 unsigned getMaxInlineSizeThreshold() const { return 64; }
130 /// ParseSubtargetFeatures - Parses features string setting specified
131 /// subtarget options. Definition of function is auto generated by tblgen.
132 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
134 /// ClassifyGlobalReference - Find the target operand flags that describe
135 /// how a global value should be referenced for the current subtarget.
136 unsigned char ClassifyGlobalReference(const GlobalValue *GV,
137 const TargetMachine &TM) const;
139 /// This function returns the name of a function which has an interface
140 /// like the non-standard bzero function, if such a function exists on
141 /// the current subtarget and it is considered prefereable over
142 /// memset with zero passed as the second argument. Otherwise it
144 const char *getBZeroEntry() const;
146 void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin,
148 unsigned NumRegionInstrs) const override;
150 bool enableEarlyIfConversion() const override;
152 std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
154 } // End llvm namespace