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