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