blob: 8f6c16589ecd270af3735803db383eb33b4ab57b [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- ARMSubtarget.h - Define Subtarget for the ARM ----------*- C++ -*--===//
Evan Chenga8e29892007-01-19 07:51:42 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file declares the ARM specific subclass of TargetSubtargetInfo.
Evan Chenga8e29892007-01-19 07:51:42 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMSUBTARGET_H
15#define ARMSUBTARGET_H
16
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070017
18#include "ARMFrameLowering.h"
19#include "ARMISelLowering.h"
20#include "ARMInstrInfo.h"
21#include "ARMJITInfo.h"
22#include "ARMSelectionDAGInfo.h"
23#include "ARMSubtarget.h"
24#include "Thumb1FrameLowering.h"
25#include "Thumb1InstrInfo.h"
26#include "Thumb2InstrInfo.h"
27#include "ARMJITInfo.h"
Evan Cheng94ca42f2011-07-07 00:08:19 +000028#include "MCTargetDesc/ARMMCTargetDesc.h"
Evan Chengb72d2a92011-01-11 21:46:47 +000029#include "llvm/ADT/Triple.h"
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070030#include "llvm/IR/DataLayout.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000031#include "llvm/MC/MCInstrItineraries.h"
32#include "llvm/Target/TargetSubtargetInfo.h"
Evan Chenga8e29892007-01-19 07:51:42 +000033#include <string>
34
Evan Cheng94214702011-07-01 20:45:01 +000035#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000036#include "ARMGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000037
Evan Chenga8e29892007-01-19 07:51:42 +000038namespace llvm {
Evan Chenge4e4ed32009-08-28 23:18:09 +000039class GlobalValue;
Evan Cheng0ddff1b2011-07-07 07:07:08 +000040class StringRef;
Renato Golin3382a842013-03-21 18:47:47 +000041class TargetOptions;
Evan Chenga8e29892007-01-19 07:51:42 +000042
Evan Cheng94214702011-07-01 20:45:01 +000043class ARMSubtarget : public ARMGenSubtargetInfo {
Evan Chenga8e29892007-01-19 07:51:42 +000044protected:
Evan Cheng3ef1c872010-09-10 01:29:16 +000045 enum ARMProcFamilyEnum {
Stephen Hinesdce4a402014-05-29 02:49:00 -070046 Others, CortexA5, CortexA7, CortexA8, CortexA9, CortexA12, CortexA15,
Stephen Hines36b56882014-04-23 16:57:46 -070047 CortexR5, Swift, CortexA53, CortexA57, Krait
Evan Cheng3ef1c872010-09-10 01:29:16 +000048 };
Amara Emerson0f22c132013-09-23 14:26:15 +000049 enum ARMProcClassEnum {
50 None, AClass, RClass, MClass
51 };
Evan Cheng3ef1c872010-09-10 01:29:16 +000052
Evan Cheng3ef1c872010-09-10 01:29:16 +000053 /// ARMProcFamily - ARM processor family: Cortex-A8, Cortex-A9, and others.
54 ARMProcFamilyEnum ARMProcFamily;
55
Amara Emerson0f22c132013-09-23 14:26:15 +000056 /// ARMProcClass - ARM processor class: None, AClass, RClass or MClass.
57 ARMProcClassEnum ARMProcClass;
58
Joey Gouly849eedc2013-06-26 16:58:26 +000059 /// HasV4TOps, HasV5TOps, HasV5TEOps,
Tim Northovercf3e4cb2013-10-07 11:10:47 +000060 /// HasV6Ops, HasV6MOps, HasV6T2Ops, HasV7Ops, HasV8Ops -
Evan Cheng39dfb0f2011-07-07 03:55:05 +000061 /// Specify whether target support specific ARM ISA variants.
62 bool HasV4TOps;
63 bool HasV5TOps;
64 bool HasV5TEOps;
65 bool HasV6Ops;
Tim Northovercf3e4cb2013-10-07 11:10:47 +000066 bool HasV6MOps;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000067 bool HasV6T2Ops;
68 bool HasV7Ops;
Joey Gouly849eedc2013-06-26 16:58:26 +000069 bool HasV8Ops;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000070
Joey Gouly2a9af9f2013-09-13 13:46:57 +000071 /// HasVFPv2, HasVFPv3, HasVFPv4, HasFPARMv8, HasNEON - Specify what
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000072 /// floating point ISAs are supported.
Evan Cheng39dfb0f2011-07-07 03:55:05 +000073 bool HasVFPv2;
74 bool HasVFPv3;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +000075 bool HasVFPv4;
Joey Gouly2a9af9f2013-09-13 13:46:57 +000076 bool HasFPARMv8;
Evan Cheng39dfb0f2011-07-07 03:55:05 +000077 bool HasNEON;
Evan Chenga8e29892007-01-19 07:51:42 +000078
David Goodwin1f0e4042009-08-05 16:01:19 +000079 /// UseNEONForSinglePrecisionFP - if the NEONFP attribute has been
80 /// specified. Use the method useNEONForSinglePrecisionFP() to
81 /// determine if NEON should actually be used.
David Goodwin42a83f22009-08-04 17:53:06 +000082 bool UseNEONForSinglePrecisionFP;
83
Bob Wilsoneb1641d2012-09-29 21:43:49 +000084 /// UseMulOps - True if non-microcoded fused integer multiply-add and
85 /// multiply-subtract instructions should be used.
86 bool UseMulOps;
87
Evan Cheng48575f62010-12-05 22:04:16 +000088 /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates
89 /// whether the FP VML[AS] instructions are slow (if so, don't use them).
90 bool SlowFPVMLx;
Jim Grosbach26767372010-03-24 22:31:46 +000091
Evan Cheng463d3582011-03-31 19:38:48 +000092 /// HasVMLxForwarding - If true, NEON has special multiplier accumulator
93 /// forwarding to allow mul + mla being issued back to back.
94 bool HasVMLxForwarding;
95
Evan Cheng7a415992010-07-13 19:21:50 +000096 /// SlowFPBrcc - True if floating point compare + branch is slow.
97 bool SlowFPBrcc;
98
Evan Cheng4761a8d2011-07-07 19:09:06 +000099 /// InThumbMode - True if compiling for Thumb, false for ARM.
Evan Cheng963b03c2011-07-07 19:05:12 +0000100 bool InThumbMode;
Anton Korobeynikov70459be2009-06-01 20:00:48 +0000101
Evan Cheng94ca42f2011-07-07 00:08:19 +0000102 /// HasThumb2 - True if Thumb2 instructions are supported.
103 bool HasThumb2;
Evan Chenga8e29892007-01-19 07:51:42 +0000104
Evan Cheng7b4d3112010-08-11 07:17:46 +0000105 /// NoARM - True if subtarget does not support ARM mode execution.
106 bool NoARM;
107
David Goodwin0dad89f2009-09-30 00:10:16 +0000108 /// PostRAScheduler - True if using post-register-allocation scheduler.
109 bool PostRAScheduler;
110
Evan Chenga8e29892007-01-19 07:51:42 +0000111 /// IsR9Reserved - True if R9 is a not available as general purpose register.
112 bool IsR9Reserved;
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000113
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000114 /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit
115 /// imms (including global addresses).
116 bool UseMovt;
117
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000118 /// SupportsTailCall - True if the OS supports tail call. The dynamic linker
119 /// must be able to synthesize call stubs for interworking between ARM and
120 /// Thumb.
121 bool SupportsTailCall;
122
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000123 /// HasFP16 - True if subtarget supports half-precision FP (We support VFP+HF
124 /// only so far)
125 bool HasFP16;
126
Bob Wilson77f42b52010-10-12 16:22:47 +0000127 /// HasD16 - True if subtarget is limited to 16 double precision
128 /// FP registers for VFPv3.
129 bool HasD16;
130
Jim Grosbach29402132010-05-05 23:44:43 +0000131 /// HasHardwareDivide - True if subtarget supports [su]div
132 bool HasHardwareDivide;
133
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000134 /// HasHardwareDivideInARM - True if subtarget supports [su]div in ARM mode
135 bool HasHardwareDivideInARM;
136
Jim Grosbach29402132010-05-05 23:44:43 +0000137 /// HasT2ExtractPack - True if subtarget supports thumb2 extract/pack
138 /// instructions.
139 bool HasT2ExtractPack;
140
Evan Cheng11db0682010-08-11 06:22:01 +0000141 /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier
142 /// instructions.
143 bool HasDataBarrier;
144
Evan Chenge44be632010-08-09 18:35:19 +0000145 /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions
146 /// over 16-bit ones.
147 bool Pref32BitThumb;
148
Bob Wilson5dde8932011-04-19 18:11:49 +0000149 /// AvoidCPSRPartialUpdate - If true, codegen would avoid using instructions
150 /// that partially update CPSR and add false dependency on the previous
151 /// CPSR setting instruction.
152 bool AvoidCPSRPartialUpdate;
153
Evan Cheng139e4072012-12-20 19:59:30 +0000154 /// AvoidMOVsShifterOperand - If true, codegen should avoid using flag setting
155 /// movs with shifter operand (i.e. asr, lsl, lsr).
156 bool AvoidMOVsShifterOperand;
157
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000158 /// HasRAS - Some processors perform return stack prediction. CodeGen should
159 /// avoid issue "normal" call instructions to callees which do not return.
160 bool HasRAS;
161
Evan Chengdfed19f2010-11-03 06:34:55 +0000162 /// HasMPExtension - True if the subtarget supports Multiprocessing
163 /// extension (ARMv7 only).
164 bool HasMPExtension;
165
Bradley Smith6186de52013-11-01 13:27:35 +0000166 /// HasVirtualization - True if the subtarget supports the Virtualization
167 /// extension.
168 bool HasVirtualization;
169
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000170 /// FPOnlySP - If true, the floating point unit only supports single
171 /// precision.
172 bool FPOnlySP;
173
Tim Northoverb94a3532013-05-23 19:11:14 +0000174 /// If true, the processor supports the Performance Monitor Extensions. These
175 /// include a generic cycle-counter as well as more fine-grained (often
176 /// implementation-specific) events.
177 bool HasPerfMon;
178
Tim Northover8c9e52a2013-04-10 12:08:35 +0000179 /// HasTrustZone - if true, processor supports TrustZone security extensions
180 bool HasTrustZone;
181
Amara Emerson5df37da2013-09-19 11:59:01 +0000182 /// HasCrypto - if true, processor supports Cryptography extensions
183 bool HasCrypto;
184
Bernard Ogden47c6d172013-10-29 09:47:35 +0000185 /// HasCRC - if true, processor supports CRC instructions
186 bool HasCRC;
187
Stephen Hines36b56882014-04-23 16:57:46 -0700188 /// If true, the instructions "vmov.i32 d0, #0" and "vmov.i32 q0, #0" are
189 /// particularly effective at zeroing a VFP register.
190 bool HasZeroCycleZeroing;
191
Bob Wilson02aba732010-09-28 04:09:35 +0000192 /// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
193 /// accesses for some types. For details, see
194 /// ARMTargetLowering::allowsUnalignedMemoryAccesses().
195 bool AllowsUnalignedMem;
196
Weiming Zhao929bdb22013-11-13 18:29:49 +0000197 /// RestrictIT - If true, the subtarget disallows generation of deprecated IT
198 /// blocks to conform to ARMv8 rule.
199 bool RestrictIT;
200
Jim Grosbacha7603982011-07-01 21:12:19 +0000201 /// Thumb2DSP - If true, the subtarget supports the v7 DSP (saturating arith
202 /// and such) instructions in Thumb2 code.
203 bool Thumb2DSP;
204
Eli Bendersky0f156af2013-01-30 16:30:19 +0000205 /// NaCl TRAP instruction is generated instead of the regular TRAP.
206 bool UseNaClTrap;
207
Stephen Hines373aa5c2014-02-06 23:41:26 -0800208 /// Force long to be a 64-bit type (RenderScript-specific)
209 bool UseLong64;
210
Stephen Hines36b56882014-04-23 16:57:46 -0700211 /// Target machine allowed unsafe FP math (such as use of NEON fp)
212 bool UnsafeFPMath;
213
Evan Chenga8e29892007-01-19 07:51:42 +0000214 /// stackAlignment - The minimum alignment known to hold of the stack frame on
215 /// entry to the function and which must be maintained by every function.
216 unsigned stackAlignment;
217
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000218 /// CPUString - String name of used CPU.
219 std::string CPUString;
220
Stephen Hines36b56882014-04-23 16:57:46 -0700221 /// IsLittle - The target is Little Endian
222 bool IsLittle;
223
Evan Chengb72d2a92011-01-11 21:46:47 +0000224 /// TargetTriple - What processor and OS we're targeting.
225 Triple TargetTriple;
226
Andrew Trickd43b5c92012-08-08 02:44:16 +0000227 /// SchedModel - Processor specific instruction costs.
228 const MCSchedModel *SchedModel;
229
Evan Cheng8557c2b2009-06-19 01:51:50 +0000230 /// Selected instruction itineraries (one entry per itinerary class.)
231 InstrItineraryData InstrItins;
Jim Grosbach764ab522009-08-11 15:33:49 +0000232
Renato Golin3382a842013-03-21 18:47:47 +0000233 /// Options passed via command line that could influence the target
234 const TargetOptions &Options;
235
Evan Chenga8e29892007-01-19 07:51:42 +0000236 public:
Evan Cheng1a3771e2007-01-19 19:22:40 +0000237 enum {
Stephen Hines36b56882014-04-23 16:57:46 -0700238 ARM_ABI_UNKNOWN,
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000239 ARM_ABI_APCS,
240 ARM_ABI_AAPCS // ARM EABI
241 } TargetABI;
242
Evan Chenga8e29892007-01-19 07:51:42 +0000243 /// This constructor initializes the data members to match that
Daniel Dunbar3be03402009-08-02 22:11:08 +0000244 /// of the specified triple.
Evan Chenga8e29892007-01-19 07:51:42 +0000245 ///
Evan Cheng276365d2011-06-30 01:53:36 +0000246 ARMSubtarget(const std::string &TT, const std::string &CPU,
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700247 const std::string &FS, TargetMachine &TM, bool IsLittle,
Stephen Hines36b56882014-04-23 16:57:46 -0700248 const TargetOptions &Options);
Evan Chenga8e29892007-01-19 07:51:42 +0000249
Dan Gohman707e0182008-04-12 04:36:06 +0000250 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
251 /// that still makes it profitable to inline the call.
Rafael Espindolae0703c82007-10-31 14:39:58 +0000252 unsigned getMaxInlineSizeThreshold() const {
Stephen Hinesdce4a402014-05-29 02:49:00 -0700253 return 64;
Rafael Espindolae0703c82007-10-31 14:39:58 +0000254 }
Anton Korobeynikov6d7d2aa2009-05-23 19:51:43 +0000255 /// ParseSubtargetFeatures - Parses features string setting specified
Evan Chenga8e29892007-01-19 07:51:42 +0000256 /// subtarget options. Definition of function is auto generated by tblgen.
Evan Cheng0ddff1b2011-07-07 07:07:08 +0000257 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Evan Chenga8e29892007-01-19 07:51:42 +0000258
Renato Golinb26f98f2013-02-16 19:14:59 +0000259 /// \brief Reset the features for the ARM target.
Stephen Hines36b56882014-04-23 16:57:46 -0700260 void resetSubtargetFeatures(const MachineFunction *MF) override;
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700261
262 /// initializeSubtargetDependencies - Initializes using a CPU and feature string
263 /// so that we can use initializer lists for subtarget initialization.
264 ARMSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
265
266 const DataLayout *getDataLayout() const { return &DL; }
267 const ARMSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
268 ARMJITInfo *getJITInfo() { return &JITInfo; }
269 const ARMBaseInstrInfo *getInstrInfo() const { return InstrInfo.get(); }
270 const ARMTargetLowering *getTargetLowering() const { return &TLInfo; }
271 const ARMFrameLowering *getFrameLowering() const { return FrameLowering.get(); }
272 const ARMBaseRegisterInfo *getRegisterInfo() const {
273 return &InstrInfo->getRegisterInfo();
274 }
275
Bill Wendling901d8002013-02-16 01:36:26 +0000276private:
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700277 const DataLayout DL;
278 ARMSelectionDAGInfo TSInfo;
279 ARMJITInfo JITInfo;
280 // Either Thumb1InstrInfo or Thumb2InstrInfo.
281 std::unique_ptr<ARMBaseInstrInfo> InstrInfo;
282 ARMTargetLowering TLInfo;
283 // Either Thumb1FrameLowering or ARMFrameLowering.
284 std::unique_ptr<ARMFrameLowering> FrameLowering;
285
Bill Wendling901d8002013-02-16 01:36:26 +0000286 void initializeEnvironment();
Bill Wendling4788d142013-02-15 22:41:25 +0000287 void resetSubtargetFeatures(StringRef CPU, StringRef FS);
Bill Wendling901d8002013-02-16 01:36:26 +0000288public:
Andrew Trick2da8bc82010-12-24 05:03:26 +0000289 void computeIssueWidth();
290
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000291 bool hasV4TOps() const { return HasV4TOps; }
292 bool hasV5TOps() const { return HasV5TOps; }
293 bool hasV5TEOps() const { return HasV5TEOps; }
294 bool hasV6Ops() const { return HasV6Ops; }
Amara Emersonca7b2d02013-10-07 16:55:23 +0000295 bool hasV6MOps() const { return HasV6MOps; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000296 bool hasV6T2Ops() const { return HasV6T2Ops; }
297 bool hasV7Ops() const { return HasV7Ops; }
Joey Gouly849eedc2013-06-26 16:58:26 +0000298 bool hasV8Ops() const { return HasV8Ops; }
Evan Chenga8e29892007-01-19 07:51:42 +0000299
Quentin Colombet8facb9e2012-11-29 19:48:01 +0000300 bool isCortexA5() const { return ARMProcFamily == CortexA5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700301 bool isCortexA7() const { return ARMProcFamily == CortexA7; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000302 bool isCortexA8() const { return ARMProcFamily == CortexA8; }
303 bool isCortexA9() const { return ARMProcFamily == CortexA9; }
Silviu Baranga616471d2012-09-13 15:05:10 +0000304 bool isCortexA15() const { return ARMProcFamily == CortexA15; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000305 bool isSwift() const { return ARMProcFamily == Swift; }
Evan Cheng44ee4712011-11-09 01:57:03 +0000306 bool isCortexM3() const { return CPUString == "cortex-m3"; }
Stephen Hines36b56882014-04-23 16:57:46 -0700307 bool isLikeA9() const { return isCortexA9() || isCortexA15() || isKrait(); }
Quentin Colombete0f1d712012-12-21 04:35:05 +0000308 bool isCortexR5() const { return ARMProcFamily == CortexR5; }
Stephen Hines36b56882014-04-23 16:57:46 -0700309 bool isKrait() const { return ARMProcFamily == Krait; }
Evan Cheng3ef1c872010-09-10 01:29:16 +0000310
Evan Cheng7b4d3112010-08-11 07:17:46 +0000311 bool hasARMOps() const { return !NoARM; }
312
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000313 bool hasVFP2() const { return HasVFPv2; }
314 bool hasVFP3() const { return HasVFPv3; }
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000315 bool hasVFP4() const { return HasVFPv4; }
Joey Gouly2a9af9f2013-09-13 13:46:57 +0000316 bool hasFPARMv8() const { return HasFPARMv8; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000317 bool hasNEON() const { return HasNEON; }
Amara Emerson5df37da2013-09-19 11:59:01 +0000318 bool hasCrypto() const { return HasCrypto; }
Bernard Ogden47c6d172013-10-29 09:47:35 +0000319 bool hasCRC() const { return HasCRC; }
Bradley Smith6186de52013-11-01 13:27:35 +0000320 bool hasVirtualization() const { return HasVirtualization; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000321 bool useNEONForSinglePrecisionFP() const {
David Goodwin42a83f22009-08-04 17:53:06 +0000322 return hasNEON() && UseNEONForSinglePrecisionFP; }
Evan Cheng39dfb0f2011-07-07 03:55:05 +0000323
Shantonu Seneae216c2010-05-06 14:57:47 +0000324 bool hasDivide() const { return HasHardwareDivide; }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000325 bool hasDivideInARMMode() const { return HasHardwareDivideInARM; }
Shantonu Seneae216c2010-05-06 14:57:47 +0000326 bool hasT2ExtractPack() const { return HasT2ExtractPack; }
Evan Cheng11db0682010-08-11 06:22:01 +0000327 bool hasDataBarrier() const { return HasDataBarrier; }
Tim Northover214c37d2013-10-25 09:30:24 +0000328 bool hasAnyDataBarrier() const {
329 return HasDataBarrier || (hasV6Ops() && !isThumb());
330 }
Bob Wilsoneb1641d2012-09-29 21:43:49 +0000331 bool useMulOps() const { return UseMulOps; }
Evan Cheng48575f62010-12-05 22:04:16 +0000332 bool useFPVMLx() const { return !SlowFPVMLx; }
Evan Cheng463d3582011-03-31 19:38:48 +0000333 bool hasVMLxForwarding() const { return HasVMLxForwarding; }
Evan Cheng7a415992010-07-13 19:21:50 +0000334 bool isFPBrccSlow() const { return SlowFPBrcc; }
Jim Grosbachfcba5e62010-08-11 15:44:15 +0000335 bool isFPOnlySP() const { return FPOnlySP; }
Tim Northoverb94a3532013-05-23 19:11:14 +0000336 bool hasPerfMon() const { return HasPerfMon; }
Tim Northover8c9e52a2013-04-10 12:08:35 +0000337 bool hasTrustZone() const { return HasTrustZone; }
Stephen Hines36b56882014-04-23 16:57:46 -0700338 bool hasZeroCycleZeroing() const { return HasZeroCycleZeroing; }
Evan Chenge44be632010-08-09 18:35:19 +0000339 bool prefers32BitThumb() const { return Pref32BitThumb; }
Bob Wilson5dde8932011-04-19 18:11:49 +0000340 bool avoidCPSRPartialUpdate() const { return AvoidCPSRPartialUpdate; }
Evan Cheng139e4072012-12-20 19:59:30 +0000341 bool avoidMOVsShifterOperand() const { return AvoidMOVsShifterOperand; }
Evan Cheng4bfcd4a2012-02-28 18:51:51 +0000342 bool hasRAS() const { return HasRAS; }
Evan Chengdfed19f2010-11-03 06:34:55 +0000343 bool hasMPExtension() const { return HasMPExtension; }
Jim Grosbacha7603982011-07-01 21:12:19 +0000344 bool hasThumb2DSP() const { return Thumb2DSP; }
Eli Bendersky0f156af2013-01-30 16:30:19 +0000345 bool useNaClTrap() const { return UseNaClTrap; }
Jim Grosbach764ab522009-08-11 15:33:49 +0000346
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000347 bool hasFP16() const { return HasFP16; }
Bob Wilson77f42b52010-10-12 16:22:47 +0000348 bool hasD16() const { return HasD16; }
Anton Korobeynikov631379e2010-03-14 18:42:38 +0000349
Evan Chengc8578942011-04-20 22:20:12 +0000350 const Triple &getTargetTriple() const { return TargetTriple; }
351
Daniel Dunbar912225e2011-04-19 21:14:45 +0000352 bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700353 bool isTargetIOS() const { return TargetTriple.isiOS(); }
Cameron Esfahani441c5572013-08-29 20:23:14 +0000354 bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
Stephen Hines36b56882014-04-23 16:57:46 -0700355 bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); }
356 bool isTargetNetBSD() const { return TargetTriple.getOS() == Triple::NetBSD; }
357 bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
358
359 bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); }
360 bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); }
361 bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); }
362
Renato Golin103ba842013-07-16 09:32:17 +0000363 // ARM EABI is the bare-metal EABI described in ARM ABI documents and
364 // can be accessed via -target arm-none-eabi. This is NOT GNUEABI.
365 // FIXME: Add a flag for bare-metal for that target and set Triple::EABI
366 // even for GNUEABI, so we can make a distinction here and still conform to
367 // the EABI on GNU (and Android) mode. This requires change in Clang, too.
Stephen Hines36b56882014-04-23 16:57:46 -0700368 // FIXME: The Darwin exception is temporary, while we move users to
369 // "*-*-*-macho" triples as quickly as possible.
Renato Golin103ba842013-07-16 09:32:17 +0000370 bool isTargetAEABI() const {
Stephen Hines36b56882014-04-23 16:57:46 -0700371 return (TargetTriple.getEnvironment() == Triple::EABI ||
372 TargetTriple.getEnvironment() == Triple::EABIHF) &&
373 !isTargetDarwin() && !isTargetWindows();
Renato Golin103ba842013-07-16 09:32:17 +0000374 }
Evan Cheng1a3771e2007-01-19 19:22:40 +0000375
Stephen Hines36b56882014-04-23 16:57:46 -0700376 // ARM Targets that support EHABI exception handling standard
377 // Darwin uses SjLj. Other targets might need more checks.
378 bool isTargetEHABICompatible() const {
379 return (TargetTriple.getEnvironment() == Triple::EABI ||
380 TargetTriple.getEnvironment() == Triple::GNUEABI ||
381 TargetTriple.getEnvironment() == Triple::EABIHF ||
382 TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
383 TargetTriple.getEnvironment() == Triple::Android) &&
384 !isTargetDarwin() && !isTargetWindows();
385 }
386
387 bool isTargetHardFloat() const {
388 // FIXME: this is invalid for WindowsCE
389 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
390 TargetTriple.getEnvironment() == Triple::EABIHF ||
391 isTargetWindows();
392 }
393 bool isTargetAndroid() const {
394 return TargetTriple.getEnvironment() == Triple::Android;
395 }
396
397 bool isAPCS_ABI() const {
398 assert(TargetABI != ARM_ABI_UNKNOWN);
399 return TargetABI == ARM_ABI_APCS;
400 }
401 bool isAAPCS_ABI() const {
402 assert(TargetABI != ARM_ABI_UNKNOWN);
403 return TargetABI == ARM_ABI_AAPCS;
404 }
Lauro Ramos Venancio3630e782007-02-13 19:52:28 +0000405
Evan Cheng963b03c2011-07-07 19:05:12 +0000406 bool isThumb() const { return InThumbMode; }
407 bool isThumb1Only() const { return InThumbMode && !HasThumb2; }
408 bool isThumb2() const { return InThumbMode && HasThumb2; }
Evan Cheng94ca42f2011-07-07 00:08:19 +0000409 bool hasThumb2() const { return HasThumb2; }
Amara Emerson0f22c132013-09-23 14:26:15 +0000410 bool isMClass() const { return ARMProcClass == MClass; }
411 bool isRClass() const { return ARMProcClass == RClass; }
412 bool isAClass() const { return ARMProcClass == AClass; }
Evan Chenga8e29892007-01-19 07:51:42 +0000413
Evan Chenga8e29892007-01-19 07:51:42 +0000414 bool isR9Reserved() const { return IsR9Reserved; }
415
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700416 bool useMovt(const MachineFunction &MF) const;
417
Bob Wilson6d2f9ce2011-10-07 17:17:49 +0000418 bool supportsTailCall() const { return SupportsTailCall; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000419
Bob Wilson02aba732010-09-28 04:09:35 +0000420 bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
421
Weiming Zhao929bdb22013-11-13 18:29:49 +0000422 bool restrictIT() const { return RestrictIT; }
423
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000424 const std::string & getCPUString() const { return CPUString; }
Anton Korobeynikov5cdc3a92009-11-24 00:44:37 +0000425
Stephen Hines36b56882014-04-23 16:57:46 -0700426 bool isLittle() const { return IsLittle; }
427
Owen Anderson654d5442010-09-28 21:57:50 +0000428 unsigned getMispredictionPenalty() const;
Stephen Hinesdce4a402014-05-29 02:49:00 -0700429
Bob Wilsoncb01efb2013-11-03 06:14:38 +0000430 /// This function returns true if the target has sincos() routine in its
431 /// compiler runtime or math libraries.
432 bool hasSinCos() const;
Andrew Trick6e8f4c42010-12-24 04:28:06 +0000433
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700434 /// True for some subtargets at > -O0.
435 bool enablePostMachineScheduler() const;
436
David Goodwinc2e8a7e2009-11-10 00:48:55 +0000437 /// enablePostRAScheduler - True at 'More' optimization.
David Goodwin4c3715c2009-10-22 23:19:17 +0000438 bool enablePostRAScheduler(CodeGenOpt::Level OptLevel,
Evan Cheng5b1b44892011-07-01 21:01:15 +0000439 TargetSubtargetInfo::AntiDepBreakMode& Mode,
Stephen Hines36b56882014-04-23 16:57:46 -0700440 RegClassVector& CriticalPathRCs) const override;
Anton Korobeynikov41a02432009-05-23 19:50:50 +0000441
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -0700442 // enableAtomicExpandLoadLinked - True if we need to expand our atomics.
443 bool enableAtomicExpandLoadLinked() const override;
444
Jim Grosbach764ab522009-08-11 15:33:49 +0000445 /// getInstrItins - Return the instruction itineraies based on subtarget
Evan Cheng8557c2b2009-06-19 01:51:50 +0000446 /// selection.
447 const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
448
Evan Chenga8e29892007-01-19 07:51:42 +0000449 /// getStackAlignment - Returns the minimum alignment known to hold of the
450 /// stack frame on entry to the function and which must be maintained by every
451 /// function for this subtarget.
452 unsigned getStackAlignment() const { return stackAlignment; }
Evan Chenge4e4ed32009-08-28 23:18:09 +0000453
454 /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect
455 /// symbol.
Dan Gohman46510a72010-04-15 01:51:59 +0000456 bool GVIsIndirectSymbol(const GlobalValue *GV, Reloc::Model RelocM) const;
Evan Chenga8e29892007-01-19 07:51:42 +0000457};
458} // End llvm namespace
459
460#endif // ARMSUBTARGET_H