blob: d679f3ef0ad6e0dc3c5199c07454ecdf0eb83738 [file] [log] [blame]
Tim Northover3b0846e2014-05-24 12:50:23 +00001//===--- 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 AArch64SUBTARGET_H
15#define AArch64SUBTARGET_H
16
Eric Christopher29aab7b2014-06-10 17:44:12 +000017#include "AArch64FrameLowering.h"
Eric Christopher841da852014-06-10 23:26:45 +000018#include "AArch64ISelLowering.h"
Benjamin Kramer1f8930e2014-07-25 11:42:14 +000019#include "AArch64InstrInfo.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000020#include "AArch64RegisterInfo.h"
Eric Christopherfcb06ca2014-06-10 18:21:53 +000021#include "AArch64SelectionDAGInfo.h"
Eric Christopher6f2a2032014-06-10 18:06:23 +000022#include "llvm/IR/DataLayout.h"
Eric Christopher29aab7b2014-06-10 17:44:12 +000023#include "llvm/Target/TargetSubtargetInfo.h"
Tim Northover3b0846e2014-05-24 12:50:23 +000024#include <string>
25
26#define GET_SUBTARGETINFO_HEADER
27#include "AArch64GenSubtargetInfo.inc"
28
29namespace llvm {
30class GlobalValue;
31class StringRef;
32
33class AArch64Subtarget : public AArch64GenSubtargetInfo {
34protected:
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
45 // HasZeroCycleRegMove - Has zero-cycle register mov instructions.
46 bool HasZeroCycleRegMove;
47
48 // HasZeroCycleZeroing - Has zero-cycle zeroing instructions.
49 bool HasZeroCycleZeroing;
50
51 /// CPUString - String name of used CPU.
52 std::string CPUString;
53
54 /// TargetTriple - What processor and OS we're targeting.
55 Triple TargetTriple;
56
Eric Christopher6f2a2032014-06-10 18:06:23 +000057 const DataLayout DL;
Eric Christopher29aab7b2014-06-10 17:44:12 +000058 AArch64FrameLowering FrameLowering;
Eric Christopherf63bc642014-06-10 22:57:25 +000059 AArch64InstrInfo InstrInfo;
Eric Christopherfcb06ca2014-06-10 18:21:53 +000060 AArch64SelectionDAGInfo TSInfo;
Eric Christopher7c9d4e02014-06-11 00:46:34 +000061 AArch64TargetLowering TLInfo;
62private:
63 /// initializeSubtargetDependencies - Initializes using CPUString and the
64 /// passed in feature string so that we can use initializer lists for
65 /// subtarget initialization.
66 AArch64Subtarget &initializeSubtargetDependencies(StringRef FS);
Eric Christopher29aab7b2014-06-10 17:44:12 +000067
Tim Northover3b0846e2014-05-24 12:50:23 +000068public:
69 /// This constructor initializes the data members to match that
70 /// of the specified triple.
71 AArch64Subtarget(const std::string &TT, const std::string &CPU,
Eric Christopher841da852014-06-10 23:26:45 +000072 const std::string &FS, TargetMachine &TM, bool LittleEndian);
Tim Northover3b0846e2014-05-24 12:50:23 +000073
Eric Christopherd9134482014-08-04 21:25:23 +000074 const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
75 return &TSInfo;
76 }
77 const AArch64FrameLowering *getFrameLowering() const override {
Eric Christopher29aab7b2014-06-10 17:44:12 +000078 return &FrameLowering;
79 }
Eric Christopherd9134482014-08-04 21:25:23 +000080 const AArch64TargetLowering *getTargetLowering() const override {
Eric Christopher7c9d4e02014-06-11 00:46:34 +000081 return &TLInfo;
Eric Christopher841da852014-06-10 23:26:45 +000082 }
Eric Christopherd9134482014-08-04 21:25:23 +000083 const AArch64InstrInfo *getInstrInfo() const override { return &InstrInfo; }
84 const DataLayout *getDataLayout() const override { return &DL; }
85 const AArch64RegisterInfo *getRegisterInfo() const override {
86 return &getInstrInfo()->getRegisterInfo();
87 }
Tim Northover3b0846e2014-05-24 12:50:23 +000088 bool enableMachineScheduler() const override { return true; }
89
90 bool hasZeroCycleRegMove() const { return HasZeroCycleRegMove; }
91
92 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
93
94 bool hasFPARMv8() const { return HasFPARMv8; }
95 bool hasNEON() const { return HasNEON; }
96 bool hasCrypto() const { return HasCrypto; }
97 bool hasCRC() const { return HasCRC; }
98
Eric Christopher17254ee2014-06-10 18:11:20 +000099 bool isLittleEndian() const { return DL.isLittleEndian(); }
Tim Northover3b0846e2014-05-24 12:50:23 +0000100
101 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
102
103 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
104
105 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
106
107 bool isCyclone() const { return CPUString == "cyclone"; }
Jiangning Liucd296372014-07-29 02:09:26 +0000108 bool isCortexA57() const { return CPUString == "cortex-a57"; }
109 bool isCortexA53() const { return CPUString == "cortex-a53"; }
Tim Northover3b0846e2014-05-24 12:50:23 +0000110
111 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
112 /// that still makes it profitable to inline the call.
113 unsigned getMaxInlineSizeThreshold() const { return 64; }
114
115 /// ParseSubtargetFeatures - Parses features string setting specified
116 /// subtarget options. Definition of function is auto generated by tblgen.
117 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
118
119 /// ClassifyGlobalReference - Find the target operand flags that describe
120 /// how a global value should be referenced for the current subtarget.
121 unsigned char ClassifyGlobalReference(const GlobalValue *GV,
122 const TargetMachine &TM) const;
123
124 /// This function returns the name of a function which has an interface
125 /// like the non-standard bzero function, if such a function exists on
126 /// the current subtarget and it is considered prefereable over
127 /// memset with zero passed as the second argument. Otherwise it
128 /// returns null.
129 const char *getBZeroEntry() const;
130
131 void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin,
132 MachineInstr *end,
133 unsigned NumRegionInstrs) const override;
134
135 bool enableEarlyIfConversion() const override;
136};
137} // End llvm namespace
138
139#endif // AArch64SUBTARGET_H