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