Merging r258471:
[oota-llvm.git] / lib / Target / AArch64 / AArch64Subtarget.h
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/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 class Triple;
33
34 class AArch64Subtarget : public AArch64GenSubtargetInfo {
35 protected:
36   enum ARMProcFamilyEnum {
37     Others,
38     CortexA35,
39     CortexA53,
40     CortexA57,
41     Cyclone,
42     ExynosM1
43   };
44
45   /// ARMProcFamily - ARM processor family: Cortex-A53, Cortex-A57, and others.
46   ARMProcFamilyEnum ARMProcFamily;
47
48   bool HasV8_1aOps;
49   bool HasV8_2aOps;
50
51   bool HasFPARMv8;
52   bool HasNEON;
53   bool HasCrypto;
54   bool HasCRC;
55   bool HasPerfMon;
56   bool HasFullFP16;
57   bool HasSPE;
58
59   // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
60   bool HasZeroCycleRegMove;
61
62   // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
63   bool HasZeroCycleZeroing;
64
65   // StrictAlign - Disallow unaligned memory accesses.
66   bool StrictAlign;
67
68   // ReserveX18 - X18 is not available as a general purpose register.
69   bool ReserveX18;
70
71   bool IsLittle;
72
73   /// CPUString - String name of used CPU.
74   std::string CPUString;
75
76   /// TargetTriple - What processor and OS we're targeting.
77   Triple TargetTriple;
78
79   AArch64FrameLowering FrameLowering;
80   AArch64InstrInfo InstrInfo;
81   AArch64SelectionDAGInfo TSInfo;
82   AArch64TargetLowering TLInfo;
83 private:
84   /// initializeSubtargetDependencies - Initializes using CPUString and the
85   /// passed in feature string so that we can use initializer lists for
86   /// subtarget initialization.
87   AArch64Subtarget &initializeSubtargetDependencies(StringRef FS);
88
89 public:
90   /// This constructor initializes the data members to match that
91   /// of the specified triple.
92   AArch64Subtarget(const Triple &TT, const std::string &CPU,
93                    const std::string &FS, const TargetMachine &TM,
94                    bool LittleEndian);
95
96   const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
97     return &TSInfo;
98   }
99   const AArch64FrameLowering *getFrameLowering() const override {
100     return &FrameLowering;
101   }
102   const AArch64TargetLowering *getTargetLowering() const override {
103     return &TLInfo;
104   }
105   const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
106   const AArch64RegisterInfo *getRegisterInfo() const override {
107     return &getInstrInfo()->getRegisterInfo();
108   }
109   const Triple &getTargetTriple() const { return TargetTriple; }
110   bool enableMachineScheduler() const override { return true; }
111   bool enablePostRAScheduler() const override {
112     return isGeneric() || isCortexA53() || isCortexA57();
113   }
114
115   bool hasV8_1aOps() const { return HasV8_1aOps; }
116   bool hasV8_2aOps() const { return HasV8_2aOps; }
117
118   bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
119
120   bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
121
122   bool requiresStrictAlign() const { return StrictAlign; }
123
124   bool isX18Reserved() const { return ReserveX18; }
125   bool hasFPARMv8() const { return HasFPARMv8; }
126   bool hasNEON() const { return HasNEON; }
127   bool hasCrypto() const { return HasCrypto; }
128   bool hasCRC() const { return HasCRC; }
129   /// CPU has TBI (top byte of addresses is ignored during HW address
130   /// translation) and OS enables it.
131   bool supportsAddressTopByteIgnored() const;
132
133   bool hasPerfMon() const { return HasPerfMon; }
134   bool hasFullFP16() const { return HasFullFP16; }
135   bool hasSPE() const { return HasSPE; }
136
137   bool isLittleEndian() const { return IsLittle; }
138
139   bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
140   bool isTargetIOS() const { return TargetTriple.isiOS(); }
141   bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
142   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
143   bool isTargetAndroid() const { return TargetTriple.isAndroid(); }
144
145   bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
146   bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
147   bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
148
149   bool isGeneric() const { return CPUString == "generic"; }
150   bool isCyclone() const { return CPUString == "cyclone"; }
151   bool isCortexA57() const { return CPUString == "cortex-a57"; }
152   bool isCortexA53() const { return CPUString == "cortex-a53"; }
153   bool isExynosM1() const { return CPUString == "exynos-m1"; }
154
155   bool useAA() const override { return isCortexA53(); }
156
157   /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
158   /// that still makes it profitable to inline the call.
159   unsigned getMaxInlineSizeThreshold() const { return 64; }
160
161   /// ParseSubtargetFeatures - Parses features string setting specified
162   /// subtarget options.  Definition of function is auto generated by tblgen.
163   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
164
165   /// ClassifyGlobalReference - Find the target operand flags that describe
166   /// how a global value should be referenced for the current subtarget.
167   unsigned char ClassifyGlobalReference(const GlobalValue *GV,
168                                         const TargetMachine &TM) const;
169
170   /// This function returns the name of a function which has an interface
171   /// like the non-standard bzero function, if such a function exists on
172   /// the current subtarget and it is considered prefereable over
173   /// memset with zero passed as the second argument. Otherwise it
174   /// returns null.
175   const char *getBZeroEntry() const;
176
177   void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin,
178                            MachineInstr *end,
179                            unsigned NumRegionInstrs) const override;
180
181   bool enableEarlyIfConversion() const override;
182
183   std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const override;
184 };
185 } // End llvm namespace
186
187 #endif